mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-30 11:05:28 +02:00
Partially finished merge
This commit is contained in:
@@ -52,7 +52,7 @@ public final class BlockTools {
|
||||
* @return true if the player succeeded in the check
|
||||
*/
|
||||
public boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) {
|
||||
if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||
if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && pluginRef.getPermissionTools().isSubSkillEnabled(player, subSkillType)) {
|
||||
return pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkill(pluginRef, player, subSkillType, true));
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ public final class ChimaeraWing {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.chimaeraWing(player)) {
|
||||
if (!pluginRef.getPermissionTools().chimaeraWing(player)) {
|
||||
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission");
|
||||
return;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
@@ -114,6 +115,10 @@ public final class ItemTools {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasItemInEitherHand(Player player, Material material) {
|
||||
return player.getInventory().getItemInMainHand().getType() == material || player.getInventory().getItemInOffHand().getType() == material;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a sword.
|
||||
*
|
||||
|
@@ -36,17 +36,42 @@ public final class Misc {
|
||||
private Misc() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if an entity is an NPC but not a villager
|
||||
* This method aims to establish compatibility between mcMMO and other plugins which create "NPCs"
|
||||
*
|
||||
* It does this by checking the following
|
||||
* 1) The entity is not a Villager
|
||||
* 2) The entity can be considered an NPC
|
||||
*
|
||||
* In this context, an NPC is a bit hard to define. Various plugins determine what an NPC is in different ways.
|
||||
* @see Misc::isNPCIncludingVillagers
|
||||
* @param entity target entity
|
||||
* @return true if the entity is not a Villager and is not a "NPC"
|
||||
*/
|
||||
public static boolean isNPCEntityExcludingVillagers(Entity entity) {
|
||||
return (entity == null
|
||||
|| (entity.hasMetadata("NPC") && !(entity instanceof Villager))
|
||||
|| (entity instanceof NPC && !(entity instanceof Villager))
|
||||
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
return (!isVillager(entity)
|
||||
&& isNPCIncludingVillagers(entity)); //Compatibility with some mod..
|
||||
}
|
||||
|
||||
public static boolean isNPCIncludingVillagers(Player entity) {
|
||||
public static boolean isNPCClassType(Entity entity) {
|
||||
return entity instanceof NPC;
|
||||
}
|
||||
|
||||
public static boolean hasNPCMetadataTag(Entity entity) {
|
||||
return entity.hasMetadata("NPC");
|
||||
}
|
||||
|
||||
public static boolean isVillager(Entity entity) {
|
||||
String entityType = entity.getType().toString();
|
||||
//This weird code is for 1.13 & 1.14 compatibility
|
||||
return entityType.equalsIgnoreCase("wandering_trader") || entity instanceof Villager;
|
||||
}
|
||||
|
||||
public static boolean isNPCIncludingVillagers(Entity entity) {
|
||||
return (entity == null
|
||||
|| (entity.hasMetadata("NPC"))
|
||||
|| (entity instanceof NPC)
|
||||
|| (hasNPCMetadataTag(entity))
|
||||
|| (isNPCClassType(entity))
|
||||
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ public final class Motd {
|
||||
* @param version Plugin version
|
||||
*/
|
||||
public static void displayVersion(Player player, String version) {
|
||||
if (Permissions.showversion(player)) {
|
||||
if (pluginRef.getPermissionTools().showversion(player)) {
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version));
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public final class Motd {
|
||||
*/
|
||||
public static void displayLuckyPerks(Player player) {
|
||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||
if (Permissions.lucky(player, skill)) {
|
||||
if (pluginRef.getPermissionTools().lucky(player, skill)) {
|
||||
player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login")));
|
||||
return;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@@ -17,52 +18,55 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
|
||||
public final class Permissions {
|
||||
private Permissions() {
|
||||
public final class PermissionTools {
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public PermissionTools(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
/*
|
||||
* GENERAL
|
||||
*/
|
||||
public static boolean motd(Permissible permissible) {
|
||||
public boolean motd(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.motd");
|
||||
}
|
||||
|
||||
public static boolean mobHealthDisplay(Permissible permissible) {
|
||||
public boolean mobHealthDisplay(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.mobhealthdisplay");
|
||||
}
|
||||
|
||||
public static boolean updateNotifications(Permissible permissible) {
|
||||
public boolean updateNotifications(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.tools.updatecheck");
|
||||
}
|
||||
|
||||
public static boolean chimaeraWing(Permissible permissible) {
|
||||
public boolean chimaeraWing(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.item.chimaerawing");
|
||||
}
|
||||
|
||||
public static boolean showversion(Permissible permissible) {
|
||||
public boolean showversion(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.showversion");
|
||||
}
|
||||
|
||||
/* BYPASS */
|
||||
public static boolean hardcoreBypass(Permissible permissible) {
|
||||
public boolean hardcoreBypass(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.bypass.hardcoremode");
|
||||
}
|
||||
|
||||
public static boolean arcaneBypass(Permissible permissible) {
|
||||
public boolean arcaneBypass(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.bypass.arcanebypass");
|
||||
}
|
||||
|
||||
public static boolean trapsBypass(Permissible permissible) {
|
||||
public boolean trapsBypass(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.bypass.fishingtraps");
|
||||
}
|
||||
|
||||
/* CHAT */
|
||||
public static boolean partyChat(Permissible permissible) {
|
||||
public boolean partyChat(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.chat.partychat");
|
||||
}
|
||||
|
||||
public static boolean adminChat(Permissible permissible) {
|
||||
public boolean adminChat(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.chat.adminchat");
|
||||
}
|
||||
|
||||
@@ -70,171 +74,171 @@ public final class Permissions {
|
||||
* COMMANDS
|
||||
*/
|
||||
|
||||
public static boolean mmoinfo(Permissible permissible) {
|
||||
public boolean mmoinfo(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mmoinfo");
|
||||
}
|
||||
|
||||
public static boolean addlevels(Permissible permissible) {
|
||||
public boolean addlevels(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.addlevels");
|
||||
}
|
||||
|
||||
public static boolean addlevelsOthers(Permissible permissible) {
|
||||
public boolean addlevelsOthers(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.addlevels.others");
|
||||
}
|
||||
|
||||
public static boolean addxp(Permissible permissible) {
|
||||
public boolean addxp(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.addxp");
|
||||
}
|
||||
|
||||
public static boolean addxpOthers(Permissible permissible) {
|
||||
public boolean addxpOthers(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.addxp.others");
|
||||
}
|
||||
|
||||
public static boolean hardcoreModify(Permissible permissible) {
|
||||
public boolean hardcoreModify(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.hardcore.modify");
|
||||
}
|
||||
|
||||
public static boolean hardcoreToggle(Permissible permissible) {
|
||||
public boolean hardcoreToggle(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.hardcore.toggle");
|
||||
}
|
||||
|
||||
public static boolean inspect(Permissible permissible) {
|
||||
public boolean inspect(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.inspect"));
|
||||
}
|
||||
|
||||
public static boolean inspectFar(Permissible permissible) {
|
||||
public boolean inspectFar(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.inspect.far"));
|
||||
}
|
||||
|
||||
public static boolean inspectHidden(Permissible permissible) {
|
||||
public boolean inspectHidden(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.inspect.hidden"));
|
||||
}
|
||||
|
||||
public static boolean inspectOffline(Permissible permissible) {
|
||||
public boolean inspectOffline(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.inspect.offline"));
|
||||
}
|
||||
|
||||
public static boolean mcability(Permissible permissible) {
|
||||
public boolean mcability(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcability"));
|
||||
}
|
||||
|
||||
public static boolean mcabilityOthers(Permissible permissible) {
|
||||
public boolean mcabilityOthers(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcability.others"));
|
||||
}
|
||||
|
||||
public static boolean adminChatSpy(Permissible permissible) {
|
||||
public boolean adminChatSpy(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcchatspy");
|
||||
}
|
||||
|
||||
public static boolean adminChatSpyOthers(Permissible permissible) {
|
||||
public boolean adminChatSpyOthers(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcchatspy.others");
|
||||
}
|
||||
|
||||
public static boolean mcgod(Permissible permissible) {
|
||||
public boolean mcgod(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcgod");
|
||||
}
|
||||
|
||||
public static boolean mcgodOthers(Permissible permissible) {
|
||||
public boolean mcgodOthers(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcgod.others");
|
||||
}
|
||||
|
||||
public static boolean mcmmoDescription(Permissible permissible) {
|
||||
public boolean mcmmoDescription(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcmmo.description");
|
||||
}
|
||||
|
||||
public static boolean mcmmoHelp(Permissible permissible) {
|
||||
public boolean mcmmoHelp(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcmmo.help");
|
||||
}
|
||||
|
||||
public static boolean mcrank(Permissible permissible) {
|
||||
public boolean mcrank(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcrank"));
|
||||
}
|
||||
|
||||
public static boolean mcrankOthers(Permissible permissible) {
|
||||
public boolean mcrankOthers(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcrank.others"));
|
||||
}
|
||||
|
||||
public static boolean mcrankFar(Permissible permissible) {
|
||||
public boolean mcrankFar(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcrank.others.far"));
|
||||
}
|
||||
|
||||
public static boolean mcrankOffline(Permissible permissible) {
|
||||
public boolean mcrankOffline(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcrank.others.offline"));
|
||||
}
|
||||
|
||||
public static boolean mcrefresh(Permissible permissible) {
|
||||
public boolean mcrefresh(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcrefresh"));
|
||||
}
|
||||
|
||||
public static boolean mcrefreshOthers(Permissible permissible) {
|
||||
public boolean mcrefreshOthers(Permissible permissible) {
|
||||
return (permissible.hasPermission("mcmmo.commands.mcrefresh.others"));
|
||||
}
|
||||
|
||||
public static boolean mctop(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean mctop(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.commands.mctop." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean mmoedit(Permissible permissible) {
|
||||
public boolean mmoedit(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mmoedit");
|
||||
}
|
||||
|
||||
public static boolean reload(Permissible permissible) {
|
||||
public boolean reload(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.reload");
|
||||
}
|
||||
|
||||
public static boolean mmoeditOthers(Permissible permissible) {
|
||||
public boolean mmoeditOthers(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mmoedit.others");
|
||||
}
|
||||
|
||||
public static boolean skillreset(Permissible permissible) {
|
||||
public boolean skillreset(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.skillreset");
|
||||
}
|
||||
|
||||
public static boolean skillreset(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean skillreset(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean skillresetOthers(Permissible permissible) {
|
||||
public boolean skillresetOthers(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.skillreset.others");
|
||||
}
|
||||
|
||||
public static boolean skillresetOthers(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean skillresetOthers(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean xplock(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean xplock(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.commands.xplock." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean xprateSet(Permissible permissible) {
|
||||
public boolean xprateSet(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.xprate.set");
|
||||
}
|
||||
|
||||
public static boolean xprateReset(Permissible permissible) {
|
||||
public boolean xprateReset(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.xprate.reset");
|
||||
}
|
||||
|
||||
public static boolean vampirismModify(Permissible permissible) {
|
||||
public boolean vampirismModify(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.vampirism.modify");
|
||||
}
|
||||
|
||||
public static boolean vampirismToggle(Permissible permissible) {
|
||||
public boolean vampirismToggle(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.vampirism.toggle");
|
||||
}
|
||||
|
||||
public static boolean mcpurge(Permissible permissible) {
|
||||
public boolean mcpurge(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcpurge");
|
||||
}
|
||||
|
||||
public static boolean mcremove(Permissible permissible) {
|
||||
public boolean mcremove(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mcremove");
|
||||
}
|
||||
|
||||
public static boolean mmoupdate(Permissible permissible) {
|
||||
public boolean mmoupdate(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.mmoupdate");
|
||||
}
|
||||
|
||||
public static boolean reloadlocale(Permissible permissible) {
|
||||
public boolean reloadlocale(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.reloadlocale");
|
||||
}
|
||||
|
||||
@@ -244,70 +248,70 @@ public final class Permissions {
|
||||
|
||||
/* BYPASS PERKS */
|
||||
|
||||
public static boolean hasRepairEnchantBypassPerk(Permissible permissible) {
|
||||
public boolean hasRepairEnchantBypassPerk(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.bypass.repairenchant");
|
||||
}
|
||||
|
||||
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) {
|
||||
public boolean hasSalvageEnchantBypassPerk(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant");
|
||||
}
|
||||
|
||||
public static boolean lucky(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean lucky(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
/* XP PERKS */
|
||||
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean tripleXp(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean tripleXp(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.xp.triple." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean doubleAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean doubleAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.xp.150percentboost." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean doubleXp(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean doubleXp(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.xp.double." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.xp.50percentboost." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.perks.xp.10percentboost." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean hasCustomXPPerk(Permissible permissible, CustomXPPerk customXPPerk) {
|
||||
public boolean hasCustomXPPerk(Permissible permissible, CustomXPPerk customXPPerk) {
|
||||
return permissible.hasPermission(customXPPerk.getPerkPermissionAddress());
|
||||
}
|
||||
|
||||
/* ACTIVATION PERKS */
|
||||
public static boolean twelveSecondActivationBoost(Permissible permissible) {
|
||||
public boolean twelveSecondActivationBoost(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.activationtime.twelveseconds");
|
||||
}
|
||||
|
||||
public static boolean eightSecondActivationBoost(Permissible permissible) {
|
||||
public boolean eightSecondActivationBoost(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.activationtime.eightseconds");
|
||||
}
|
||||
|
||||
public static boolean fourSecondActivationBoost(Permissible permissible) {
|
||||
public boolean fourSecondActivationBoost(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.activationtime.fourseconds");
|
||||
}
|
||||
|
||||
/* COOLDOWN PERKS */
|
||||
public static boolean halvedCooldowns(Permissible permissible) {
|
||||
public boolean halvedCooldowns(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.cooldowns.halved");
|
||||
}
|
||||
|
||||
public static boolean thirdedCooldowns(Permissible permissible) {
|
||||
public boolean thirdedCooldowns(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.cooldowns.thirded");
|
||||
}
|
||||
|
||||
public static boolean quarteredCooldowns(Permissible permissible) {
|
||||
public boolean quarteredCooldowns(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.perks.cooldowns.quartered");
|
||||
}
|
||||
|
||||
@@ -315,201 +319,197 @@ public final class Permissions {
|
||||
* SKILLS
|
||||
*/
|
||||
|
||||
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".vanillaxpboost");
|
||||
}
|
||||
|
||||
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) {
|
||||
return permissible.hasPermission(subSkillType.getPermissionNodeAddress());
|
||||
public boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) {
|
||||
return permissible.hasPermission(subSkillType.getPermissionNodeAddress(pluginRef));
|
||||
}
|
||||
|
||||
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) {
|
||||
public boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) {
|
||||
return permissible.hasPermission(abstractSubSkill.getPermissionNode());
|
||||
}
|
||||
|
||||
public static boolean bonusDamage(Permissible permissible, PrimarySkillType skill) {
|
||||
public boolean bonusDamage(Permissible permissible, PrimarySkillType skill) {
|
||||
return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".bonusdamage");
|
||||
}
|
||||
|
||||
/* ACROBATICS */
|
||||
public static boolean dodge(Permissible permissible) {
|
||||
public boolean dodge(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.acrobatics.dodge");
|
||||
}
|
||||
|
||||
public static boolean gracefulRoll(Permissible permissible) {
|
||||
public boolean gracefulRoll(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.acrobatics.gracefulroll");
|
||||
}
|
||||
|
||||
public static boolean roll(Permissible permissible) {
|
||||
public boolean roll(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.acrobatics.roll");
|
||||
}
|
||||
|
||||
/* ALCHEMY */
|
||||
public static boolean catalysis(Permissible permissible) {
|
||||
public boolean catalysis(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.alchemy.catalysis");
|
||||
}
|
||||
|
||||
public static boolean concoctions(Permissible permissible) {
|
||||
public boolean concoctions(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.alchemy.concoctions");
|
||||
}
|
||||
|
||||
/* ARCHERY */
|
||||
public static boolean arrowRetrieval(Permissible permissible) {
|
||||
public boolean arrowRetrieval(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.archery.trackarrows");
|
||||
}
|
||||
|
||||
public static boolean daze(Permissible permissible) {
|
||||
public boolean daze(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.archery.daze");
|
||||
}
|
||||
|
||||
/* AXES */
|
||||
public static boolean skullSplitter(Permissible permissible) {
|
||||
public boolean skullSplitter(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.axes.skullsplitter");
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
public static boolean gigaDrillBreaker(Permissible permissible) {
|
||||
public boolean gigaDrillBreaker(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.excavation.gigadrillbreaker");
|
||||
}
|
||||
|
||||
/* HERBALISM */
|
||||
public static boolean greenTerra(Permissible permissible) {
|
||||
public boolean greenTerra(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.herbalism.greenterra");
|
||||
}
|
||||
|
||||
public static boolean greenThumbBlock(Permissible permissible, Material material) {
|
||||
public boolean greenThumbBlock(Permissible permissible, Material material) {
|
||||
return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean greenThumbPlant(Permissible permissible, Material material) {
|
||||
public boolean greenThumbPlant(Permissible permissible, Material material) {
|
||||
return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase());
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
public static boolean biggerBombs(Permissible permissible) {
|
||||
public boolean biggerBombs(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs");
|
||||
}
|
||||
|
||||
public static boolean demolitionsExpertise(Permissible permissible) {
|
||||
public boolean demolitionsExpertise(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.mining.blastmining.demolitionsexpertise");
|
||||
}
|
||||
|
||||
public static boolean remoteDetonation(Permissible permissible) {
|
||||
public boolean remoteDetonation(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.mining.blastmining.detonate");
|
||||
}
|
||||
|
||||
public static boolean superBreaker(Permissible permissible) {
|
||||
public boolean superBreaker(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.mining.superbreaker");
|
||||
}
|
||||
|
||||
/* REPAIR */
|
||||
public static boolean repairItemType(Permissible permissible, ItemType repairItemType) {
|
||||
public boolean repairItemType(Permissible permissible, ItemType repairItemType) {
|
||||
return permissible.hasPermission("mcmmo.ability.repair." + repairItemType.toString().toLowerCase() + "repair");
|
||||
}
|
||||
|
||||
public static boolean repairMaterialType(Permissible permissible, ItemMaterialCategory repairItemMaterialCategory) {
|
||||
public boolean repairMaterialType(Permissible permissible, ItemMaterialCategory repairItemMaterialCategory) {
|
||||
return permissible.hasPermission("mcmmo.ability.repair." + repairItemMaterialCategory.toString().toLowerCase() + "repair");
|
||||
}
|
||||
|
||||
/* SALVAGE */
|
||||
public static boolean advancedSalvage(Permissible permissible) {
|
||||
public boolean advancedSalvage(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.salvage.advancedsalvage");
|
||||
}
|
||||
|
||||
public static boolean arcaneSalvage(Permissible permissible) {
|
||||
public boolean arcaneSalvage(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.salvage.arcanesalvage");
|
||||
}
|
||||
|
||||
public static boolean salvageItemType(Permissible permissible, ItemType salvageItemType) {
|
||||
public boolean salvageItemType(Permissible permissible, ItemType salvageItemType) {
|
||||
return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemType.toString().toLowerCase() + "salvage");
|
||||
}
|
||||
|
||||
public static boolean salvageMaterialType(Permissible permissible, ItemMaterialCategory salvageItemMaterialCategory) {
|
||||
public boolean salvageMaterialType(Permissible permissible, ItemMaterialCategory salvageItemMaterialCategory) {
|
||||
return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemMaterialCategory.toString().toLowerCase() + "salvage");
|
||||
}
|
||||
|
||||
/* SMELTING */
|
||||
public static boolean fluxMining(Permissible permissible) {
|
||||
public boolean fluxMining(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.smelting.fluxmining");
|
||||
}
|
||||
|
||||
public static boolean fuelEfficiency(Permissible permissible) {
|
||||
public boolean fuelEfficiency(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.smelting.fuelefficiency");
|
||||
}
|
||||
|
||||
/* SWORDS */
|
||||
public static boolean serratedStrikes(Permissible permissible) {
|
||||
public boolean serratedStrikes(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.swords.serratedstrikes");
|
||||
}
|
||||
|
||||
/* TAMING */
|
||||
public static boolean callOfTheWild(Permissible permissible, EntityType type) {
|
||||
public boolean callOfTheWild(Permissible permissible, EntityType type) {
|
||||
return permissible.hasPermission("mcmmo.ability.taming.callofthewild." + type.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean renamePets(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.taming.callofthewild.renamepets");
|
||||
}
|
||||
|
||||
/* UNARMED */
|
||||
public static boolean berserk(Permissible permissible) {
|
||||
public boolean berserk(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.unarmed.berserk");
|
||||
}
|
||||
|
||||
/* WOODCUTTING */
|
||||
public static boolean treeFeller(Permissible permissible) {
|
||||
public boolean treeFeller(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.ability.woodcutting.treefeller");
|
||||
}
|
||||
|
||||
/*
|
||||
* PARTY
|
||||
*/
|
||||
public static boolean partySizeBypass(Permissible permissible) {
|
||||
public boolean partySizeBypass(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.bypass.partylimit");
|
||||
}
|
||||
|
||||
public static boolean party(Permissible permissible) {
|
||||
public boolean party(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.party");
|
||||
}
|
||||
|
||||
public static boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) {
|
||||
public boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) {
|
||||
return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean friendlyFire(Permissible permissible) {
|
||||
public boolean friendlyFire(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.party.friendlyfire");
|
||||
}
|
||||
|
||||
/* TELEPORT */
|
||||
public static boolean partyTeleportSend(Permissible permissible) {
|
||||
public boolean partyTeleportSend(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.ptp.send");
|
||||
}
|
||||
|
||||
public static boolean partyTeleportAccept(Permissible permissible) {
|
||||
public boolean partyTeleportAccept(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.ptp.accept");
|
||||
}
|
||||
|
||||
public static boolean partyTeleportAcceptAll(Permissible permissible) {
|
||||
public boolean partyTeleportAcceptAll(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.ptp.acceptall");
|
||||
}
|
||||
|
||||
public static boolean partyTeleportToggle(Permissible permissible) {
|
||||
public boolean partyTeleportToggle(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.ptp.toggle");
|
||||
}
|
||||
|
||||
public static boolean partyTeleportAllWorlds(Permissible permissible) {
|
||||
public boolean partyTeleportAllWorlds(Permissible permissible) {
|
||||
return permissible.hasPermission("mcmmo.commands.ptp.world.all");
|
||||
}
|
||||
|
||||
public static boolean partyTeleportWorld(Permissible permissible, World world) {
|
||||
public boolean partyTeleportWorld(Permissible permissible, World world) {
|
||||
return permissible.hasPermission("mcmmo.commands.ptp.world." + world.getName());
|
||||
}
|
||||
|
||||
public static void generateWorldTeleportPermissions() {
|
||||
public void generateWorldTeleportPermissions() {
|
||||
Server server = pluginRef.getServer();
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
|
||||
@@ -522,7 +522,7 @@ public final class Permissions {
|
||||
* XP Perks are defined by user config files and are not known until runtime
|
||||
* This method registers Permissions with the server software as needed
|
||||
*/
|
||||
public static void addCustomXPPerks() {
|
||||
public void addCustomXPPerks() {
|
||||
pluginRef.getLogger().info("Registering custom XP perks with server software...");
|
||||
PluginManager pluginManager = pluginRef.getServer().getPluginManager();
|
||||
|
||||
@@ -539,7 +539,7 @@ public final class Permissions {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addDynamicPermission(String permissionName, PluginManager pluginManager) {
|
||||
private void addDynamicPermission(String permissionName, PluginManager pluginManager) {
|
||||
Permission permission = new Permission(permissionName);
|
||||
permission.setDefault(PermissionDefault.OP);
|
||||
pluginManager.addPermission(permission);
|
@@ -517,7 +517,7 @@ public class TextComponentFactory {
|
||||
public void getSubSkillTextComponents(Player player, List<TextComponent> textComponents, PrimarySkillType parentSkill) {
|
||||
for (SubSkillType subSkillType : SubSkillType.values()) {
|
||||
if (subSkillType.getParentSkill() == parentSkill) {
|
||||
if (Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||
if (pluginRef.getPermissionTools().isSubSkillEnabled(player, subSkillType)) {
|
||||
if (!InteractionManager.hasSubSkill(subSkillType))
|
||||
textComponents.add(pluginRef.getTextComponentFactory().getSubSkillTextComponent(player, subSkillType));
|
||||
}
|
||||
@@ -527,7 +527,7 @@ public class TextComponentFactory {
|
||||
/* NEW SKILL SYSTEM */
|
||||
for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
|
||||
if (abstractSubSkill.getPrimarySkill() == parentSkill) {
|
||||
if (Permissions.isSubSkillEnabled(player, abstractSubSkill))
|
||||
if (pluginRef.getPermissionTools().isSubSkillEnabled(player, abstractSubSkill))
|
||||
textComponents.add(pluginRef.getTextComponentFactory().getSubSkillTextComponent(player, abstractSubSkill));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util.commands;
|
||||
|
||||
import com.gmail.nossr50.commands.*;
|
||||
import com.gmail.nossr50.commands.admin.PlayerDebugCommand;
|
||||
import com.gmail.nossr50.commands.admin.ReloadLocaleCommand;
|
||||
import com.gmail.nossr50.commands.chat.AdminChatCommand;
|
||||
import com.gmail.nossr50.commands.chat.ChatSpyCommand;
|
||||
@@ -151,6 +152,16 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new MmoInfoCommand(pluginRef));
|
||||
}
|
||||
|
||||
|
||||
private void registerMmoDebugCommand() {
|
||||
PluginCommand command = pluginRef.getCommand("mmodebug");
|
||||
command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmodebug"));
|
||||
command.setPermission(null); //No perm required to save support headaches
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mmodebug"));
|
||||
command.setExecutor(new PlayerDebugCommand());
|
||||
}
|
||||
|
||||
private void registerMcChatSpyCommand() {
|
||||
PluginCommand command = pluginRef.getCommand("mcchatspy");
|
||||
command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcchatspy"));
|
||||
@@ -415,6 +426,7 @@ public final class CommandRegistrationManager {
|
||||
public void registerCommands() {
|
||||
// Generic Commands
|
||||
registerMmoInfoCommand();
|
||||
registerMmoDebugCommand();
|
||||
registerMcabilityCommand();
|
||||
registerMcgodCommand();
|
||||
registerMcChatSpyCommand();
|
||||
|
@@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@@ -115,6 +114,16 @@ public class NotificationManager {
|
||||
player.sendMessage(preColoredString);
|
||||
}
|
||||
|
||||
public void sendPlayerInformationChatOnlyPrefixed(Player player, String key, String... values)
|
||||
{
|
||||
if(pluginRef.getUserManager().getPlayer(player) == null || !pluginRef.getUserManager().getPlayer(player).useChatNotifications())
|
||||
return;
|
||||
|
||||
String preColoredString = pluginRef.getLocaleManager().getString(key, (Object[]) values);
|
||||
String prefixFormattedMessage = pluginRef.getLocaleManager().getString("mcMMO.Template.Prefix", preColoredString);
|
||||
player.sendMessage(prefixFormattedMessage);
|
||||
}
|
||||
|
||||
public void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
|
||||
{
|
||||
if(pluginRef.getUserManager().getPlayer(player) == null || !pluginRef.getUserManager().getPlayer(player).useChatNotifications())
|
||||
@@ -228,7 +237,7 @@ public class NotificationManager {
|
||||
return;
|
||||
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (player.isOp() || Permissions.adminChat(player)) {
|
||||
if (player.isOp() || pluginRef.getPermissionTools().adminChat(player)) {
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("Notifications.Admin.Format.Others", msg));
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -24,7 +23,7 @@ public class PlayerLevelTools {
|
||||
* Register our custom permission perks with bukkit
|
||||
*/
|
||||
private void registerCustomPerkPermissions() {
|
||||
Permissions.addCustomXPPerks();
|
||||
pluginRef.getPermissionTools().addCustomXPPerks();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +57,7 @@ public class PlayerLevelTools {
|
||||
|
||||
//Check all registered XP Perk nodes for this player
|
||||
for (CustomXPPerk customXPPerk : customXpPerkNodes) {
|
||||
if (Permissions.hasCustomXPPerk(player, customXPPerk)) {
|
||||
if (pluginRef.getPermissionTools().hasCustomXPPerk(player, customXPPerk)) {
|
||||
enabledXPPerks.add(customXPPerk);
|
||||
}
|
||||
}
|
||||
@@ -92,17 +91,17 @@ public class PlayerLevelTools {
|
||||
}
|
||||
|
||||
//Disgusting legacy support start
|
||||
if (Permissions.quadrupleXp(player, skill)) {
|
||||
if (pluginRef.getPermissionTools().quadrupleXp(player, skill)) {
|
||||
xpPerkValues.add(4.0);
|
||||
} else if (Permissions.tripleXp(player, skill)) {
|
||||
} else if (pluginRef.getPermissionTools().tripleXp(player, skill)) {
|
||||
xpPerkValues.add(3.0);
|
||||
} else if (Permissions.doubleAndOneHalfXp(player, skill)) {
|
||||
} else if (pluginRef.getPermissionTools().doubleAndOneHalfXp(player, skill)) {
|
||||
xpPerkValues.add(2.5);
|
||||
} else if (Permissions.doubleXp(player, skill)) {
|
||||
} else if (pluginRef.getPermissionTools().doubleXp(player, skill)) {
|
||||
xpPerkValues.add(2.0);
|
||||
} else if (Permissions.oneAndOneHalfXp(player, skill)) {
|
||||
} else if (pluginRef.getPermissionTools().oneAndOneHalfXp(player, skill)) {
|
||||
xpPerkValues.add(1.5);
|
||||
} else if (Permissions.oneAndOneTenthXp(player, skill)) {
|
||||
} else if (pluginRef.getPermissionTools().oneAndOneTenthXp(player, skill)) {
|
||||
xpPerkValues.add(1.1);
|
||||
}
|
||||
//Disgusting legacy support end
|
||||
|
@@ -51,9 +51,11 @@ public final class UserManager {
|
||||
public void remove(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = getPlayer(player);
|
||||
player.removeMetadata(MetadataConstants.PLAYER_DATA_METAKEY, pluginRef);
|
||||
mcMMOPlayer.cleanup();
|
||||
|
||||
if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer))
|
||||
if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer)) {
|
||||
playerDataSet.remove(mcMMOPlayer); //Clear sync save tracking
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,6 @@ package com.gmail.nossr50.util.random;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RandomChanceSkill implements RandomChanceExecution {
|
||||
@@ -28,7 +27,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
||||
this.skillLevel = 0;
|
||||
|
||||
if (player != null)
|
||||
isLucky = Permissions.lucky(player, primarySkillType);
|
||||
isLucky = pluginRef.getPermissionTools().lucky(player, primarySkillType);
|
||||
else
|
||||
isLucky = false;
|
||||
}
|
||||
@@ -50,7 +49,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
|
||||
this.skillLevel = 0;
|
||||
|
||||
if (player != null)
|
||||
isLucky = Permissions.lucky(player, primarySkillType);
|
||||
isLucky = pluginRef.getPermissionTools().lucky(player, primarySkillType);
|
||||
else
|
||||
isLucky = false;
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -249,7 +248,7 @@ public class RandomChanceTools {
|
||||
double successChance = getActivationChance(skillActivationType, subSkillType, player);
|
||||
String[] displayValues = new String[2];
|
||||
|
||||
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill(pluginRef));
|
||||
boolean isLucky = pluginRef.getPermissionTools().lucky(player, subSkillType.getParentSkill(pluginRef));
|
||||
|
||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
|
||||
@@ -266,7 +265,7 @@ public class RandomChanceTools {
|
||||
|
||||
String[] displayValues = new String[2];
|
||||
|
||||
boolean isLucky = Permissions.lucky(player, primarySkillType);
|
||||
boolean isLucky = pluginRef.getPermissionTools().lucky(player, primarySkillType);
|
||||
|
||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||
displayValues[1] = isLucky ? percent.format(Math.min(successChance_lucky, 100.0D) / 100.0D) : null;
|
||||
@@ -281,7 +280,7 @@ public class RandomChanceTools {
|
||||
|
||||
//TODO: Account for lucky in this
|
||||
|
||||
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill(pluginRef));
|
||||
boolean isLucky = pluginRef.getPermissionTools().lucky(player, subSkillType.getParentSkill(pluginRef));
|
||||
|
||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
|
||||
@@ -290,7 +289,7 @@ public class RandomChanceTools {
|
||||
}
|
||||
|
||||
public double addLuck(Player player, PrimarySkillType primarySkillType, double chance) {
|
||||
if (Permissions.lucky(player, primarySkillType))
|
||||
if (pluginRef.getPermissionTools().lucky(player, primarySkillType))
|
||||
return chance * 1.333D;
|
||||
else
|
||||
return chance;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.util.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.core.MetadataConstants;
|
||||
import com.gmail.nossr50.datatypes.experience.SpecialXPKey;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
@@ -17,10 +18,8 @@ import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@@ -76,8 +75,9 @@ public final class CombatTools {
|
||||
swordsManager.serratedStrikes(target, initialDamage, modifiers);
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK);
|
||||
if(canUseLimitBreak(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
@@ -118,8 +118,9 @@ public final class CombatTools {
|
||||
finalDamage += axesManager.criticalHit(target, finalDamage);
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK);
|
||||
if(canUseLimitBreak(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
@@ -155,39 +156,54 @@ public final class CombatTools {
|
||||
unarmedManager.disarmCheck((Player) target);
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK);
|
||||
if(canUseLimitBreak(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK);
|
||||
}
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.UNARMED);
|
||||
Unarmed.lastAttacked = System.currentTimeMillis(); //Track how often the player is punching
|
||||
unarmedManager.setLastAttacked(System.currentTimeMillis()); //Track how often the player is punching
|
||||
}
|
||||
|
||||
private void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) {
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
|
||||
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(master);
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
if(master != null && !master.isOnline() && master.isValid()) {
|
||||
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(master);
|
||||
|
||||
if (tamingManager.canUseFastFoodService()) {
|
||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||
//Make sure the profiles been loaded
|
||||
if(mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
if (tamingManager.canUseFastFoodService()) {
|
||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||
}
|
||||
|
||||
tamingManager.pummel(target, wolf);
|
||||
|
||||
if (tamingManager.canUseSharpenedClaws()) {
|
||||
if(target instanceof Player) {
|
||||
finalDamage+=tamingManager.sharpenedClaws(false);
|
||||
} else {
|
||||
finalDamage+=tamingManager.sharpenedClaws(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tamingManager.canUseGore()) {
|
||||
finalDamage+=tamingManager.gore(target, initialDamage);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.TAMING);
|
||||
}
|
||||
|
||||
tamingManager.pummel(target, wolf);
|
||||
|
||||
if (tamingManager.canUseSharpenedClaws()) {
|
||||
finalDamage += tamingManager.getSharpenedClawsDamage();
|
||||
}
|
||||
|
||||
if (tamingManager.canUseGore()) {
|
||||
finalDamage += tamingManager.gore(target, initialDamage);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.TAMING);
|
||||
}
|
||||
|
||||
private void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) {
|
||||
@@ -223,8 +239,9 @@ public final class CombatTools {
|
||||
archeryManager.processArrowRetrievalActivation(target, arrow);
|
||||
}
|
||||
|
||||
if (canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
|
||||
finalDamage += getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
|
||||
if(canUseLimitBreak(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
|
||||
@@ -374,19 +391,81 @@ public final class CombatTools {
|
||||
}
|
||||
}
|
||||
|
||||
public int getLimitBreakDamage(Player player, SubSkillType subSkillType) {
|
||||
return pluginRef.getRankTools().getRank(player, subSkillType);
|
||||
public int getLimitBreakDamage(Player player, LivingEntity defender, SubSkillType subSkillType) {
|
||||
if(defender instanceof Player) {
|
||||
Player playerDefender = (Player) defender;
|
||||
return getLimitBreakDamageAgainstQuality(player, subSkillType, getArmorQualityLevel(playerDefender));
|
||||
} else {
|
||||
return getLimitBreakDamageAgainstQuality(player, subSkillType, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLimitBreakDamageAgainstQuality(Player player, SubSkillType subSkillType, int armorQualityLevel) {
|
||||
int rawDamageBoost = pluginRef.getRankTools().getRank(player, subSkillType);
|
||||
|
||||
if(armorQualityLevel <= 4) {
|
||||
rawDamageBoost *= .25; //75% Nerf
|
||||
} else if(armorQualityLevel <= 8) {
|
||||
rawDamageBoost *= .50; //50% Nerf
|
||||
} else if(armorQualityLevel <= 12) {
|
||||
rawDamageBoost *= .75; //25% Nerf
|
||||
}
|
||||
|
||||
return rawDamageBoost;
|
||||
}
|
||||
|
||||
public int getArmorQualityLevel(Player defender) {
|
||||
int armorQualityLevel = 0;
|
||||
|
||||
for(ItemStack itemStack : defender.getInventory().getArmorContents()) {
|
||||
if(itemStack != null) {
|
||||
armorQualityLevel += getArmorQuality(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
return armorQualityLevel;
|
||||
}
|
||||
|
||||
private int getArmorQuality(ItemStack itemStack) {
|
||||
switch(itemStack.getType()) {
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_BOOTS:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_LEGGINGS:
|
||||
return 1;
|
||||
case IRON_HELMET:
|
||||
case IRON_BOOTS:
|
||||
case IRON_CHESTPLATE:
|
||||
case IRON_LEGGINGS:
|
||||
return 2;
|
||||
case GOLDEN_HELMET:
|
||||
case GOLDEN_BOOTS:
|
||||
case GOLDEN_CHESTPLATE:
|
||||
case GOLDEN_LEGGINGS:
|
||||
return 3;
|
||||
case DIAMOND_HELMET:
|
||||
case DIAMOND_BOOTS:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case DIAMOND_LEGGINGS:
|
||||
return 6;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if player has access to their weapons limit break
|
||||
*
|
||||
* @param player target player
|
||||
* @param player target entity
|
||||
* @return true if the player has access to the limit break
|
||||
*/
|
||||
public boolean canUseLimitBreak(Player player, SubSkillType subSkillType) {
|
||||
return pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType)
|
||||
&& Permissions.isSubSkillEnabled(player, subSkillType);
|
||||
public boolean canUseLimitBreak(Player player, LivingEntity target, SubSkillType subSkillType) {
|
||||
if(target instanceof Player || AdvancedConfig.getInstance().canApplyLimitBreakPVE()) {
|
||||
return pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType)
|
||||
&& pluginRef.getPermissionTools().isSubSkillEnabled(player, subSkillType);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,7 +689,7 @@ public final class CombatTools {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((pluginRef.getPartyManager().inSameParty(player, defender) || pluginRef.getPartyManager().areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
||||
if ((pluginRef.getPartyManager().inSameParty(player, defender) || pluginRef.getPartyManager().areAllies(player, defender)) && !(pluginRef.getPermissionTools().friendlyFire(player) && pluginRef.getPermissionTools().friendlyFire(defender))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -633,7 +712,7 @@ public final class CombatTools {
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
Player owner = (Player) ((Tameable) entity).getOwner();
|
||||
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) {
|
||||
if (!(pluginRef.getPermissionTools().friendlyFire(player) && pluginRef.getPermissionTools().friendlyFire(owner))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.util.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class PerksUtils {
|
||||
@@ -12,11 +11,11 @@ public final class PerksUtils {
|
||||
}
|
||||
|
||||
public static int handleCooldownPerks(Player player, int cooldown) {
|
||||
if (Permissions.halvedCooldowns(player)) {
|
||||
if (pluginRef.getPermissionTools().halvedCooldowns(player)) {
|
||||
cooldown *= 0.5;
|
||||
} else if (Permissions.thirdedCooldowns(player)) {
|
||||
} else if (pluginRef.getPermissionTools().thirdedCooldowns(player)) {
|
||||
cooldown *= (2.0 / 3.0);
|
||||
} else if (Permissions.quarteredCooldowns(player)) {
|
||||
} else if (pluginRef.getPermissionTools().quarteredCooldowns(player)) {
|
||||
cooldown *= 0.75;
|
||||
}
|
||||
|
||||
@@ -31,7 +30,7 @@ public final class PerksUtils {
|
||||
* @return the activation chance with "lucky perk" accounted for
|
||||
*/
|
||||
public static int handleLuckyPerks(Player player, PrimarySkillType skill) {
|
||||
if (Permissions.lucky(player, skill)) {
|
||||
if (pluginRef.getPermissionTools().lucky(player, skill)) {
|
||||
return LUCKY_SKILL_ACTIVATION_CHANCE;
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.SkillUnlockNotificationTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
@@ -45,7 +44,7 @@ public class RankTools {
|
||||
continue;
|
||||
|
||||
//Don't send notifications if the player lacks the permission node
|
||||
if(!Permissions.isSubSkillEnabled(mcMMOPlayer.getPlayer(), subSkillType))
|
||||
if(!pluginRef.getPermissionTools().isSubSkillEnabled(mcMMOPlayer.getPlayer(), subSkillType))
|
||||
continue;
|
||||
|
||||
//The players level is the exact level requirement for this skill
|
||||
|
@@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -263,11 +262,11 @@ public class SkillTools {
|
||||
}
|
||||
|
||||
public int getEnduranceLength(Player player) {
|
||||
if (Permissions.twelveSecondActivationBoost(player)) {
|
||||
if (pluginRef.getPermissionTools().twelveSecondActivationBoost(player)) {
|
||||
return 12;
|
||||
} else if (Permissions.eightSecondActivationBoost(player)) {
|
||||
} else if (pluginRef.getPermissionTools().eightSecondActivationBoost(player)) {
|
||||
return 8;
|
||||
} else if (Permissions.fourSecondActivationBoost(player)) {
|
||||
} else if (pluginRef.getPermissionTools().fourSecondActivationBoost(player)) {
|
||||
return 4;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -728,7 +727,7 @@ public class SkillTools {
|
||||
}
|
||||
|
||||
public boolean doesPlayerHaveSkillPermission(PrimarySkillType primarySkillType, Player player) {
|
||||
return Permissions.skillEnabled(player, primarySkillType);
|
||||
return pluginRef.getPermissionTools().skillEnabled(player, primarySkillType);
|
||||
}
|
||||
|
||||
public boolean canCombatSkillsTrigger(PrimarySkillType primarySkillType, Entity target) {
|
||||
|
Reference in New Issue
Block a user