Static Abuse Removal - BlockUtils -> BlockTools

This commit is contained in:
nossr50 2019-07-04 08:03:11 -07:00
parent c5a7c88e0c
commit 05f289e6e6
51 changed files with 322 additions and 337 deletions

View File

@ -23,7 +23,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]); DatabaseType previousType = getDatabaseType(args[1]);
DatabaseType newType = pluginRef.getDatabaseManager().getDatabaseType(); DatabaseType newType = pluginRef.getDatabaseManager().getDatabaseType();
if (previousType == newType || (newType == DatabaseType.CUSTOM && pluginRef.getDatabaseManagerFactory().getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) { if (previousType == newType || (newType == DatabaseType.CUSTOM && pluginRef.getDatabaseManagerFactory().getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
@ -64,14 +64,30 @@ public class ConvertDatabaseCommand implements CommandExecutor {
pluginRef.getDatabaseManager().saveUser(profile); pluginRef.getDatabaseManager().saveUser(profile);
} }
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
} }
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(pluginRef); new DatabaseConversionTask(pluginRef, oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(pluginRef);
return true; return true;
default: default:
return false; return false;
} }
} }
public DatabaseType getDatabaseType(String typeName) {
for (DatabaseType type : DatabaseType.values()) {
if (type.name().equalsIgnoreCase(typeName)) {
return type;
}
}
if (typeName.equalsIgnoreCase("file")) {
return DatabaseType.FLATFILE;
} else if (typeName.equalsIgnoreCase("mysql")) {
return DatabaseType.SQL;
}
return DatabaseType.CUSTOM;
}
} }

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -59,7 +58,7 @@ public class AxesCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER); canSkullSplitter = Permissions.skullSplitter(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES); canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES);
canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY); canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY);
canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT); canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT);

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,7 +34,7 @@ public class ExcavationCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER); canGigaDrill = Permissions.gigaDrillBreaker(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY); canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
} }

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -87,7 +86,7 @@ public class FishingCommand extends SkillCommand {
// FISHERMAN'S DIET // FISHERMAN'S DIET
if (canFishermansDiet) { if (canFishermansDiet) {
fishermansDietRank = RankUtils.getRank(player, SubSkillType.FISHING_FISHERMANS_DIET); fishermansDietRank = pluginRef.getRankTools().getRank(player, SubSkillType.FISHING_FISHERMANS_DIET);
} }
// MASTER ANGLER // MASTER ANGLER
@ -156,7 +155,7 @@ public class FishingCommand extends SkillCommand {
} }
if (canTreasureHunt) { if (canTreasureHunt) {
messages.add(getStatMessage(false, true, SubSkillType.FISHING_TREASURE_HUNTER, String.valueOf(lootTier), String.valueOf(RankUtils.getHighestRank(SubSkillType.FISHING_TREASURE_HUNTER)))); messages.add(getStatMessage(false, true, SubSkillType.FISHING_TREASURE_HUNTER, String.valueOf(lootTier), String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.FISHING_TREASURE_HUNTER))));
messages.add(getStatMessage(true, true, SubSkillType.FISHING_TREASURE_HUNTER, messages.add(getStatMessage(true, true, SubSkillType.FISHING_TREASURE_HUNTER,
String.valueOf(commonTreasure), String.valueOf(commonTreasure),
String.valueOf(uncommonTreasure), String.valueOf(uncommonTreasure),

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -50,7 +49,7 @@ public class HerbalismCommand extends SkillCommand {
// FARMERS DIET // FARMERS DIET
if (canFarmersDiet) { if (canFarmersDiet) {
farmersDietRank = RankUtils.getRank(player, SubSkillType.HERBALISM_FARMERS_DIET); farmersDietRank = pluginRef.getRankTools().getRank(player, SubSkillType.HERBALISM_FARMERS_DIET);
} }
// GREEN TERRA // GREEN TERRA
@ -62,7 +61,7 @@ public class HerbalismCommand extends SkillCommand {
// GREEN THUMB // GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) { if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB); greenThumbStage = pluginRef.getRankTools().getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB); String[] greenThumbStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB);
greenThumbChance = greenThumbStrings[0]; greenThumbChance = greenThumbStrings[0];
@ -88,8 +87,8 @@ public class HerbalismCommand extends SkillCommand {
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK); hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player); canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA)); canGreenThumbPlants = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS)); canGreenThumbBlocks = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS));
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET); canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS); canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB); canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB);

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -66,11 +65,11 @@ public class MiningCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBiggerBombs = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player); canBiggerBombs = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player);
canBlast = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player); canBlast = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player);
canDemoExpert = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player); canDemoExpert = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS); canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS);
canSuperBreaker = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player); canSuperBreaker = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player);
} }
@Override @Override
@ -83,7 +82,7 @@ public class MiningCommand extends SkillCommand {
} }
if (canBlast) { if (canBlast) {
messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING)), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.MINING_BLAST_MINING)), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
//messages.add(pluginRef.getLocaleManager().getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); //messages.add(pluginRef.getLocaleManager().getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
} }

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -94,8 +93,8 @@ public class RepairCommand extends SkillCommand {
messages.add(getStatMessage(false, true, messages.add(getStatMessage(false, true,
SubSkillType.REPAIR_ARCANE_FORGING, SubSkillType.REPAIR_ARCANE_FORGING,
String.valueOf(RankUtils.getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)), String.valueOf(pluginRef.getRankTools().getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)),
RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING))); pluginRef.getRankTools().getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING)));
if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() || pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants()) { if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() || pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants()) {
messages.add(getStatMessage(true, true, SubSkillType.REPAIR_ARCANE_FORGING, messages.add(getStatMessage(true, true, SubSkillType.REPAIR_ARCANE_FORGING,

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -40,14 +39,14 @@ public class SalvageCommand extends SkillCommand {
if (canScrapCollector) { if (canScrapCollector) {
messages.add(getStatMessage(false, true, messages.add(getStatMessage(false, true,
SubSkillType.SALVAGE_SCRAP_COLLECTOR, SubSkillType.SALVAGE_SCRAP_COLLECTOR,
String.valueOf(RankUtils.getRank(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)), String.valueOf(pluginRef.getRankTools().getRank(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)),
RankUtils.getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR))); pluginRef.getRankTools().getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR)));
} }
if (canArcaneSalvage) { if (canArcaneSalvage) {
messages.add(getStatMessage(false, true, SubSkillType.SALVAGE_ARCANE_SALVAGE, messages.add(getStatMessage(false, true, SubSkillType.SALVAGE_ARCANE_SALVAGE,
String.valueOf(salvageManager.getArcaneSalvageRank()), String.valueOf(salvageManager.getArcaneSalvageRank()),
String.valueOf(RankUtils.getHighestRank(SubSkillType.SALVAGE_ARCANE_SALVAGE)))); String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.SALVAGE_ARCANE_SALVAGE))));
if (Salvage.arcaneSalvageEnchantLoss) { if (Salvage.arcaneSalvageEnchantLoss) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100))); messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100)));

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -250,6 +249,6 @@ public abstract class SkillCommand implements TabExecutor {
* @return true if the player has permission and has the skill unlocked * @return true if the player has permission and has the skill unlocked
*/ */
protected boolean canUseSubskill(Player player, SubSkillType subSkillType) { protected boolean canUseSubskill(Player player, SubSkillType subSkillType) {
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType); return Permissions.isSubSkillEnabled(player, subSkillType) && pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType);
} }
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,7 +53,7 @@ public class SmeltingCommand extends SkillCommand {
canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY); canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT); canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT);
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING); //canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART); canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
} }
@Override @Override

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -58,7 +57,7 @@ public class SwordsCommand extends SkillCommand {
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE); canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK); canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canSerratedStrike = RankUtils.hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player); canSerratedStrike = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
} }
@Override @Override
@ -69,8 +68,8 @@ public class SwordsCommand extends SkillCommand {
double ruptureDamagePlayer = pluginRef.getConfigManager().getConfigSwords().getRuptureDamagePlayer(); double ruptureDamagePlayer = pluginRef.getConfigManager().getConfigSwords().getRuptureDamagePlayer();
double pveRupture = pluginRef.getConfigManager().getConfigSwords().getRuptureDamageMobs(); double pveRupture = pluginRef.getConfigManager().getConfigSwords().getRuptureDamageMobs();
double pvpDamageRupture = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? ruptureDamagePlayer * 1.5D : ruptureDamagePlayer; double pvpDamageRupture = pluginRef.getRankTools().getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? ruptureDamagePlayer * 1.5D : ruptureDamagePlayer;
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? pveRupture * 1.5D : pveRupture; double ruptureDamageMobs = pluginRef.getRankTools().getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? pveRupture * 1.5D : pveRupture;
if (canCounter) { if (canCounter) {
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance) messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -70,7 +69,7 @@ public class UnarmedCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBerserk = RankUtils.hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player); canBerserk = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_IRON_ARM_STYLE); canIronArm = canUseSubskill(player, SubSkillType.UNARMED_IRON_ARM_STYLE);
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT); canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM); canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -51,8 +50,8 @@ public class WoodcuttingCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player); canTreeFell = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1; canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && pluginRef.getRankTools().getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER); canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER); /*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON); canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);

View File

@ -80,7 +80,7 @@ public class DatabaseManagerFactory {
return customManager.getConstructor().newInstance(); return customManager.getConstructor().newInstance();
} }
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable { public DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return clazz.getConstructor().newInstance(); return clazz.getConstructor().newInstance();
} }
} }

View File

@ -4,20 +4,4 @@ public enum DatabaseType {
FLATFILE, FLATFILE,
SQL, SQL,
CUSTOM; CUSTOM;
public static DatabaseType getDatabaseType(String typeName) {
for (DatabaseType type : values()) {
if (type.name().equalsIgnoreCase(typeName)) {
return type;
}
}
if (typeName.equalsIgnoreCase("file")) {
return FLATFILE;
} else if (typeName.equalsIgnoreCase("mysql")) {
return SQL;
}
return CUSTOM;
}
} }

View File

@ -5,19 +5,22 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import java.util.concurrent.Delayed; import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
//TODO: Hmm, not sure this is working correctly.
public class SkillXpGain implements Delayed { public class SkillXpGain implements Delayed {
private final long expiryTime; private final long expiryTime;
private final double xp; private final double xp;
private final PrimarySkillType type; private final PrimarySkillType type;
private final int interval;
public SkillXpGain(PrimarySkillType type, double xp) { public SkillXpGain(PrimarySkillType type, double xp, int interval) {
this.expiryTime = System.currentTimeMillis() + getDuration(); this.expiryTime = System.currentTimeMillis() + getDuration();
this.xp = xp; this.xp = xp;
this.type = type; this.type = type;
this.interval = interval;
} }
private static long getDuration() { private long getDuration() {
return TimeUnit.MINUTES.toMillis(pluginRef.getConfigManager().getConfigLeveling().getDimishedReturnTimeInterval()); return TimeUnit.MINUTES.toMillis(interval);
} }
public PrimarySkillType getSkill() { public PrimarySkillType getSkill() {

View File

@ -34,7 +34,6 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -232,8 +231,8 @@ public class McMMOPlayer {
updateXPBar(primarySkillType, plugin); updateXPBar(primarySkillType, plugin);
} }
public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType, int skillLevel) { public void processUnlockNotifications(PrimarySkillType primarySkillType, int skillLevel) {
RankUtils.executeSkillUnlockNotifications(plugin, this, primarySkillType, skillLevel); pluginRef.getRankTools().executeSkillUnlockNotifications( this, primarySkillType, skillLevel);
} }
public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin) { public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin) {
@ -895,7 +894,7 @@ public class McMMOPlayer {
//TODO: This is hacky and temporary solution until skills are moved to the new system //TODO: This is hacky and temporary solution until skills are moved to the new system
//Potential problems with this include skills with two super abilities (ie mining) //Potential problems with this include skills with two super abilities (ie mining)
if (!pluginRef.getSkillTools().isSuperAbilityUnlocked(primarySkillType, getPlayer())) { if (!pluginRef.getSkillTools().isSuperAbilityUnlocked(primarySkillType, getPlayer())) {
int diff = RankUtils.getSuperAbilityUnlockRequirement(pluginRef.getSkillTools().getSuperAbility(primarySkillType)) - getSkillLevel(primarySkillType); int diff = pluginRef.getRankTools().getSuperAbilityUnlockRequirement(pluginRef.getSkillTools().getSuperAbility(primarySkillType)) - getSkillLevel(primarySkillType);
//Inform the player they are not yet skilled enough //Inform the player they are not yet skilled enough
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType)); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType));

View File

@ -389,7 +389,7 @@ public class PlayerProfile {
* @param xp Experience amount to add * @param xp Experience amount to add
*/ */
public void registerXpGain(PrimarySkillType primarySkillType, double xp) { public void registerXpGain(PrimarySkillType primarySkillType, double xp) {
gainedSkillsXp.add(new SkillXpGain(primarySkillType, xp)); gainedSkillsXp.add(new SkillXpGain(primarySkillType, xp, pluginRef.getConfigManager().getConfigLeveling().getDimishedReturnTimeInterval()));
rollingSkillsXp.put(primarySkillType, getRegisteredXpGain(primarySkillType) + xp); rollingSkillsXp.put(primarySkillType, getRegisteredXpGain(primarySkillType) + xp);
} }

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills; package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material; import org.bukkit.Material;
@ -197,19 +196,19 @@ public enum SuperAbilityType {
public boolean blockCheck(BlockState blockState) { public boolean blockCheck(BlockState blockState) {
switch (this) { switch (this) {
case BERSERK: case BERSERK:
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW); return (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case GIGA_DRILL_BREAKER: case GIGA_DRILL_BREAKER:
return BlockUtils.affectedByGigaDrillBreaker(blockState); return pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState);
case GREEN_TERRA: case GREEN_TERRA:
return BlockUtils.canMakeMossy(blockState); return pluginRef.getBlockTools().canMakeMossy(blockState);
case SUPER_BREAKER: case SUPER_BREAKER:
return BlockUtils.affectedBySuperBreaker(blockState); return pluginRef.getBlockTools().affectedBySuperBreaker(blockState);
case TREE_FELLER: case TREE_FELLER:
return BlockUtils.isLog(blockState); return pluginRef.getBlockTools().isLog(blockState);
default: default:
return false; return false;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.meta.TrackedArrowMeta;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,7 +53,7 @@ public class ArcheryBehaviour {
} }
public double getDamageBonusPercent(Player player) { public double getDamageBonusPercent(Player player) {
return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * pluginRef.getConfigManager().getConfigArchery().getSkillShotDamageMultiplier()) / 100.0D; return ((pluginRef.getRankTools().getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * pluginRef.getConfigManager().getConfigArchery().getSkillShotDamageMultiplier()) / 100.0D;
} }
public double getSkillShotDamageCap() { public double getSkillShotDamageCap() {

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -40,6 +39,6 @@ public class AxesBehaviour {
* @return The axe mastery bonus damage which will be added to their attack * @return The axe mastery bonus damage which will be added to their attack
*/ */
public double getAxeMasteryBonusDamage(Player player) { public double getAxeMasteryBonusDamage(Player player) {
return RankUtils.getRank(player, SubSkillType.AXES_AXE_MASTERY) * pluginRef.getConfigManager().getConfigAxes().getAxeMasteryMultiplier(); return pluginRef.getRankTools().getRank(player, SubSkillType.AXES_AXE_MASTERY) * pluginRef.getConfigManager().getConfigAxes().getAxeMasteryMultiplier();
} }
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.util.BlockUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -79,7 +78,7 @@ public class HerbalismBehaviour {
dropAmount++; dropAmount++;
if (herbalismManager.checkDoubleDrop(target.getState())) if (herbalismManager.checkDoubleDrop(target.getState()))
BlockUtils.markDropsAsBonus(target.getState(), triple); pluginRef.getBlockTools().markDropsAsBonus(target.getState(), triple);
} }
for (BlockFace blockFace : new BlockFace[]{BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}) for (BlockFace blockFace : new BlockFace[]{BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
@ -139,7 +138,7 @@ public class HerbalismBehaviour {
} }
//Mark the original block for bonus drops //Mark the original block for bonus drops
BlockUtils.markDropsAsBonus(blockState, bonusDropAmount); pluginRef.getBlockTools().markDropsAsBonus(blockState, bonusDropAmount);
return dropAmount; return dropAmount;
} }
@ -167,7 +166,7 @@ public class HerbalismBehaviour {
amount += 1; amount += 1;
if (herbalismManager.checkDoubleDrop(relativeUpBlock.getState())) if (herbalismManager.checkDoubleDrop(relativeUpBlock.getState()))
BlockUtils.markDropsAsBonus(relativeUpBlock.getState(), triple); pluginRef.getBlockTools().markDropsAsBonus(relativeUpBlock.getState(), triple);
} }

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -49,7 +48,7 @@ public class MiningBehaviour {
for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) { for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) {
if (getBlastDamageDecrease(i + 1) > 0) if (getBlastDamageDecrease(i + 1) > 0)
return RankUtils.getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i + 1); return pluginRef.getRankTools().getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i + 1);
} }
return 0; return 0;
@ -59,7 +58,7 @@ public class MiningBehaviour {
for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) { for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) {
if (getBlastRadiusModifier(i + 1) > 0) if (getBlastRadiusModifier(i + 1) > 0)
return RankUtils.getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i + 1); return pluginRef.getRankTools().getRankUnlockLevel(SubSkillType.MINING_BLAST_MINING, i + 1);
} }
return 0; return 0;

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -181,7 +180,7 @@ public class Roll extends AcrobaticsSubSkill {
} }
private boolean canRoll(Player player) { private boolean canRoll(Player player) {
return RankUtils.hasUnlockedSubskill(player, SubSkillType.ACROBATICS_ROLL) && Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL); return pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.ACROBATICS_ROLL) && Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL);
} }
/** /**

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
@ -85,7 +84,7 @@ public class BlockListener implements Listener {
// movedBlock = movedBlock.getRelative(direction, 2); // movedBlock = movedBlock.getRelative(direction, 2);
for (Block b : event.getBlocks()) { for (Block b : event.getBlocks()) {
if (BlockUtils.shouldBeWatched(b.getState())) { if (pluginRef.getBlockTools().shouldBeWatched(b.getState())) {
movedBlock = b.getRelative(direction); movedBlock = b.getRelative(direction);
if (pluginRef.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural()) if (pluginRef.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural())
@ -127,7 +126,7 @@ public class BlockListener implements Listener {
if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getBlock().getWorld().getName())) if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getBlock().getWorld().getName()))
return; return;
if (BlockUtils.shouldBeWatched(event.getBlock().getState())) { if (pluginRef.getBlockTools().shouldBeWatched(event.getBlock().getState())) {
pluginRef.getPlaceStore().setTrue(event.getBlock()); pluginRef.getPlaceStore().setTrue(event.getBlock());
} }
} }
@ -143,7 +142,7 @@ public class BlockListener implements Listener {
if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().isPreventCobblestoneStoneGeneratorXP()) { if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().isPreventCobblestoneStoneGeneratorXP()) {
if (material != Material.OBSIDIAN if (material != Material.OBSIDIAN
&& BlockUtils.shouldBeWatched(material) && pluginRef.getBlockTools().shouldBeWatched(material)
&& pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) { //Hacky fix to prevent trees growing from being marked as unnatural && pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) { //Hacky fix to prevent trees growing from being marked as unnatural
pluginRef.getPlaceStore().setTrue(newBlock); pluginRef.getPlaceStore().setTrue(newBlock);
} }
@ -166,7 +165,7 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) { if (pluginRef.getBlockTools().shouldBeWatched(blockState)) {
// Don't count de-barking wood // Don't count de-barking wood
if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType())) if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType()))
pluginRef.getPlaceStore().setTrue(blockState); pluginRef.getPlaceStore().setTrue(blockState);
@ -212,7 +211,7 @@ public class BlockListener implements Listener {
BlockState blockState = replacedBlockState.getBlock().getState(); BlockState blockState = replacedBlockState.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) { if (pluginRef.getBlockTools().shouldBeWatched(blockState)) {
pluginRef.getPlaceStore().setTrue(blockState); pluginRef.getPlaceStore().setTrue(blockState);
} }
} }
@ -226,7 +225,7 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
if (!BlockUtils.shouldBeWatched(blockState)) { if (!pluginRef.getBlockTools().shouldBeWatched(blockState)) {
return; return;
} }
@ -256,7 +255,7 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
if (!BlockUtils.shouldBeWatched(blockState)) { if (!pluginRef.getBlockTools().shouldBeWatched(blockState)) {
return; return;
} }
@ -280,7 +279,7 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
/* HERBALISM */ /* HERBALISM */
if (BlockUtils.affectedByGreenTerra(blockState)) { if (pluginRef.getBlockTools().affectedByGreenTerra(blockState)) {
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/* Green Terra */ /* Green Terra */
@ -298,13 +297,13 @@ public class BlockListener implements Listener {
} }
/* MINING */ /* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.MINING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) { else if (pluginRef.getBlockTools().affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.MINING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState); miningManager.miningBlockCheck(blockState);
} }
/* WOOD CUTTING */ /* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.WOODCUTTING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) { else if (pluginRef.getBlockTools().isLog(blockState) && ItemUtils.isAxe(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.WOODCUTTING, player) && !pluginRef.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) { if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState); woodcuttingManager.processTreeFeller(blockState);
@ -314,7 +313,7 @@ public class BlockListener implements Listener {
} }
/* EXCAVATION */ /* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.EXCAVATION, player) && !pluginRef.getPlaceStore().isTrue(blockState)) { else if (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.EXCAVATION, player) && !pluginRef.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState); excavationManager.excavationBlockCheck(blockState);
@ -432,18 +431,18 @@ public class BlockListener implements Listener {
* *
* We check permissions here before processing activation. * We check permissions here before processing activation.
*/ */
if (BlockUtils.canActivateAbilities(blockState)) { if (pluginRef.getBlockTools().canActivateAbilities(blockState)) {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (pluginRef.getBlockTools().affectedByGreenTerra(blockState) || pluginRef.getBlockTools().canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && pluginRef.getBlockTools().isLog(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && pluginRef.getBlockTools().affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || pluginRef.getBlockTools().affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
} }
} }
@ -509,7 +508,7 @@ public class BlockListener implements Listener {
* *
* We don't need to check permissions here because they've already been checked for the ability to even activate. * We don't need to check permissions here because they've already been checked for the ability to even activate.
*/ */
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) { if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && pluginRef.getBlockTools().canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) { if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
blockState.update(true); blockState.update(true);
} }
@ -517,12 +516,12 @@ public class BlockListener implements Listener {
if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP); SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { } else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && pluginRef.getBlockTools().affectedByBlockCracker(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) { if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update(); blockState.update();
} }
} }
} else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { } else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && pluginRef.getBlockTools().isLeaves(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP); SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} }

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -158,7 +157,7 @@ public class EntityListener implements Listener {
// When the event is fired for the falling block that changes back to a // When the event is fired for the falling block that changes back to a
// normal block // normal block
// event.getBlock().getType() returns AIR // event.getBlock().getType() returns AIR
if (!BlockUtils.shouldBeWatched(block.getState()) if (!pluginRef.getBlockTools().shouldBeWatched(block.getState())
&& block.getState().getType() != Material.WATER && block.getState().getType() != Material.WATER
&& block.getType() != Material.AIR) { && block.getType() != Material.AIR) {
return; return;

View File

@ -18,7 +18,6 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -606,7 +605,7 @@ public class PlayerListener implements Listener {
/* SALVAGE CHECKS */ /* SALVAGE CHECKS */
else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial() else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial()
&& pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player)
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& pluginRef.getSalvageableManager().isSalvageable(heldItem) && pluginRef.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) { && heldItem.getAmount() <= 1) {
SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager(); SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager();
@ -720,9 +719,9 @@ public class PlayerListener implements Listener {
BlockState blockState = block.getState(); BlockState blockState = block.getState();
/* ACTIVATION & ITEM CHECKS */ /* ACTIVATION & ITEM CHECKS */
if (BlockUtils.canActivateTools(blockState)) { if (pluginRef.getBlockTools().canActivateTools(blockState)) {
if (pluginRef.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { if (pluginRef.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) {
if (BlockUtils.canActivateHerbalism(blockState)) { if (pluginRef.getBlockTools().canActivateHerbalism(blockState)) {
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM); mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.PlayerLevelTools; import com.gmail.nossr50.util.player.PlayerLevelTools;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -36,7 +35,7 @@ public class SelfListener implements Listener {
} }
//Reset the delay timer //Reset the delay timer
RankUtils.resetUnlockDelayTimer(); pluginRef.getRankTools().resetUnlockDelayTimer();
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) if (pluginRef.getScoreboardSettings().getScoreboardsEnabled())
pluginRef.getScoreboardManager().handleLevelUp(player, skill); pluginRef.getScoreboardManager().handleLevelUp(player, skill);

View File

@ -41,7 +41,7 @@ import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceTools; import com.gmail.nossr50.util.random.RandomChanceTools;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.CombatTools; import com.gmail.nossr50.util.skills.CombatTools;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankTools;
import com.gmail.nossr50.util.skills.SkillTools; import com.gmail.nossr50.util.skills.SkillTools;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import net.shatteredlands.shatt.backup.ZipLibrary; import net.shatteredlands.shatt.backup.ZipLibrary;
@ -83,16 +83,18 @@ public class mcMMO extends JavaPlugin {
private EventManager eventManager; private EventManager eventManager;
private UserManager userManager; private UserManager userManager;
private ScoreboardManager scoreboardManager; private ScoreboardManager scoreboardManager;
private RandomChanceTools randomChanceTools;
/* Not-Managers but my naming scheme sucks */ /* Not-Managers but my naming scheme sucks */
private DatabaseManagerFactory databaseManagerFactory; private DatabaseManagerFactory databaseManagerFactory;
private CommandTools commandTools; private CommandTools commandTools;
private SkillTools skillTools; //TODO: Remove once a new skill system is in place private SkillTools skillTools; //TODO: Remove once a new skill system is in place
private BlockTools blockTools;
private CombatTools combatTools; //TODO: Rewrite this garbo private CombatTools combatTools; //TODO: Rewrite this garbo
private TextComponentFactory textComponentFactory; private TextComponentFactory textComponentFactory;
private PlayerLevelTools playerLevelTools; private PlayerLevelTools playerLevelTools;
private MaterialMapStore materialMapStore; private MaterialMapStore materialMapStore;
private RandomChanceTools randomChanceTools;
private RankTools rankTools;
/* Never-Ending tasks */ /* Never-Ending tasks */
private BleedTimerTask bleedTimerTask; private BleedTimerTask bleedTimerTask;
@ -190,8 +192,11 @@ public class mcMMO extends JavaPlugin {
Permissions.generateWorldTeleportPermissions(); Permissions.generateWorldTeleportPermissions();
} }
//Init Rank Tools
rankTools = new RankTools(this);
//Populate Ranked Skill Maps (DO THIS LAST) //Populate Ranked Skill Maps (DO THIS LAST)
RankUtils.populateRanks(); rankTools.populateRanks();
} }
//If anonymous statistics are enabled then use them //If anonymous statistics are enabled then use them
@ -250,6 +255,9 @@ public class mcMMO extends JavaPlugin {
//Init Random Chance Tools //Init Random Chance Tools
randomChanceTools = new RandomChanceTools(this); randomChanceTools = new RandomChanceTools(this);
//Init Block Tools
blockTools = new BlockTools(this);
} }
@Override @Override
@ -761,4 +769,12 @@ public class mcMMO extends JavaPlugin {
public RandomChanceTools getRandomChanceTools() { public RandomChanceTools getRandomChanceTools() {
return randomChanceTools; return randomChanceTools;
} }
public RankTools getRankTools() {
return rankTools;
}
public BlockTools getBlockTools() {
return blockTools;
}
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -25,7 +24,7 @@ public class PistonTrackerTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
// Check to see if futureEmptyBlock is empty - if it isn't; the blocks didn't move // Check to see if futureEmptyBlock is empty - if it isn't; the blocks didn't move
if (!BlockUtils.isPistonPiece(futureEmptyBlock.getState())) { if (!pluginRef.getBlockTools().isPistonPiece(futureEmptyBlock.getState())) {
return; return;
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.runnables; package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -25,7 +24,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
return; return;
} }
if (!BlockUtils.isPistonPiece(movedBlock.getState())) { if (!pluginRef.getBlockTools().isPistonPiece(movedBlock.getState())) {
// The block didn't move // The block didn't move
return; return;
} }

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -62,7 +61,7 @@ public class AcrobaticsManager extends SkillManager {
} }
public boolean canDodge(Entity damager) { public boolean canDodge(Entity damager) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
return false; return false;
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ACROBATICS_DODGE)) { if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ACROBATICS_DODGE)) {

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -32,21 +31,21 @@ public class ArcheryManager extends SkillManager {
} }
public boolean canDaze(LivingEntity target) { public boolean canDaze(LivingEntity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE))
return false; return false;
return target instanceof Player && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE); return target instanceof Player && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE);
} }
public boolean canSkillShot() { public boolean canSkillShot() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT);
} }
public boolean canRetrieveArrows() { public boolean canRetrieveArrows() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL);

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,35 +30,35 @@ public class AxesManager extends SkillManager {
} }
public boolean canUseAxeMastery() { public boolean canUseAxeMastery() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_AXE_MASTERY)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_AXE_MASTERY))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_AXE_MASTERY); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_AXE_MASTERY);
} }
public boolean canCriticalHit(LivingEntity target) { public boolean canCriticalHit(LivingEntity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES))
return false; return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES); return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES);
} }
public boolean canImpact(LivingEntity target) { public boolean canImpact(LivingEntity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT))
return false; return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT) && axesBehaviour.hasArmor(target); return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT) && axesBehaviour.hasArmor(target);
} }
public boolean canGreaterImpact(LivingEntity target) { public boolean canGreaterImpact(LivingEntity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_GREATER_IMPACT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_GREATER_IMPACT))
return false; return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_GREATER_IMPACT) && !axesBehaviour.hasArmor(target); return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_GREATER_IMPACT) && !axesBehaviour.hasArmor(target);
} }
public boolean canUseSkullSplitter(LivingEntity target) { public boolean canUseSkullSplitter(LivingEntity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_SKULL_SPLITTER)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_SKULL_SPLITTER))
return false; return false;
return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
@ -130,7 +129,7 @@ public class AxesManager extends SkillManager {
} }
public double getImpactDurabilityDamage() { public double getImpactDurabilityDamage() {
return pluginRef.getConfigManager().getConfigAxes().getConfigAxesImpact().getImpactDurabilityDamageModifier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT); return pluginRef.getConfigManager().getConfigAxes().getConfigAxesImpact().getImpactDurabilityDamageModifier() * pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT);
} }
/** /**

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -72,7 +71,7 @@ public class ExcavationManager extends SkillManager {
} }
public int getArchaeologyRank() { public int getArchaeologyRank() {
return RankUtils.getRank(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY); return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY);
} }
public void printExcavationDebug(Player player, BlockState blockState) public void printExcavationDebug(Player player, BlockState blockState)

View File

@ -17,12 +17,10 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -65,11 +63,11 @@ public class FishingManager extends SkillManager {
} }
public boolean canShake(Entity target) { public boolean canShake(Entity target) {
return target instanceof LivingEntity && RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_SHAKE) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_SHAKE); return target instanceof LivingEntity && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_SHAKE) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_SHAKE);
} }
public boolean canMasterAngler() { public boolean canMasterAngler() {
return getSkillLevel() >= RankUtils.getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER); return getSkillLevel() >= pluginRef.getRankTools().getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER);
} }
public void setFishingRodCastTimestamp() { public void setFishingRodCastTimestamp() {
@ -164,11 +162,11 @@ public class FishingManager extends SkillManager {
} }
public void setFishingTarget() { public void setFishingTarget() {
getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); getPlayer().getTargetBlock(pluginRef.getBlockTools().getTransparentBlocks(), 100);
} }
public boolean canIceFish(Block block) { public boolean canIceFish(Block block) {
if (getSkillLevel() < RankUtils.getUnlockLevel(SubSkillType.FISHING_ICE_FISHING)) { if (getSkillLevel() < pluginRef.getRankTools().getUnlockLevel(SubSkillType.FISHING_ICE_FISHING)) {
return false; return false;
} }
@ -196,7 +194,7 @@ public class FishingManager extends SkillManager {
* @return the loot tier * @return the loot tier
*/ */
public int getLootTier() { public int getLootTier() {
return RankUtils.getRank(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER); return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER);
} }
public double getShakeChance() { public double getShakeChance() {
@ -204,7 +202,7 @@ public class FishingManager extends SkillManager {
} }
public int getInnerPeaceMultiplier() { public int getInnerPeaceMultiplier() {
return pluginRef.getConfigManager().getConfigFishing().getVanillaXPMultInnerPeace(RankUtils.getRank(getPlayer(), SubSkillType.FISHING_INNER_PEACE)); return pluginRef.getConfigManager().getConfigFishing().getVanillaXPMultInnerPeace(pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.FISHING_INNER_PEACE));
} }
/** /**
@ -263,8 +261,8 @@ public class FishingManager extends SkillManager {
} }
public boolean isMagicHunterEnabled() { public boolean isMagicHunterEnabled() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_MAGIC_HUNTER) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_MAGIC_HUNTER)
&& RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER);
} }

View File

@ -14,9 +14,11 @@ import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask; import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -43,35 +45,35 @@ public class HerbalismManager extends SkillManager {
} }
public boolean canGreenThumbBlock(BlockState blockState) { public boolean canGreenThumbBlock(BlockState blockState) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB))
return false; return false;
Player player = getPlayer(); Player player = getPlayer();
ItemStack item = player.getInventory().getItemInMainHand(); ItemStack item = player.getInventory().getItemInMainHand();
return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && pluginRef.getBlockTools().canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
} }
public boolean canUseShroomThumb(BlockState blockState) { public boolean canUseShroomThumb(BlockState blockState) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB))
return false; return false;
Player player = getPlayer(); Player player = getPlayer();
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
Material itemType = inventory.getItemInMainHand().getType(); Material itemType = inventory.getItemInMainHand().getType();
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB); return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && pluginRef.getBlockTools().canMakeShroomy(blockState) && Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
} }
public boolean canUseHylianLuck() { public boolean canUseHylianLuck() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK);
} }
public boolean canGreenTerraBlock(BlockState blockState) { public boolean canGreenTerraBlock(BlockState blockState) {
return mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState); return mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && pluginRef.getBlockTools().canMakeMossy(blockState);
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {
@ -163,7 +165,7 @@ public class HerbalismManager extends SkillManager {
} else { } else {
/* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */ /* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */
if (checkDoubleDrop(blockState)) if (checkDoubleDrop(blockState))
BlockUtils.markDropsAsBonus(blockState, greenTerra); pluginRef.getBlockTools().markDropsAsBonus(blockState, greenTerra);
} }
if (Permissions.greenThumbPlant(player, material)) { if (Permissions.greenThumbPlant(player, material)) {
@ -185,7 +187,7 @@ public class HerbalismManager extends SkillManager {
* @return true if double drop succeeds * @return true if double drop succeeds
*/ */
public boolean checkDoubleDrop(BlockState blockState) { public boolean checkDoubleDrop(BlockState blockState) {
return BlockUtils.checkDoubleDrops(getPlayer(), blockState, SubSkillType.HERBALISM_DOUBLE_DROPS); return pluginRef.getBlockTools().checkDoubleDrops(getPlayer(), blockState, SubSkillType.HERBALISM_DOUBLE_DROPS);
} }
/** /**
@ -281,7 +283,7 @@ public class HerbalismManager extends SkillManager {
* @param greenTerra boolean to determine if greenTerra is active or not * @param greenTerra boolean to determine if greenTerra is active or not
*/ */
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) { private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
if (!BlockUtils.isFullyGrown(blockState)) if (!pluginRef.getBlockTools().isFullyGrown(blockState))
return; return;
Player player = getPlayer(); Player player = getPlayer();
@ -387,6 +389,6 @@ public class HerbalismManager extends SkillManager {
} }
private int getGreenThumbStage() { private int getGreenThumbStage() {
return RankUtils.getRank(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB); return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB);
} }
} }

View File

@ -11,10 +11,8 @@ import com.gmail.nossr50.datatypes.skills.behaviours.MiningBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -50,7 +48,7 @@ public class MiningManager extends SkillManager {
} }
public boolean canUseDemolitionsExpertise() { public boolean canUseDemolitionsExpertise() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DEMOLITIONS_EXPERTISE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DEMOLITIONS_EXPERTISE))
return false; return false;
return getSkillLevel() >= miningBehaviour.getDemolitionExpertUnlockLevel() && Permissions.demolitionsExpertise(getPlayer()); return getSkillLevel() >= miningBehaviour.getDemolitionExpertUnlockLevel() && Permissions.demolitionsExpertise(getPlayer());
@ -66,18 +64,18 @@ public class MiningManager extends SkillManager {
public boolean canUseBlastMining() { public boolean canUseBlastMining() {
//Not checking permissions? //Not checking permissions?
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BLAST_MINING); return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BLAST_MINING);
} }
public boolean canUseBiggerBombs() { public boolean canUseBiggerBombs() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS))
return false; return false;
return getSkillLevel() >= miningBehaviour.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer()); return getSkillLevel() >= miningBehaviour.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer());
} }
public boolean canDoubleDrop() { public boolean canDoubleDrop() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS); return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS);
} }
/** /**
@ -104,7 +102,7 @@ public class MiningManager extends SkillManager {
//TODO: Make this readable //TODO: Make this readable
if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS)) { if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS)) {
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getSuperAbility())); pluginRef.getBlockTools().markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getSuperAbility()));
} }
} }
@ -113,7 +111,7 @@ public class MiningManager extends SkillManager {
*/ */
public void remoteDetonation() { public void remoteDetonation() {
Player player = getPlayer(); Player player = getPlayer();
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), miningBehaviour.MAXIMUM_REMOTE_DETONATION_DISTANCE); Block targetBlock = player.getTargetBlock(pluginRef.getBlockTools().getTransparentBlocks(), miningBehaviour.MAXIMUM_REMOTE_DETONATION_DISTANCE);
//Blast mining cooldown check needs to be first so the player can be messaged //Blast mining cooldown check needs to be first so the player can be messaged
if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !pluginRef.getEventManager().simulateBlockBreak(targetBlock, player, true)) { if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !pluginRef.getEventManager().simulateBlockBreak(targetBlock, player, true)) {
@ -155,7 +153,7 @@ public class MiningManager extends SkillManager {
for (Block block : blockList) { for (Block block : blockList) {
BlockState blockState = block.getState(); BlockState blockState = block.getState();
if (BlockUtils.isOre(blockState)) { if (pluginRef.getBlockTools().isOre(blockState)) {
ores.add(blockState); ores.add(blockState);
} else { } else {
debris.add(blockState); debris.add(blockState);
@ -209,7 +207,7 @@ public class MiningManager extends SkillManager {
* @return the Blast Mining tier * @return the Blast Mining tier
*/ */
public int getBlastMiningTier() { public int getBlastMiningTier() {
return RankUtils.getRank(getPlayer(), SubSkillType.MINING_BLAST_MINING); return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.MINING_BLAST_MINING);
} }
/** /**

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -203,7 +202,7 @@ public class RepairManager extends SkillManager {
* @return the current Arcane Forging rank * @return the current Arcane Forging rank
*/ */
public int getArcaneForgingRank() { public int getArcaneForgingRank() {
return RankUtils.getRank(getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING); return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING);
} }
/** /**
@ -235,7 +234,7 @@ public class RepairManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
if (Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_REPAIR_MASTERY) if (Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_REPAIR_MASTERY)
&& RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_REPAIR_MASTERY)) { && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_REPAIR_MASTERY)) {
double maxBonusCalc = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY) / 100.0D; double maxBonusCalc = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY) / 100.0D;
double skillLevelBonusCalc = (maxBonusCalc / pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY)) * (getSkillLevel() / 100.0D); double skillLevelBonusCalc = (maxBonusCalc / pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY)) * (getSkillLevel() / 100.0D);
@ -261,7 +260,7 @@ public class RepairManager extends SkillManager {
* @return true if bonus granted, false otherwise * @return true if bonus granted, false otherwise
*/ */
private boolean checkPlayerProcRepair() { private boolean checkPlayerProcRepair() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_SUPER_REPAIR)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_SUPER_REPAIR))
return false; return false;
if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.REPAIR_SUPER_REPAIR, getPlayer())) { if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.REPAIR_SUPER_REPAIR, getPlayer())) {

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location; import org.bukkit.Location;
@ -81,8 +80,8 @@ public class SalvageManager extends SkillManager {
int minimumSalvageableLevel = salvageable.getMinimumLevel();*/ int minimumSalvageableLevel = salvageable.getMinimumLevel();*/
// Level check // Level check
if (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) { if (!pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Salvage.Skills.Adept.Level", String.valueOf(RankUtils.getUnlockLevel(SubSkillType.SALVAGE_ARCANE_SALVAGE)), StringUtils.getPrettyItemString(item.getType())); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Salvage.Skills.Adept.Level", String.valueOf(pluginRef.getRankTools().getUnlockLevel(SubSkillType.SALVAGE_ARCANE_SALVAGE)), StringUtils.getPrettyItemString(item.getType()));
return; return;
} }
@ -120,7 +119,7 @@ public class SalvageManager extends SkillManager {
} }
} }
if(lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) { if(lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && pluginRef.getRankTools().isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
} else if(salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) { } else if(salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) {
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
@ -167,7 +166,7 @@ public class SalvageManager extends SkillManager {
}*/ }*/
public int getSalvageLimit() { public int getSalvageLimit() {
return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_SCRAP_COLLECTOR)); return (pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SALVAGE_SCRAP_COLLECTOR));
} }
/** /**
@ -176,7 +175,7 @@ public class SalvageManager extends SkillManager {
* @return the current Arcane Salvage rank * @return the current Arcane Salvage rank
*/ */
public int getArcaneSalvageRank() { public int getArcaneSalvageRank() {
return RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE); return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE);
} }
/*public double getExtractFullEnchantChance() { /*public double getExtractFullEnchantChance() {
@ -217,7 +216,7 @@ public class SalvageManager extends SkillManager {
private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) { private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) {
Player player = getPlayer(); Player player = getPlayer();
if (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE) || !Permissions.arcaneSalvage(player)) { if (!pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE) || !Permissions.arcaneSalvage(player)) {
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed"); pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed");
return null; return null;
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -33,7 +32,7 @@ public class SmeltingManager extends SkillManager {
} }
public int getFuelEfficiencyMultiplier() { public int getFuelEfficiencyMultiplier() {
switch (RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY)) { switch (pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
case 1: case 1:
return 2; return 2;
case 2: case 2:
@ -72,6 +71,6 @@ public class SmeltingManager extends SkillManager {
* @return the vanilla XP multiplier * @return the vanilla XP multiplier
*/ */
public int getVanillaXpMultiplier() { public int getVanillaXpMultiplier() {
return Math.max(1, RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_UNDERSTANDING_THE_ART)); return Math.max(1, pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SMELTING_UNDERSTANDING_THE_ART));
} }
} }

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -30,22 +29,22 @@ public class SwordsManager extends SkillManager {
} }
public boolean canUseStab() { public boolean canUseStab() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_STAB) && RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_STAB); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_STAB) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_STAB);
} }
public boolean canUseRupture() { public boolean canUseRupture() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_RUPTURE) && RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_RUPTURE); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_RUPTURE) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_RUPTURE);
} }
public boolean canUseCounterAttack(Entity target) { public boolean canUseCounterAttack(Entity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK))
return false; return false;
return target instanceof LivingEntity && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK); return target instanceof LivingEntity && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK);
} }
public boolean canUseSerratedStrike() { public boolean canUseSerratedStrike() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_SERRATED_STRIKES)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_SERRATED_STRIKES))
return false; return false;
return mcMMOPlayer.getAbilityMode(SuperAbilityType.SERRATED_STRIKES); return mcMMOPlayer.getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
@ -72,7 +71,7 @@ public class SwordsManager extends SkillManager {
} }
} }
pluginRef.getBleedTimerTask().add(target, getPlayer(), getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand())); pluginRef.getBleedTimerTask().add(target, getPlayer(), getRuptureBleedTicks(), pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand()));
if (mcMMOPlayer.useChatNotifications()) { if (mcMMOPlayer.useChatNotifications()) {
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding"); pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
@ -81,7 +80,7 @@ public class SwordsManager extends SkillManager {
} }
public double getStabDamage() { public double getStabDamage() {
int rank = RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_STAB); int rank = pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SWORDS_STAB);
if (rank > 0) { if (rank > 0) {
double stabDamage = 1.0D + (rank * 1.5); double stabDamage = 1.0D + (rank * 1.5);
@ -103,7 +102,7 @@ public class SwordsManager extends SkillManager {
} }
public int getRuptureBleedTicks() { public int getRuptureBleedTicks() {
int bleedTicks = pluginRef.getConfigManager().getConfigSwords().getRuptureBaseTicks() * RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE); int bleedTicks = pluginRef.getConfigManager().getConfigSwords().getRuptureBaseTicks() * pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE);
/*if (bleedTicks > AdvancedConfig.getInstance().getRuptureMaxTicks()) /*if (bleedTicks > AdvancedConfig.getInstance().getRuptureMaxTicks())
bleedTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();*/ bleedTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();*/

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.skills.taming; package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -16,7 +14,6 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -28,13 +25,13 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class TamingManager extends SkillManager { public class TamingManager extends SkillManager {
private static HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<>(); private HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<>();
public TamingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { public TamingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
super(pluginRef, mcMMOPlayer, PrimarySkillType.TAMING); super(pluginRef, mcMMOPlayer, PrimarySkillType.TAMING);
} }
protected static void addToTracker(LivingEntity livingEntity) { protected void addToTracker(LivingEntity livingEntity) {
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity); TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity);
if (!summonedEntities.containsKey(livingEntity.getType())) { if (!summonedEntities.containsKey(livingEntity.getType())) {
@ -44,53 +41,53 @@ public class TamingManager extends SkillManager {
summonedEntities.get(livingEntity.getType()).add(trackedEntity); summonedEntities.get(livingEntity.getType()).add(trackedEntity);
} }
protected static List<TrackedTamingEntity> getTrackedEntities(EntityType entityType) { protected List<TrackedTamingEntity> getTrackedEntities(EntityType entityType) {
return summonedEntities.get(entityType); return summonedEntities.get(entityType);
} }
protected static void removeFromTracker(TrackedTamingEntity trackedEntity) { protected void removeFromTracker(TrackedTamingEntity trackedEntity) {
summonedEntities.get(trackedEntity.getLivingEntity().getType()).remove(trackedEntity); summonedEntities.get(trackedEntity.getLivingEntity().getType()).remove(trackedEntity);
} }
public boolean canUseThickFur() { public boolean canUseThickFur() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_THICK_FUR); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_THICK_FUR);
} }
public boolean canUseEnvironmentallyAware() { public boolean canUseEnvironmentallyAware() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
} }
public boolean canUseShockProof() { public boolean canUseShockProof() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF);
} }
public boolean canUseHolyHound() { public boolean canUseHolyHound() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_HOLY_HOUND); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_HOLY_HOUND);
} }
public boolean canUseFastFoodService() { public boolean canUseFastFoodService() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE);
} }
public boolean canUseSharpenedClaws() { public boolean canUseSharpenedClaws() {
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS); && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS);
} }
public boolean canUseGore() { public boolean canUseGore() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE);
} }
public boolean canUseBeastLore() { public boolean canUseBeastLore() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE);
@ -112,7 +109,7 @@ public class TamingManager extends SkillManager {
* @param damage The damage being absorbed by the wolf * @param damage The damage being absorbed by the wolf
*/ */
public void fastFoodService(Wolf wolf, double damage) { public void fastFoodService(Wolf wolf, double damage) {
//static chance (3rd param) //chance (3rd param)
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.TAMING_FAST_FOOD_SERVICE, getPlayer())) { if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.TAMING_FAST_FOOD_SERVICE, getPlayer())) {
return; return;
} }
@ -157,7 +154,7 @@ public class TamingManager extends SkillManager {
* Summon an ocelot to your side. * Summon an ocelot to your side.
*/ */
public void summonOcelot() { public void summonOcelot() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) { if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) {
@ -171,7 +168,7 @@ public class TamingManager extends SkillManager {
* Summon a wolf to your side. * Summon a wolf to your side.
*/ */
public void summonWolf() { public void summonWolf() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) { if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) {
@ -185,7 +182,7 @@ public class TamingManager extends SkillManager {
* Summon a horse to your side. * Summon a horse to your side.
*/ */
public void summonHorse() { public void summonHorse() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) { if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) {
@ -226,7 +223,7 @@ public class TamingManager extends SkillManager {
} }
public void pummel(LivingEntity target, Wolf wolf) { public void pummel(LivingEntity target, Wolf wolf) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
return; return;
if (!pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL))) if (!pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -32,7 +31,7 @@ public class UnarmedManager extends SkillManager {
} }
public boolean canUseIronArm() { public boolean canUseIronArm() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
@ -43,14 +42,14 @@ public class UnarmedManager extends SkillManager {
} }
public boolean canDisarm(LivingEntity target) { public boolean canDisarm(LivingEntity target) {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM))
return false; return false;
return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_DISARM); return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_DISARM);
} }
public boolean canDeflect() { public boolean canDeflect() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT))
return false; return false;
Player player = getPlayer(); Player player = getPlayer();
@ -59,7 +58,7 @@ public class UnarmedManager extends SkillManager {
} }
public boolean canUseBlockCracker() { public boolean canUseBlockCracker() {
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER); return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER);
@ -150,7 +149,7 @@ public class UnarmedManager extends SkillManager {
} }
public double getIronArmDamage() { public double getIronArmDamage() {
int rank = RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE); int rank = pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
if (rank == 1) { if (rank == 1) {
return 4; return 4;

View File

@ -9,11 +9,9 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.behaviours.WoodcuttingBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.WoodcuttingBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -40,7 +38,7 @@ public class WoodcuttingManager extends SkillManager {
public boolean canUseLeafBlower(ItemStack heldItem) { public boolean canUseLeafBlower(ItemStack heldItem) {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER) return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER)
&& RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER)
&& ItemUtils.isAxe(heldItem); && ItemUtils.isAxe(heldItem);
} }
@ -51,7 +49,7 @@ public class WoodcuttingManager extends SkillManager {
public boolean canGetDoubleDrops() { public boolean canGetDoubleDrops() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER) return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& RankUtils.hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER) && pluginRef.getRankTools().hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer()); && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer());
} }
@ -198,7 +196,7 @@ public class WoodcuttingManager extends SkillManager {
Material type = inHand.getType(); Material type = inHand.getType();
for (BlockState blockState : treeFellerBlocks) { for (BlockState blockState : treeFellerBlocks) {
if (BlockUtils.isLog(blockState)) { if (pluginRef.getBlockTools().isLog(blockState)) {
durabilityLoss += pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage(); durabilityLoss += pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage();
} }
} }
@ -229,11 +227,11 @@ public class WoodcuttingManager extends SkillManager {
treeFellerReachedThreshold = true; treeFellerReachedThreshold = true;
} }
if (BlockUtils.isLog(blockState)) { if (pluginRef.getBlockTools().isLog(blockState)) {
treeFellerBlocks.add(blockState); treeFellerBlocks.add(blockState);
futureCenterBlocks.add(blockState); futureCenterBlocks.add(blockState);
return true; return true;
} else if (BlockUtils.isLeaves(blockState)) { } else if (pluginRef.getBlockTools().isLeaves(blockState)) {
treeFellerBlocks.add(blockState); treeFellerBlocks.add(blockState);
return false; return false;
} }
@ -269,14 +267,14 @@ public class WoodcuttingManager extends SkillManager {
xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount); xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount);
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
} else { } else {
if (BlockUtils.isLog(blockState)) { if (pluginRef.getBlockTools().isLog(blockState)) {
if (canGetDoubleDrops()) { if (canGetDoubleDrops()) {
woodcuttingBehaviour.checkForDoubleDrop(blockState); woodcuttingBehaviour.checkForDoubleDrop(blockState);
} }
xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount); xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount);
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
} }
if (BlockUtils.isLeaves(blockState)) { if (pluginRef.getBlockTools().isLeaves(blockState)) {
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
} }
} }

View File

@ -3,8 +3,7 @@ package com.gmail.nossr50.util;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.meta.BonusDropMeta; import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -15,9 +14,12 @@ import org.bukkit.entity.Player;
import java.util.HashSet; import java.util.HashSet;
public final class BlockUtils { public final class BlockTools {
private BlockUtils() { private final mcMMO pluginRef;
public BlockTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
/** /**
@ -26,7 +28,7 @@ public final class BlockUtils {
* @param blockState target blockstate * @param blockState target blockstate
* @param triple marks the block to give triple drops * @param triple marks the block to give triple drops
*/ */
public static void markDropsAsBonus(BlockState blockState, boolean triple) { public void markDropsAsBonus(BlockState blockState, boolean triple) {
if (triple) if (triple)
blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(2, pluginRef)); blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(2, pluginRef));
else else
@ -39,7 +41,7 @@ public final class BlockUtils {
* @param blockState target blockstate * @param blockState target blockstate
* @param amount amount of extra items to drop * @param amount amount of extra items to drop
*/ */
public static void markDropsAsBonus(BlockState blockState, int amount) { public void markDropsAsBonus(BlockState blockState, int amount) {
blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, pluginRef)); blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, pluginRef));
} }
@ -49,9 +51,9 @@ public final class BlockUtils {
* @param blockState the blockstate * @param blockState the blockstate
* @return true if the player succeeded in the check * @return true if the player succeeded in the check
*/ */
public static boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) { 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()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
return pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true)); return pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkill(pluginRef, player, subSkillType, true));
} }
return false; return false;
@ -63,7 +65,7 @@ public final class BlockUtils {
* @param block The {@link Block} of the block to check * @param block The {@link Block} of the block to check
* @return true if the block awards XP, false otherwise * @return true if the block awards XP, false otherwise
*/ */
public static boolean shouldBeWatched(Block block) { public boolean shouldBeWatched(Block block) {
return affectedByGigaDrillBreaker(block.getType()) || affectedByGreenTerra(block.getType()) || affectedBySuperBreaker(block.getType()) || isLog(block.getType()); return affectedByGigaDrillBreaker(block.getType()) || affectedByGreenTerra(block.getType()) || affectedBySuperBreaker(block.getType()) || isLog(block.getType());
} }
@ -73,7 +75,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block awards XP, false otherwise * @return true if the block awards XP, false otherwise
*/ */
public static boolean shouldBeWatched(BlockState blockState) { public boolean shouldBeWatched(BlockState blockState) {
return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || isLog(blockState); return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || isLog(blockState);
} }
@ -83,7 +85,7 @@ public final class BlockUtils {
* @param material The {@link Material} of the block to check * @param material The {@link Material} of the block to check
* @return true if the block awards XP, false otherwise * @return true if the block awards XP, false otherwise
*/ */
public static boolean shouldBeWatched(Material material) { public boolean shouldBeWatched(Material material) {
return affectedByGigaDrillBreaker(material) || affectedByGreenTerra(material) || affectedBySuperBreaker(material) || isLog(material); return affectedByGigaDrillBreaker(material) || affectedByGreenTerra(material) || affectedBySuperBreaker(material) || isLog(material);
} }
@ -94,7 +96,7 @@ public final class BlockUtils {
* @return true if the block should allow ability activation, false * @return true if the block should allow ability activation, false
* otherwise * otherwise
*/ */
public static boolean canActivateAbilities(BlockState blockState) { public boolean canActivateAbilities(BlockState blockState) {
return !pluginRef.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType()); return !pluginRef.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType());
} }
@ -106,7 +108,7 @@ public final class BlockUtils {
* @return true if the block should allow ability activation, false * @return true if the block should allow ability activation, false
* otherwise * otherwise
*/ */
public static boolean canActivateTools(BlockState blockState) { public boolean canActivateTools(BlockState blockState) {
return !pluginRef.getMaterialMapStore().isToolActivationBlackListed(blockState.getType()); return !pluginRef.getMaterialMapStore().isToolActivationBlackListed(blockState.getType());
} }
@ -116,7 +118,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block is an ore, false otherwise * @return true if the block is an ore, false otherwise
*/ */
public static boolean isOre(BlockState blockState) { public boolean isOre(BlockState blockState) {
return MaterialUtils.isOre(blockState.getType()); return MaterialUtils.isOre(blockState.getType());
} }
@ -126,7 +128,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block can be made mossy, false otherwise * @return true if the block can be made mossy, false otherwise
*/ */
public static boolean canMakeMossy(BlockState blockState) { public boolean canMakeMossy(BlockState blockState) {
return pluginRef.getMaterialMapStore().isMossyWhiteListed(blockState.getType()); return pluginRef.getMaterialMapStore().isMossyWhiteListed(blockState.getType());
} }
@ -136,7 +138,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Green Terra, false otherwise * @return true if the block should affected by Green Terra, false otherwise
*/ */
public static boolean affectedByGreenTerra(BlockState blockState) { public boolean affectedByGreenTerra(BlockState blockState) {
return pluginRef.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(blockState.getType()); return pluginRef.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(blockState.getType());
} }
@ -146,7 +148,7 @@ public final class BlockUtils {
* @param material The {@link Material} of the block to check * @param material The {@link Material} of the block to check
* @return true if the block should affected by Green Terra, false otherwise * @return true if the block should affected by Green Terra, false otherwise
*/ */
public static boolean affectedByGreenTerra(Material material) { public boolean affectedByGreenTerra(Material material) {
return pluginRef.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(material); return pluginRef.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(material);
} }
@ -157,7 +159,7 @@ public final class BlockUtils {
* @return true if the block should affected by Super Breaker, false * @return true if the block should affected by Super Breaker, false
* otherwise * otherwise
*/ */
public static Boolean affectedBySuperBreaker(BlockState blockState) { public Boolean affectedBySuperBreaker(BlockState blockState) {
if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(blockState.getType())) if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(blockState.getType()))
return true; return true;
@ -171,7 +173,7 @@ public final class BlockUtils {
* @return true if the block should affected by Super Breaker, false * @return true if the block should affected by Super Breaker, false
* otherwise * otherwise
*/ */
public static Boolean affectedBySuperBreaker(Material material) { public Boolean affectedBySuperBreaker(Material material) {
if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material))
return true; return true;
@ -184,7 +186,7 @@ public final class BlockUtils {
* @param material target blocks material * @param material target blocks material
* @return * @return
*/ */
public static boolean isMineable(Material material) { public boolean isMineable(Material material) {
switch (material) { switch (material) {
case COAL_ORE: case COAL_ORE:
case DIAMOND_ORE: case DIAMOND_ORE:
@ -211,7 +213,7 @@ public final class BlockUtils {
} }
} }
public static boolean isMineable(BlockState blockState) { public boolean isMineable(BlockState blockState) {
return isMineable(blockState.getType()); return isMineable(blockState.getType());
} }
@ -222,7 +224,7 @@ public final class BlockUtils {
* @return true if the block should affected by Giga Drill Breaker, false * @return true if the block should affected by Giga Drill Breaker, false
* otherwise * otherwise
*/ */
public static boolean affectedByGigaDrillBreaker(Material material) { public boolean affectedByGigaDrillBreaker(Material material) {
if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(material)) if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(material))
return true; return true;
@ -236,7 +238,7 @@ public final class BlockUtils {
* @return true if the block should affected by Giga Drill Breaker, false * @return true if the block should affected by Giga Drill Breaker, false
* otherwise * otherwise
*/ */
public static boolean affectedByGigaDrillBreaker(BlockState blockState) { public boolean affectedByGigaDrillBreaker(BlockState blockState) {
if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(blockState.getType())) if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(blockState.getType()))
return true; return true;
@ -250,7 +252,7 @@ public final class BlockUtils {
* @return true if a shovel is typically used for digging this block * @return true if a shovel is typically used for digging this block
*/ */
@Deprecated @Deprecated
public static boolean isDiggable(BlockState blockState) { public boolean isDiggable(BlockState blockState) {
return isDiggable(blockState.getType()); return isDiggable(blockState.getType());
} }
@ -260,7 +262,7 @@ public final class BlockUtils {
* @param material target blocks material * @param material target blocks material
* @return true if a shovel is typically used for digging this block * @return true if a shovel is typically used for digging this block
*/ */
public static boolean isDiggable(Material material) { public boolean isDiggable(Material material) {
switch (material) { switch (material) {
case CLAY: case CLAY:
case FARMLAND: case FARMLAND:
@ -288,7 +290,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block is a log, false otherwise * @return true if the block is a log, false otherwise
*/ */
public static boolean isLog(BlockState blockState) { public boolean isLog(BlockState blockState) {
if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(blockState.getType())) if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(blockState.getType()))
return true; return true;
@ -302,7 +304,7 @@ public final class BlockUtils {
* @param material The {@link Material} of the block to check * @param material The {@link Material} of the block to check
* @return true if the block is a log, false otherwise * @return true if the block is a log, false otherwise
*/ */
public static boolean isLog(Material material) { public boolean isLog(Material material) {
if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(material)) if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(material))
return true; return true;
@ -316,7 +318,7 @@ public final class BlockUtils {
* @param material target material * @param material target material
* @return true if the block is gathered via axe * @return true if the block is gathered via axe
*/ */
public static boolean isLoggingRelated(Material material) { public boolean isLoggingRelated(Material material) {
switch (material) { switch (material) {
case ACACIA_LOG: case ACACIA_LOG:
case BIRCH_LOG: case BIRCH_LOG:
@ -354,7 +356,7 @@ public final class BlockUtils {
* @param blockState target blockstate * @param blockState target blockstate
* @return true if the block is gathered via axe * @return true if the block is gathered via axe
*/ */
public static boolean isLoggingRelated(BlockState blockState) { public boolean isLoggingRelated(BlockState blockState) {
return isLoggingRelated(blockState.getType()); return isLoggingRelated(blockState.getType());
} }
@ -364,7 +366,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block is a leaf, false otherwise * @return true if the block is a leaf, false otherwise
*/ */
public static boolean isLeaves(BlockState blockState) { public boolean isLeaves(BlockState blockState) {
return pluginRef.getMaterialMapStore().isLeavesWhiteListed(blockState.getType()); return pluginRef.getMaterialMapStore().isLeavesWhiteListed(blockState.getType());
} }
@ -374,7 +376,7 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Flux Mining, false otherwise * @return true if the block should affected by Flux Mining, false otherwise
*/ */
public static boolean affectedByFluxMining(BlockState blockState) { public boolean affectedByFluxMining(BlockState blockState) {
switch (blockState.getType()) { switch (blockState.getType()) {
case IRON_ORE: case IRON_ORE:
case GOLD_ORE: case GOLD_ORE:
@ -393,7 +395,7 @@ public final class BlockUtils {
* @return true if the block can be activate Herbalism abilities, false * @return true if the block can be activate Herbalism abilities, false
* otherwise * otherwise
*/ */
public static boolean canActivateHerbalism(BlockState blockState) { public boolean canActivateHerbalism(BlockState blockState) {
return pluginRef.getMaterialMapStore().isHerbalismAbilityWhiteListed(blockState.getType()); return pluginRef.getMaterialMapStore().isHerbalismAbilityWhiteListed(blockState.getType());
} }
@ -404,7 +406,7 @@ public final class BlockUtils {
* @return true if the block should affected by Block Cracker, false * @return true if the block should affected by Block Cracker, false
* otherwise * otherwise
*/ */
public static boolean affectedByBlockCracker(BlockState blockState) { public boolean affectedByBlockCracker(BlockState blockState) {
return pluginRef.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType()); return pluginRef.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType());
} }
@ -414,23 +416,23 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block can be made into Mycelium, false otherwise * @return true if the block can be made into Mycelium, false otherwise
*/ */
public static boolean canMakeShroomy(BlockState blockState) { public boolean canMakeShroomy(BlockState blockState) {
return pluginRef.getMaterialMapStore().isShroomyWhiteListed(blockState.getType()); return pluginRef.getMaterialMapStore().isShroomyWhiteListed(blockState.getType());
} }
/** // /**
* Determine if a given block is an mcMMO anvil // * Determine if a given block is an mcMMO anvil
* // *
* @param blockState The {@link BlockState} of the block to check // * @param blockState The {@link BlockState} of the block to check
* @return true if the block is an mcMMO anvil, false otherwise // * @return true if the block is an mcMMO anvil, false otherwise
*/ // */
public static boolean isMcMMOAnvil(BlockState blockState) { // public boolean isMcMMOAnvil(BlockState blockState) {
Material type = blockState.getType(); // Material type = blockState.getType();
//
// return type == Repair.getInstance().getAnvilMaterial() || type == Salvage.anvilMaterial;
// }
return type == Repair.getInstance().getAnvilMaterial() || type == Salvage.anvilMaterial; public boolean isPistonPiece(BlockState blockState) {
}
public static boolean isPistonPiece(BlockState blockState) {
Material type = blockState.getType(); Material type = blockState.getType();
return type == Material.MOVING_PISTON || type == Material.AIR; return type == Material.MOVING_PISTON || type == Material.AIR;
@ -441,7 +443,7 @@ public final class BlockUtils {
* *
* @return HashSet with the IDs of every transparent block * @return HashSet with the IDs of every transparent block
*/ */
public static HashSet<Material> getTransparentBlocks() { public HashSet<Material> getTransparentBlocks() {
HashSet<Material> transparentBlocks = new HashSet<>(); HashSet<Material> transparentBlocks = new HashSet<>();
for (Material material : Material.values()) { for (Material material : Material.values()) {
@ -453,7 +455,7 @@ public final class BlockUtils {
return transparentBlocks; return transparentBlocks;
} }
public static boolean isFullyGrown(BlockState blockState) { public boolean isFullyGrown(BlockState blockState) {
BlockData data = blockState.getBlockData(); BlockData data = blockState.getBlockData();
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE) if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE)
return true; return true;

View File

@ -411,8 +411,8 @@ public class EventManager {
return !isCancelled; return !isCancelled;
} }
public void callAbilityDeactivateEvent(Player player, SuperAbilityType ability) { public void callAbilityDeactivateEvent(Player player, SuperAbilityType superAbilityType) {
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, PrimarySkillType.getPrimarySkillBySuperAbility(ability)); McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, pluginRef.getSkillTools().getPrimarySkillBySuperAbility(superAbilityType));
pluginRef.getServer().getPluginManager().callEvent(event); pluginRef.getServer().getPluginManager().callEvent(event);
} }

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.*; import net.md_5.bungee.api.chat.*;
@ -273,7 +272,7 @@ public class TextComponentFactory {
//Get skill name //Get skill name
String skillName = subSkillType.getLocaleName(); String skillName = subSkillType.getLocaleName();
boolean skillUnlocked = RankUtils.hasUnlockedSubskill(player, subSkillType); boolean skillUnlocked = pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType);
TextComponent textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked); TextComponent textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked);
@ -297,7 +296,7 @@ public class TextComponentFactory {
//Setup Text Component //Setup Text Component
SubSkillType subSkillType = abstractSubSkill.getSubSkillType(); SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
boolean skillUnlocked = RankUtils.hasUnlockedSubskill(player, subSkillType); boolean skillUnlocked = pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType);
TextComponent textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked); TextComponent textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked);
@ -313,7 +312,7 @@ public class TextComponentFactory {
private TextComponent initNewSkillTextComponent(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) { private TextComponent initNewSkillTextComponent(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
TextComponent textComponent; TextComponent textComponent;
if (skillUnlocked) { if (skillUnlocked) {
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1) if (pluginRef.getRankTools().getHighestRank(subSkillType) == pluginRef.getRankTools().getRank(player, subSkillType) && subSkillType.getNumRanks() > 1)
textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.MaxRankSkillName", skillName)); textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.MaxRankSkillName", skillName));
else else
textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.SkillName", skillName)); textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.SkillName", skillName));
@ -322,7 +321,7 @@ public class TextComponentFactory {
} else { } else {
textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.Mystery", textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.Mystery",
String.valueOf(RankUtils.getUnlockLevel(subSkillType)))); String.valueOf(pluginRef.getRankTools().getUnlockLevel(subSkillType))));
textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mmoinfo ???")); textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mmoinfo ???"));
} }
@ -364,23 +363,23 @@ public class TextComponentFactory {
SubSkillType subSkillType = abstractSubSkill.getSubSkillType(); SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
//SubSkillType Name //SubSkillType Name
ComponentBuilder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, abstractSubSkill)); ComponentBuilder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, pluginRef.getRankTools().hasUnlockedSubskill(player, abstractSubSkill));
if (!RankUtils.hasUnlockedSubskill(player, abstractSubSkill)) { if (!pluginRef.getRankTools().hasUnlockedSubskill(player, abstractSubSkill)) {
//Skill is not unlocked yet //Skill is not unlocked yet
addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder); addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
} else { } else {
addSubSkillTypeToHoverEventJSON(abstractSubSkill, componentBuilder); addSubSkillTypeToHoverEventJSON(abstractSubSkill, componentBuilder);
//RANK //RANK
int curRank = RankUtils.getRank(player, abstractSubSkill); int curRank = pluginRef.getRankTools().getRank(player, abstractSubSkill);
int nextRank = 0; int nextRank = 0;
if (curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0) { if (curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0) {
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank + 1); nextRank = pluginRef.getRankTools().getRankUnlockLevel(abstractSubSkill, curRank + 1);
} }
addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank); addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, abstractSubSkill.getNumRanks(), pluginRef.getRankTools().getRank(player, abstractSubSkill), nextRank);
componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.DescriptionHeader")); componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.DescriptionHeader"));
componentBuilder.append("\n").append(abstractSubSkill.getDescription()).append("\n"); componentBuilder.append("\n").append(abstractSubSkill.getDescription()).append("\n");
@ -399,13 +398,13 @@ public class TextComponentFactory {
private ComponentBuilder setupSkillComponentNameStyle(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) { private ComponentBuilder setupSkillComponentNameStyle(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
ComponentBuilder componentBuilder; ComponentBuilder componentBuilder;
if (skillUnlocked) { if (skillUnlocked) {
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1) if (pluginRef.getRankTools().getHighestRank(subSkillType) == pluginRef.getRankTools().getRank(player, subSkillType) && subSkillType.getNumRanks() > 1)
componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.MaxRankSkillName", skillName)); componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.MaxRankSkillName", skillName));
else else
componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.SkillName", skillName)); componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.SkillName", skillName));
} else } else
componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.Mystery", componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.Mystery",
String.valueOf(RankUtils.getUnlockLevel(subSkillType)))); String.valueOf(pluginRef.getRankTools().getUnlockLevel(subSkillType))));
return componentBuilder; return componentBuilder;
} }
@ -433,13 +432,13 @@ public class TextComponentFactory {
private void addLocked(SubSkillType subSkillType, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) { private void addLocked(SubSkillType subSkillType, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) {
addLocked(ccLocked, ccLevelRequirement, componentBuilder); addLocked(ccLocked, ccLevelRequirement, componentBuilder);
componentBuilder.append(String.valueOf(RankUtils.getSubSkillUnlockLevel(subSkillType, 1))).color(ccLevelRequired); componentBuilder.append(String.valueOf(pluginRef.getRankTools().getSubSkillUnlockLevel(subSkillType, 1))).color(ccLevelRequired);
//componentBuilder.append("\n"); //componentBuilder.append("\n");
} }
private void addLocked(AbstractSubSkill abstractSubSkill, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) { private void addLocked(AbstractSubSkill abstractSubSkill, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) {
addLocked(ccLocked, ccLevelRequirement, componentBuilder); addLocked(ccLocked, ccLevelRequirement, componentBuilder);
componentBuilder.append(String.valueOf(RankUtils.getSubSkillUnlockLevel(abstractSubSkill, 1))).color(ccLevelRequired); componentBuilder.append(String.valueOf(pluginRef.getRankTools().getSubSkillUnlockLevel(abstractSubSkill, 1))).color(ccLevelRequired);
//componentBuilder.append("\n");m //componentBuilder.append("\n");m
} }
@ -468,9 +467,9 @@ public class TextComponentFactory {
ChatColor ccLevelRequired = ChatColor.RED; ChatColor ccLevelRequired = ChatColor.RED;
//SubSkillType Name //SubSkillType Name
ComponentBuilder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, subSkillType)); ComponentBuilder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType));
if (!RankUtils.hasUnlockedSubskill(player, subSkillType)) { if (!pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType)) {
//Skill is not unlocked yet //Skill is not unlocked yet
addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder); addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
} else { } else {
@ -478,14 +477,14 @@ public class TextComponentFactory {
//RANK //RANK
if (subSkillType.getNumRanks() > 0) { if (subSkillType.getNumRanks() > 0) {
int curRank = RankUtils.getRank(player, subSkillType); int curRank = pluginRef.getRankTools().getRank(player, subSkillType);
int nextRank = 0; int nextRank = 0;
if (curRank < subSkillType.getNumRanks() && subSkillType.getNumRanks() > 0) { if (curRank < subSkillType.getNumRanks() && subSkillType.getNumRanks() > 0) {
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank + 1); nextRank = pluginRef.getRankTools().getRankUnlockLevel(subSkillType, curRank + 1);
} }
addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank); addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, subSkillType.getNumRanks(), pluginRef.getRankTools().getRank(player, subSkillType), nextRank);
} }
@ -536,7 +535,7 @@ public class TextComponentFactory {
public TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) { public TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) {
TextComponent unlockMessage = new TextComponent(""); TextComponent unlockMessage = new TextComponent("");
unlockMessage.setText(pluginRef.getLocaleManager().getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType))); unlockMessage.setText(pluginRef.getLocaleManager().getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), pluginRef.getRankTools().getRank(player, subSkillType)));
unlockMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, getSubSkillHoverComponent(player, subSkillType))); unlockMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, getSubSkillHoverComponent(player, subSkillType)));
unlockMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + subSkillType.getParentSkill().toString().toLowerCase())); unlockMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + subSkillType.getParentSkill().toString().toLowerCase()));
return unlockMessage; return unlockMessage;

View File

@ -376,7 +376,7 @@ public final class CombatTools {
} }
public int getLimitBreakDamage(Player player, SubSkillType subSkillType) { public int getLimitBreakDamage(Player player, SubSkillType subSkillType) {
return RankUtils.getRank(player, subSkillType); return pluginRef.getRankTools().getRank(player, subSkillType);
} }
/** /**
@ -386,7 +386,7 @@ public final class CombatTools {
* @return true if the player has access to the limit break * @return true if the player has access to the limit break
*/ */
public boolean canUseLimitBreak(Player player, SubSkillType subSkillType) { public boolean canUseLimitBreak(Player player, SubSkillType subSkillType) {
return RankUtils.hasUnlockedSubskill(player, subSkillType) return pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType)
&& Permissions.isSubSkillEnabled(player, subSkillType); && Permissions.isSubSkillEnabled(player, subSkillType);
} }

View File

@ -8,28 +8,34 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.SkillUnlockNotificationTask; import com.gmail.nossr50.runnables.skills.SkillUnlockNotificationTask;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.HashMap; import java.util.HashMap;
public class RankUtils { public class RankTools {
private static HashMap<String, HashMap<Integer, Integer>> subSkillRanks;
private static int count = 0; private final mcMMO pluginRef;
public RankTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
private HashMap<String, HashMap<Integer, Integer>> subSkillRanks;
private int count = 0;
/** /**
* @param plugin plugin instance ref
* @param mcMMOPlayer target player * @param mcMMOPlayer target player
* @param primarySkillType target primary skill * @param primarySkillType target primary skill
* @param newLevel the new level of this skill * @param newLevel the new level of this skill
*/ */
public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel) { public void executeSkillUnlockNotifications(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel) {
for (SubSkillType subSkillType : primarySkillType.getSkillAbilities()) { for (SubSkillType subSkillType : pluginRef.getSkillTools().getSkillAbilities(primarySkillType)) {
int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType); int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType);
HashMap<Integer, Integer> innerMap = subSkillRanks.get(subSkillType.toString()); HashMap<Integer, Integer> innerMap = subSkillRanks.get(subSkillType.toString());
@ -44,21 +50,21 @@ public class RankUtils {
//The players level is the exact level requirement for this skill //The players level is the exact level requirement for this skill
if (newLevel == innerMap.get(playerRankInSkill)) { if (newLevel == innerMap.get(playerRankInSkill)) {
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType); SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(pluginRef, mcMMOPlayer, subSkillType);
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100)); skillUnlockNotificationTask.runTaskLater(pluginRef, (count * 100));
count++; count++;
} }
} }
} }
public static void resetUnlockDelayTimer() { public void resetUnlockDelayTimer() {
count = 0; count = 0;
} }
/* NEW SYSTEM */ /* NEW SYSTEM */
private static void addRanks(AbstractSubSkill abstractSubSkill) { private void addRanks(AbstractSubSkill abstractSubSkill) {
//Fill out the rank array //Fill out the rank array
for (int i = 0; i < abstractSubSkill.getNumRanks(); i++) { for (int i = 0; i < abstractSubSkill.getNumRanks(); i++) {
//This adds the highest ranks first //This adds the highest ranks first
@ -69,7 +75,7 @@ public class RankUtils {
} }
} }
private static void addRanks(SubSkillType subSkillType) { private void addRanks(SubSkillType subSkillType) {
//Fill out the rank array //Fill out the rank array
for (int i = 0; i < subSkillType.getNumRanks(); i++) { for (int i = 0; i < subSkillType.getNumRanks(); i++) {
//This adds the highest ranks first //This adds the highest ranks first
@ -83,7 +89,7 @@ public class RankUtils {
/** /**
* Populates the ranks for every skill we know about * Populates the ranks for every skill we know about
*/ */
public static void populateRanks() { public void populateRanks() {
for (SubSkillType subSkillType : SubSkillType.values()) { for (SubSkillType subSkillType : SubSkillType.values()) {
addRanks(subSkillType); addRanks(subSkillType);
} }
@ -100,7 +106,7 @@ public class RankUtils {
* @param subSkillType the target subskill * @param subSkillType the target subskill
* @return true if the player has at least one rank in the skill * @return true if the player has at least one rank in the skill
*/ */
public static boolean hasUnlockedSubskill(Player player, SubSkillType subSkillType) { public boolean hasUnlockedSubskill(Player player, SubSkillType subSkillType) {
int curRank = getRank(player, subSkillType); int curRank = getRank(player, subSkillType);
//-1 means the skill has no unlockable levels and is therefor unlocked //-1 means the skill has no unlockable levels and is therefor unlocked
@ -114,7 +120,7 @@ public class RankUtils {
* @param abstractSubSkill the target subskill * @param abstractSubSkill the target subskill
* @return true if the player has at least one rank in the skill * @return true if the player has at least one rank in the skill
*/ */
public static boolean hasUnlockedSubskill(Player player, AbstractSubSkill abstractSubSkill) { public boolean hasUnlockedSubskill(Player player, AbstractSubSkill abstractSubSkill) {
int curRank = getRank(player, abstractSubSkill); int curRank = getRank(player, abstractSubSkill);
//-1 means the skill has no unlockable levels and is therefor unlocked //-1 means the skill has no unlockable levels and is therefor unlocked
@ -129,7 +135,7 @@ public class RankUtils {
* @param subSkillType the target subskill * @param subSkillType the target subskill
* @return true if the player is at least that rank in this subskill * @return true if the player is at least that rank in this subskill
*/ */
public static boolean hasReachedRank(int rank, Player player, SubSkillType subSkillType) { public boolean hasReachedRank(int rank, Player player, SubSkillType subSkillType) {
return getRank(player, subSkillType) >= rank; return getRank(player, subSkillType) >= rank;
} }
@ -141,7 +147,7 @@ public class RankUtils {
* @param abstractSubSkill the target subskill * @param abstractSubSkill the target subskill
* @return true if the player is at least that rank in this subskill * @return true if the player is at least that rank in this subskill
*/ */
public static boolean hasReachedRank(int rank, Player player, AbstractSubSkill abstractSubSkill) { public boolean hasReachedRank(int rank, Player player, AbstractSubSkill abstractSubSkill) {
return getRank(player, abstractSubSkill) >= rank; return getRank(player, abstractSubSkill) >= rank;
} }
@ -152,7 +158,7 @@ public class RankUtils {
* @param subSkillType Target subskill * @param subSkillType Target subskill
* @return The rank the player currently has achieved in this skill. -1 for skills without ranks. * @return The rank the player currently has achieved in this skill. -1 for skills without ranks.
*/ */
public static int getRank(Player player, SubSkillType subSkillType) { public int getRank(Player player, SubSkillType subSkillType) {
String skillName = subSkillType.toString(); String skillName = subSkillType.toString();
int numRanks = subSkillType.getNumRanks(); int numRanks = subSkillType.getNumRanks();
@ -172,7 +178,7 @@ public class RankUtils {
return 0; return 0;
//Skill level of parent skill //Skill level of parent skill
int currentSkillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(subSkillType.getParentSkill()); int currentSkillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(subSkillType.getParentSkill(pluginRef));
for (int i = 0; i < numRanks; i++) { for (int i = 0; i < numRanks; i++) {
//Compare against the highest to lowest rank in that order //Compare against the highest to lowest rank in that order
@ -198,7 +204,7 @@ public class RankUtils {
* @param abstractSubSkill Target subskill * @param abstractSubSkill Target subskill
* @return The rank the player currently has achieved in this skill. -1 for skills without ranks. * @return The rank the player currently has achieved in this skill. -1 for skills without ranks.
*/ */
public static int getRank(Player player, AbstractSubSkill abstractSubSkill) { public int getRank(Player player, AbstractSubSkill abstractSubSkill) {
String skillName = abstractSubSkill.getConfigKeyName(); String skillName = abstractSubSkill.getConfigKeyName();
int numRanks = abstractSubSkill.getNumRanks(); int numRanks = abstractSubSkill.getNumRanks();
@ -243,7 +249,7 @@ public class RankUtils {
* @param abstractSubSkill The subskill to add ranks for * @param abstractSubSkill The subskill to add ranks for
* @param rank The rank to add * @param rank The rank to add
*/ */
private static void addRank(AbstractSubSkill abstractSubSkill, int rank) { private void addRank(AbstractSubSkill abstractSubSkill, int rank) {
initMaps(abstractSubSkill.getConfigKeyName()); initMaps(abstractSubSkill.getConfigKeyName());
HashMap<Integer, Integer> rankMap = subSkillRanks.get(abstractSubSkill.getConfigKeyName()); HashMap<Integer, Integer> rankMap = subSkillRanks.get(abstractSubSkill.getConfigKeyName());
@ -252,7 +258,7 @@ public class RankUtils {
} }
@Deprecated @Deprecated
private static void addRank(SubSkillType subSkillType, int rank) { private void addRank(SubSkillType subSkillType, int rank) {
initMaps(subSkillType.toString()); initMaps(subSkillType.toString());
HashMap<Integer, Integer> rankMap = subSkillRanks.get(subSkillType.toString()); HashMap<Integer, Integer> rankMap = subSkillRanks.get(subSkillType.toString());
@ -260,14 +266,14 @@ public class RankUtils {
rankMap.put(rank, getRankUnlockLevel(subSkillType, rank)); rankMap.put(rank, getRankUnlockLevel(subSkillType, rank));
} }
private static void initMaps(String s) { private void initMaps(String s) {
if (subSkillRanks == null) if (subSkillRanks == null)
subSkillRanks = new HashMap<>(); subSkillRanks = new HashMap<>();
subSkillRanks.computeIfAbsent(s, k -> new HashMap<>()); subSkillRanks.computeIfAbsent(s, k -> new HashMap<>());
} }
/* public static int getSubSkillUnlockRequirement(SubSkillType subSkillType) /* public int getSubSkillUnlockRequirement(SubSkillType subSkillType)
{ {
String skillName = subSkillType.toString(); String skillName = subSkillType.toString();
int numRanks = subSkillType.getNumRanks(); int numRanks = subSkillType.getNumRanks();
@ -292,11 +298,11 @@ public class RankUtils {
* @return The level at which this rank unlocks * @return The level at which this rank unlocks
*/ */
@Deprecated @Deprecated
public static int getRankUnlockLevel(SubSkillType subSkillType, int rank) { public int getRankUnlockLevel(SubSkillType subSkillType, int rank) {
return getSubSkillUnlockLevel(subSkillType, rank); return getSubSkillUnlockLevel(subSkillType, rank);
} }
public static int getRankUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) { public int getRankUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) {
return getSubSkillUnlockLevel(abstractSubSkill, rank); return getSubSkillUnlockLevel(abstractSubSkill, rank);
} }
@ -306,7 +312,7 @@ public class RankUtils {
* @param subSkillType target subskill * @param subSkillType target subskill
* @return The unlock requirements for rank 1 in this skill * @return The unlock requirements for rank 1 in this skill
*/ */
public static int getUnlockLevel(SubSkillType subSkillType) { public int getUnlockLevel(SubSkillType subSkillType) {
return getSubSkillUnlockLevel(subSkillType, 1); return getSubSkillUnlockLevel(subSkillType, 1);
} }
@ -316,7 +322,7 @@ public class RankUtils {
* @param abstractSubSkill target subskill * @param abstractSubSkill target subskill
* @return The unlock requirements for rank 1 in this skill * @return The unlock requirements for rank 1 in this skill
*/ */
public static int getUnlockLevel(AbstractSubSkill abstractSubSkill) { public int getUnlockLevel(AbstractSubSkill abstractSubSkill) {
return getSubSkillUnlockLevel(abstractSubSkill, 1); return getSubSkillUnlockLevel(abstractSubSkill, 1);
} }
@ -326,11 +332,11 @@ public class RankUtils {
* @param subSkillType target subskill * @param subSkillType target subskill
* @return the last rank of a subskill * @return the last rank of a subskill
*/ */
public static int getHighestRank(SubSkillType subSkillType) { public int getHighestRank(SubSkillType subSkillType) {
return subSkillType.getNumRanks(); return subSkillType.getNumRanks();
} }
public static String getHighestRankStr(SubSkillType subSkillType) { public String getHighestRankStr(SubSkillType subSkillType) {
return String.valueOf(subSkillType.getNumRanks()); return String.valueOf(subSkillType.getNumRanks());
} }
@ -340,11 +346,11 @@ public class RankUtils {
* @param abstractSubSkill target subskill * @param abstractSubSkill target subskill
* @return the last rank of a subskill * @return the last rank of a subskill
*/ */
public static int getHighestRank(AbstractSubSkill abstractSubSkill) { public int getHighestRank(AbstractSubSkill abstractSubSkill) {
return abstractSubSkill.getNumRanks(); return abstractSubSkill.getNumRanks();
} }
public static int getSuperAbilityUnlockRequirement(SuperAbilityType superAbilityType) { public int getSuperAbilityUnlockRequirement(SuperAbilityType superAbilityType) {
return getRankUnlockLevel(superAbilityType.getSubSkillTypeDefinition(), 1); return getRankUnlockLevel(superAbilityType.getSubSkillTypeDefinition(), 1);
} }
@ -355,7 +361,7 @@ public class RankUtils {
* @param rank the rank we are checking * @param rank the rank we are checking
* @return the level requirement for a subskill at this particular rank * @return the level requirement for a subskill at this particular rank
*/ */
public static int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank) { public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank) {
return findRankByRootAddress(rank, subSkillType); return findRankByRootAddress(rank, subSkillType);
} }
@ -366,7 +372,7 @@ public class RankUtils {
* @param rank the rank we are checking * @param rank the rank we are checking
* @return the level requirement for a subskill at this particular rank * @return the level requirement for a subskill at this particular rank
*/ */
public static int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) { public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) {
return findRankByRootAddress(rank, abstractSubSkill.getSubSkillType()); return findRankByRootAddress(rank, abstractSubSkill.getSubSkillType());
} }
@ -377,13 +383,13 @@ public class RankUtils {
* @param rank the rank we are checking * @param rank the rank we are checking
* @return the level requirement for a subskill at this particular rank * @return the level requirement for a subskill at this particular rank
*/ */
private static int findRankByRootAddress(int rank, SubSkillType subSkillType) { private int findRankByRootAddress(int rank, SubSkillType subSkillType) {
CommentedConfigurationNode rankConfigRoot = pluginRef.getConfigManager().getConfigRanksRootNode(); CommentedConfigurationNode rankConfigRoot = pluginRef.getConfigManager().getConfigRanksRootNode();
try { try {
SkillRankProperty skillRankProperty SkillRankProperty skillRankProperty
= (SkillRankProperty) rankConfigRoot.getNode(subSkillType.getParentSkill().getCapitalizedPrimarySkillName()) = (SkillRankProperty) rankConfigRoot.getNode(pluginRef.getSkillTools().getCapitalizedPrimarySkillName(subSkillType.getParentSkill(pluginRef)))
.getNode(subSkillType.getHoconFriendlyConfigName()) .getNode(subSkillType.getHoconFriendlyConfigName())
.getValue(TypeToken.of(SkillRankProperty.class)); .getValue(TypeToken.of(SkillRankProperty.class));
@ -397,10 +403,10 @@ public class RankUtils {
} }
//Default to the max level for the skill if any errors were encountered incorrect //Default to the max level for the skill if any errors were encountered incorrect
return pluginRef.getConfigManager().getConfigLeveling().getSkillLevelCap(subSkillType.getParentSkill()); return pluginRef.getConfigManager().getConfigLeveling().getSkillLevelCap(subSkillType.getParentSkill(pluginRef));
} }
public static boolean isPlayerMaxRankInSubSkill(Player player, SubSkillType subSkillType) { public boolean isPlayerMaxRankInSubSkill(Player player, SubSkillType subSkillType) {
int playerRank = getRank(player, subSkillType); int playerRank = getRank(player, subSkillType);
int highestRank = getHighestRank(subSkillType); int highestRank = getHighestRank(subSkillType);

View File

@ -276,7 +276,7 @@ public class SkillTools {
} }
public int handleFoodSkills(Player player, int eventFoodLevel, SubSkillType subSkillType) { public int handleFoodSkills(Player player, int eventFoodLevel, SubSkillType subSkillType) {
int curRank = RankUtils.getRank(player, subSkillType); int curRank = pluginRef.getRankTools().getRank(player, subSkillType);
int currentFoodLevel = player.getFoodLevel(); int currentFoodLevel = player.getFoodLevel();
int foodChange = eventFoodLevel - currentFoodLevel; int foodChange = eventFoodLevel - currentFoodLevel;
@ -643,7 +643,7 @@ public class SkillTools {
} }
public boolean isSuperAbilityUnlocked(PrimarySkillType primarySkillType, Player player) { public boolean isSuperAbilityUnlocked(PrimarySkillType primarySkillType, Player player) {
return RankUtils.getRank(player, getSuperAbility(primarySkillType).getSubSkillTypeDefinition()) >= 1; return pluginRef.getRankTools().getRank(player, getSuperAbility(primarySkillType).getSubSkillTypeDefinition()) >= 1;
} }
public boolean getPVPEnabled(PrimarySkillType primarySkillType) { public boolean getPVPEnabled(PrimarySkillType primarySkillType) {