From 974862a60aa9309c14aaa4d993868dface5b0f84 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Sun, 6 Jan 2013 17:52:31 -0800 Subject: [PATCH] Updating permissions for consistency. --- .../java/com/gmail/nossr50/api/ChatAPI.java | 2 +- .../gmail/nossr50/commands/CommandHelper.java | 26 +- .../gmail/nossr50/commands/SkillCommand.java | 1 - .../commands/general/InspectCommand.java | 4 +- .../gmail/nossr50/commands/mc/MccCommand.java | 18 +- .../nossr50/commands/party/ACommand.java | 4 +- .../commands/skills/AcrobaticsCommand.java | 11 +- .../commands/skills/ArcheryCommand.java | 11 +- .../nossr50/commands/skills/AxesCommand.java | 15 +- .../commands/skills/ExcavationCommand.java | 9 +- .../commands/skills/FishingCommand.java | 15 +- .../commands/skills/HerbalismCommand.java | 15 +- .../commands/skills/MiningCommand.java | 15 +- .../commands/skills/RepairCommand.java | 29 +- .../commands/skills/SwordsCommand.java | 11 +- .../commands/skills/TamingCommand.java | 21 +- .../commands/skills/UnarmedCommand.java | 13 +- .../commands/skills/WoodcuttingCommand.java | 11 +- .../nossr50/commands/spout/XplockCommand.java | 2 +- .../gmail/nossr50/datatypes/AbilityType.java | 19 +- .../gmail/nossr50/datatypes/McMMOPlayer.java | 11 +- .../gmail/nossr50/datatypes/SkillType.java | 24 +- .../nossr50/listeners/BlockListener.java | 18 +- .../nossr50/listeners/EntityListener.java | 10 +- .../nossr50/listeners/HardcoreListener.java | 2 +- .../nossr50/listeners/PlayerListener.java | 68 +-- .../skills/acrobatics/AcrobaticsManager.java | 9 +- .../skills/acrobatics/RollEventHandler.java | 2 +- .../skills/archery/ArcheryManager.java | 21 +- .../com/gmail/nossr50/skills/combat/Axes.java | 6 +- .../nossr50/skills/gathering/Excavation.java | 4 +- .../nossr50/skills/gathering/Fishing.java | 12 +- .../nossr50/skills/gathering/Herbalism.java | 18 +- .../nossr50/skills/gathering/Mining.java | 4 +- .../nossr50/skills/gathering/WoodCutting.java | 6 +- .../gmail/nossr50/skills/repair/Repair.java | 13 +- .../nossr50/skills/repair/RepairItemType.java | 6 +- .../skills/repair/RepairMaterialType.java | 16 +- .../gmail/nossr50/skills/repair/Salvage.java | 3 +- .../skills/repair/SimpleRepairManager.java | 2 +- .../nossr50/skills/swords/SwordsManager.java | 21 +- .../nossr50/skills/taming/TamingManager.java | 46 +- .../skills/unarmed/UnarmedManager.java | 28 +- .../java/com/gmail/nossr50/util/Combat.java | 15 +- .../java/com/gmail/nossr50/util/Item.java | 2 +- .../com/gmail/nossr50/util/Permissions.java | 511 +++++++++++------- .../java/com/gmail/nossr50/util/Skills.java | 40 +- src/main/resources/plugin.yml | 186 ++++++- 48 files changed, 782 insertions(+), 574 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java index 0d7b7a4a0..e45efdfb6 100644 --- a/src/main/java/com/gmail/nossr50/api/ChatAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -64,7 +64,7 @@ public final class ChatAPI { mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage()); for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - if (Permissions.getInstance().adminChat(player) || player.isOp()) + if (Permissions.adminChat(player) || player.isOp()) player.sendMessage(aPrefix + chatEvent.getMessage()); } } diff --git a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandHelper.java index 1e038f104..c164ee0c9 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandHelper.java @@ -23,7 +23,7 @@ public class CommandHelper { if (sender instanceof Player) { Player player = (Player) sender; - if (!Permissions.getInstance().permission(player, permission)) { + if (!Permissions.hasPermission(player, permission)) { player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); return true; } @@ -58,23 +58,23 @@ public class CommandHelper { display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); - if (Permissions.getInstance().excavation(inspect)) { + if (Permissions.excavation(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) })); } - if (Permissions.getInstance().fishing(inspect)) { + if (Permissions.fishing(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) })); } - if (Permissions.getInstance().herbalism(inspect)) { + if (Permissions.herbalism(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) })); } - if (Permissions.getInstance().mining(inspect)) { + if (Permissions.mining(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) })); } - if (Permissions.getInstance().woodcutting(inspect)) { + if (Permissions.woodcutting(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) })); } } @@ -101,23 +101,23 @@ public class CommandHelper { display.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); - if (Permissions.getInstance().axes(inspect)) { + if (Permissions.axes(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) })); } - if (Permissions.getInstance().archery(inspect)) { + if (Permissions.archery(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) })); } - if (Permissions.getInstance().swords(inspect)) { + if (Permissions.swords(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) })); } - if (Permissions.getInstance().taming(inspect)) { + if (Permissions.taming(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) })); } - if (Permissions.getInstance().unarmed(inspect)) { + if (Permissions.unarmed(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) })); } } @@ -144,11 +144,11 @@ public class CommandHelper { display.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); - if (Permissions.getInstance().acrobatics(inspect)) { + if (Permissions.acrobatics(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) })); } - if (Permissions.getInstance().repair(inspect)) { + if (Permissions.repair(inspect)) { display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) })); } } diff --git a/src/main/java/com/gmail/nossr50/commands/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/SkillCommand.java index e56911820..61804f0a9 100644 --- a/src/main/java/com/gmail/nossr50/commands/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/SkillCommand.java @@ -25,7 +25,6 @@ public abstract class SkillCommand implements CommandExecutor { protected float skillValue; protected DecimalFormat percent = new DecimalFormat("##0.00%"); - protected Permissions permInstance = Permissions.getInstance(); public SkillCommand(SkillType skill) { this.skill = skill; 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 5404ae1ef..b413d2c97 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -30,7 +30,7 @@ public class InspectCommand implements CommandExecutor { if (mcmmoPlayer != null) { Player target = mcmmoPlayer.getPlayer(); - if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) { + if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.inspectDistanceBypass((Player) sender)) { sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); return true; } @@ -44,7 +44,7 @@ public class InspectCommand implements CommandExecutor { return true; } else { - if (sender instanceof Player && !sender.isOp() && !Permissions.getInstance().inspectOfflineBypass((Player) sender)) { + if (sender instanceof Player && !sender.isOp() && !Permissions.inspectOfflineBypass((Player) sender)) { sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java index 968eec25d..438ab3632 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java @@ -24,19 +24,19 @@ public class MccCommand implements CommandExecutor { player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---"); //TODO: Needs more locale. - if (Permissions.getInstance().party(player)) { + if (Permissions.party(player)) { player.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); player.sendMessage("/party " + LocaleLoader.getString("Commands.Party")); player.sendMessage("/party q " + LocaleLoader.getString("Commands.Party.Quit")); - if (Permissions.getInstance().partyChat(player)) { + if (Permissions.partyChat(player)) { player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle")); } player.sendMessage("/invite " + LocaleLoader.getString("Commands.Party.Invite")); player.sendMessage("/accept " + LocaleLoader.getString("Commands.Party.Accept")); - if (Permissions.getInstance().partyTeleport(player)) { + if (Permissions.partyTeleport(player)) { player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport")); } } @@ -45,27 +45,27 @@ public class MccCommand implements CommandExecutor { player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats")); player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards")); - if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) { + if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.skillReset(player)) { player.sendMessage("/skillreset " + LocaleLoader.getString("Commands.Reset")); } - if (Permissions.getInstance().mcAbility(player)) { + if (Permissions.mcAbility(player)) { player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility")); } - if (Permissions.getInstance().adminChat(player)) { + if (Permissions.adminChat(player)) { player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle")); } - if (Permissions.getInstance().inspect(player)) { + if (Permissions.inspect(player)) { player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect")); } - if (Permissions.getInstance().mmoedit(player)) { + if (Permissions.mmoedit(player)) { player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit")); } - if (Permissions.getInstance().mcgod(player)) { + if (Permissions.mcgod(player)) { player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod")); } 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 de535b45f..cb4bf9eba 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java @@ -81,7 +81,7 @@ public class ACommand implements CommandExecutor { plugin.getLogger().info("[A]<" + player.getName() + "> " + message); for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) { - if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) { + if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) { otherPlayer.sendMessage(prefix + message); } } @@ -100,7 +100,7 @@ public class ACommand implements CommandExecutor { plugin.getLogger().info("[A]<*Console*> " + message); for (Player player : plugin.getServer().getOnlinePlayers()) { - if (Permissions.getInstance().adminChat(player) || player.isOp()) { + if (Permissions.adminChat(player) || player.isOp()) { player.sendMessage(prefix + message); } } 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 51c61cb8c..6abe06713 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.commands.SkillCommand; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class AcrobaticsCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -26,6 +27,7 @@ public class AcrobaticsCommand extends SkillCommand { private boolean canDodge; private boolean canRoll; private boolean canGracefulRoll; + private boolean lucky; public AcrobaticsCommand() { super(SkillType.ACROBATICS); @@ -47,9 +49,10 @@ public class AcrobaticsCommand extends SkillCommand { @Override protected void permissionsCheck() { - canDodge = permInstance.dodge(player); - canRoll = permInstance.roll(player); - canGracefulRoll = permInstance.gracefulRoll(player); + canDodge = Permissions.dodge(player); + canRoll = Permissions.roll(player); + canGracefulRoll = Permissions.gracefulRoll(player); + lucky = Permissions.luckyAcrobatics(player); } @Override @@ -59,7 +62,7 @@ public class AcrobaticsCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Acrobatics" }) })); } 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 cd1e7e5da..bdc6472d5 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.commands.SkillCommand; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class ArcheryCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -30,6 +31,7 @@ public class ArcheryCommand extends SkillCommand { private boolean canSkillShot; private boolean canDaze; private boolean canRetrieve; + private boolean lucky; public ArcheryCommand() { super(SkillType.ARCHERY); @@ -54,9 +56,10 @@ public class ArcheryCommand extends SkillCommand { @Override protected void permissionsCheck() { - canSkillShot = permInstance.archeryBonus(player); - canDaze = permInstance.daze(player); - canRetrieve = permInstance.trackArrows(player); + canSkillShot = Permissions.archeryBonus(player); + canDaze = Permissions.daze(player); + canRetrieve = Permissions.trackArrows(player); + lucky = Permissions.luckyArchery(player); } @Override @@ -66,7 +69,7 @@ public class ArcheryCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.archery")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Archery" }) })); } 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 f422f39bd..d09dc46ea 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -9,6 +9,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; public class AxesCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -32,6 +33,7 @@ public class AxesCommand extends SkillCommand { private boolean canBonusDamage; private boolean canImpact; private boolean canGreaterImpact; + private boolean lucky; public AxesCommand() { super(SkillType.AXES); @@ -54,11 +56,12 @@ public class AxesCommand extends SkillCommand { @Override protected void permissionsCheck() { - canSkullSplitter = permInstance.skullSplitter(player); - canCritical = permInstance.criticalHit(player); - canBonusDamage = permInstance.axeBonus(player); - canImpact = permInstance.impact(player); - canGreaterImpact = permInstance.greaterImpact(player); + canSkullSplitter = Permissions.skullSplitter(player); + canCritical = Permissions.criticalHit(player); + canBonusDamage = Permissions.axeBonus(player); + canImpact = Permissions.impact(player); + canGreaterImpact = Permissions.greaterImpact(player); + lucky = Permissions.luckyAxes(player); } @Override @@ -68,7 +71,7 @@ public class AxesCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.axes")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Axes" }) })); } 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 c72694c08..54240a1bb 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.commands.SkillCommand; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class ExcavationCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -15,6 +16,7 @@ public class ExcavationCommand extends SkillCommand { private boolean canGigaDrill; private boolean canTreasureHunt; + private boolean lucky; public ExcavationCommand() { super(SkillType.EXCAVATION); @@ -27,8 +29,9 @@ public class ExcavationCommand extends SkillCommand { @Override protected void permissionsCheck() { - canGigaDrill = permInstance.gigaDrillBreaker(player); - canTreasureHunt = permInstance.excavationTreasures(player); + canGigaDrill = Permissions.gigaDrillBreaker(player); + canTreasureHunt = Permissions.excavationTreasures(player); + lucky = Permissions.luckyExcavation(player); } @Override @@ -38,7 +41,7 @@ public class ExcavationCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.excavation")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Excavation" }) })); } 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 c599d35dc..50233e6ff 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.gathering.Fishing; +import com.gmail.nossr50.util.Permissions; public class FishingCommand extends SkillCommand { @@ -22,6 +23,7 @@ public class FishingCommand extends SkillCommand { private boolean canMagicHunt; private boolean canShake; private boolean canFishermansDiet; + private boolean lucky; public FishingCommand() { super(SkillType.FISHING); @@ -32,7 +34,7 @@ public class FishingCommand extends SkillCommand { lootTier = Fishing.getFishingLootTier(profile); magicChance = percent.format(lootTier / 15D); int dropChance = Fishing.getShakeChance(lootTier); - if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + if (Permissions.luckyFishing(player)) { dropChance = (int) (dropChance * 1.25D); } shakeChance = String.valueOf(dropChance); @@ -57,10 +59,11 @@ public class FishingCommand extends SkillCommand { @Override protected void permissionsCheck() { - canTreasureHunt = permInstance.fishingTreasures(player); - canMagicHunt = permInstance.fishingMagic(player); - canShake = permInstance.shakeMob(player); - canFishermansDiet = permInstance.fishermansDiet(player); + canTreasureHunt = Permissions.fishingTreasures(player); + canMagicHunt = Permissions.fishingMagic(player); + canShake = Permissions.shakeMob(player); + canFishermansDiet = Permissions.fishermansDiet(player); + lucky = Permissions.luckyFishing(player); } @Override @@ -70,7 +73,7 @@ public class FishingCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Fishing" }) })); } 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 7f8a657ab..306aae036 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -9,6 +9,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class HerbalismCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -35,6 +36,7 @@ public class HerbalismCommand extends SkillCommand { private boolean canFarmersDiet; private boolean canDoubleDrop; private boolean doubleDropsDisabled; + private boolean lucky; public HerbalismCommand() { super(SkillType.HERBALISM); @@ -63,12 +65,13 @@ public class HerbalismCommand extends SkillCommand { protected void permissionsCheck() { Config configInstance = Config.getInstance(); - canGreenTerra = permInstance.greenTerra(player); - canGreenThumbWheat = permInstance.greenThumbWheat(player); - canGreenThumbBlocks = permInstance.greenThumbBlocks(player); - canFarmersDiet = permInstance.farmersDiet(player); - canDoubleDrop = permInstance.herbalismDoubleDrops(player); + canGreenTerra = Permissions.greenTerra(player); + canGreenThumbWheat = Permissions.greenThumbWheat(player); + canGreenThumbBlocks = Permissions.greenThumbBlocks(player); + canFarmersDiet = Permissions.farmersDiet(player); + canDoubleDrop = Permissions.herbalismDoubleDrops(player); doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled(); + lucky = Permissions.luckyHerbalism(player); } @Override @@ -78,7 +81,7 @@ public class HerbalismCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Herbalism" }) })); } 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 66d1d12f7..70b2af8aa 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -10,6 +10,7 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; public class MiningCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -38,6 +39,7 @@ public class MiningCommand extends SkillCommand { private boolean canBiggerBombs; private boolean canDemoExpert; private boolean doubleDropsDisabled; + private boolean lucky; public MiningCommand() { super(SkillType.MINING); @@ -101,12 +103,13 @@ public class MiningCommand extends SkillCommand { protected void permissionsCheck() { Config configInstance = Config.getInstance(); - canBiggerBombs = permInstance.biggerBombs(player); - canBlast = permInstance.blastMining(player); - canDemoExpert = permInstance.demolitionsExpertise(player); - canDoubleDrop = permInstance.miningDoubleDrops(player); - canSuperBreaker = permInstance.superBreaker(player); + canBiggerBombs = Permissions.biggerBombs(player); + canBlast = Permissions.blastMining(player); + canDemoExpert = Permissions.demolitionsExpertise(player); + canDoubleDrop = Permissions.miningDoubleDrops(player); + canSuperBreaker = Permissions.superBreaker(player); doubleDropsDisabled = configInstance.miningDoubleDropsDisabled(); + lucky = Permissions.luckyMining(player); } @Override @@ -116,7 +119,7 @@ public class MiningCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.mining")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Mining" }) })); } 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 94d9a00b7..11ab0fb25 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Repairable; +import com.gmail.nossr50.util.Permissions; public class RepairCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -36,6 +37,7 @@ public class RepairCommand extends SkillCommand { private boolean canRepairLeather; private boolean canRepairWood; private boolean arcaneBypass; + private boolean lucky; private int salvageLevel; private int diamondLevel; @@ -74,18 +76,19 @@ public class RepairCommand extends SkillCommand { @Override protected void permissionsCheck() { - canSuperRepair = permInstance.repairBonus(player); - canMasterRepair = permInstance.repairMastery(player); - canArcaneForge = permInstance.arcaneForging(player); - canSalvage = permInstance.salvage(player); - canRepairDiamond = permInstance.diamondRepair(player); - canRepairGold = permInstance.goldRepair(player); - canRepairIron = permInstance.ironRepair(player); - canRepairStone = permInstance.stoneRepair(player); - canRepairString = permInstance.stringRepair(player); - canRepairLeather = permInstance.leatherRepair(player); - canRepairWood = permInstance.woodRepair(player); - arcaneBypass = permInstance.arcaneBypass(player); + canSuperRepair = Permissions.repairBonus(player); + canMasterRepair = Permissions.repairMastery(player); + canArcaneForge = Permissions.arcaneForging(player); + canSalvage = Permissions.salvage(player); + canRepairDiamond = Permissions.diamondRepair(player); + canRepairGold = Permissions.goldRepair(player); + canRepairIron = Permissions.ironRepair(player); + canRepairStone = Permissions.stoneRepair(player); + canRepairString = Permissions.stringRepair(player); + canRepairLeather = Permissions.leatherRepair(player); + canRepairWood = Permissions.woodRepair(player); + arcaneBypass = Permissions.arcaneBypass(player); + lucky = Permissions.luckyRepair(player); } @Override @@ -95,7 +98,7 @@ public class RepairCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.repair")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Repair" }) })); } 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 3a5649071..6a0fb0418 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.commands.SkillCommand; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class SwordsCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -29,6 +30,7 @@ public class SwordsCommand extends SkillCommand { private boolean canCounter; private boolean canSerratedStrike; private boolean canBleed; + private boolean lucky; public SwordsCommand() { super(SkillType.SWORDS); @@ -53,9 +55,10 @@ public class SwordsCommand extends SkillCommand { @Override protected void permissionsCheck() { - canBleed = permInstance.swordsBleed(player); - canCounter = permInstance.counterAttack(player); - canSerratedStrike = permInstance.serratedStrikes(player); + canBleed = Permissions.swordsBleed(player); + canCounter = Permissions.counterAttack(player); + canSerratedStrike = Permissions.serratedStrikes(player); + lucky = Permissions.luckySwords(player); } @Override @@ -65,7 +68,7 @@ public class SwordsCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.swords")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Swords" }) })); } 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 03f915b34..f60e7e103 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -9,6 +9,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class TamingCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -31,6 +32,7 @@ public class TamingCommand extends SkillCommand { private boolean canShockProof; private boolean canCallWild; private boolean canFastFood; + private boolean lucky; public TamingCommand() { super(SkillType.TAMING); @@ -45,14 +47,15 @@ public class TamingCommand extends SkillCommand { @Override protected void permissionsCheck() { - canBeastLore = permInstance.beastLore(player); - canCallWild = permInstance.callOfTheWild(player); - canEnvironmentallyAware = permInstance.environmentallyAware(player); - canFastFood = permInstance.fastFoodService(player); - canGore = permInstance.gore(player); - canSharpenedClaws = permInstance.sharpenedClaws(player); - canShockProof = permInstance.shockProof(player); - canThickFur = permInstance.thickFur(player); + canBeastLore = Permissions.beastLore(player); + canCallWild = Permissions.callOfTheWild(player); + canEnvironmentallyAware = Permissions.environmentallyAware(player); + canFastFood = Permissions.fastFoodService(player); + canGore = Permissions.gore(player); + canSharpenedClaws = Permissions.sharpenedClaws(player); + canShockProof = Permissions.shockProof(player); + canThickFur = Permissions.thickFur(player); + lucky = Permissions.luckyTaming(player); } @Override @@ -62,7 +65,7 @@ public class TamingCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.taming")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Taming" }) })); } 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 2cb86b9fa..370e52040 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.commands.SkillCommand; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class UnarmedCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -28,6 +29,7 @@ public class UnarmedCommand extends SkillCommand { private boolean canDisarm; private boolean canBonusDamage; private boolean canDeflect; + private boolean lucky; public UnarmedCommand() { super(SkillType.UNARMED); @@ -50,10 +52,11 @@ public class UnarmedCommand extends SkillCommand { @Override protected void permissionsCheck() { - canBerserk = permInstance.berserk(player); - canBonusDamage = permInstance.unarmedBonus(player); - canDeflect = permInstance.deflect(player); - canDisarm = permInstance.disarm(player); + canBerserk = Permissions.berserk(player); + canBonusDamage = Permissions.unarmedBonus(player); + canDeflect = Permissions.deflect(player); + canDisarm = Permissions.disarm(player); + lucky = Permissions.luckyUnarmed(player); } @Override @@ -63,7 +66,7 @@ public class UnarmedCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Unarmed" }) })); } 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 80ea1fc32..6352f6a5f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -9,6 +9,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class WoodcuttingCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -24,6 +25,7 @@ public class WoodcuttingCommand extends SkillCommand { private boolean canLeafBlow; private boolean canDoubleDrop; private boolean doubleDropsDisabled; + private boolean lucky; public WoodcuttingCommand() { super(SkillType.WOODCUTTING); @@ -42,10 +44,11 @@ public class WoodcuttingCommand extends SkillCommand { protected void permissionsCheck() { Config configInstance = Config.getInstance(); - canTreeFell = permInstance.treeFeller(player); - canDoubleDrop = permInstance.woodcuttingDoubleDrops(player); - canLeafBlow = permInstance.leafBlower(player); + canTreeFell = Permissions.treeFeller(player); + canDoubleDrop = Permissions.woodcuttingDoubleDrops(player); + canLeafBlow = Permissions.leafBlower(player); doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled(); + lucky = Permissions.luckyWoodcutting(player); } @Override @@ -55,7 +58,7 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) { + if (lucky) { String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Woodcutting" }) })); } 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 e322ae6b2..18ff70558 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java @@ -65,7 +65,7 @@ public class XplockCommand implements CommandExecutor { case 1: if (Skills.isSkill(args[0])) { - if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) { + if (Permissions.hasPermission(player, "mcmmo.skills." + args[0].toLowerCase())) { spoutHud.setXpBarLocked(true); spoutHud.setSkillLock(Skills.getSkillType(args[0])); spoutHud.updateXpBar(); diff --git a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java index e3a7e8125..79209bd11 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java @@ -144,35 +144,34 @@ public enum AbilityType { * @return true if the player has permissions, false otherwise */ public boolean getPermissions(Player player) { - Permissions permInstance = Permissions.getInstance(); switch (this) { case BERSERK: - return permInstance.berserk(player); + return Permissions.berserk(player); case BLAST_MINING: - return permInstance.blastMining(player); + return Permissions.blastMining(player); case GIGA_DRILL_BREAKER: - return permInstance.gigaDrillBreaker(player); + return Permissions.gigaDrillBreaker(player); case GREEN_TERRA: - return permInstance.greenTerra(player); + return Permissions.greenTerra(player); case LEAF_BLOWER: - return permInstance.leafBlower(player); + return Permissions.leafBlower(player); case SERRATED_STRIKES: - return permInstance.serratedStrikes(player); + return Permissions.serratedStrikes(player); case SKULL_SPLIITER: - return permInstance.skullSplitter(player); + return Permissions.skullSplitter(player); case SUPER_BREAKER: - return permInstance.superBreaker(player); + return Permissions.superBreaker(player); case TREE_FELLER: - return permInstance.treeFeller(player); + return Permissions.treeFeller(player); default: return false; diff --git a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java index ecad2956c..4b1d189e7 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java @@ -12,6 +12,7 @@ import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModChecks; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class McMMOPlayer { @@ -154,19 +155,19 @@ public class McMMOPlayer { } } - if (player.hasPermission("mcmmo.perks.xp.quadruple")) { + if (Permissions.xpQuadruple(player)) { xp = xp * 4; } - else if (player.hasPermission("mcmmo.perks.xp.triple")) { + else if (Permissions.xpTriple(player)) { xp = xp * 3; } - else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) { + else if (Permissions.xpDoubleAndOneHalf(player)) { xp = (int) (xp * 2.5); } - else if (player.hasPermission("mcmmo.perks.xp.double")) { + else if (Permissions.xpDouble(player)) { xp = xp * 2; } - else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) { + else if (Permissions.xpOneAndOneHalf(player)) { xp = (int) (xp * 1.5); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/SkillType.java index e678d6b64..658315b8b 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/SkillType.java @@ -75,40 +75,40 @@ public enum SkillType { public boolean getPermissions(Player player) { switch (this) { case ACROBATICS: - return Permissions.getInstance().acrobatics(player); + return Permissions.acrobatics(player); case ARCHERY: - return Permissions.getInstance().archery(player); + return Permissions.archery(player); case AXES: - return Permissions.getInstance().axes(player); + return Permissions.axes(player); case EXCAVATION: - return Permissions.getInstance().excavation(player); + return Permissions.excavation(player); case FISHING: - return Permissions.getInstance().fishing(player); + return Permissions.fishing(player); case HERBALISM: - return Permissions.getInstance().herbalism(player); + return Permissions.herbalism(player); case MINING: - return Permissions.getInstance().mining(player); + return Permissions.mining(player); case REPAIR: - return Permissions.getInstance().repair(player); + return Permissions.repair(player); case SWORDS: - return Permissions.getInstance().swords(player); + return Permissions.swords(player); case TAMING: - return Permissions.getInstance().taming(player); + return Permissions.taming(player); case UNARMED: - return Permissions.getInstance().unarmed(player); + return Permissions.unarmed(player); case WOODCUTTING: - return Permissions.getInstance().woodcutting(player); + return Permissions.woodcutting(player); default: return false; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index ec683a906..b781f303c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -184,12 +184,11 @@ public class BlockListener implements Listener { ItemStack inHand = player.getItemInHand(); Config configInstance = Config.getInstance(); - Permissions permInstance = Permissions.getInstance(); /* HERBALISM */ if (BlockChecks.canBeGreenTerra(block)) { /* Green Terra */ - if (profile.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) { + if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) { Skills.abilityCheck(player, SkillType.HERBALISM); } @@ -198,13 +197,13 @@ public class BlockListener implements Listener { Herbalism.herbalismProcCheck(block, player, event, plugin); } - if (permInstance.herbalism(player)) { + if (Permissions.herbalism(player)) { Herbalism.herbalismProcCheck(block, player, event, plugin); } } /* MINING */ - else if (BlockChecks.canBeSuperBroken(block) && permInstance.mining(player)) { + else if (BlockChecks.canBeSuperBroken(block) && Permissions.mining(player)) { if (configInstance.getMiningRequiresTool()) { if (ItemChecks.isPickaxe(inHand)) { Mining.miningBlockCheck(player, block); @@ -216,7 +215,7 @@ public class BlockListener implements Listener { } /* WOOD CUTTING */ - else if (BlockChecks.isLog(block) && permInstance.woodcutting(player)) { + else if (BlockChecks.isLog(block) && Permissions.woodcutting(player)) { if (configInstance.getWoodcuttingRequiresTool()) { if (ItemChecks.isAxe(inHand)) { WoodCutting.woodcuttingBlockCheck(player, block); @@ -226,13 +225,13 @@ public class BlockListener implements Listener { WoodCutting.woodcuttingBlockCheck(player, block); } - if (profile.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) { + if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(inHand)) { WoodCutting.treeFeller(event); } } /* EXCAVATION */ - else if (BlockChecks.canBeGigaDrillBroken(block) && permInstance.excavation(player) && !mcMMO.placeStore.isTrue(block)) { + else if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.excavation(player) && !mcMMO.placeStore.isTrue(block)) { if (configInstance.getExcavationRequiresTool()) { if (ItemChecks.isShovel(inHand)) { Excavation.excavationProcCheck(block, player); @@ -298,7 +297,6 @@ public class BlockListener implements Listener { Material material = block.getType(); Config configInstance = Config.getInstance(); - Permissions permInstance = Permissions.getInstance(); /* * ABILITY PREPARATION CHECKS @@ -307,7 +305,7 @@ public class BlockListener implements Listener { if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) { Skills.abilityCheck(player, SkillType.HERBALISM); } - else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here? + else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) { //TODO: Why are we checking the permissions here? Skills.abilityCheck(player, SkillType.WOODCUTTING); } else if (profile.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) { @@ -329,7 +327,7 @@ public class BlockListener implements Listener { /* * ABILITY TRIGGER CHECKS */ - if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) { + if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.greenTerra(player) && BlockChecks.makeMossy(block)) { Herbalism.greenTerra(player, block); } else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) { diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index f831b4819..ad06b83de 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -151,7 +151,7 @@ public class EntityListener implements Listener { AcrobaticsManager acroManager = new AcrobaticsManager(player); acroManager.rollCheck(event); } - else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) { + else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) { BlastMining.demolitionsExpertise(player, event); } @@ -219,7 +219,7 @@ public class EntityListener implements Listener { if (plugin.tntIsTracked(id)) { Player player = plugin.getTNTPlayer(id); - if (Permissions.getInstance().biggerBombs(player)) { + if (Permissions.biggerBombs(player)) { BlastMining.biggerBombs(player, event); } } @@ -363,10 +363,10 @@ public class EntityListener implements Listener { return; } - if (herb && !Permissions.getInstance().farmersDiet(player)) { + if (herb && !Permissions.farmersDiet(player)) { return; } - else if (fish && !Permissions.getInstance().fishermansDiet(player)) { + else if (fish && !Permissions.fishermansDiet(player)) { return; } @@ -399,7 +399,7 @@ public class EntityListener implements Listener { if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC - if (Permissions.getInstance().taming(player) && !mcMMO.p.placeStore.isSpawnedPet((Entity) event.getEntity())) { + if (Permissions.taming(player) && !mcMMO.p.placeStore.isSpawnedPet((Entity) event.getEntity())) { PlayerProfile profile = Users.getProfile(player); EntityType type = event.getEntityType(); int xp = 0; diff --git a/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java b/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java index e23731f40..12b8cace7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java @@ -23,7 +23,7 @@ public class HardcoreListener implements Listener { if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC - if (!Permissions.getInstance().hardcoremodeBypass(player)) { + if (!Permissions.hardcoremodeBypass(player)) { if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) { Hardcore.invokeVampirism(player.getKiller(), player); } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 379ce0545..811c33be8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -72,14 +72,14 @@ public class PlayerListener implements Listener { } if (profile.getGodMode()) { - if (!Permissions.getInstance().mcgod(player)) { + if (!Permissions.mcgod(player)) { profile.toggleGodMode(); player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden")); } } if (profile.inParty()) { - if (!Permissions.getInstance().party(player)) { + if (!Permissions.party(player)) { profile.removeParty(); player.sendMessage(LocaleLoader.getString("Party.Forbidden")); } @@ -99,7 +99,7 @@ public class PlayerListener implements Listener { if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC - if (Permissions.getInstance().fishing(player)) { + if (Permissions.fishing(player)) { State state = event.getState(); switch (state) { @@ -112,7 +112,7 @@ public class PlayerListener implements Listener { return; } - if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= shakeUnlockLevel && Permissions.getInstance().shakeMob(player)) { + if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= shakeUnlockLevel && Permissions.shakeMob(player)) { Fishing.shakeMob(event); } break; @@ -184,7 +184,7 @@ public class PlayerListener implements Listener { if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC //TODO: Locale ALL the things. - if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) { + if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) { String prefix = ChatColor.GOLD + "[mcMMO] "; String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; @@ -201,76 +201,76 @@ public class PlayerListener implements Listener { } } - if (player.hasPermission("mcmmo.perks.xp.quadruple")) { + if (Permissions.xpQuadruple(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) })); } - else if (player.hasPermission("mcmmo.perks.xp.triple")) { + else if (Permissions.xpTriple(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 3 }) })); } - else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) { + else if (Permissions.xpDoubleAndOneHalf(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 2.5 }) })); } - else if (player.hasPermission("mcmmo.perks.xp.double")) { + else if (Permissions.xpDouble(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 2 }) })); } - else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) { + else if (Permissions.xpOneAndOneHalf(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 1.5 }) })); } - if (player.hasPermission("mcmmo.perks.cooldowns.halved")) { + if (Permissions.cooldownsHalved(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/2" }) })); } - else if (player.hasPermission("mcmmo.perks.cooldowns.thirded")) { + else if (Permissions.cooldownsThirded(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/3" }) })); } - else if (player.hasPermission("mcmmo.perks.cooldowns.quartered")) { + else if (Permissions.cooldownsQuartered(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/4" }) })); } - if (player.hasPermission("mcmmo.perks.activationtime.twelveseconds")) { + if (Permissions.activationTwelve(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 12 }) })); } - else if (player.hasPermission("mcmmo.perks.activationtime.eightseconds")) { + else if (Permissions.activationEight(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 8 }) })); } - else if (player.hasPermission("mcmmo.perks.activationtime.fourseconds")) { + else if (Permissions.activationFour(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 4 }) })); } - if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { + if (Permissions.luckyAcrobatics(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.archery")) { + else if (Permissions.luckyArchery(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.axes")) { + else if (Permissions.luckyAxes(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.excavation")) { + else if (Permissions.luckyExcavation(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + else if (Permissions.luckyFishing(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + else if (Permissions.luckyHerbalism(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.mining")) { + else if (Permissions.luckyMining(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.repair")) { + else if (Permissions.luckyRepair(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.swords")) { + else if (Permissions.luckySwords(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.taming")) { + else if (Permissions.luckyTaming(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { + else if (Permissions.luckyUnarmed(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } - else if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) { + else if (Permissions.luckyWoodcutting(player)) { player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") })); } @@ -321,7 +321,7 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_BLOCK: /* REPAIR CHECKS */ - if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) { + if (Permissions.repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) { if (mcMMO.repairManager.isRepairable(inHand)) { mcMMO.repairManager.handleRepair(player, inHand); event.setCancelled(true); @@ -329,7 +329,7 @@ public class PlayerListener implements Listener { } } /* SALVAGE CHECKS */ - if (Permissions.getInstance().salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) { + if (Permissions.salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) { if (Salvage.isSalvageable(inHand)) { final Location location = block.getLocation(); Salvage.handleSalvage(player, location, inHand); @@ -353,7 +353,7 @@ public class PlayerListener implements Listener { } /* GREEN THUMB CHECK */ - if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.getInstance().greenThumbBlocks(player)) { + if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.greenThumbBlocks(player)) { Herbalism.greenThumbBlocks(inHand, player, block); } @@ -363,7 +363,7 @@ public class PlayerListener implements Listener { } /* BLAST MINING CHECK */ - if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) { + if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) { BlastMining.detonate(event, player, plugin); } @@ -386,7 +386,7 @@ public class PlayerListener implements Listener { Item.itemChecks(player); /* BLAST MINING CHECK */ - if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) { + if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) { BlastMining.detonate(event, player, plugin); } @@ -474,7 +474,7 @@ public class PlayerListener implements Listener { plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage()); for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) { - if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) { + if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) { otherPlayer.sendMessage(prefix + chatEvent.getMessage()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 241b042a6..749bf0a8f 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -13,7 +13,6 @@ public class AcrobaticsManager { private Player player; private PlayerProfile profile; private int skillLevel; - private Permissions permissionInstance = Permissions.getInstance(); public AcrobaticsManager (Player player) { this.player = player; @@ -30,7 +29,7 @@ public class AcrobaticsManager { if(player == null) return; - if (!permissionInstance.roll(player)) { + if (!Permissions.roll(player)) { return; } @@ -41,7 +40,7 @@ public class AcrobaticsManager { int randomChance = 1000; - if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { + if (Permissions.luckyAcrobatics(player)) { randomChance = (int) (randomChance * 0.75); } @@ -64,7 +63,7 @@ public class AcrobaticsManager { if(player == null) return; - if (!permissionInstance.dodge(player)) { + if (!Permissions.dodge(player)) { return; } @@ -72,7 +71,7 @@ public class AcrobaticsManager { int randomChance = 4000; - if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { + if (Permissions.luckyAcrobatics(player)) { randomChance = (int) (randomChance * 0.75); } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java index 4ef6f39d4..f78524f40 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java @@ -83,7 +83,7 @@ public class RollEventHandler extends AcrobaticsEventHandler { if(player == null) return; - if (Permissions.getInstance().gracefulRoll(player)) { + if (Permissions.gracefulRoll(player)) { this.isGraceful = player.isSneaking(); } else { 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 3faf7080f..c7e98265d 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -16,7 +16,6 @@ public class ArcheryManager { private Player player; private PlayerProfile profile; private int skillLevel; - private Permissions permissionsInstance; private float dazeBonusMax = advancedConfig.getDazeBonusMax(); private float dazeMaxBonusLevel = advancedConfig.getDazeMaxBonusLevel(); @@ -32,7 +31,6 @@ public class ArcheryManager { return; this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY); - this.permissionsInstance = Permissions.getInstance(); } /** @@ -44,17 +42,14 @@ public class ArcheryManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.trackArrows(player)) { + if (!Permissions.trackArrows(player)) { return; } ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.archery")) { + if (Permissions.luckyArchery(player)) { randomChance = (int) (randomChance * 0.75); } final float chance = (float) (((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * skillLevel); @@ -73,10 +68,7 @@ public class ArcheryManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.daze(player)) { + if (!Permissions.daze(player)) { return; } @@ -84,7 +76,7 @@ public class ArcheryManager { int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.archery")) { + if (Permissions.luckyArchery(player)) { randomChance = (int) (randomChance * 0.75); } @@ -104,10 +96,7 @@ public class ArcheryManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.archeryBonus(player)) { + if (!Permissions.archeryBonus(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java index 22ac29c55..dafeb16d7 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java @@ -90,7 +90,7 @@ public class Axes { int randomChance = 100; double chance = (MAX_CHANCE / MAX_BONUS_LEVEL) * skillCheck; - if (attacker.hasPermission("mcmmo.perks.lucky.axes")) { + if (Permissions.luckyAxes(attacker)) { randomChance = (int) (randomChance * 0.75); } @@ -179,13 +179,13 @@ public class Axes { final double GREATER_IMPACT_MULTIPLIER = advancedConfig.getGreaterImpactModifier(); final int GREATER_IMPACT_DAMAGE = advancedConfig.getGreaterImpactBonusDamage(); - if (!Permissions.getInstance().greaterImpact(attacker)) { + if (!Permissions.greaterImpact(attacker)) { return; } int randomChance = 100; - if (attacker.hasPermission("mcmmo.perks.lucky.axes")) { + if (Permissions.luckyAxes(attacker)) { randomChance = (int) (randomChance * 0.75); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java index 28d682090..39e62042d 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java @@ -61,7 +61,7 @@ public class Excavation { xp = Config.getInstance().getExcavationBaseXP(); } - if (Permissions.getInstance().excavationTreasures(player)) { + if (Permissions.excavationTreasures(player)) { switch (type) { case DIRT: treasures = TreasuresConfig.getInstance().excavationFromDirt; @@ -99,7 +99,7 @@ public class Excavation { if (skillLevel >= treasure.getDropLevel()) { int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.excavation")) { + if (Permissions.luckyExcavation(player)) { randomChance = (int) (randomChance * 0.75); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index 7f49ee586..6d57d360b 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -107,13 +107,13 @@ public class Fishing { } if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 - && Permissions.getInstance().fishingTreasures(player)) { + && Permissions.fishingTreasures(player)) { FishingTreasure treasure = rewards.get(random.nextInt(rewards .size())); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + if (Permissions.luckyFishing(player)) { randomChance = (int) (randomChance * 0.75); } @@ -167,12 +167,12 @@ public class Fishing { if (ItemChecks.isEnchantable(fishingResults)) { int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.fishing")) { + if (Permissions.luckyFishing(player)) { randomChance = (int) (randomChance * 0.75); } if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE - && Permissions.getInstance().fishingMagic(player)) { + && Permissions.fishingMagic(player)) { for (Enchantment newEnchant : Enchantment.values()) { if (newEnchant.canEnchantItem(fishingResults)) { Map resultEnchantments = fishingResults @@ -226,7 +226,7 @@ public class Fishing { public static void shakeMob(PlayerFishEvent event) { int randomChance = 100; - if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) { + if (Permissions.luckyFishing(event.getPlayer())) { randomChance = (int) (randomChance * 1.25); } @@ -236,7 +236,7 @@ public class Fishing { int dropChance = getShakeChance(lootTier); - if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) { + if (Permissions.luckyFishing(player)) { dropChance = (int) (dropChance * 1.25); // With lucky perk on max // level tier, its 100% } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index 7cddc3d41..616cdb5de 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -103,7 +103,7 @@ public class Herbalism { int randomChance = 1000; - if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + if (Permissions.luckyHerbalism(player)) { randomChance = (int) (randomChance * 0.75); } @@ -136,7 +136,7 @@ public class Herbalism { mat = Material.WHEAT; xp = Config.getInstance().getHerbalismXPWheat(); - if (Permissions.getInstance().greenThumbWheat(player)) { + if (Permissions.greenThumbWheat(player)) { greenThumbWheat(block, player, event, plugin); } } @@ -154,7 +154,7 @@ public class Herbalism { mat = Material.NETHER_STALK; xp = Config.getInstance().getHerbalismXPNetherWart(); - if (Permissions.getInstance().greenThumbNetherwart(player)) { + if (Permissions.greenThumbNetherwart(player)) { greenThumbWheat(block, player, event, plugin); } } @@ -211,7 +211,7 @@ public class Herbalism { xp = Config.getInstance().getHerbalismXPCocoa(); - if (Permissions.getInstance().greenThumbCocoa(player)) { + if (Permissions.greenThumbCocoa(player)) { greenThumbWheat(block, player, event, plugin); } } @@ -223,7 +223,7 @@ public class Herbalism { xp = Config.getInstance().getHerbalismXPCarrot(); - if (Permissions.getInstance().greenThumbCarrots(player)) { + if (Permissions.greenThumbCarrots(player)) { greenThumbWheat(block, player, event, plugin); } } @@ -234,7 +234,7 @@ public class Herbalism { mat = Material.POTATO; xp = Config.getInstance().getHerbalismXPPotato(); - if (Permissions.getInstance().greenThumbPotatoes(player)) { + if (Permissions.greenThumbPotatoes(player)) { greenThumbWheat(block, player, event, plugin); } } @@ -254,7 +254,7 @@ public class Herbalism { return; } - if (Permissions.getInstance().herbalismDoubleDrops(player)) { + if (Permissions.herbalismDoubleDrops(player)) { ItemStack is = null; if (customPlant) { @@ -431,7 +431,7 @@ public class Herbalism { int randomChance = 1500; - if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + if (Permissions.luckyHerbalism(player)) { randomChance = (int) (randomChance * 0.75); } @@ -491,7 +491,7 @@ public class Herbalism { int randomChance = 1500; - if (player.hasPermission("mcmmo.perks.lucky.herbalism")) { + if (Permissions.luckyHerbalism(player)) { randomChance = (int) (randomChance * 0.75); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java index d389078e8..3e3968f6b 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java @@ -336,11 +336,11 @@ public class Mining { int randomChance = 100; int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillCheck); - if (player.hasPermission("mcmmo.perks.lucky.mining")) { + if (Permissions.luckyMining(player)) { randomChance = (int) (randomChance * 0.75); } - if (chance > random.nextInt(randomChance) && Permissions.getInstance().miningDoubleDrops(player)) { + if (chance > random.nextInt(randomChance) && Permissions.miningDoubleDrops(player)) { if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { silkTouchDrops(block); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java index c588ceb37..d6d5f5e6e 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -220,7 +220,7 @@ public class WoodCutting { } } - if (Permissions.getInstance().woodcutting(player)) { + if (Permissions.woodcutting(player)) { Skills.xpProcessing(player, profile, SkillType.WOODCUTTING, xp); } } @@ -353,11 +353,11 @@ public class WoodCutting { int randomChance = 100; int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel); - if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) { + if (Permissions.luckyWoodcutting(player)) { randomChance = (int) (randomChance * 0.75); } - if (chance > random.nextInt(randomChance) && Permissions.getInstance().woodcuttingDoubleDrops(player)) { + if (chance > random.nextInt(randomChance) && Permissions.woodcuttingDoubleDrops(player)) { Config configInstance = Config.getInstance(); ItemStack item; Location location; 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 019ac2cf3..3d724b3b1 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -27,7 +27,6 @@ public class Repair { private static Random random = new Random(); private static Config configInstance = Config.getInstance(); - private static Permissions permInstance = Permissions.getInstance(); static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -92,7 +91,7 @@ public class Repair { * @param is Item being repaired */ protected static void addEnchants(Player player, ItemStack is) { - if(permInstance.arcaneBypass(player)) { + if(Permissions.arcaneBypass(player)) { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); return; } @@ -104,7 +103,7 @@ public class Repair { int rank = getArcaneForgingRank(Users.getProfile(player)); - if (rank == 0 || !permInstance.arcaneForging(player)) { + if (rank == 0 || !Permissions.arcaneForging(player)) { for (Enchantment x : enchants.keySet()) { is.removeEnchantment(x); } @@ -120,7 +119,7 @@ public class Repair { int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.repair")) { + if (Permissions.luckyRepair(player)) { randomChance = (int) (randomChance * 0.75); } @@ -244,7 +243,7 @@ public class Repair { if(skillLevel >= repairMasteryMaxBonusLevel) bonus = ((float) repairMasteryChanceMax / 100F); else bonus = (((float) skillLevel) / ((float) repairMasteryMaxBonusLevel)) * (((float) repairMasteryChanceMax) / 100F); - if (permInstance.repairMastery(player)) { + if (Permissions.repairMastery(player)) { bonus = (((float) repairAmount) * bonus); repairAmount += (int) bonus; } @@ -281,9 +280,9 @@ public class Repair { int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel); if (skillLevel >= MAX_BONUS_LEVEL) chance = MAX_CHANCE; - if (player.hasPermission("mcmmo.perks.lucky.repair")) randomChance = (int) (randomChance * 0.75); + if (Permissions.luckyRepair(player)) randomChance = (int) (randomChance * 0.75); - if (chance > random.nextInt(randomChance) && permInstance.repairBonus(player)){ + if (chance > random.nextInt(randomChance) && Permissions.repairBonus(player)){ player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy")); return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java index 5ed7ddec8..0e8ca9acb 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairItemType.java @@ -18,13 +18,13 @@ public enum RepairItemType { public boolean getPermissions(Player player) { switch (this) { case ARMOR: - return Permissions.getInstance().armorRepair(player); + return Permissions.armorRepair(player); case TOOL: - return Permissions.getInstance().toolRepair(player); + return Permissions.toolRepair(player); case OTHER: - return Permissions.getInstance().otherRepair(player); + return Permissions.otherRepair(player); default: return false; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java index 68f6a6b6d..13a3b05c4 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairMaterialType.java @@ -23,28 +23,28 @@ public enum RepairMaterialType { public boolean getPermissions(Player player) { switch (this) { case STRING: - return Permissions.getInstance().stringRepair(player); + return Permissions.stringRepair(player); case LEATHER: - return Permissions.getInstance().leatherRepair(player); + return Permissions.leatherRepair(player); case WOOD: - return Permissions.getInstance().woodRepair(player); + return Permissions.woodRepair(player); case STONE: - return Permissions.getInstance().stoneRepair(player); + return Permissions.stoneRepair(player); case IRON: - return Permissions.getInstance().ironRepair(player); + return Permissions.ironRepair(player); case GOLD: - return Permissions.getInstance().goldRepair(player); + return Permissions.goldRepair(player); case DIAMOND: - return Permissions.getInstance().diamondRepair(player); + return Permissions.diamondRepair(player); case OTHER: - return Permissions.getInstance().otherMaterialRepair(player); + return Permissions.otherMaterialRepair(player); default: return false; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index 4d15272f1..090341d88 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -21,10 +21,9 @@ import com.gmail.nossr50.util.Users; public class Salvage { private static Config configInstance = Config.getInstance(); - private static Permissions permInstance = Permissions.getInstance(); public static void handleSalvage(final Player player, final Location location, final ItemStack inHand) { - if (!permInstance.salvage(player) || !configInstance.getSalvageEnabled()) { + if (!Permissions.salvage(player) || !configInstance.getSalvageEnabled()) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java index b27241764..b73ae5b43 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java @@ -138,7 +138,7 @@ public class SimpleRepairManager implements RepairManager { } // Handle the enchants - if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.getInstance().arcaneBypass(player)) { + if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.arcaneBypass(player)) { // Generalize away enchantment work Repair.addEnchants(player, item); } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index f3dec39e6..f3f961192 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -14,13 +14,11 @@ public class SwordsManager { private Player player; private PlayerProfile profile; private int skillLevel; - private Permissions permissionsInstance; public SwordsManager (Player player) { this.player = player; this.profile = Users.getProfile(player); this.skillLevel = profile.getSkillLevel(SkillType.SWORDS); - this.permissionsInstance = Permissions.getInstance(); } /** @@ -32,10 +30,7 @@ public class SwordsManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.swordsBleed(player)) { + if (!Permissions.swordsBleed(player)) { return; } @@ -46,7 +41,7 @@ public class SwordsManager { int bleedMaxLevel = AdvancedConfig.getInstance().getBleedMaxBonusLevel(); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.swords")) { + if (Permissions.luckySwords(player)) { randomChance = (int) (randomChance * 0.75); } @@ -62,10 +57,7 @@ public class SwordsManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.counterAttack(player)) { + if (!Permissions.counterAttack(player)) { return; } @@ -77,7 +69,7 @@ public class SwordsManager { int counterMaxLevel = AdvancedConfig.getInstance().getCounterMaxBonusLevel(); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.swords")) { + if (Permissions.luckySwords(player)) { randomChance = (int) (randomChance * 0.75); } @@ -93,10 +85,7 @@ public class SwordsManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.serratedStrikes(player)) { + if (!Permissions.serratedStrikes(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index aa93d7bd5..b60898de7 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -19,14 +19,12 @@ public class TamingManager { private Player player; private PlayerProfile profile; private int skillLevel; - private Permissions permissionsInstance; private Config configInstance; public TamingManager (Player player) { this.player = player; this.profile = Users.getProfile(player); this.skillLevel = profile.getSkillLevel(SkillType.TAMING); - this.permissionsInstance = Permissions.getInstance(); this.configInstance = Config.getInstance(); } @@ -40,17 +38,14 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.fastFoodService(player)) { + if (!Permissions.fastFoodService(player)) { return; } if (skillLevel >= Taming.FAST_FOOD_SERVICE_ACTIVATION_LEVEL) { int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.taming")) { + if (Permissions.luckyTaming(player)) { randomChance = (int) (randomChance * 0.75); } @@ -71,10 +66,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.sharpenedClaws(player)) { + if (!Permissions.sharpenedClaws(player)) { return; } @@ -94,10 +86,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.gore(player)) { + if (!Permissions.gore(player)) { return; } @@ -107,7 +96,7 @@ public class TamingManager { int goreMaxLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel(); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.taming")) { + if (Permissions.luckyTaming(player)) { randomChance = (int) (randomChance * 0.75); } @@ -175,10 +164,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.beastLore(player)) { + if (!Permissions.beastLore(player)) { return; } @@ -197,10 +183,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.callOfTheWild(player)) { + if (!Permissions.callOfTheWild(player)) { return; } @@ -235,10 +218,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.environmentallyAware(player)) { + if (!Permissions.environmentallyAware(player)) { return; } @@ -273,10 +253,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.thickFur(player)) { + if (!Permissions.thickFur(player)) { return; } @@ -296,10 +273,7 @@ public class TamingManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.shockProof(player)) { + if (!Permissions.shockProof(player)) { return; } 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 7cbaa3c07..f4e3427c5 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -13,13 +13,11 @@ public class UnarmedManager { private Player player; private PlayerProfile profile; private int skillLevel; - private Permissions permissionsInstance; public UnarmedManager (Player player) { this.player = player; this.profile = Users.getProfile(player); this.skillLevel = profile.getSkillLevel(SkillType.UNARMED); - this.permissionsInstance = Permissions.getInstance(); } /** @@ -31,10 +29,7 @@ public class UnarmedManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.disarm(player)) { + if (!Permissions.disarm(player)) { return; } @@ -47,7 +42,7 @@ public class UnarmedManager { int disarmMaxLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel(); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { + if (Permissions.luckyUnarmed(player)) { randomChance = (int) (randomChance * 0.75); } @@ -71,10 +66,7 @@ public class UnarmedManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.deflect(player)) { + if (!Permissions.deflect(player)) { return; } @@ -84,7 +76,7 @@ public class UnarmedManager { int deflectMaxLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel(); int randomChance = 100; - if (player.hasPermission("mcmmo.perks.lucky.unarmed")) { + if (Permissions.luckyUnarmed(player)) { randomChance = (int) (randomChance * 0.75); } @@ -104,10 +96,7 @@ public class UnarmedManager { if(player == null) return; - if(permissionsInstance == null) - return; - - if (!permissionsInstance.unarmedBonus(player)) { + if (!Permissions.unarmedBonus(player)) { return; } @@ -127,10 +116,7 @@ public class UnarmedManager { if(defender == null) return false; - if(permissionsInstance == null) - return false; - - if (!permissionsInstance.ironGrip(defender)) { + if (!Permissions.ironGrip(defender)) { return false; } @@ -140,7 +126,7 @@ public class UnarmedManager { int ironGripMaxLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel(); int randomChance = 100; - if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) { + if (Permissions.luckyUnarmed(defender)) { randomChance = (int) (randomChance * 0.75); } diff --git a/src/main/java/com/gmail/nossr50/util/Combat.java b/src/main/java/com/gmail/nossr50/util/Combat.java index 819967a75..d842a2996 100644 --- a/src/main/java/com/gmail/nossr50/util/Combat.java +++ b/src/main/java/com/gmail/nossr50/util/Combat.java @@ -40,7 +40,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager; public class Combat { private static Config configInstance = Config.getInstance(); - private static Permissions permInstance = Permissions.getInstance(); /** * Apply combat modifiers and process and XP gain. @@ -86,7 +85,7 @@ public class Combat { startGainXp(attacker, attackerProfile, target, SkillType.SWORDS); } - else if (ItemChecks.isAxe(itemInHand) && permInstance.axes(attacker)) { + else if (ItemChecks.isAxe(itemInHand) && Permissions.axes(attacker)) { if (targetIsPlayer || targetIsTamedPet) { if (!configInstance.getAxesPVP()) { return; @@ -98,25 +97,25 @@ public class Combat { Skills.abilityCheck(attacker, SkillType.AXES); - if (permInstance.axeBonus(attacker)) { + if (Permissions.axeBonus(attacker)) { Axes.axesBonus(attacker, event); } - if (permInstance.criticalHit(attacker)) { + if (Permissions.criticalHit(attacker)) { Axes.axeCriticalCheck(attacker, event); } - if (permInstance.impact(attacker)) { + if (Permissions.impact(attacker)) { Axes.impact(attacker, target, event); } - if (attackerProfile.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) { + if (attackerProfile.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.skullSplitter(attacker)) { applyAbilityAoE(attacker, target, event.getDamage() / 2, SkillType.AXES); } startGainXp(attacker, attackerProfile, target, SkillType.AXES); } - else if (itemInHand.getType() == Material.AIR && permInstance.unarmed(attacker)) { + else if (itemInHand.getType() == Material.AIR && Permissions.unarmed(attacker)) { if (targetIsPlayer || targetIsTamedPet) { if (!configInstance.getUnarmedPVP()) { return; @@ -132,7 +131,7 @@ public class Combat { unarmedManager.bonusDamage(event); - if (attackerProfile.getAbilityMode(AbilityType.BERSERK) && permInstance.berserk(attacker)) { + if (attackerProfile.getAbilityMode(AbilityType.BERSERK) && Permissions.berserk(attacker)) { event.setDamage((int) (event.getDamage() * 1.5)); } diff --git a/src/main/java/com/gmail/nossr50/util/Item.java b/src/main/java/com/gmail/nossr50/util/Item.java index 6e421be15..6bb9d2c40 100644 --- a/src/main/java/com/gmail/nossr50/util/Item.java +++ b/src/main/java/com/gmail/nossr50/util/Item.java @@ -31,7 +31,7 @@ public class Item { Block block = player.getLocation().getBlock(); int amount = inHand.getAmount(); - if (Permissions.getInstance().chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { + if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { if (Skills.cooldownOver(profile.getRecentlyHurt(), 60, player) && amount >= Config.getInstance().getChimaeraCost()) { player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost())); diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 97aa71f55..6cce4b1f2 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -1,219 +1,332 @@ package com.gmail.nossr50.util; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Permissions { private static volatile Permissions instance; - public boolean permission(Player player, String perm) { - return player.hasPermission(perm); + public static boolean hasPermission(CommandSender sender, String perm) + { + if(sender.hasPermission(perm)) + return true; + + return false; } - public static Permissions getInstance() { - if (instance == null) { - instance = new Permissions(); - } + public static boolean hasPermission(Player sender, String perm) + { + if(sender.hasPermission(perm)) + return true; - return instance; + return false; } /* * GENERIC PERMISSIONS */ - public boolean motd(Player player) { - return player.hasPermission("mcmmo.motd"); + public static boolean motd(Player player) { + return hasPermission(player, "mcmmo.motd"); } - public boolean admin(Player player) { - return player.hasPermission("mcmmo.admin"); + public static boolean admin(Player player) { + return hasPermission(player, "mcmmo.admin"); } /* * MCMMO.BYPASS.* */ - public boolean hardcoremodeBypass(Player player) { - return player.hasPermission("mcmmo.bypass.hardcoremode"); + public static boolean hardcoremodeBypass(Player player) { + return hasPermission(player, "mcmmo.bypass.hardcoremode"); } - public boolean arcaneBypass(Player player) { - return player.hasPermission("mcmmo.bypass.arcanebypass"); + public static boolean arcaneBypass(Player player) { + return hasPermission(player, "mcmmo.bypass.arcanebypass"); } - public boolean inspectDistanceBypass(Player player) { - return player.hasPermission("mcmmo.bypass.inspect.distance"); + public static boolean inspectDistanceBypass(Player player) { + return hasPermission(player, "mcmmo.bypass.inspect.distance"); } - public boolean inspectOfflineBypass(Player player) { - return player.hasPermission("mcmmo.bypass.inspect.offline"); + public static boolean inspectOfflineBypass(Player player) { + return hasPermission(player, "mcmmo.bypass.inspect.offline"); } /* * MCMMO.TOOLS.* */ - public boolean mcrefresh(Player player) { - return player.hasPermission("mcmmo.tools.mcrefresh"); + public static boolean mcrefresh(Player player) { + return hasPermission(player, "mcmmo.tools.mcrefresh"); } - public boolean mcremove(Player player) { - return player.hasPermission("mcmmo.tools.mcremove"); + public static boolean mcremove(Player player) { + return hasPermission(player, "mcmmo.tools.mcremove"); } - public boolean mmoedit(Player player) { - return player.hasPermission("mcmmo.tools.mmoedit"); + public static boolean mmoedit(Player player) { + return hasPermission(player, "mcmmo.tools.mmoedit"); } - public boolean mcgod(Player player) { - return player.hasPermission("mcmmo.tools.mcgod"); + public static boolean mcgod(Player player) { + return hasPermission(player, "mcmmo.tools.mcgod"); + } + + /* + * MCMMO.PERKS.LUCKY* + */ + + public static boolean luckyAcrobatics(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.acrobatics"); + } + + public static boolean luckyArchery(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.archery"); + } + + public static boolean luckyAxes(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.axes"); + } + + public static boolean luckyExcavation(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.excavation"); + } + + public static boolean luckyFishing(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.fishing"); + } + + public static boolean luckyHerbalism(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.herbalism"); + } + + public static boolean luckyMining(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.mining"); + } + + public static boolean luckyRepair(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.repair"); + } + + public static boolean luckySwords(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.swords"); + } + + public static boolean luckyTaming(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.taming"); + } + + public static boolean luckyUnarmed(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.unarmed"); + } + + public static boolean luckyWoodcutting(Player player) { + return hasPermission(player, "mcmmo.perks.lucky.woodcutting"); + } + + /* + * MCMMO.PERKS.XP* + */ + + public static boolean xpQuadruple(Player player) { + return hasPermission(player, "mcmmo.perks.xp.quadruple"); + } + + public static boolean xpTriple(Player player) { + return hasPermission(player, "mcmmo.perks.xp.triple"); + } + + public static boolean xpDoubleAndOneHalf(Player player) { + return hasPermission(player, "mcmmo.perks.xp.150percentboost"); + } + + public static boolean xpDouble(Player player) { + return hasPermission(player, "mcmmo.perks.xp.double"); + } + + public static boolean xpOneAndOneHalf(Player player) { + return hasPermission(player, "mcmmo.perks.xp.50percentboost"); + } + + /* + * MCMMO.PERKS.COOLDOWNS* + */ + + public static boolean cooldownsHalved(Player player) { + return hasPermission(player, "mcmmo.perks.cooldowns.halved"); + } + + public static boolean cooldownsThirded(Player player) { + return hasPermission(player, "mcmmo.perks.cooldowns.thirded"); + } + + public static boolean cooldownsQuartered(Player player) { + return hasPermission(player, "mcmmo.perks.cooldowns.quartered"); + } + + /* + * MCMMO.PERKS.ACTIVATIONTIME* + */ + + public static boolean activationTwelve(Player player) { + return hasPermission(player, "mcmmo.perks.activationtime.twelveseconds"); + } + + public static boolean activationEight(Player player) { + return hasPermission(player, "mcmmo.perks.activationtime.eightseconds"); + } + + public static boolean activationFour(Player player) { + return hasPermission(player, "mcmmo.perks.activationtime.fourseconds"); } /* * MCMMO.ABILITY.TAMING.* */ - public boolean fastFoodService(Player player) { - return player.hasPermission("mcmmo.ability.taming.fastfoodservice"); + public static boolean fastFoodService(Player player) { + return hasPermission(player, "mcmmo.ability.taming.fastfoodservice"); } - public boolean sharpenedClaws(Player player) { - return player.hasPermission("mcmmo.ability.taming.sharpenedclaws"); + public static boolean sharpenedClaws(Player player) { + return hasPermission(player, "mcmmo.ability.taming.sharpenedclaws"); } - public boolean gore(Player player) { - return player.hasPermission("mcmmo.ability.taming.gore"); + public static boolean gore(Player player) { + return hasPermission(player, "mcmmo.ability.taming.gore"); } - public boolean callOfTheWild(Player player) { - return player.hasPermission("mcmmo.ability.taming.callofthewild"); + public static boolean callOfTheWild(Player player) { + return hasPermission(player, "mcmmo.ability.taming.callofthewild"); } - public boolean environmentallyAware(Player player) { - return player.hasPermission("mcmmo.ability.taming.environmentallyaware"); + public static boolean environmentallyAware(Player player) { + return hasPermission(player, "mcmmo.ability.taming.environmentallyaware"); } - public boolean thickFur(Player player) { - return player.hasPermission("mcmmo.ability.taming.thickfur"); + public static boolean thickFur(Player player) { + return hasPermission(player, "mcmmo.ability.taming.thickfur"); } - public boolean shockProof(Player player) { - return player.hasPermission("mcmmo.ability.taming.shockproof"); + public static boolean shockProof(Player player) { + return hasPermission(player, "mcmmo.ability.taming.shockproof"); } - public boolean beastLore(Player player) { - return player.hasPermission("mcmmo.ability.taming.beastlore"); + public static boolean beastLore(Player player) { + return hasPermission(player, "mcmmo.ability.taming.beastlore"); } /* * MCMMO.ABILITY.FISHING.* */ - public boolean shakeMob(Player player) { - return player.hasPermission("mcmmo.ability.fishing.shakemob"); + public static boolean shakeMob(Player player) { + return hasPermission(player, "mcmmo.ability.fishing.shakemob"); } - public boolean fishingTreasures(Player player) { - return player.hasPermission("mcmmo.ability.fishing.treasures"); + public static boolean fishingTreasures(Player player) { + return hasPermission(player, "mcmmo.ability.fishing.treasures"); } - public boolean fishingMagic(Player player) { - return player.hasPermission("mcmmo.ability.fishing.magic"); + public static boolean fishingMagic(Player player) { + return hasPermission(player, "mcmmo.ability.fishing.magic"); } - public boolean fishermansDiet(Player player) { - return player.hasPermission("mcmmo.ability.fishing.fishermansdiet"); + public static boolean fishermansDiet(Player player) { + return hasPermission(player, "mcmmo.ability.fishing.fishermansdiet"); } /* * MCMMO.ABILITY.MINING.* */ - public boolean superBreaker(Player player) { - return player.hasPermission("mcmmo.ability.mining.superbreaker"); + public static boolean superBreaker(Player player) { + return hasPermission(player, "mcmmo.ability.mining.superbreaker"); } - public boolean miningDoubleDrops(Player player) { - return player.hasPermission("mcmmo.ability.mining.doubledrops"); + public static boolean miningDoubleDrops(Player player) { + return hasPermission(player, "mcmmo.ability.mining.doubledrops"); } /* * MCMMO.ABILITY.WOODCUTTING.* */ - public boolean treeFeller(Player player) { - return player.hasPermission("mcmmo.ability.woodcutting.treefeller"); + public static boolean treeFeller(Player player) { + return hasPermission(player, "mcmmo.ability.woodcutting.treefeller"); } - public boolean leafBlower(Player player) { - return player.hasPermission("mcmmo.ability.woodcutting.leafblower"); + public static boolean leafBlower(Player player) { + return hasPermission(player, "mcmmo.ability.woodcutting.leafblower"); } - public boolean woodcuttingDoubleDrops(Player player) { - return player.hasPermission("mcmmo.ability.woodcutting.doubledrops"); + public static boolean woodcuttingDoubleDrops(Player player) { + return hasPermission(player, "mcmmo.ability.woodcutting.doubledrops"); } /* * MCMMO.ABILITY.REPAIR.* */ - public boolean repairBonus(Player player) { - return player.hasPermission("mcmmo.ability.repair.repairbonus"); + public static boolean repairBonus(Player player) { + return hasPermission(player, "mcmmo.ability.repair.repairbonus"); } - public boolean repairMastery(Player player) { - return player.hasPermission("mcmmo.ability.repair.repairmastery"); + public static boolean repairMastery(Player player) { + return hasPermission(player, "mcmmo.ability.repair.repairmastery"); } - public boolean arcaneForging(Player player) { - return player.hasPermission("mcmmo.ability.repair.arcaneforging"); + public static boolean arcaneForging(Player player) { + return hasPermission(player, "mcmmo.ability.repair.arcaneforging"); } - public boolean woodRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.woodrepair"); + public static boolean woodRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.woodrepair"); } - public boolean stoneRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.stonerepair"); + public static boolean stoneRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.stonerepair"); } - public boolean leatherRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.leatherrepair"); + public static boolean leatherRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.leatherrepair"); } - public boolean ironRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.ironrepair"); + public static boolean ironRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.ironrepair"); } - public boolean goldRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.goldrepair"); + public static boolean goldRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.goldrepair"); } - public boolean diamondRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.diamondrepair"); + public static boolean diamondRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.diamondrepair"); } - public boolean armorRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.armorrepair"); + public static boolean armorRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.armorrepair"); } - public boolean toolRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.toolrepair"); + public static boolean toolRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.toolrepair"); } - public boolean otherMaterialRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.othermaterialrepair"); + public static boolean otherMaterialRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.othermaterialrepair"); } - public boolean otherRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.otherrepair"); + public static boolean otherRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.otherrepair"); } - public boolean stringRepair(Player player) { - return player.hasPermission("mcmmo.ability.repair.stringrepair"); + public static boolean stringRepair(Player player) { + return hasPermission(player, "mcmmo.ability.repair.stringrepair"); } - public boolean salvage(Player player) { - return player.hasPermission("mcmmo.ability.repair.salvage"); + public static boolean salvage(Player player) { + return hasPermission(player, "mcmmo.ability.repair.salvage"); } @@ -221,196 +334,196 @@ public class Permissions { * MCMMO.ABILITY.UNARMED.* */ - public boolean unarmedBonus(Player player) { - return player.hasPermission("mcmmo.ability.unarmed.bonusdamage"); + public static boolean unarmedBonus(Player player) { + return hasPermission(player, "mcmmo.ability.unarmed.bonusdamage"); } - public boolean disarm(Player player) { - return player.hasPermission("mcmmo.ability.unarmed.disarm"); + public static boolean disarm(Player player) { + return hasPermission(player, "mcmmo.ability.unarmed.disarm"); } - public boolean berserk(Player player) { - return player.hasPermission("mcmmo.ability.unarmed.berserk"); + public static boolean berserk(Player player) { + return hasPermission(player, "mcmmo.ability.unarmed.berserk"); } - public boolean deflect(Player player) { - return player.hasPermission("mcmmo.ability.unarmed.deflect"); + public static boolean deflect(Player player) { + return hasPermission(player, "mcmmo.ability.unarmed.deflect"); } - public boolean ironGrip(Player player) { - return player.hasPermission("mcmmo.ability.unarmed.irongrip"); + public static boolean ironGrip(Player player) { + return hasPermission(player, "mcmmo.ability.unarmed.irongrip"); } /* * MCMMO.ABILITY.ARCHERY.* */ - public boolean trackArrows(Player player) { - return player.hasPermission("mcmmo.ability.archery.trackarrows"); + public static boolean trackArrows(Player player) { + return hasPermission(player, "mcmmo.ability.archery.trackarrows"); } - public boolean daze(Player player) { - return player.hasPermission("mcmmo.ability.archery.daze"); + public static boolean daze(Player player) { + return hasPermission(player, "mcmmo.ability.archery.daze"); } - public boolean archeryBonus(Player player) { - return player.hasPermission("mcmmo.ability.archery.bonusdamage"); + public static boolean archeryBonus(Player player) { + return hasPermission(player, "mcmmo.ability.archery.bonusdamage"); } /* * MCMMO.ABILITY.HERBALISM.* */ - public boolean herbalismDoubleDrops(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.doubledrops"); + public static boolean herbalismDoubleDrops(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.doubledrops"); } - public boolean greenTerra(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenterra"); + public static boolean greenTerra(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenterra"); } - public boolean greenThumbBlocks(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenthumbblocks"); + public static boolean greenThumbBlocks(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenthumbblocks"); } - public boolean greenThumbCarrots(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenthumbcarrots"); + public static boolean greenThumbCarrots(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenthumbcarrots"); } - public boolean greenThumbCocoa(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenthumbcocoa"); + public static boolean greenThumbCocoa(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenthumbcocoa"); } - public boolean greenThumbNetherwart(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenthumbnetherwart"); + public static boolean greenThumbNetherwart(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenthumbnetherwart"); } - public boolean greenThumbPotatoes(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenthumbpotatoes"); + public static boolean greenThumbPotatoes(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenthumbpotatoes"); } - public boolean greenThumbWheat(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.greenthumbwheat"); + public static boolean greenThumbWheat(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.greenthumbwheat"); } - public boolean farmersDiet(Player player) { - return player.hasPermission("mcmmo.ability.herbalism.farmersdiet"); + public static boolean farmersDiet(Player player) { + return hasPermission(player, "mcmmo.ability.herbalism.farmersdiet"); } /* * MCMMO.ABILITY.EXCAVATION.* */ - public boolean gigaDrillBreaker(Player player) { - return player.hasPermission("mcmmo.ability.excavation.gigadrillbreaker"); + public static boolean gigaDrillBreaker(Player player) { + return hasPermission(player, "mcmmo.ability.excavation.gigadrillbreaker"); } - public boolean excavationTreasures(Player player) { - return player.hasPermission("mcmmo.ability.excavation.treasures"); + public static boolean excavationTreasures(Player player) { + return hasPermission(player, "mcmmo.ability.excavation.treasures"); } /* * MCMMO.ABILITY.SWORDS.* */ - public boolean swordsBleed(Player player) { - return player.hasPermission("mcmmo.ability.swords.bleed"); + public static boolean swordsBleed(Player player) { + return hasPermission(player, "mcmmo.ability.swords.bleed"); } - public boolean serratedStrikes(Player player) { - return player.hasPermission("mcmmo.ability.swords.serratedstrikes"); + public static boolean serratedStrikes(Player player) { + return hasPermission(player, "mcmmo.ability.swords.serratedstrikes"); } - public boolean counterAttack(Player player) { - return player.hasPermission("mcmmo.ability.swords.counterattack"); + public static boolean counterAttack(Player player) { + return hasPermission(player, "mcmmo.ability.swords.counterattack"); } /* * MCMMO.ABILITY.AXES.* */ - public boolean skullSplitter(Player player) { - return player.hasPermission("mcmmo.ability.axes.skullsplitter"); + public static boolean skullSplitter(Player player) { + return hasPermission(player, "mcmmo.ability.axes.skullsplitter"); } - public boolean axeBonus(Player player) { - return player.hasPermission("mcmmo.ability.axes.bonusdamage"); + public static boolean axeBonus(Player player) { + return hasPermission(player, "mcmmo.ability.axes.bonusdamage"); } - public boolean criticalHit(Player player) { - return player.hasPermission("mcmmo.ability.axes.criticalhit"); + public static boolean criticalHit(Player player) { + return hasPermission(player, "mcmmo.ability.axes.criticalhit"); } - public boolean impact(Player player) { - return player.hasPermission("mcmmo.ability.axes.impact"); + public static boolean impact(Player player) { + return hasPermission(player, "mcmmo.ability.axes.impact"); } - public boolean greaterImpact(Player player) { - return player.hasPermission("mcmmo.ability.axes.greaterimpact"); + public static boolean greaterImpact(Player player) { + return hasPermission(player, "mcmmo.ability.axes.greaterimpact"); } /* * MCMMO.ABILITY.ACROBATICS.* */ - public boolean roll(Player player) { - return player.hasPermission("mcmmo.ability.acrobatics.roll"); + public static boolean roll(Player player) { + return hasPermission(player, "mcmmo.ability.acrobatics.roll"); } - public boolean gracefulRoll(Player player) { - return player.hasPermission("mcmmo.ability.acrobatics.gracefulroll"); + public static boolean gracefulRoll(Player player) { + return hasPermission(player, "mcmmo.ability.acrobatics.gracefulroll"); } - public boolean dodge(Player player) { - return player.hasPermission("mcmmo.ability.acrobatics.dodge"); + public static boolean dodge(Player player) { + return hasPermission(player, "mcmmo.ability.acrobatics.dodge"); } /* * MCMMO.ABILITY.BLASTMINING.* */ - public boolean biggerBombs(Player player) { - return player.hasPermission("mcmmo.ability.blastmining.biggerbombs"); + public static boolean biggerBombs(Player player) { + return hasPermission(player, "mcmmo.ability.blastmining.biggerbombs"); } - public boolean demolitionsExpertise(Player player) { - return player.hasPermission("mcmmo.ability.blastmining.demolitionsexpertise"); + public static boolean demolitionsExpertise(Player player) { + return hasPermission(player, "mcmmo.ability.blastmining.demolitionsexpertise"); } - public boolean blastMining(Player player) { - return player.hasPermission("mcmmo.ability.blastmining.detonate"); + public static boolean blastMining(Player player) { + return hasPermission(player, "mcmmo.ability.blastmining.detonate"); } /* * MCMMO.ITEM.* */ - public boolean chimaeraWing(Player player) { - return player.hasPermission("mcmmo.item.chimaerawing"); + public static boolean chimaeraWing(Player player) { + return hasPermission(player, "mcmmo.item.chimaerawing"); } /* * MCMMO.COMMANDS.* */ - public boolean mcAbility(Player player) { - return player.hasPermission("mcmmo.commands.ability"); + public static boolean mcAbility(Player player) { + return hasPermission(player, "mcmmo.commands.ability"); } - public boolean partyTeleport(Player player) { - return player.hasPermission("mcmmo.commands.ptp"); + public static boolean partyTeleport(Player player) { + return hasPermission(player, "mcmmo.commands.ptp"); } - public boolean inspect(Player player) { - return player.hasPermission("mcmmo.commands.inspect"); + public static boolean inspect(Player player) { + return hasPermission(player, "mcmmo.commands.inspect"); } - public boolean party(Player player) { - return player.hasPermission("mcmmo.commands.party"); + public static boolean party(Player player) { + return hasPermission(player, "mcmmo.commands.party"); } - public boolean skillReset(Player player) { - return player.hasPermission("mcmmo.skillreset"); + public static boolean skillReset(Player player) { + return hasPermission(player, "mcmmo.skillreset"); } @@ -418,67 +531,67 @@ public class Permissions { * MCMMO.CHAT.* */ - public boolean partyChat(Player player) { - return player.hasPermission("mcmmo.chat.partychat"); + public static boolean partyChat(Player player) { + return hasPermission(player, "mcmmo.chat.partychat"); } - public boolean partyLock(Player player) { - return player.hasPermission("mcmmo.chat.partylock"); + public static boolean partyLock(Player player) { + return hasPermission(player, "mcmmo.chat.partylock"); } - public boolean adminChat(Player player) { - return player.hasPermission("mcmmo.chat.adminchat"); + public static boolean adminChat(Player player) { + return hasPermission(player, "mcmmo.chat.adminchat"); } /* * MCMMO.SKILLS.* */ - public boolean taming(Player player) { - return player.hasPermission("mcmmo.skills.taming"); + public static boolean taming(Player player) { + return hasPermission(player, "mcmmo.skills.taming"); } - public boolean mining(Player player) { - return player.hasPermission("mcmmo.skills.mining"); + public static boolean mining(Player player) { + return hasPermission(player, "mcmmo.skills.mining"); } - public boolean fishing(Player player) { - return player.hasPermission("mcmmo.skills.fishing"); + public static boolean fishing(Player player) { + return hasPermission(player, "mcmmo.skills.fishing"); } - public boolean woodcutting(Player player) { - return player.hasPermission("mcmmo.skills.woodcutting"); + public static boolean woodcutting(Player player) { + return hasPermission(player, "mcmmo.skills.woodcutting"); } - public boolean repair(Player player) { - return player.hasPermission("mcmmo.skills.repair"); + public static boolean repair(Player player) { + return hasPermission(player, "mcmmo.skills.repair"); } - public boolean unarmed(Player player) { - return player.hasPermission("mcmmo.skills.unarmed"); + public static boolean unarmed(Player player) { + return hasPermission(player, "mcmmo.skills.unarmed"); } - public boolean archery(Player player) { - return player.hasPermission("mcmmo.skills.archery"); + public static boolean archery(Player player) { + return hasPermission(player, "mcmmo.skills.archery"); } - public boolean herbalism(Player player) { - return player.hasPermission("mcmmo.skills.herbalism"); + public static boolean herbalism(Player player) { + return hasPermission(player, "mcmmo.skills.herbalism"); } - public boolean excavation(Player player) { - return player.hasPermission("mcmmo.skills.excavation"); + public static boolean excavation(Player player) { + return hasPermission(player, "mcmmo.skills.excavation"); } - public boolean swords(Player player) { - return player.hasPermission("mcmmo.skills.swords"); + public static boolean swords(Player player) { + return hasPermission(player, "mcmmo.skills.swords"); } - public boolean axes(Player player) { - return player.hasPermission("mcmmo.skills.axes"); + public static boolean axes(Player player) { + return hasPermission(player, "mcmmo.skills.axes"); } - public boolean acrobatics(Player player) { - return player.hasPermission("mcmmo.skills.acrobatics"); + public static boolean acrobatics(Player player) { + return hasPermission(player, "mcmmo.skills.acrobatics"); } } diff --git a/src/main/java/com/gmail/nossr50/util/Skills.java b/src/main/java/com/gmail/nossr50/util/Skills.java index 9c6b82574..25dca50d1 100644 --- a/src/main/java/com/gmail/nossr50/util/Skills.java +++ b/src/main/java/com/gmail/nossr50/util/Skills.java @@ -46,13 +46,13 @@ public class Skills { int adjustedCooldown = cooldown; //Reduced Cooldown Donor Perks - if (player.hasPermission("mcmmo.perks.cooldowns.halved")) { + if (Permissions.cooldownsHalved(player)) { adjustedCooldown = (int) (adjustedCooldown * 0.5); } - else if (player.hasPermission("mcmmo.perks.cooldowns.thirded")) { + else if (Permissions.cooldownsThirded(player)) { adjustedCooldown = (int) (adjustedCooldown * 0.66); } - else if (player.hasPermission("mcmmo.perks.cooldowns.quartered")) { + else if (Permissions.cooldownsQuartered(player)) { adjustedCooldown = (int) (adjustedCooldown * 0.75); } @@ -75,13 +75,13 @@ public class Skills { int adjustedCooldown = cooldown; //Reduced Cooldown Donor Perks - if (player.hasPermission("mcmmo.perks.cooldowns.halved")) { + if (Permissions.cooldownsHalved(player)) { adjustedCooldown = (int) (adjustedCooldown * 0.5); } - else if (player.hasPermission("mcmmo.perks.cooldowns.thirded")) { + else if (Permissions.cooldownsThirded(player)) { adjustedCooldown = (int) (adjustedCooldown * 0.66); } - else if (player.hasPermission("mcmmo.perks.cooldowns.quartered")) { + else if (Permissions.cooldownsQuartered(player)) { adjustedCooldown = (int) (adjustedCooldown * 0.75); } @@ -343,11 +343,11 @@ public class Skills { * @return true if the player has combat skills, false otherwise */ public static boolean hasCombatSkills(Player player) { - if (Permissions.getInstance().axes(player) - || Permissions.getInstance().archery(player) - || Permissions.getInstance().swords(player) - || Permissions.getInstance().taming(player) - || Permissions.getInstance().unarmed(player)) { + if (Permissions.axes(player) + || Permissions.archery(player) + || Permissions.swords(player) + || Permissions.taming(player) + || Permissions.unarmed(player)) { return true; } else { @@ -362,11 +362,11 @@ public class Skills { * @return true if the player has gathering skills, false otherwise */ public static boolean hasGatheringSkills(Player player) { - if (Permissions.getInstance().excavation(player) - || Permissions.getInstance().fishing(player) - || Permissions.getInstance().herbalism(player) - || Permissions.getInstance().mining(player) - || Permissions.getInstance().woodcutting(player)) { + if (Permissions.excavation(player) + || Permissions.fishing(player) + || Permissions.herbalism(player) + || Permissions.mining(player) + || Permissions.woodcutting(player)) { return true; } else { @@ -381,7 +381,7 @@ public class Skills { * @return true if the player has misc skills, false otherwise */ public static boolean hasMiscSkills(Player player) { - if (Permissions.getInstance().acrobatics(player) || Permissions.getInstance().repair(player)) { + if (Permissions.acrobatics(player) || Permissions.repair(player)) { return true; } else { @@ -440,13 +440,13 @@ public class Skills { int ticks = 2 + (profile.getSkillLevel(type) / abilityLengthIncreaseLevel); - if (player.hasPermission("mcmmo.perks.activationtime.twelveseconds")) { + if (Permissions.activationTwelve(player)) { ticks = ticks + 12; } - else if (player.hasPermission("mcmmo.perks.activationtime.eightseconds")) { + else if (Permissions.activationEight(player)) { ticks = ticks + 8; } - else if (player.hasPermission("mcmmo.perks.activationtime.fourseconds")) { + else if (Permissions.activationFour(player)) { ticks = ticks + 4; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cbf70746c..5bd8fe98e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,19 @@ name: mcMMO version: ${project.version}-b${BUILD_NUMBER} -description: mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience. +description: > + mcMMO takes core Minecraft game mechanics and expands them to add an extensive + RPG experience, the goal of the project has always been a quality RPG + experience. Everything in mcMMO is carefully thought out and is constantly + improving. mcMMO adds eleven skills to train in and level in, while also + offering a high level of customization for server admins. There are countless + features, including custom sounds, graphical elements, and more added when + running mcMMO in conjunction with Spout. I carefully read feedback and + evaluate the mechanics of mcMMO in every update to provide an ever-evolving + experience. author: nossr50 -authors: [NuclearW, gmcferrin, bm01] -website: http://forums.bukkit.org/threads/rpg-mech-mcmmo-v1-3-05-rpg-addiction-redefined-multi-lingual-1-2-5-r1-0.68601/ +authors: [NuclearW, gmcferrin, bm01, Glitchfinder, TfT_02] +website: http://dev.bukkit.org/server-mods/mcmmo/ main: com.gmail.nossr50.mcMMO softdepend: [Spout] @@ -117,31 +126,54 @@ commands: description: Toggle Admin chat or send admin chat messages permissions: mcmmo.*: + description: Implies all mcmmo permissions. + children: + mcmmo.all: true + mcmmo.all: description: Implies all mcmmo permissions. children: mcmmo.defaults: true - mcmmo.tools.*: true - mcmmo.chat.adminchat: true + mcmmo.defaultsop: true + mcmmo.perks.all: true + mcmmo.bypass.all: true mcmmo.defaults: default: true description: mcmmo permisions that default to true children: - mcmmo.ability.*: true - mcmmo.item.*: true + mcmmo.ability.all: true + mcmmo.item.all: true mcmmo.motd: true - mcmmo.commands.*: true + mcmmo.commands.all: true mcmmo.chat.partychat: true - mcmmo.skills.*: true + mcmmo.skills.all: true mcmmo.defaultsop: default: op description: mcmmo permissions that default to op children: mcmmo.chat.adminchat: true mcmmo.admin: true - mcmmo.tools.*: true + mcmmo.tools.all: true mcmmo.admin: - description: Allows access to mmoupdate and other sensitive commands - mcmmo.perks.activationtime: + description: Allows access to mmoupdate and other sensitive commands + mcmmo.perks.*: + default: false + description: implies access to all mcmmo perks + children: + mcmmo.perks.all: true + mcmmo.perks.all: + default: false + description: implies access to all mcmmo perks + children: + mcmmo.perks.activationtime.all: true + mcmmo.perks.cooldowns.all: true + mcmmo.perks.xp.all: true + mcmmo.perks.lucky.all: true + mcmmo.perks.activationtime.*: + default: false + description: Increased activation time perks typically given to donors or VIPs + children: + mcmmo.perks.activationtime.all: true + mcmmo.perks.activationtime.all: default: false description: Increased activation time perks typically given to donors or VIPs children: @@ -157,7 +189,12 @@ permissions: mcmmo.perks.activationtime.fourseconds: default: false description: Increases activation time by 4 seconds - mcmmo.perks.cooldowns: + mcmmo.perks.cooldowns.*: + default: false + description: Reduced cooldown perks typically given to donors or VIPs + children: + mcmmo.perks.cooldowns.all: true + mcmmo.perks.cooldowns.all: default: false description: Reduced cooldown perks typically given to donors or VIPs children: @@ -173,7 +210,12 @@ permissions: mcmmo.perks.cooldowns.halved: default: false description: Cuts cooldowns down by 1/2 - mcmmo.perks.xp: + mcmmo.perks.xp.*: + default: false + description: XP Perks typically given to donors or VIPs + children: + mcmmo.perks.xp.all: true + mcmmo.perks.xp.all: default: false description: XP Perks typically given to donors or VIPs children: @@ -198,6 +240,11 @@ permissions: default: false description: Mulitplies incoming XP by 1.5 mcmmo.perks.lucky.*: + default: false + description: Gives all abilities & skills a 33.3% better chance to activate. + children: + mcmmo.perks.lucky.all: true + mcmmo.perks.lucky.all: default: false description: Gives all abilities & skills a 33.3% better chance to activate. children: @@ -250,6 +297,11 @@ permissions: default: false description: Gives Woodcutting abilities & skills a 33.3% better chance to activate. mcmmo.bypass.*: + default: false + description: Implies all bypass permissions. + children: + mcmmo.bypass.all: true + mcmmo.bypass.all: default: false description: Implies all bypass permissions. children: @@ -270,6 +322,10 @@ permissions: default: op description: Allows user to bypass Inspect's offline player requirements mcmmo.tools.*: + description: Implies all mcmmo.tools permissions. + children: + mcmmo.tools.all: true + mcmmo.tools.all: description: Implies all mcmmo.tools permissions. children: mcmmo.tools.mcrefresh: true @@ -287,20 +343,28 @@ permissions: mcmmo.ability.*: description: Implies all mcmmo.ability permissions. children: - mcmmo.ability.taming.*: true - mcmmo.ability.fishing.*: true - mcmmo.ability.mining.*: true - mcmmo.ability.woodcutting.*: true - mcmmo.ability.repair.*: true - mcmmo.ability.unarmed.*: true - mcmmo.ability.archery.*: true - mcmmo.ability.herbalism.*: true - mcmmo.ability.excavation.*: true - mcmmo.ability.swords.*: true - mcmmo.ability.axes.*: true - mcmmo.ability.acrobatics.*: true - mcmmo.ability.blastmining.*: true + mcmmo.ability.all: true + mcmmo.ability.all: + description: Implies all mcmmo.ability permissions. + children: + mcmmo.ability.taming.all: true + mcmmo.ability.fishing.all: true + mcmmo.ability.mining.all: true + mcmmo.ability.woodcutting.all: true + mcmmo.ability.repair.all: true + mcmmo.ability.unarmed.all: true + mcmmo.ability.archery.all: true + mcmmo.ability.herbalism.all: true + mcmmo.ability.excavation.all: true + mcmmo.ability.swords.all: true + mcmmo.ability.axes.all: true + mcmmo.ability.acrobatics.all: true + mcmmo.ability.blastmining.all: true mcmmo.ability.taming.*: + description: Allows access to all Taming abilities + children: + mcmmo.ability.taming.all: true + mcmmo.ability.taming.all: description: Allows access to all Taming abilities children: mcmmo.ability.taming.fastfoodservice: true @@ -328,6 +392,10 @@ permissions: mcmmo.ability.taming.beastlore: description: Allows access to the Beast Lore ability mcmmo.ability.fishing.*: + description: Allows access to all Fishing abilities + children: + mcmmo.ability.fishing.all: true + mcmmo.ability.fishing.all: description: Allows access to all Fishing abilities children: mcmmo.ability.fishing.shakemob: true @@ -343,6 +411,10 @@ permissions: mcmmo.ability.fishing.fishermansdiet: description: Allows access to the Fishermans's Diet ability mcmmo.ability.mining.*: + description: Allows access to all Mining abilities + children: + mcmmo.ability.mining.all: true + mcmmo.ability.mining.all: description: Allows access to all Mining abilities children: mcmmo.ability.mining.superbreaker: true @@ -352,6 +424,10 @@ permissions: mcmmo.ability.mining.doubledrops: description: Allows double drop chance when mining mcmmo.ability.woodcutting.*: + description: Allows access to all Woodcutting abilities + children: + mcmmo.ability.woodcutting.all: true + mcmmo.ability.woodcutting.all: description: Allows access to all Woodcutting abilities children: mcmmo.ability.woodcutting.treefeller: true @@ -364,6 +440,10 @@ permissions: mcmmo.ability.woodcutting.doubledrops: description: Allows double drop chance when woodcutting mcmmo.ability.repair.*: + description: Allows access to all Repair abilities + children: + mcmmo.ability.repair.all: true + mcmmo.ability.repair.all: description: Allows access to all Repair abilities children: mcmmo.ability.repair.repairbonus: true @@ -412,6 +492,10 @@ permissions: mcmmo.ability.repair.otherrepair: description: Allows ability to repair items of type OTHER mcmmo.ability.unarmed.*: + description: Allows access to all Unarmed abilities + children: + mcmmo.ability.unarmed.all: true + mcmmo.ability.unarmed.all: description: Allows access to all Unarmed abilities children: mcmmo.ability.unarmed.bonusdamage: true @@ -430,6 +514,10 @@ permissions: mcmmo.ability.unarmed.irongrip: description: Allows access to the Iron Grip ability mcmmo.ability.archery.*: + description: Allows access to all Archery abilities + children: + mcmmo.ability.archery.all: true + mcmmo.ability.archery.all: description: Allows access to all Archery abilities children: mcmmo.ability.archery.trackarrows: true @@ -442,6 +530,10 @@ permissions: mcmmo.ability.archery.bonusdamage: description: Allows bonus damage from Archery mcmmo.ability.herbalism.*: + description: Allows access to all Herbalism abilities + children: + mcmmo.ability.herbalism.all: true + mcmmo.ability.herbalism.all: description: Allows access to all Herbalism abilities children: mcmmo.ability.herbalism.doubledrops: true @@ -469,6 +561,10 @@ permissions: mcmmo.ability.herbalism.farmersdiet: description: Allows access to the Farmer's Diet ability mcmmo.ability.excavation.*: + description: Allows access to all Excavation abilities + children: + mcmmo.ability.excavation.all: true + mcmmo.ability.excavation.all: description: Allows access to all Excavation abilities children: mcmmo.ability.excavation.gigadrillbreaker: true @@ -478,6 +574,10 @@ permissions: mcmmo.ability.excavation.treasures: description: Allows treasure drops from Excavation mcmmo.ability.swords.*: + description: Allows access to all Swords abilities + children: + mcmmo.ability.swords.all: true + mcmmo.ability.swords.all: description: Allows access to all Swords abilities children: mcmmo.ability.swords.bleed: true @@ -490,6 +590,10 @@ permissions: mcmmo.ability.swords.counterattack: description: Allows access to the Counter Attack ability mcmmo.ability.axes.*: + description: Allows access to all Axes abilities + children: + mcmmo.ability.axes.all: true + mcmmo.ability.axes.all: description: Allows access to all Axes abilities children: mcmmo.ability.axes.skullsplitter: true @@ -508,6 +612,10 @@ permissions: mcmmo.ability.axes.greaterimpact: description: Allows access to the Greater Impact ability mcmmo.ability.acrobatics.*: + description: Allows access to all Acrobatics abilities + children: + mcmmo.ability.acrobatics.all: true + mcmmo.ability.acrobatics.all: description: Allows access to all Acrobatics abilities children: mcmmo.ability.acrobatics.roll: true @@ -520,6 +628,10 @@ permissions: mcmmo.ability.acrobatics.dodge: description: Allows access to the Dodge ability mcmmo.ability.blastmining.*: + description: Allows access to all Blast Mining abilities + children: + mcmmo.ability.blastmining.all: true + mcmmo.ability.blastmining.all: description: Allows access to all Blast Mining abilities children: mcmmo.ability.blastmining.biggerbombs: true @@ -532,14 +644,22 @@ permissions: mcmmo.ability.blastmining.detonate: description: Allows for remote TNT detonation mcmmo.item.*: + description: Implies all mcmmo.item permissions + children: + mcmmo.item.all: true + mcmmo.item.all: description: Implies all mcmmo.item permissions children: mcmmo.item.chimaerawing: true mcmmo.item.chimaerawing: description: Allows use of Chimaera Wing item mcmmo.motd: - description: Allows access to the motd + description: Allows access to the motd mcmmo.commands.*: + description: Implies all mcmmo.commands permissions. + children: + mcmmo.commands.all: true + mcmmo.commands.all: description: Implies all mcmmo.commands permissions. children: mcmmo.commands.ability: true @@ -553,8 +673,12 @@ permissions: mcmmo.commands.inspect: description: Allows access to the inspect command mcmmo.commands.party: - description: Allows acces to the party command + description: Allows acces to the party command mcmmo.chat.*: + description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) + children: + mcmmo.chat.all: true + mcmmo.chat.all: description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) children: mcmmo.chat.adminchat: true @@ -564,6 +688,10 @@ permissions: mcmmo.chat.partychat: description: Allows participation in party chat mcmmo.skills.*: + description: Implies all mcmmo.skills permissions. + children: + mcmmo.skills.all: true + mcmmo.skills.all: description: Implies all mcmmo.skills permissions. children: mcmmo.skills.fishing: true