diff --git a/Changelog.txt b/Changelog.txt index 0a7b1537a..375b9e26f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,19 +10,27 @@ Key: Version 1.3.06-dev + Added permissions check to skill functions + Added API functions for obtaining offline profiles & profiles via player names + + Added API functions for admin & party chat + + Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed. = Fixed bug where Herbalism required double drops permission to give XP = Fixed bug where {0} would be displayed in front of your power level in mcstats - = Fixed mmoupdate not being useable from console + = Fixed mmoupdate not being useable from console = Fixed bug with repairing wooden tools + = Fixed bug with repairing wooden tools + = Fixed bug with Nether Wart not awarding XP + = Fixed bug with fishing treasures when treasures list is empty + = Fixed bug with only getting one level when there was enough XP for multiple levels. + ! Changed how the tree feller threshold worked for the better ! Changed /mcremove to no longer kick players when they are removed from database ! Changed /mcremove to work on offline users for FlatFile ! Changed PlayerProfile constructor to always take a boolean ! Changed getPlayerProfile function to work for online & offline users ! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts) ! Changed /addlevel command to work for offline users - ! Changed party & admin chat handling to be nicer to developers + ! Changed party & admin chat handling to be nicer to developers ! Changed /mcrefresh to work from console ! Changed /mcrefresh to work for offline players + ! Changed UpdateXPBar function to hopefully avoid errors Version 1.3.05 + Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index 8528719d0..d3c2d6be9 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -100,7 +100,7 @@ public class Combat { } if (targetType.equals(EntityType.PLAYER) && mcPermissions.getInstance().disarm(attacker)) { - Unarmed.disarmProcCheck(PPa, (Player) target); + Unarmed.disarmProcCheck(attacker, (Player) target); } startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin); @@ -351,10 +351,10 @@ public class Combat { String message = ""; if (type.equals(SkillType.AXES)) { - message = mcLocale.getString("Axes.Combat.Cleave.Struck"); + message = mcLocale.getString("Axes.HitByCleave"); } else if (type.equals(SkillType.SWORDS)) { - message = mcLocale.getString("Swords.Combat.SS.Struck"); + message = mcLocale.getString("Swords.HitBySerratedStrikes"); } dealDamage(defender, damageAmount, attacker); diff --git a/src/main/java/com/gmail/nossr50/Item.java b/src/main/java/com/gmail/nossr50/Item.java index 1dc461d7d..6f1fd3049 100644 --- a/src/main/java/com/gmail/nossr50/Item.java +++ b/src/main/java/com/gmail/nossr50/Item.java @@ -38,7 +38,7 @@ public class Item { for (int y = 0; block.getY() + y < player.getWorld().getMaxHeight(); y++) { if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) { - player.sendMessage(mcLocale.getString("Item.ChimaeraWing.Fail")); + player.sendMessage(mcLocale.getString("Item.ChimaeraWingFail")); player.teleport(block.getRelative(0, y - 1, 0).getLocation()); return; } @@ -51,10 +51,10 @@ public class Item { player.teleport(player.getWorld().getSpawnLocation()); } - player.sendMessage(mcLocale.getString("Item.ChimaeraWing.Pass")); + player.sendMessage(mcLocale.getString("Item.ChimaeraWingPass")); } else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing) { - player.sendMessage(mcLocale.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)})); + player.sendMessage(mcLocale.getString("Item.InjuredWait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)})); } else if (is.getAmount() <= LoadProperties.feathersConsumedByChimaeraWing) { player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(LoadProperties.chimaeraId)); diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java new file mode 100644 index 000000000..2ce4ce52e --- /dev/null +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -0,0 +1,68 @@ +package com.gmail.nossr50.api; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; +import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; + +public class ChatAPI { + /** + * Send a message to all members of a party + *
+ * This function is designed for API usage. + * + * @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 + */ + public void sendPartyChat(String sender, String party, String message) { + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message); + Bukkit.getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return; + } + + String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.GREEN + ") "; + + Bukkit.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage()); + + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + if (Users.getProfile(player).inParty()) { + if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) { + player.sendMessage(pPrefix + chatEvent.getMessage()); + } + } + } + } + + /** + * Send a message to administrators + *
+ * This function is designed for API usage. + * + * @param sender The name of the sender to display in the chat + * @param message The message to send + */ + public void sendAdminChat(String sender, String message) { + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message); + Bukkit.getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return; + } + + String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.AQUA + "} "; + + Bukkit.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage()); + + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + if (mcPermissions.getInstance().adminChat(player) || player.isOp()) + player.sendMessage(aPrefix + chatEvent.getMessage()); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java index 03f626295..d88029e1b 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -48,7 +48,7 @@ public class InspectCommand implements CommandExecutor { CommandHelper.printGatheringSkills(player, sender); CommandHelper.printCombatSkills(player, sender); CommandHelper.printMiscSkills(player, sender); - sender.sendMessage(mcLocale.getString("Commands.PowerLevel", new Object[] { PP.getPowerLevel() })); + sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() })); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java index 05eb461a1..bb8d366c1 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java @@ -27,8 +27,8 @@ public class McstatsCommand implements CommandExecutor { CommandHelper.printGatheringSkills(player); CommandHelper.printCombatSkills(player); CommandHelper.printMiscSkills(player); - - player.sendMessage(mcLocale.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) })); + + player.sendMessage(mcLocale.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) })); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java index d8e00aada..9e34a5644 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java @@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor { int newValue; SkillType skill; String skillName; - String usage = ChatColor.RED + "Proper usage is /mmoedit [player] "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /mmoedit [player] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java index 14ab0c893..9f4d909de 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.locale.mcLocale; public class ACommand implements CommandExecutor { @@ -26,6 +27,13 @@ public class ACommand implements CommandExecutor { aMessage = aMessage + " " + args[i]; } + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage); + Bukkit.getPluginManager().callEvent(chatEvent); + + if(chatEvent.isCancelled()) return true; + + aMessage = chatEvent.getMessage(); + String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} "; Bukkit.getLogger().info("[A]<*Console*> " + aMessage); @@ -54,19 +62,11 @@ public class ACommand implements CommandExecutor { for (int i = 1; i <= args.length - 1; i++) { aMessage = aMessage + " " + args[i]; } - Users.getProfile(player).toggleAdminChat(); player.chat(aMessage); Users.getProfile(player).toggleAdminChat(); - String name = player.getName(); - String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} "; - Bukkit.getLogger().info("[A]<" + name + "> " + aMessage); - for (Player herp : Bukkit.getServer().getOnlinePlayers()) { - if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) - herp.sendMessage(aPrefix + aMessage); - } return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java index bee20a978..5179adfc2 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; import com.gmail.nossr50.locale.mcLocale; public class PCommand implements CommandExecutor { @@ -27,6 +28,13 @@ public class PCommand implements CommandExecutor { pMessage = pMessage + " " + args[i]; } + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], pMessage); + Bukkit.getPluginManager().callEvent(chatEvent); + + if(chatEvent.isCancelled()) return true; + + pMessage = chatEvent.getMessage(); + String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") "; Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage); 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 fe46b41a6..389ee90d5 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -37,7 +37,7 @@ public class UnarmedCommand implements CommandExecutor { percentage = "33.3"; if (PP.getSkillLevel(SkillType.UNARMED) < 1000) - arrowpercentage = String.valueOf(((skillvalue / 1000) * 100) / 2); + arrowpercentage = String.valueOf((skillvalue / 2000) * 100); else arrowpercentage = "50"; diff --git a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java index 96b6a7f15..0a4906b35 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java @@ -11,77 +11,15 @@ import com.gmail.nossr50.skills.Herbalism; import com.gmail.nossr50.skills.Mining; public enum AbilityType { - BERSERK( - LoadProperties.berserkCooldown, - "Unarmed.Skills.Berserk.On", - "Unarmed.Skills.Berserk.Off", - "Unarmed.Skills.Berserk.Other.On", - "Unarmed.Skills.Berserk.Refresh", - "Unarmed.Skills.Berserk.Other.Off"), - - SUPER_BREAKER( - LoadProperties.superBreakerCooldown, - "Mining.Skills.SuperBreaker.On", - "Mining.Skills.SuperBreaker.Off", - "Mining.Skills.SuperBreaker.Other.On", - "Mining.Skills.SuperBreaker.Refresh", - "Mining.Skills.SuperBreaker.Other.Off"), - - GIGA_DRILL_BREAKER( - LoadProperties.gigaDrillBreakerCooldown, - "Excavation.Skills.GigaDrillBreaker.On", - "Excavation.Skills.GigaDrillBreaker.Off", - "Excavation.Skills.GigaDrillBreaker.Other.On", - "Excavation.Skills.GigaDrillBreaker.Refresh", - "Excavation.Skills.GigaDrillBreaker.Other.Off"), - - GREEN_TERRA( - LoadProperties.greenTerraCooldown, - "Herbalism.Skills.GTe.On", - "Herbalism.Skills.GTe.Off", - "Herbalism.Skills.GTe.Other.On", - "Herbalism.Skills.GTe.Refresh", - "Herbalism.Skills.GTe.Other.Off"), - - SKULL_SPLIITER( - LoadProperties.skullSplitterCooldown, - "Axes.Skills.SS.On", - "Axes.Skills.SS.Off", - "Axes.Skills.SS.Other.On", - "Axes.Skills.SS.Refresh", - "Axes.Skills.SS.Other.Off"), - - TREE_FELLER( - LoadProperties.treeFellerCooldown, - "Woodcutting.Skills.TreeFeller.On", - "Woodcutting.Skills.TreeFeller.Off", - "Woodcutting.Skills.TreeFeller.Other.On", - "Woodcutting.Skills.TreeFeller.Refresh", - "Woodcutting.Skills.TreeFeller.Other.Off"), - - SERRATED_STRIKES( - LoadProperties.serratedStrikeCooldown, - "Swords.Skills.SS.On", - "Swords.Skills.SS.Off", - "Swords.Skills.SS.Other.On", - "Swords.Skills.SS.Refresh", - "Swords.Skills.SS.Other.Off"), - - BLAST_MINING( - LoadProperties.blastMiningCooldown, - null, - null, - "Mining.Blast.Other.On", - "Mining.Blast.Refresh", - null), - - LEAF_BLOWER( - 0, - null, - null, - null, - null, - null); + BERSERK(LoadProperties.berserkCooldown, mcLocale.getString("Skills.BerserkOn"), mcLocale.getString("Skills.BerserkOff"), "Skills.BerserkPlayer", mcLocale.getString("Skills.YourBerserk"), "Skills.BerserkPlayerOff"), + SUPER_BREAKER(LoadProperties.superBreakerCooldown, mcLocale.getString("Skills.SuperBreakerOn"), mcLocale.getString("Skills.SuperBreakerOff"), "Skills.SuperBreakerPlayer", mcLocale.getString("Skills.YourSuperBreaker"), "Skills.SuperBreakerPlayerOff"), + GIGA_DRILL_BREAKER(LoadProperties.gigaDrillBreakerCooldown, mcLocale.getString("Skills.GigaDrillBreakerOn"), mcLocale.getString("Skills.GigaDrillBreakerOff"), "Skills.GigaDrillBreakerPlayer", mcLocale.getString("Skills.YourGigaDrillBreaker"), "Skills.GigaDrillBreakerPlayerOff"), + GREEN_TERRA(LoadProperties.greenTerraCooldown, mcLocale.getString("Skills.GreenTerraOn"), mcLocale.getString("Skills.GreenTerraOff"), "Skills.GreenTerraPlayer", mcLocale.getString("Skills.YourGreenTerra"), mcLocale.getString("Skills.GreenTerraPlayerOff")), + SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter"), "Skills.SkullSplitterPlayerOff"), + TREE_FELLER(LoadProperties.treeFellerCooldown, mcLocale.getString("Skills.TreeFellerOn"), mcLocale.getString("Skills.TreeFellerOff"), "Skills.TreeFellerPlayer", mcLocale.getString("Skills.YourTreeFeller"), "Skills.TreeFellerPlayerOff"), + SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"), "Skills.SerratedStrikesPlayerOff"), + BLAST_MINING(LoadProperties.blastMiningCooldown, null, null, "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), null), + LEAF_BLOWER(0, null, null, null, null, null); private int cooldown; private String abilityOn; @@ -104,11 +42,11 @@ public enum AbilityType { } public String getAbilityOn() { - return mcLocale.getString(this.abilityOn); + return this.abilityOn; } public String getAbilityOff() { - return mcLocale.getString(this.abilityOff); + return this.abilityOff; } public String getAbilityPlayer(Player player) { @@ -120,7 +58,7 @@ public enum AbilityType { } public String getAbilityRefresh() { - return mcLocale.getString(this.abilityRefresh); + return this.abilityRefresh; } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 5944d593a..cb503fa6e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -982,6 +982,10 @@ public class PlayerProfile { return skillsXp.get(skillType); } + public void skillUp(SkillType skillType, int newValue) { + skills.put(skillType, skills.get(skillType) + newValue); + } + /** * Adds XP to the player, doesn't calculate for XP Rate * @@ -1056,6 +1060,27 @@ public class PlayerProfile { lastgained = skillType; } + /** + * Remove XP from a skill. + * + * @param skillType Type of skill to modify + * @param xp Amount of xp to remove + */ + public void removeXP(SkillType skillType, int xp) { + if (skillType.equals(SkillType.ALL)) { + for (SkillType skill : SkillType.values()) { + if (skill.equals(SkillType.ALL)) { + continue; + } + + skillsXp.put(skill, skillsXp.get(skill) - xp); + } + } + else { + skillsXp.put(skillType, skillsXp.get(skillType) - xp); + } + } + /** * Modify a skill level. * diff --git a/src/main/java/com/gmail/nossr50/datatypes/ToolType.java b/src/main/java/com/gmail/nossr50/datatypes/ToolType.java index 50d779908..cf898bba9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/ToolType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/ToolType.java @@ -7,12 +7,12 @@ import com.gmail.nossr50.ItemChecks; import com.gmail.nossr50.locale.mcLocale; public enum ToolType { - AXE(mcLocale.getString("Axes.Ability.Lower"), mcLocale.getString("Axes.Ability.Ready")), - FISTS(mcLocale.getString("Unarmed.Ability.Lower"), mcLocale.getString("Unarmed.Ability.Ready")), - HOE(mcLocale.getString("Herbalism.Ability.Lower"), mcLocale.getString("Herbalism.Ability.Ready")), - PICKAXE(mcLocale.getString("Mining.Ability.Lower"), mcLocale.getString("Mining.Ability.Ready")), - SHOVEL(mcLocale.getString("Excavation.Ability.Lower"), mcLocale.getString("Excavation.Ability.Ready")), - SWORD(mcLocale.getString("Swords.Ability.Lower"), mcLocale.getString("Swords.Ability.Ready")); + AXE(mcLocale.getString("Skills.LowerAxe"), mcLocale.getString("Skills.ReadyAxe")), + FISTS(mcLocale.getString("Skills.LowerFists"), mcLocale.getString("Skills.ReadyFists")), + HOE(mcLocale.getString("Skills.LowerHoe"), mcLocale.getString("Skills.ReadyHoe")), + PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")), + SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")), + SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword")); private String lowerTool; private String raiseTool; diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java new file mode 100644 index 000000000..4625a761c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java @@ -0,0 +1,11 @@ +package com.gmail.nossr50.events.chat; + +/** + * Called when a chat is sent to the admin chat channel + */ +public class McMMOAdminChatEvent extends McMMOChatEvent{ + + public McMMOAdminChatEvent(String sender, String message) { + super(sender, message); + } +} diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java new file mode 100644 index 000000000..fafa6da9f --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -0,0 +1,60 @@ +package com.gmail.nossr50.events.chat; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class McMMOChatEvent extends Event implements Cancellable{ + private boolean cancelled; + private String sender; + private String message; + + public McMMOChatEvent(String sender, String message) { + this.sender = sender; + this.message = message; + } + + /** + * @return String name of the player who sent the chat, or "Console" + */ + public String getSender() { + return sender; + } + + /** + * @return String message that will be sent + */ + public String getMessage() { + return message; + } + + /** + * @param message String message to be sent in chat + */ + public void setMessage(String message) { + this.message = message; + } + + /** Rest of file is required boilerplate for custom events **/ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + /** Following are required for Cancellable **/ + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } +} diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java new file mode 100644 index 000000000..112dd24cd --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java @@ -0,0 +1,20 @@ +package com.gmail.nossr50.events.chat; + +/** + * Called when a chat is sent to a party channel + */ +public class McMMOPartyChatEvent extends McMMOChatEvent{ + private String party; + + public McMMOPartyChatEvent(String sender, String party, String message) { + super(sender, message); + this.party = party; + } + + /** + * @return String name of the party the message will be sent to + */ + public String getParty() { + return party; + } +} diff --git a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java index 2c472a148..b1363e2ad 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -39,6 +39,8 @@ import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.datatypes.AbilityType; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; +import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; +import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.skills.BlastMining; @@ -68,7 +70,7 @@ public class mcPlayerListener implements Listener { if (PP.getGodMode()) { if (!mcPermissions.getInstance().mcgod(player)) { PP.toggleGodMode(); - player.sendMessage(mcLocale.getString("Commands.GodMode.Forbidden")); + player.sendMessage(mcLocale.getString("GodMode.Forbidden")); } } @@ -167,8 +169,8 @@ public class mcPlayerListener implements Listener { Player player = event.getPlayer(); if (mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd) { - player.sendMessage(mcLocale.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion(), "mcmmo"})); - player.sendMessage(mcLocale.getString("mcMMO.Wiki")); + player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), "mcmmo"})); + player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI")); } //THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY @@ -297,20 +299,23 @@ public class mcPlayerListener implements Listener { Set recipients = event.getRecipients(); Set intendedRecipients = new HashSet(); - String header = ""; ChatColor color = null; if (partyChat || adminChat) { - if (partyChat) { - if (!PP.inParty()) { player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale return; } color = ChatColor.GREEN; - header = color + "[P] (" + PP.getParty() + ") "; + + McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage()); + plugin.getServer().getPluginManager().callEvent(chatEvent); + + if(chatEvent.isCancelled()) return; + + event.setMessage(chatEvent.getMessage()); for (Player x : plugin.getServer().getOnlinePlayers()) { if (Party.getInstance().inSameParty(player, x)) { @@ -318,21 +323,29 @@ public class mcPlayerListener implements Listener { } } + event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s"); } if (adminChat) { color = ChatColor.AQUA; - header = color + "[A] "; + + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage()); + plugin.getServer().getPluginManager().callEvent(chatEvent); + + if(chatEvent.isCancelled()) return; + + event.setMessage(chatEvent.getMessage()); for (Player x : plugin.getServer().getOnlinePlayers()) { if (x.isOp() || mcPermissions.getInstance().adminChat(x)) { intendedRecipients.add(x); } } + + event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s"); } recipients.retainAll(intendedRecipients); - event.setFormat(header + "<" + ChatColor.WHITE + "%1$s" + color + "> %2$s"); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index efb99ef2e..f09d04075 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -213,18 +213,18 @@ public class mcMMO extends JavaPlugin { //Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands) //Skills commands - aliasMap.put(mcLocale.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics"); - aliasMap.put(mcLocale.getString("Archery.SkillName").toLowerCase(), "archery"); - aliasMap.put(mcLocale.getString("Axes.SkillName").toLowerCase(), "axes"); - aliasMap.put(mcLocale.getString("Excavation.SkillName").toLowerCase(), "excavation"); - aliasMap.put(mcLocale.getString("Fishing.SkillName").toLowerCase(), "fishing"); - aliasMap.put(mcLocale.getString("Herbalism.SkillName").toLowerCase(), "herbalism"); - aliasMap.put(mcLocale.getString("Mining.SkillName").toLowerCase(), "mining"); - aliasMap.put(mcLocale.getString("Repair.SkillName").toLowerCase(), "repair"); - aliasMap.put(mcLocale.getString("Swords.SkillName").toLowerCase(), "swords"); - aliasMap.put(mcLocale.getString("Taming.SkillName").toLowerCase(), "taming"); - aliasMap.put(mcLocale.getString("Unarmed.SkillName").toLowerCase(), "unarmed"); - aliasMap.put(mcLocale.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting"); + aliasMap.put(mcLocale.getString("m.SkillAcrobatics").toLowerCase(), "acrobatics"); + aliasMap.put(mcLocale.getString("m.SkillArchery").toLowerCase(), "archery"); + aliasMap.put(mcLocale.getString("m.SkillAxes").toLowerCase(), "axes"); + aliasMap.put(mcLocale.getString("m.SkillExcavation").toLowerCase(), "excavation"); + aliasMap.put(mcLocale.getString("m.SkillFishing").toLowerCase(), "fishing"); + aliasMap.put(mcLocale.getString("m.SkillHerbalism").toLowerCase(), "herbalism"); + aliasMap.put(mcLocale.getString("m.SkillMining").toLowerCase(), "mining"); + aliasMap.put(mcLocale.getString("m.SkillRepair").toLowerCase(), "repair"); + aliasMap.put(mcLocale.getString("m.SkillSwords").toLowerCase(), "swords"); + aliasMap.put(mcLocale.getString("m.SkillTaming").toLowerCase(), "taming"); + aliasMap.put(mcLocale.getString("m.SkillUnarmed").toLowerCase(), "unarmed"); + aliasMap.put(mcLocale.getString("m.SkillWoodCutting").toLowerCase(), "woodcutting"); //Register commands //Skills commands diff --git a/src/main/java/com/gmail/nossr50/party/Party.java b/src/main/java/com/gmail/nossr50/party/Party.java index 76639221d..94b6904cd 100644 --- a/src/main/java/com/gmail/nossr50/party/Party.java +++ b/src/main/java/com/gmail/nossr50/party/Party.java @@ -239,10 +239,10 @@ public class Party { informPartyMembers(player); if (!invite) { - player.sendMessage(mcLocale.getString("Commands.Party.Join", new Object[]{ newParty })); + player.sendMessage(mcLocale.getString("mcPlayerListener.JoinedParty", new Object[]{ newParty })); } else { - player.sendMessage(mcLocale.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() })); + player.sendMessage(mcLocale.getString("mcPlayerListener.InviteAccepted", new Object[]{ PP.getParty() })); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/mcBleedTimer.java b/src/main/java/com/gmail/nossr50/runnables/mcBleedTimer.java index 68a27596d..4b671139b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/mcBleedTimer.java +++ b/src/main/java/com/gmail/nossr50/runnables/mcBleedTimer.java @@ -54,7 +54,7 @@ public class mcBleedTimer implements Runnable { PP.decreaseBleedTicks(); if (PP.getBleedTicks() == 0) { - player.sendMessage(mcLocale.getString("Swords.Combat.Bleeding.Stopped")); + player.sendMessage(mcLocale.getString("Swords.StoppedBleeding")); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/Acrobatics.java index f116fd207..205c2ebd5 100644 --- a/src/main/java/com/gmail/nossr50/skills/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/Acrobatics.java @@ -68,10 +68,10 @@ public class Acrobatics { } if (gracefulRoll) { - player.sendMessage(mcLocale.getString("Acrobatics.Ability.Proc")); + player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll")); } else { - player.sendMessage(mcLocale.getString("Acrobatics.Roll.Text")); + player.sendMessage(mcLocale.getString("Acrobatics.Roll")); } } } @@ -108,7 +108,7 @@ public class Acrobatics { int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL); if (random.nextInt(4000) <= skillCheck && mcPermissions.getInstance().dodge(defender)) { - defender.sendMessage(mcLocale.getString("Acrobatics.Combat.Proc")); + defender.sendMessage(mcLocale.getString("Acrobatics.Dodge")); if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) { PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER); diff --git a/src/main/java/com/gmail/nossr50/skills/Axes.java b/src/main/java/com/gmail/nossr50/skills/Axes.java index 766ba2d5d..ae4d82013 100644 --- a/src/main/java/com/gmail/nossr50/skills/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/Axes.java @@ -82,12 +82,12 @@ public class Axes { if (entity instanceof Player){ event.setDamage((int) (damage * PVP_MODIFIER)); Player player = (Player) entity; - player.sendMessage(mcLocale.getString("Axes.Combat.CritStruck")); + player.sendMessage(mcLocale.getString("Axes.HitCritically")); } else { event.setDamage(damage * PVE_MODIFIER); } - attacker.sendMessage(mcLocale.getString("Axes.Combat.CriticalHit")); + attacker.sendMessage(mcLocale.getString("Axes.CriticalHit")); } } @@ -140,7 +140,7 @@ public class Axes { if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) { event.setDamage(event.getDamage() + 2); target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER)); - attacker.sendMessage(mcLocale.getString("Axes.Combat.GI.Proc")); + attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy")); } } diff --git a/src/main/java/com/gmail/nossr50/skills/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/BlastMining.java index a8bc7f6c8..01964c272 100644 --- a/src/main/java/com/gmail/nossr50/skills/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/BlastMining.java @@ -273,7 +273,7 @@ public class BlastMining { } } - player.sendMessage(mcLocale.getString("Mining.Blast.Boom")); + player.sendMessage(mcLocale.getString("BlastMining.Boom")); /* Create the TNT entity */ TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class); diff --git a/src/main/java/com/gmail/nossr50/skills/Fishing.java b/src/main/java/com/gmail/nossr50/skills/Fishing.java index 8c92c8f9f..a74c5e82f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/Fishing.java @@ -97,12 +97,14 @@ public class Fishing { break; } - if (LoadProperties.fishingDrops && rewards.size() > 0) { - FishingTreasure treasure = rewards.get(random.nextInt(rewards.size())); + if (LoadProperties.fishingDrops) { + if (rewards.size() > 0) { + FishingTreasure treasure = rewards.get(random.nextInt(rewards.size())); - if (random.nextDouble() * 100 <= treasure.getDropChance()) { - Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp()); - theCatch.setItemStack(treasure.getDrop()); + if (random.nextDouble() * 100 <= treasure.getDropChance()) { + Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp()); + theCatch.setItemStack(treasure.getDrop()); + } } } else { @@ -115,7 +117,6 @@ public class Fishing { theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value } - m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); //Always drop a fish PP.addXP(SkillType.FISHING, LoadProperties.mfishing); Skills.XpCheckSkill(SkillType.FISHING, player); } diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index 092a94757..9562242a7 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -90,6 +90,7 @@ public class Herbalism { case CROPS: case JACK_O_LANTERN: case MELON_BLOCK: + case NETHER_WARTS: case PUMPKIN: case RED_MUSHROOM: case RED_ROSE: diff --git a/src/main/java/com/gmail/nossr50/skills/Repair.java b/src/main/java/com/gmail/nossr50/skills/Repair.java index b4b5d5e81..8a37dd84f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/Repair.java @@ -11,6 +11,7 @@ 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; @@ -102,7 +103,7 @@ public class Repair { } } else { - player.sendMessage(mcLocale.getString("Repair.Skills.FullDurability")); + player.sendMessage(mcLocale.getString("Skills.FullDurability")); } } @@ -189,7 +190,7 @@ public class Repair { for (Enchantment x : enchants.keySet()) { is.removeEnchantment(x); } - player.sendMessage(mcLocale.getString("Repair.Arcane.Lost")); + player.sendMessage(mcLocale.getString("Repair.LostEnchants")); return; } @@ -216,13 +217,13 @@ public class Repair { Map newEnchants = is.getEnchantments(); if (newEnchants.isEmpty()) { - player.sendMessage(mcLocale.getString("Repair.Arcane.Fail")); + player.sendMessage(mcLocale.getString("Repair.ArcaneFailed")); } else if (downgraded || newEnchants.size() < enchants.size()) { - player.sendMessage(mcLocale.getString("Repair.Arcane.Downgrade")); + player.sendMessage(mcLocale.getString("Repair.Downgraded")); } else { - player.sendMessage(mcLocale.getString("Repair.Arcane.Perfect")); + player.sendMessage(mcLocale.getString("Repair.ArcanePerfect")); } } @@ -349,12 +350,12 @@ public class Repair { int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR); if (is.getAmount() != 1) { - player.sendMessage(mcLocale.getString("Repair.Skills.StackedItems")); + player.sendMessage(mcLocale.getString("Skills.StackedItems")); } else { if (ItemChecks.isDiamondTool(is) || ItemChecks.isDiamondArmor(is)) { if (skillLevel < LoadProperties.repairdiamondlevel) { - player.sendMessage(mcLocale.getString("Repair.Skills.AdeptDiamond")); + player.sendMessage(mcLocale.getString("Skills.AdeptDiamond")); } else { player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.BLUE + m.prettyItemString(LoadProperties.rDiamond)); @@ -362,7 +363,7 @@ public class Repair { } else if (ItemChecks.isIronTool(is) || ItemChecks.isIronArmor(is)) { if (skillLevel < LoadProperties.repairIronLevel) { - player.sendMessage(mcLocale.getString("Repair.Skills.AdeptIron")); + player.sendMessage(mcLocale.getString("Skills.AdeptIron")); } else { player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(LoadProperties.rIron)); @@ -370,7 +371,7 @@ public class Repair { } else if (ItemChecks.isGoldTool(is) || ItemChecks.isGoldArmor(is)) { if (skillLevel < LoadProperties.repairGoldLevel) { - player.sendMessage(mcLocale.getString("Repair.Skills.AdeptGold")); + player.sendMessage(mcLocale.getString("Skills.AdeptGold")); } else { player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.GOLD + m.prettyItemString(LoadProperties.rGold)); @@ -378,7 +379,7 @@ public class Repair { } else if (ItemChecks.isStoneTool(is)) { if (skillLevel < LoadProperties.repairStoneLevel) { - player.sendMessage(mcLocale.getString("Repair.Skills.AdeptStone")); + player.sendMessage(mcLocale.getString("Skills.AdeptStone")); } else { player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.GRAY + m.prettyItemString(LoadProperties.rStone)); @@ -408,7 +409,7 @@ public class Repair { int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR); if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().repairBonus(player)) { - player.sendMessage(mcLocale.getString("Repair.Skills.FeltEasy")); + player.sendMessage(mcLocale.getString("Skills.FeltEasy")); return true; } @@ -467,7 +468,7 @@ public class Repair { } } else { - player.sendMessage(mcLocale.getString("Repair.Listener.Anvil")); + player.sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil")); } PP.togglePlacedAnvil(); diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java index 9fbb297a5..e841f548e 100644 --- a/src/main/java/com/gmail/nossr50/skills/Skills.java +++ b/src/main/java/com/gmail/nossr50/skills/Skills.java @@ -188,8 +188,9 @@ public class Skills { while (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) { if ((skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) && (m.getPowerLevelCap() >= PP.getPowerLevel() + 1)) { + PP.removeXP(skillType, PP.getXpToLevel(skillType)); skillups++; - PP.addLevels(skillType, 1); + PP.skillUp(skillType, 1); McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType); Bukkit.getPluginManager().callEvent(eventToFire); @@ -212,23 +213,22 @@ public class Skills { if (sPlayer.isSpoutCraftEnabled()) { if (LoadProperties.xpbar) { - SpoutStuff.updateXpBar(sPlayer); + SpoutStuff.updateXpBar(player); } SpoutStuff.levelUpNotification(skillType, sPlayer); - + /* Update custom titles */ if(LoadProperties.showPowerLevel) { - sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" - + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PP.getPowerLevel())); + sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE + "." + ChatColor.GREEN + String.valueOf(PP.getPowerLevel())); } } else { - player.sendMessage(mcLocale.getString(capitalized + "Skillup", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)})); + player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)})); } } else { - player.sendMessage(mcLocale.getString(capitalized + "Skillup", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)})); + player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)})); } } @@ -237,7 +237,7 @@ public class Skills { SpoutPlayer sPlayer = (SpoutPlayer) player; if (sPlayer.isSpoutCraftEnabled()) { if (LoadProperties.xpbar) { - SpoutStuff.updateXpBar(sPlayer); + SpoutStuff.updateXpBar(player); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/Swords.java b/src/main/java/com/gmail/nossr50/skills/Swords.java index d23894cf5..c68a1fc48 100644 --- a/src/main/java/com/gmail/nossr50/skills/Swords.java +++ b/src/main/java/com/gmail/nossr50/skills/Swords.java @@ -73,7 +73,7 @@ public class Swords { else { mcBleedTimer.add(entity); } - attacker.sendMessage(mcLocale.getString("Swords.Combat.Bleeding")); + attacker.sendMessage(mcLocale.getString("Swords.EnemyBleeding")); } } @@ -104,10 +104,10 @@ public class Swords { if (random.nextInt(2000) <= skillCheck) { Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER); - defender.sendMessage(mcLocale.getString("Swords.Combat.Countered")); + defender.sendMessage(mcLocale.getString("Swords.CounterAttacked")); if (attacker instanceof Player) { - ((Player) attacker).sendMessage(mcLocale.getString("Swords.Combat.Counter.Hit")); + ((Player) attacker).sendMessage(mcLocale.getString("Swords.HitByCounterAttack")); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/Taming.java b/src/main/java/com/gmail/nossr50/skills/Taming.java index c809dcdf8..24c762916 100644 --- a/src/main/java/com/gmail/nossr50/skills/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/Taming.java @@ -154,7 +154,7 @@ public class Taming { } wolf.teleport(master.getLocation()); - master.sendMessage(mcLocale.getString("Taming.Listener.Wolf")); + master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); } } break; @@ -232,11 +232,11 @@ public class Taming { if (x.getType().equals(type)) { switch (type) { case WOLF: - player.sendMessage(mcLocale.getString("Taming.Summon.Fail.Wolf")); + player.sendMessage(mcLocale.getString("m.TamingSummonWolfFailed")); return; case OCELOT: - player.sendMessage(mcLocale.getString("Taming.Summon.Fail.Ocelot")); + player.sendMessage(mcLocale.getString("m.TamingSummonOcelotFailed")); return; default: @@ -258,7 +258,7 @@ public class Taming { } player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount)); - player.sendMessage(mcLocale.getString("Taming.Summon.Complete")); + player.sendMessage(mcLocale.getString("m.TamingSummon")); } else { player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(summonItem.getId())); diff --git a/src/main/java/com/gmail/nossr50/skills/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/Unarmed.java index 0e553a374..0fe6fbc6b 100644 --- a/src/main/java/com/gmail/nossr50/skills/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/Unarmed.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.skills; import java.util.Random; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -43,16 +44,17 @@ public class Unarmed { * @param PPa Profile of the attacking player * @param defender The defending player */ - public static void disarmProcCheck(PlayerProfile PPa, Player defender) { + public static void disarmProcCheck(Player attacker, Player defender) { final int MAX_BONUS_LEVEL = 1000; + PlayerProfile PPa = Users.getProfile(attacker); int skillLevel = PPa.getSkillLevel(SkillType.UNARMED); int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL); ItemStack inHand = defender.getItemInHand(); if (!inHand.getType().equals(Material.AIR)) { - if (random.nextInt(3000) <= skillCheck) { + if (random.nextInt(3000) <= skillCheck && ironGrip(defender, attacker)) { defender.sendMessage(mcLocale.getString("Skills.Disarmed")); m.mcDropItem(defender.getLocation(), inHand); @@ -78,4 +80,21 @@ public class Unarmed { defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); } } + + public static boolean ironGrip(Player defender, Player attacker) { + final int MAX_BONUS_LEVEL = 1000; + + PlayerProfile PPd = Users.getProfile(defender); + int skillLevel = PPd.getSkillLevel(SkillType.UNARMED); + int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL); + + if (random.nextInt(1000) <= skillCheck) { + defender.sendMessage(ChatColor.GREEN + "Your iron grip kept you from being disarmed!"); //TODO: Use locale + attacker.sendMessage(ChatColor.RED + "Your opponent has an iron grip!"); //TODO: Use locale + return true; + } + else { + return false; + } + } } diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 6efe03403..1197a3873 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -53,8 +53,8 @@ public class WoodCutting { * @param PP The PlayerProfile of the player */ private static void removeBlocks(ArrayList toBeFelled, Player player, PlayerProfile PP) { - if (toBeFelled.size() > LoadProperties.treeFellerThreshold) { - player.sendMessage(mcLocale.getString("Woodcutting.Skills.TreeFellerThreshold")); + if (toBeFelled.size() >= LoadProperties.treeFellerThreshold) { + player.sendMessage(mcLocale.getString("Skills.Woodcutting.TreeFellerThreshold")); return; } @@ -67,7 +67,7 @@ public class WoodCutting { /* This is to prevent using wood axes everytime you tree fell */ if ((inHand.getDurability() + durabilityLoss >= inHand.getType().getMaxDurability()) || inHand.getType().equals(Material.AIR)) { - player.sendMessage(mcLocale.getString("Woodcutting.Skills.TreeFeller.Splinter")); + player.sendMessage(mcLocale.getString("TreeFeller.AxeSplinters")); int health = player.getHealth(); @@ -186,6 +186,10 @@ public class WoodCutting { */ private static void processTreeFelling(Block currentBlock, ArrayList toBeFelled) { Material type = currentBlock.getType(); + + if(toBeFelled.size() >= LoadProperties.treeFellerThreshold) { + return; + } if (type.equals(Material.LOG) || type.equals(Material.LEAVES)) { toBeFelled.add(currentBlock); diff --git a/src/main/resources/locale/locale_de.properties b/src/main/resources/locale/locale_de.properties index b443d2e67..dcfb4e06e 100644 --- a/src/main/resources/locale/locale_de.properties +++ b/src/main/resources/locale/locale_de.properties @@ -227,7 +227,7 @@ mcPlayerListener.AdminChatOn=nur Adminchat [[YELLOW]]an mcPlayerListener.AdminChatOff=nur Adminchat [[RED]]aus mcPlayerListener.MOTD=[[YELLOW]]Auf diesem Server laeuft mcMMO {0}. Hilfe: [[AQUA]]/{1}[[YELLOW]] [[DARK_GRAY]] mcPlayerListener.WIKI=[[AQUA]]http://mcmmo.wikia.com[[YELLOW]] - mcMMO Wiki -mcPlayerListener.PowerLevel=[[DARK_RED]]POWER LEVEL: +mcPlayerListener.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[DARK_AQUA]]____ mcMMO[[YELLOW]] Power Level [[DARK_AQUA]]Rangliste ____ mcPlayerListener.SkillLeaderboard=[[DARK_AQUA]]____ mcMMO [[YELLOW]]{0}[[DARK_AQUA]] Rangliste ____ mcPlayerListener.RepairSkill=[[YELLOW]]Reparieren Skill [[DARK_AQUA]](Repair): diff --git a/src/main/resources/locale/locale_es_es.properties b/src/main/resources/locale/locale_es_es.properties index ff8cdc40d..78818f616 100644 --- a/src/main/resources/locale/locale_es_es.properties +++ b/src/main/resources/locale/locale_es_es.properties @@ -228,7 +228,7 @@ mcPlayerListener.AdminChatOn=Solo Chat de Admins [[GREEN]]Activado mcPlayerListener.AdminChatOff=Solo Chat de Admins [[RED]]Desactivado mcPlayerListener.MOTD=[[BLUE]]Este server esta ejecutando mcMMO {0} escribe [[YELLOW]]/{1}[[BLUE]] para obtener ayuda. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki -mcPlayerListener.PowerLevel=[[DARK_RED]]NIVEL DE PODER: +mcPlayerListener.PowerLevel=[[DARK_RED]]NIVEL DE PODER: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--mcMMO[[BLUE]] Nivel de Poder [[YELLOW]]Ranking de lideres-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Ranking de lideres-- mcPlayerListener.RepairSkill=Reparar: diff --git a/src/main/resources/locale/locale_fi.properties b/src/main/resources/locale/locale_fi.properties index b23d5a30a..9bfba19c3 100644 --- a/src/main/resources/locale/locale_fi.properties +++ b/src/main/resources/locale/locale_fi.properties @@ -228,7 +228,7 @@ mcPlayerListener.AdminChatOn=Vain admin juttelu [[GREEN]]P mcPlayerListener.AdminChatOff=Vain admin juttelu [[RED]]Pois päältä mcPlayerListener.MOTD=[[BLUE]]Tällä serverillä on mcMMO {0} kirjoita [[YELLOW]]/{1}[[BLUE]] apua varten. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki -mcPlayerListener.PowerLevel=[[DARK_RED]]VOIMATASO: +mcPlayerListener.PowerLevel=[[DARK_RED]]VOIMATASO: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--mcMMO[[BLUE]] Voimataso [[YELLOW]]Tulostaulukko-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Tulostaulukko-- mcPlayerListener.RepairSkill=[[YELLOW]]Korjaus: diff --git a/src/main/resources/locale/locale_fr.properties b/src/main/resources/locale/locale_fr.properties index e555c60a5..f47b38a94 100644 --- a/src/main/resources/locale/locale_fr.properties +++ b/src/main/resources/locale/locale_fr.properties @@ -228,7 +228,7 @@ mcPlayerListener.AdminChatOn=Admin Chat uniquement [[GREEN]]On mcPlayerListener.AdminChatOff=Admin Chat uniquement [[RED]]Off mcPlayerListener.MOTD=[[BLUE]]Ce serveur fonctionne avec mcMMO {0} [[YELLOW]]/{1}[[BLUE]] pour voir l'aide. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki - [[YELLOW]]Traduit par avalondrey & Misa -mcPlayerListener.PowerLevel=[[DARK_RED]]POWER LEVEL: +mcPlayerListener.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard-- mcPlayerListener.RepairSkill=[[YELLOW]]Réparation (/Repair) : diff --git a/src/main/resources/locale/locale_it.properties b/src/main/resources/locale/locale_it.properties index 233f0a884..df15eab3d 100644 --- a/src/main/resources/locale/locale_it.properties +++ b/src/main/resources/locale/locale_it.properties @@ -230,7 +230,7 @@ mcPlayerListener.AdminChatOn=Admin Chat [[GREEN]]Attiva mcPlayerListener.AdminChatOff=Admin Chat [[RED]]Disattiva mcPlayerListener.MOTD=[[BLUE]]Questo server tiene McMmmo {0} scrivi [[YELLOW]]/{1}[[BLUE]] per la lista aiuti. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki -mcPlayerListener.PowerLevel=[[DARK_RED]]Livello di potenza: +mcPlayerListener.PowerLevel=[[DARK_RED]]Livello di potenza: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--mcMMO[[BLUE]] Livello di potenza [[YELLOW]]Classifica-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Classifica-- mcPlayerListener.RepairSkill=Riparazioni: diff --git a/src/main/resources/locale/locale_nl.properties b/src/main/resources/locale/locale_nl.properties index 8e0b54b90..96526676e 100644 --- a/src/main/resources/locale/locale_nl.properties +++ b/src/main/resources/locale/locale_nl.properties @@ -234,7 +234,7 @@ mcPlayerListener.AdminChatOn=Alleen Admin Chat [[GREEN]]aan mcPlayerListener.AdminChatOff=Alleen Admin Chat [[RED]]uit mcPlayerListener.MOTD=[[BLUE]]Deze server werkt op mcMMO {0} type [[YELLOW]]/{1}[[BLUE]] voor hulp. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki -mcPlayerListener.PowerLevel=[[DARK_RED]]POWER LEVEL: +mcPlayerListener.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Highscore-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Highscore-- mcPlayerListener.RepairSkill=Repareren: diff --git a/src/main/resources/locale/locale_pl.properties b/src/main/resources/locale/locale_pl.properties index 3095ac8e3..2fc2e7a80 100644 --- a/src/main/resources/locale/locale_pl.properties +++ b/src/main/resources/locale/locale_pl.properties @@ -228,7 +228,7 @@ mcPlayerListener.AdminChatOn=Chat tylko dla adminow [[GREEN]]WLACZONY mcPlayerListener.AdminChatOff=Chat tylko dla adminow [[RED]]WYLACZONY mcPlayerListener.MOTD=[[BLUE]]Ten server uzywa plugina mcMMO {0} wpisz [[YELLOW]]/{1}[[BLUE]] aby uzyskac pomoc. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki -mcPlayerListener.PowerLevel=[[DARK_RED]]POZIOM MOCY: +mcPlayerListener.PowerLevel=[[DARK_RED]]POZIOM MOCY: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--Ranking [[BLUE]]poziomu mocy [[YELLOW]]mcMMO-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--Ranking [[BLUE]]{0}[[YELLOW]] mcMMO-- mcPlayerListener.RepairSkill=Naprawa: diff --git a/src/main/resources/locale/locale_pt_br.properties b/src/main/resources/locale/locale_pt_br.properties index 65887b87d..7c1fb9a03 100644 --- a/src/main/resources/locale/locale_pt_br.properties +++ b/src/main/resources/locale/locale_pt_br.properties @@ -234,7 +234,7 @@ mcPlayerListener.AdminChatOn=Chat do Admin [[GREEN]]On mcPlayerListener.AdminChatOff=Chat do Admin [[RED]]Off mcPlayerListener.MOTD=[[BLUE]]Esse Server está rodando o mcMMO {0} digite [[YELLOW]]/{1}[[BLUE]] para obter ajuda. mcPlayerListener.WIKI=[[BLUE]]Para mais informaçoes - [[GREEN]]http://mcmmo.wikia.com -mcPlayerListener.PowerLevel=[[RED]]NIVEL TOTAL: +mcPlayerListener.PowerLevel=[[RED]]NIVEL TOTAL: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[BLUE]]-Classificaçao - [[GREEN]]Nível - [[WHITE]]Jogador- mcPlayerListener.SkillLeaderboard=[[BLUE]]-Classificaçao em [[GREEN]]{0} mcPlayerListener.RepairSkill=Reparaçao (Repair): diff --git a/src/main/resources/locale/locale_ru.properties b/src/main/resources/locale/locale_ru.properties index cc4dd9b2c..2b1bfdbae 100644 --- a/src/main/resources/locale/locale_ru.properties +++ b/src/main/resources/locale/locale_ru.properties @@ -228,7 +228,7 @@ mcPlayerListener.AdminChatOn= mcPlayerListener.AdminChatOff=Òîëüêî àäìèí ÷àò [[RED]]Âûêëþ÷åíî mcPlayerListener.MOTD=[[BLUE]]Íà ýòîì ñåðâåðå óñòàíîâëåí ïëàãèí McMMO {0} type [[YELLOW]]/{1}[[BLUE]] äëÿ ïîìîùè. mcPlayerListener.WIKI=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Âèêèïåäèÿ -mcPlayerListener.PowerLevel=[[DARK_RED]]Óðîâåíü óìåíèé: +mcPlayerListener.PowerLevel=[[DARK_RED]]Óðîâåíü óìåíèé: [[GREEN]]{0} mcPlayerListener.PowerLevelLeaderboard=[[YELLOW]]--mcMMO[[BLUE]] Óðîâåíü óìåíèé [[YELLOW]]Äîñêà Ëèäåðîâ-- mcPlayerListener.SkillLeaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Äîñêà Ëèäåðîâ-- mcPlayerListener.RepairSkill=Ïî÷èíêà: