diff --git a/Changelog.txt b/Changelog.txt index 6389a4028..0e1b3b367 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,8 @@ 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 diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index a2e533cbd..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); diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java index 9c5582f93..2ce4ce52e 100644 --- a/src/main/java/com/gmail/nossr50/api/ChatAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -23,7 +23,9 @@ public class ChatAPI { McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message); Bukkit.getPluginManager().callEvent(chatEvent); - if(chatEvent.isCancelled()) return; + if (chatEvent.isCancelled()) { + return; + } String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.GREEN + ") "; @@ -50,7 +52,9 @@ public class ChatAPI { McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message); Bukkit.getPluginManager().callEvent(chatEvent); - if(chatEvent.isCancelled()) return; + if (chatEvent.isCancelled()) { + return; + } String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.AQUA + "} "; 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/skills/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/Unarmed.java index 0e553a374..ad54f35e1 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(3000) <= 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; + } + } }