Refactoring code part 1 to prep for adding a bunch of unit tests

This commit is contained in:
nossr50 2021-04-08 10:39:07 -07:00
parent 0636f578dd
commit 5080d86e44
115 changed files with 993 additions and 970 deletions

View File

@ -1,4 +1,5 @@
Version 2.1.189
Removed MHD command (it didn't do anything for a while now)
Removed UP warning
Updated pl locale (Thanks Mich3l3k)

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.api.exceptions.*;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
@ -802,7 +801,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid
*/
public static int getLevelCap(String skillType) {
return Config.getInstance().getLevelCap(getSkillType(skillType));
return mcMMO.p.getGeneralConfig().getLevelCap(getSkillType(skillType));
}
/**
@ -813,7 +812,7 @@ public final class ExperienceAPI {
* @return the overall power level cap
*/
public static int getPowerLevelCap() {
return Config.getInstance().getPowerLevelCap();
return mcMMO.p.getGeneralConfig().getPowerLevelCap();
}
/**

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
@ -108,7 +107,7 @@ public final class PartyAPI {
*/
public static int getMaxPartySize()
{
return Config.getInstance().getPartyMaxSize();
return mcMMO.p.getGeneralConfig().getPartyMaxSize();
}
/**

View File

@ -1,46 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.FlatFileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class MHDCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
if (mcMMO.getDatabaseManager() instanceof FlatFileDatabaseManager) {
FlatFileDatabaseManager m = (FlatFileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
return false;
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
@ -26,7 +25,7 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit);
sender.sendMessage(LocaleLoader.getString("mcMMO.Description.FormerDevs"));
if (Config.getInstance().getDonateMessageEnabled()) {
if (mcMMO.p.getGeneralConfig().getDonateMessageEnabled()) {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
}

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
@ -32,7 +32,7 @@ public class McscoreboardCommand implements TabExecutor {
}
if (args[0].equalsIgnoreCase("keep")) {
if (!Config.getInstance().getAllowKeepBoard() || !Config.getInstance().getScoreboardsEnabled()) {
if (!mcMMO.p.getGeneralConfig().getAllowKeepBoard() || !mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
import com.gmail.nossr50.locale.LocaleLoader;
@ -39,7 +37,7 @@ public class XprateCommand implements TabExecutor {
if (mcMMO.p.isXPEventEnabled()) {
if(AdvancedConfig.getInstance().useTitlesForXPEvent())
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Stop"),
@ -47,7 +45,7 @@ public class XprateCommand implements TabExecutor {
10, 10*20, 20);
}
if(Config.getInstance().broadcastEventMessages())
if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
{
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
@ -92,7 +90,7 @@ public class XprateCommand implements TabExecutor {
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if(AdvancedConfig.getInstance().useTitlesForXPEvent())
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"),
@ -100,7 +98,7 @@ public class XprateCommand implements TabExecutor {
10, 10*20, 20);
}
if(Config.getInstance().broadcastEventMessages())
if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
{
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));

View File

@ -27,7 +27,13 @@ public class ConvertDatabaseCommand implements CommandExecutor {
return true;
}
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType, mcMMO.getUsersFilePath(), mcMMO.p.getLogger(), mcMMO.p.getPurgeTime(), mcMMO.p.getAdvancedConfig().getStartingLevel());
if(oldDatabase == null) {
sender.sendMessage("Unable to load the old database! Check your log for errors.");
return true;
}
oldDatabase.init();
if (previousType == DatabaseType.CUSTOM) {
Class<?> clazz;
@ -41,6 +47,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
}
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
oldDatabase.init();
} catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
@ -17,7 +16,7 @@ public class McpurgeCommand implements TabExecutor {
if (args.length == 0) {
mcMMO.getDatabaseManager().purgePowerlessUsers();
if (Config.getInstance().getOldUsersCutoff() != -1) {
if (mcMMO.p.getGeneralConfig().getOldUsersCutoff() != -1) {
mcMMO.getDatabaseManager().purgeOldUsers();
}

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -22,7 +22,7 @@ public class MmoshowdbCommand implements TabExecutor {
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (mcMMO.p.getGeneralConfig().getUseMySQL() ? "sql" : "flatfile")));
return true;
}
return false;

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor;
@ -85,7 +85,7 @@ public class PartyInfoCommand implements CommandExecutor {
}
private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) {
return party.getLevel() >= Config.getInstance().getPartyFeatureUnlockLevel(partyFeature);
return party.getLevel() >= mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(partyFeature);
}
private void displayShareModeInfo(Player player, Party party) {

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -53,7 +53,7 @@ public class PartyInviteCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty();
if (PartyManager.isPartyFull(target, playerParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize()));
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), mcMMO.p.getGeneralConfig().getPartyMaxSize()));
return true;
}

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.text.StringUtils;
@ -28,7 +28,7 @@ public class PartyItemShareCommand implements CommandExecutor {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
return true;
}

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.text.StringUtils;
@ -25,7 +25,7 @@ public class PartyXpShareCommand implements CommandExecutor {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5"));
return true;
}

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -51,7 +51,7 @@ public class PartyAllianceCommand implements TabExecutor {
switch (args.length) {
case 1:
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
if (playerParty.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true;
}
@ -69,7 +69,7 @@ public class PartyAllianceCommand implements TabExecutor {
case 2:
case 3:
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
if (playerParty.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true;
}

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
@ -35,7 +35,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), Config.getInstance().getPTPCommandTimeout())) {
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), mcMMO.p.getGeneralConfig().getPTPCommandTimeout())) {
ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true;
@ -48,7 +48,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if (Config.getInstance().getPTPCommandWorldPermissions()) {
if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld();
World playerWorld = player.getWorld();

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
@ -76,7 +75,7 @@ public class PtpCommand implements TabExecutor {
Party party = mcMMOPlayer.getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2"));
return true;
}
@ -91,7 +90,7 @@ public class PtpCommand implements TabExecutor {
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
int hurtCooldown = mcMMO.p.getGeneralConfig().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
@ -111,7 +110,7 @@ public class PtpCommand implements TabExecutor {
return true;
}
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
int ptpCooldown = mcMMO.p.getGeneralConfig().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
@ -165,7 +164,7 @@ public class PtpCommand implements TabExecutor {
Player target = mcMMOTarget.getPlayer();
if (Config.getInstance().getPTPCommandWorldPermissions()) {
if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld();
World playerWorld = player.getWorld();
@ -194,7 +193,7 @@ public class PtpCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", mcMMO.p.getGeneralConfig().getPTPCommandTimeout()));
}
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
@ -245,7 +244,7 @@ public class PtpCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup();
long warmup = mcMMO.p.getGeneralConfig().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -36,12 +35,12 @@ public class InspectCommand implements TabExecutor {
return true;
}
if (Config.getInstance().getScoreboardsEnabled()
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
&& sender instanceof Player
&& Config.getInstance().getInspectUseBoard()) {
&& mcMMO.p.getGeneralConfig().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) {
if (!mcMMO.p.getGeneralConfig().getInspectUseChat()) {
return true;
}
}
@ -76,12 +75,12 @@ public class InspectCommand implements TabExecutor {
return true;
}
if (Config.getInstance().getScoreboardsEnabled()
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
&& sender instanceof Player
&& Config.getInstance().getInspectUseBoard()) {
&& mcMMO.p.getGeneralConfig().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer);
if (!Config.getInstance().getInspectUseChat()) {
if (!mcMMO.p.getGeneralConfig().getInspectUseChat()) {
return true;
}
}

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -30,10 +30,10 @@ public class MccooldownCommand implements TabExecutor {
if (args.length == 0) {
Player player = (Player) sender;
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) {
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && mcMMO.p.getGeneralConfig().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) {
if (!mcMMO.p.getGeneralConfig().getCooldownUseChat()) {
return true;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
@ -91,7 +90,7 @@ public class McrankCommand implements TabExecutor {
return;
}
long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750);
long cooldownMillis = Math.min(mcMMO.p.getGeneralConfig().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis)));
@ -108,8 +107,8 @@ public class McrankCommand implements TabExecutor {
mcMMOPlayer.actualizeDatabaseATS();
}
boolean useBoard = Config.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
boolean useChat = !useBoard || Config.getInstance().getRankUseChat();
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -33,10 +33,10 @@ public class McstatsCommand implements TabExecutor {
Player player = (Player) sender;
if (Config.getInstance().getStatsUseBoard() && Config.getInstance().getScoreboardsEnabled()) {
if (mcMMO.p.getGeneralConfig().getStatsUseBoard() && mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!Config.getInstance().getStatsUseChat()) {
if (!mcMMO.p.getGeneralConfig().getStatsUseChat()) {
return true;
}
}
@ -48,7 +48,7 @@ public class McstatsCommand implements TabExecutor {
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = Config.getInstance().getPowerLevelCap();
int powerLevelCap = mcMMO.p.getGeneralConfig().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@ -86,7 +85,7 @@ public class MctopCommand implements TabExecutor {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
long cooldownMillis = Math.max(mcMMO.p.getGeneralConfig().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D;
@ -112,8 +111,8 @@ public class MctopCommand implements TabExecutor {
}
private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
boolean useChat = !useBoard || Config.getInstance().getTopUseChat();
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}

View File

@ -69,7 +69,7 @@ public class AcrobaticsCommand extends SkillCommand {
//Chance Stat Calculations
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
//damageThreshold = mcMMO.p.getAdvancedConfig().getRollDamageThreshold();
String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);

View File

@ -1,11 +1,10 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@ -74,7 +73,7 @@ public abstract class SkillCommand implements TabExecutor {
float skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
if (mcMMO.p.getAdvancedConfig().doesSkillCommandSendBlankLines())
for (int i = 0; i < 2; i++) {
player.sendMessage("");
}
@ -106,13 +105,13 @@ public abstract class SkillCommand implements TabExecutor {
//Link Header
if (Config.getInstance().getUrlLinksEnabled()) {
if (mcMMO.p.getGeneralConfig().getUrlLinksEnabled()) {
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player);
}
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) {
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && mcMMO.p.getGeneralConfig().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
}
@ -226,8 +225,8 @@ public abstract class SkillCommand implements TabExecutor {
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int abilityLengthVar = mcMMO.p.getAdvancedConfig().getAbilityLength();
int abilityLengthCap = mcMMO.p.getAdvancedConfig().getAbilityLengthCap();
int length;
@ -268,7 +267,7 @@ public abstract class SkillCommand implements TabExecutor {
}
protected String getLimitBreakDescriptionParameter() {
if(AdvancedConfig.getInstance().canApplyLimitBreakPVE()) {
if(mcMMO.p.getAdvancedConfig().canApplyLimitBreakPVE()) {
return "(PVP/PVE)";
} else {
return "(PVP)";

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
@ -46,17 +46,17 @@ public class SwordsCommand extends SkillCommand {
// SWORDS_RUPTURE
if (canRupture) {
int ruptureRank = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE);
ruptureLengthSecondsAgainstPlayers = String.valueOf(AdvancedConfig.getInstance().getRuptureDurationSeconds(true));
ruptureLengthSecondsAgainstMobs = String.valueOf(AdvancedConfig.getInstance().getRuptureDurationSeconds(false));
ruptureLengthSecondsAgainstPlayers = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureDurationSeconds(true));
ruptureLengthSecondsAgainstMobs = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureDurationSeconds(false));
rupturePureTickDamageAgainstPlayers = String.valueOf(AdvancedConfig.getInstance().getRuptureTickDamage(true, ruptureRank));
rupturePureTickDamageAgainstMobs = String.valueOf(AdvancedConfig.getInstance().getRuptureTickDamage(false, ruptureRank));
rupturePureTickDamageAgainstPlayers = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureTickDamage(true, ruptureRank));
rupturePureTickDamageAgainstMobs = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureTickDamage(false, ruptureRank));
ruptureExplosionDamageAgainstPlayers = String.valueOf(AdvancedConfig.getInstance().getRuptureExplosionDamage(true, ruptureRank));
ruptureExplosionDamageAgainstMobs = String.valueOf(AdvancedConfig.getInstance().getRuptureExplosionDamage(false, ruptureRank));
ruptureExplosionDamageAgainstPlayers = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureExplosionDamage(true, ruptureRank));
ruptureExplosionDamageAgainstMobs = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureExplosionDamage(false, ruptureRank));
ruptureChanceToApply = String.valueOf(AdvancedConfig.getInstance().getRuptureChanceToApplyOnHit(ruptureRank) + "%");
ruptureChanceToApplyLucky = String.valueOf(AdvancedConfig.getInstance().getRuptureChanceToApplyOnHit(ruptureRank) * 1.33);
ruptureChanceToApply = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureChanceToApplyOnHit(ruptureRank) + "%");
ruptureChanceToApplyLucky = String.valueOf(mcMMO.p.getAdvancedConfig().getRuptureChanceToApplyOnHit(ruptureRank) * 1.33);
}
// SERRATED STRIKES

View File

@ -6,25 +6,17 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.ChatColor;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class AdvancedConfig extends AutoUpdateConfigLoader {
private static AdvancedConfig instance;
private AdvancedConfig() {
super("advanced.yml");
public AdvancedConfig(File dataFolder) {
super("advanced.yml", dataFolder);
validate();
}
public static AdvancedConfig getInstance() {
if (instance == null) {
instance = new AdvancedConfig();
}
return instance;
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
@ -68,15 +60,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
reason.add("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
}
/* ALCHEMY */
/*if (getCatalysisUnlockLevel() < 0) {
reason.add("Skills.Alchemy.Catalysis.UnlockLevel should be at least 0!");
}
if (getCatalysisMaxBonusLevel() <= getCatalysisUnlockLevel()) {
reason.add("Skills.Alchemy.Catalysis.MaxBonusLevel should be greater than Skills.Alchemy.Catalysis.UnlockLevel!");
}*/
if (getCatalysisMinSpeed() <= 0) {
reason.add("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
}
@ -85,21 +68,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
reason.add("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
}
/*List<Alchemy.Tier> alchemyTierList = Arrays.asList(Alchemy.Tier.values());
for (Alchemy.Tier tier : alchemyTierList) {
if (getConcoctionsTierLevel(tier) < 0) {
reason.add("Skills.Alchemy.Rank_Levels.Rank_" + rank + " should be at least 0!");
}
if (tier != Alchemy.Tier.fromNumerical(Alchemy.Tier.values().length)) {
Alchemy.Tier nextTier = alchemyTierList.get(alchemyTierList.indexOf(tier) - 1);
if (getConcoctionsTierLevel(tier) > getConcoctionsTierLevel(nextTier)) {
reason.add("Skills.Alchemy.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Alchemy.Rank_Levels.Rank_" + nextrank + "!");
}
}
}*/
/* ARCHERY */
if (getSkillShotRankDamageMultiplier() <= 0) {

View File

@ -11,10 +11,20 @@ import java.util.LinkedHashMap;
import java.util.Set;
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName, File dataFolder) {
super(relativePath, fileName, dataFolder);
}
public AutoUpdateConfigLoader(String fileName, File dataFolder) {
super(fileName, dataFolder);
}
@Deprecated
public AutoUpdateConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName);
}
@Deprecated
public AutoUpdateConfigLoader(String fileName) {
super(fileName);
}
@ -136,7 +146,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
saveName += ".new";
}
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dataFolder, saveName)));
writer.write(output);
writer.flush();
writer.close();

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
@ -12,16 +13,33 @@ public abstract class ConfigLoader {
protected String fileName;
protected final File configFile;
protected FileConfiguration config;
protected @NotNull File dataFolder;
public ConfigLoader(String relativePath, String fileName) {
public ConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
this.dataFolder = dataFolder;
configFile = new File(dataFolder, relativePath + File.separator + fileName);
loadFile();
}
public ConfigLoader(String fileName, @NotNull File dataFolder) {
this.fileName = fileName;
this.dataFolder = dataFolder;
configFile = new File(dataFolder, fileName);
loadFile();
}
@Deprecated
public ConfigLoader(String relativePath, String fileName) {
this.fileName = fileName;
configFile = new File(mcMMO.p.getDataFolder(), relativePath + File.separator + fileName);
loadFile();
}
@Deprecated
public ConfigLoader(String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), fileName);
configFile = new File(mcMMO.p.getDataFolder(), fileName);
loadFile();
}

View File

@ -12,27 +12,19 @@ import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
public class Config extends AutoUpdateConfigLoader {
private static Config instance;
public class GeneralConfig extends AutoUpdateConfigLoader {
private Config() {
super("config.yml");
public GeneralConfig(@NotNull File dataFolder) {
super("config.yml", dataFolder);
validate();
}
public static Config getInstance() {
if (instance == null) {
instance = new Config();
}
return instance;
}
@Override
protected void loadKeys() {
@ -63,47 +55,6 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
}
/* Scoreboards */
/*if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
}
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
}
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
}
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
}
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (!(getRankUseChat() || getRankUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
}
if (!(getTopUseChat() || getTopUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
}
if (!(getStatsUseChat() || getStatsUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
}
if (!(getInspectUseChat() || getInspectUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
}*/
/* Database Purging */
if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
@ -200,42 +151,6 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
// if (getTamingCOTWMaterial(EntityType.WOLF) == null) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Material is invalid!!");
// }
//
// if (getTamingCOTWMaterial(EntityType.OCELOT) == null) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Material is invalid!!");
// }
//
// if (getTamingCOTWMaterial(EntityType.HORSE) == null) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Material is invalid!!");
// }
//
// if (getTamingCOTWCost(EntityType.WOLF) <= 0) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Amount should be greater than 0!");
// }
//
// if (getTamingCOTWCost(EntityType.OCELOT) <= 0) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Amount should be greater than 0!");
// }
//
// if (getTamingCOTWCost(EntityType.HORSE) <= 0) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Amount should be greater than 0!");
// }
//
// if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Summon_Amount should be greater than 0!");
// }
//
// if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Summon_Amount should be greater than 0!");
// }
//
// if (getTamingCOTWAmount(EntityType.HORSE) <= 0) {
// reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Summon_Amount should be greater than 0!");
// }
return noErrorsInConfig(reason);
}

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -88,7 +89,7 @@ public class RankConfig extends AutoUpdateConfigLoader {
* @return the level requirement for a subskill at this particular rank
*/
private int findRankByRootAddress(int rank, String key) {
String scalingKey = Config.getInstance().getIsRetroMode() ? ".RetroMode." : ".Standard.";
String scalingKey = mcMMO.p.getGeneralConfig().getIsRetroMode() ? ".RetroMode." : ".Standard.";
String targetRank = "Rank_" + rank;

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
@ -15,15 +14,13 @@ import java.util.Map;
import java.util.UUID;
public interface DatabaseManager {
// One month in milliseconds
long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
// During convertUsers, how often to output a status
int progressInterval = 200;
/**
* Purge users with 0 power level from the database.
*/
void purgePowerlessUsers();
int purgePowerlessUsers();
/**
* Purge users who haven't logged on in over a certain time frame from the database.
@ -76,6 +73,8 @@ public interface DatabaseManager {
*/
Map<PrimarySkillType, Integer> readRank(String playerName);
default void init() {};
/**
* Add a new user to the database.
*

View File

@ -1,13 +1,16 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.mcMMO;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.logging.Logger;
public class DatabaseManagerFactory {
private static Class<? extends DatabaseManager> customManager = null;
public static DatabaseManager getDatabaseManager() {
public static DatabaseManager getDatabaseManager(@NotNull String userFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
if (customManager != null) {
try {
return createDefaultCustomDatabaseManager();
@ -20,10 +23,10 @@ public class DatabaseManagerFactory {
mcMMO.p.debug("Failed to create custom database manager");
e.printStackTrace();
}
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
mcMMO.p.debug("Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
}
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatFileDatabaseManager();
return mcMMO.p.getGeneralConfig().getUseMySQL() ? new SQLDatabaseManager() : new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
}
/**
@ -56,11 +59,11 @@ public class DatabaseManagerFactory {
return customManager;
}
public static DatabaseManager createDatabaseManager(DatabaseType type) {
public static @Nullable DatabaseManager createDatabaseManager(@NotNull DatabaseType type, @NotNull String userFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
switch (type) {
case FLATFILE:
mcMMO.p.getLogger().info("Using FlatFile Database");
return new FlatFileDatabaseManager();
return new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
case SQL:
mcMMO.p.getLogger().info("Using SQL Database");
@ -80,7 +83,7 @@ public class DatabaseManagerFactory {
}
}
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
private static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
return customManager.getConstructor().newInstance();
}

View File

@ -1,15 +1,13 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.player.UniqueDataType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.OfflinePlayer;
@ -19,14 +17,20 @@ import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
public final class FlatFileDatabaseManager implements DatabaseManager {
private final HashMap<PrimarySkillType, List<PlayerStat>> playerStatHash = new HashMap<>();
private final List<PlayerStat> powerLevels = new ArrayList<>();
public static final String IGNORED = "IGNORED";
private final @NotNull HashMap<PrimarySkillType, List<PlayerStat>> playerStatHash = new HashMap<>();
private final @NotNull List<PlayerStat> powerLevels = new ArrayList<>();
private long lastUpdate = 0;
private final @NotNull String usersFilePath;
private final @NotNull Logger logger;
private final long purgeTime;
private final int startingLevel;
private final long UPDATE_WAIT_TIME = 600000L; // 10 minutes
private final File usersFile;
private final @NotNull File usersFile;
private static final Object fileWritingLock = new Object();
public static int USERNAME_INDEX = 0;
@ -72,20 +76,26 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public static int DATA_ENTRY_COUNT = COOLDOWN_CHIMAERA_WING + 1; //Update this everytime new data is added
protected FlatFileDatabaseManager() {
usersFile = new File(mcMMO.getUsersFilePath());
protected FlatFileDatabaseManager(@NotNull String usersFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
usersFile = new File(usersFilePath);
this.usersFilePath = usersFilePath;
this.logger = logger;
this.purgeTime = purgeTime;
this.startingLevel = startingLevel;
}
public void init() {
checkStructure();
updateLeaderboards();
}
public void purgePowerlessUsers() {
public int purgePowerlessUsers() {
int purgedUsers = 0;
mcMMO.p.getLogger().info("Purging powerless users...");
logger.info("Purging powerless users...");
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
// This code is O(n) instead of O(n²)
synchronized (fileWritingLock) {
@ -96,7 +106,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
Map<PrimarySkillType, Integer> skills = getSkillMapFromLine(character);
Map<Skill, Integer> skills = getSkillMapFromLine(character);
boolean powerless = true;
for (int skill : skills.values()) {
@ -120,7 +130,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
}
catch (IOException e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
if (in != null) {
@ -142,18 +152,18 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
logger.info("Purged " + purgedUsers + " users from the database.");
return purgedUsers;
}
public void purgeOldUsers() {
int removedPlayers = 0;
long currentTime = System.currentTimeMillis();
mcMMO.p.getLogger().info("Purging old users...");
logger.info("Purging old users...");
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
// This code is O(n) instead of O(n²)
synchronized (fileWritingLock) {
@ -179,7 +189,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
rewrite = true;
}
if (currentTime - lastPlayed > PURGE_TIME) {
if (currentTime - lastPlayed > purgeTime) {
removedPlayers++;
}
else {
@ -200,7 +210,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
}
catch (IOException e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
if (in != null) {
@ -222,7 +232,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
mcMMO.p.getLogger().info("Purged " + removedPlayers + " users from the database.");
logger.info("Purged " + removedPlayers + " users from the database.");
}
public boolean removeUser(String playerName, UUID uuid) {
@ -231,7 +241,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
@ -242,7 +251,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) {
// Write out the same file but when we get to the player we want to remove, we skip his line.
if (!worked && line.split(":")[USERNAME_INDEX].equalsIgnoreCase(playerName)) {
mcMMO.p.getLogger().info("User found, removing...");
logger.info("User found, removing...");
worked = true;
continue; // Skip the player
}
@ -254,7 +263,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
}
catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
if (in != null) {
@ -286,13 +295,12 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
//Not used in FlatFile
}
public boolean saveUser(PlayerProfile profile) {
public boolean saveUser(@NotNull PlayerProfile profile) {
String playerName = profile.getPlayerName();
UUID uuid = profile.getUniqueId();
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
boolean corruptDataFound = false;
synchronized (fileWritingLock) {
@ -309,7 +317,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
if(!line.contains(":")) {
if(!corruptDataFound) {
mcMMO.p.getLogger().severe("mcMMO found some unexpected or corrupted data in mcmmo.users and is removing it, it is possible some data has been lost.");
logger.severe("mcMMO found some unexpected or corrupted data in mcmmo.users and is removing it, it is possible some data has been lost.");
corruptDataFound = true;
}
@ -318,12 +326,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
String[] splitData = line.split(":");
//This would be rare, but check the splitData for having enough entries to contain a username
if(splitData.length < USERNAME_INDEX) { //UUID have been in mcMMO DB for a very long time so any user without
//Something is wrong if we don't have enough split data to have an entry for a username
//This would be rare, but check the splitData for having enough entries to contain a UUID
if(splitData.length < UUID_INDEX) { //UUID have been in mcMMO DB for a very long time so any user without
if(!corruptDataFound) {
mcMMO.p.getLogger().severe("mcMMO found some unexpected or corrupted data in mcmmo.users and is removing it, it is possible some data has been lost.");
logger.severe("mcMMO found some unexpected or corrupted data in mcmmo.users and is removing it, it is possible some data has been lost.");
corruptDataFound = true;
}
@ -378,7 +385,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
private void writeUserToLine(PlayerProfile profile, String playerName, @Nullable UUID uuid, StringBuilder writer) {
private void writeUserToLine(PlayerProfile profile, @NotNull String playerName, @Nullable UUID uuid, StringBuilder writer) {
writer.append(playerName).append(":");
writer.append(profile.getSkillLevel(PrimarySkillType.MINING)).append(":");
writer.append(":");
@ -417,8 +424,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
writer.append(profile.getSkillXpLevel(PrimarySkillType.FISHING)).append(":");
writer.append((int) profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
writer.append(IGNORED).append(":"); //mob health bar
writer.append(profile.getSkillLevel(PrimarySkillType.ALCHEMY)).append(":");
writer.append(profile.getSkillXpLevel(PrimarySkillType.ALCHEMY)).append(":");
writer.append(uuid != null ? uuid.toString() : "NULL").append(":");
@ -430,7 +436,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public @NotNull List<PlayerStat> readLeaderboard(@Nullable PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException {
//Fix for a plugin that people are using that is throwing SQL errors
if(skill != null && skill.isChildSkill()) {
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
logger.severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
}
@ -465,26 +471,26 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
synchronized (fileWritingLock) {
try {
// Open the file to write the player
out = new BufferedWriter(new FileWriter(mcMMO.getUsersFilePath(), true));
out = new BufferedWriter(new FileWriter(usersFilePath, true));
String startingLevel = AdvancedConfig.getInstance().getStartingLevel() + ":";
String startingLevelStr = startingLevel + ":";
// Add the player to the end
out.append(playerName).append(":");
out.append(startingLevel); // Mining
out.append(startingLevelStr); // Mining
out.append(":");
out.append(":");
out.append("0:"); // Xp
out.append(startingLevel); // Woodcutting
out.append(startingLevelStr); // Woodcutting
out.append("0:"); // WoodCuttingXp
out.append(startingLevel); // Repair
out.append(startingLevel); // Unarmed
out.append(startingLevel); // Herbalism
out.append(startingLevel); // Excavation
out.append(startingLevel); // Archery
out.append(startingLevel); // Swords
out.append(startingLevel); // Axes
out.append(startingLevel); // Acrobatics
out.append(startingLevelStr); // Repair
out.append(startingLevelStr); // Unarmed
out.append(startingLevelStr); // Herbalism
out.append(startingLevelStr); // Excavation
out.append(startingLevelStr); // Archery
out.append(startingLevelStr); // Swords
out.append(startingLevelStr); // Axes
out.append(startingLevelStr); // Acrobatics
out.append("0:"); // RepairXp
out.append("0:"); // UnarmedXp
out.append("0:"); // HerbalismXp
@ -494,7 +500,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.append("0:"); // AxesXp
out.append("0:"); // AcrobaticsXp
out.append(":");
out.append(startingLevel); // Taming
out.append(startingLevelStr); // Taming
out.append("0:"); // TamingXp
out.append("0:"); // DATS
out.append("0:"); // DATS
@ -504,12 +510,12 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.append("0:"); // DATS
out.append("0:"); // DATS
out.append(":");
out.append(startingLevel); // Fishing
out.append(startingLevelStr); // Fishing
out.append("0:"); // FishingXp
out.append("0:"); // Blast Mining
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin
out.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":"); // Mob Healthbar HUD
out.append(startingLevel); // Alchemy
out.append(IGNORED).append(":"); // Mob Healthbar HUD
out.append(startingLevelStr); // Alchemy
out.append("0:"); // AlchemyXp
out.append(uuid != null ? uuid.toString() : "NULL").append(":"); // UUID
out.append("0:"); // Scoreboard tips shown
@ -543,7 +549,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
private @NotNull PlayerProfile loadPlayerByUUID(@NotNull UUID uuid, @Nullable String playerName) {
BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
@ -580,7 +585,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
/* Check for nickname changes and update since we are here anyways */
if (!rawSplitData[USERNAME_INDEX].equalsIgnoreCase(playerName)) {
//mcMMO.p.getLogger().info("Name updated for player: " + rawSplitData[USERNAME_INDEX] + " => " + playerName);
//logger.info("Name updated for player: " + rawSplitData[USERNAME_INDEX] + " => " + playerName);
rawSplitData[USERNAME_INDEX] = playerName;
}
@ -610,7 +615,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
private @NotNull PlayerProfile loadPlayerByName(@NotNull String playerName) {
BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
@ -661,7 +665,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public void convertUsers(DatabaseManager destination) {
BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath();
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
@ -706,7 +709,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
int i = 0;
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
@ -718,8 +720,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
String[] character = line.split(":");
if (!worked && character[USERNAME_INDEX].equalsIgnoreCase(userName)) {
if (character.length < 42) {
mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!");
mcMMO.p.getLogger().severe("Database entry is invalid.");
logger.severe("Could not update UUID for " + userName + "!");
logger.severe("Database entry is invalid.");
continue;
}
@ -735,10 +737,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
}
catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
mcMMO.p.getLogger().info(i + " entries written while saving UUID for " + userName);
logger.info(i + " entries written while saving UUID for " + userName);
if (in != null) {
try {
in.close();
@ -764,7 +766,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs) {
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
int i = 0;
synchronized (fileWritingLock) {
@ -777,8 +778,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
String[] character = line.split(":");
if (!fetchedUUIDs.isEmpty() && fetchedUUIDs.containsKey(character[USERNAME_INDEX])) {
if (character.length < 42) {
mcMMO.p.getLogger().severe("Could not update UUID for " + character[USERNAME_INDEX] + "!");
mcMMO.p.getLogger().severe("Database entry is invalid.");
logger.severe("Could not update UUID for " + character[USERNAME_INDEX] + "!");
logger.severe("Database entry is invalid.");
continue;
}
@ -794,10 +795,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
}
catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
mcMMO.p.getLogger().info(i + " entries written while saving UUID batch");
logger.info(i + " entries written while saving UUID batch");
if (in != null) {
try {
in.close();
@ -823,7 +824,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<>();
BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
@ -862,7 +862,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
return;
}
String usersFilePath = mcMMO.getUsersFilePath();
lastUpdate = System.currentTimeMillis(); // Log when the last update was run
powerLevels.clear(); // Clear old values from the power levels
@ -894,7 +893,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
playerName = data[USERNAME_INDEX];
int powerLevel = 0;
Map<PrimarySkillType, Integer> skills = getSkillMapFromLine(data);
Map<Skill, Integer> skills = getSkillMapFromLine(data);
powerLevel += putStat(acrobatics, playerName, skills.get(PrimarySkillType.ACROBATICS));
powerLevel += putStat(alchemy, playerName, skills.get(PrimarySkillType.ALCHEMY));
@ -914,7 +913,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString());
logger.severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e);
}
finally {
if (in != null) {
@ -969,7 +968,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
if (usersFile.exists()) {
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
@ -996,14 +994,14 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
//Not enough data found to be considered a user reliably (NOTE: not foolproof)
if(rawSplitData.length < (UUID_INDEX + 1)) {
if(!corruptDataFound) {
mcMMO.p.getLogger().severe("Some corrupt data was found in mcmmo.users and has been repaired, it is possible that some player data has been lost in this process.");
logger.severe("Some corrupt data was found in mcmmo.users and has been repaired, it is possible that some player data has been lost in this process.");
corruptDataFound = true;
}
if(rawSplitData.length >= 10 //The value here is kind of arbitrary, it shouldn't be too low to avoid false positives, but also we aren't really going to correctly identify when player data has been corrupted or not with 100% accuracy ever
&& rawSplitData[0] != null && !rawSplitData[0].isEmpty()) {
if(rawSplitData[0].length() <= 16 && rawSplitData[0].length() >= 3) {
mcMMO.p.getLogger().severe("Not enough data found to recover corrupted player data for user: "+rawSplitData[0]);
logger.severe("Not enough data found to recover corrupted player data for user: "+rawSplitData[0]);
}
}
//This user may have had a name so declare it
@ -1016,7 +1014,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
//TODO: Check if the commented out code was even necessary
rawSplitData[USERNAME_INDEX] = "_INVALID_OLD_USERNAME_'";
if (rawSplitData.length < UUID_INDEX + 1 || rawSplitData[UUID_INDEX].equals("NULL")) {
mcMMO.p.getLogger().severe("Fixing duplicate player names found in mcmmo.users");
logger.severe("Fixing duplicate player names found in mcmmo.users");
continue;
}
}
@ -1026,8 +1024,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
&& (!rawSplitData[UUID_INDEX].isEmpty()
&& !rawSplitData[UUID_INDEX].equals("NULL") && !players.add(rawSplitData[UUID_INDEX]))) {
mcMMO.p.getLogger().severe("Removing duplicate player data from mcmmo.users");
mcMMO.p.getLogger().info("Duplicate Data: "+line);
logger.severe("Removing duplicate player data from mcmmo.users");
logger.info("Duplicate Data: "+line);
continue;
}
@ -1049,7 +1047,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
}
catch (IOException e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
}
finally {
if (in != null) {
@ -1072,7 +1070,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
if(corruptDataFound)
mcMMO.p.getLogger().info("Corrupt data was found and removed, everything should be working fine. It is possible some player data was lost.");
logger.info("Corrupt data was found and removed, everything should be working fine. It is possible some player data was lost.");
return;
}
@ -1080,8 +1078,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
usersFile.getParentFile().mkdir();
try {
mcMMO.p.debug("Creating mcmmo.users file...");
new File(mcMMO.getUsersFilePath()).createNewFile();
logger.info("Creating mcmmo.users file...");
new File(usersFilePath).createNewFile();
}
catch (IOException e) {
e.printStackTrace();
@ -1119,11 +1117,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
private PlayerProfile loadFromLine(@NotNull String[] character) {
Map<PrimarySkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
Map<Skill, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<Skill, Float> skillsXp = new HashMap<>(); // Skill & XP
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
Map<UniqueDataType, Integer> uniquePlayerDataMap = new EnumMap<>(UniqueDataType.class);
MobHealthbarType mobHealthbarType;
int scoreboardTipsShown;
String username = character[USERNAME_INDEX];
@ -1155,12 +1152,12 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
// Acrobatics - Unused
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.BLAST_MINING, COOLDOWN_BLAST_MINING, username);
try {
mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]);
}
catch (Exception e) {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
}
// try {
// mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]);
// }
// catch (Exception e) {
// mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
// }
UUID uuid;
try {
@ -1184,44 +1181,45 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
uniquePlayerDataMap.put(UniqueDataType.CHIMAERA_WING_DATS, 0);
}
return new PlayerProfile(character[USERNAME_INDEX], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown, uniquePlayerDataMap);
return new PlayerProfile(character[USERNAME_INDEX], uuid, skills, skillsXp, skillsDATS, null, scoreboardTipsShown, uniquePlayerDataMap);
}
private void tryLoadSkillCooldownFromRawData(@NotNull Map<SuperAbilityType, Integer> cooldownMap, @NotNull String[] character, @NotNull SuperAbilityType superAbilityType, int cooldownSuperBreaker, @NotNull String userName) {
try {
cooldownMap.put(superAbilityType, Integer.valueOf(character[cooldownSuperBreaker]));
} catch (NumberFormatException e) {
mcMMO.p.getLogger().severe("Data corruption when trying to load the value for skill "+superAbilityType.toString()+" for player named " + userName+ " setting value to zero");
logger.severe("Data corruption when trying to load the value for skill "+superAbilityType+" for player named " + userName+ " setting value to zero");
e.printStackTrace();
}
}
private void tryLoadSkillFloatValuesFromRawData(@NotNull Map<PrimarySkillType, Float> skillMap, @NotNull String[] character, @NotNull PrimarySkillType primarySkillType, int index, @NotNull String userName) {
private void tryLoadSkillFloatValuesFromRawData(@NotNull Map<Skill, Float> skillMap, @NotNull String[] character, @NotNull Skill primarySkillType, int index, @NotNull String userName) {
try {
float valueFromString = Integer.parseInt(character[index]);
skillMap.put(primarySkillType, valueFromString);
} catch (NumberFormatException e) {
skillMap.put(primarySkillType, 0F);
mcMMO.p.getLogger().severe("Data corruption when trying to load the value for skill "+primarySkillType.toString()+" for player named " + userName+ " setting value to zero");
logger.severe("Data corruption when trying to load the value for skill "+primarySkillType+" for player named " + userName+ " setting value to zero");
e.printStackTrace();
}
}
private void tryLoadSkillIntValuesFromRawData(@NotNull Map<PrimarySkillType, Integer> skillMap, @NotNull String[] character, @NotNull PrimarySkillType primarySkillType, int index, @NotNull String userName) {
private void tryLoadSkillIntValuesFromRawData(@NotNull Map<Skill, Integer> skillMap, @NotNull String[] character, @NotNull Skill skill, int index, @NotNull String userName) {
try {
int valueFromString = Integer.parseInt(character[index]);
skillMap.put(primarySkillType, valueFromString);
skillMap.put(skill, valueFromString);
} catch (NumberFormatException e) {
skillMap.put(primarySkillType, 0);
mcMMO.p.getLogger().severe("Data corruption when trying to load the value for skill "+primarySkillType.toString()+" for player named " + userName+ " setting value to zero");
skillMap.put(skill, 0);
logger.severe("Data corruption when trying to load the value for skill "+skill+" for player named " + userName+ " setting value to zero");
e.printStackTrace();
}
}
private @NotNull Map<PrimarySkillType, Integer> getSkillMapFromLine(@NotNull String[] character) {
Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
private @NotNull Map<Skill, Integer> getSkillMapFromLine(@NotNull String[] character) {
HashMap<Skill, Integer> skills = new HashMap<>(); // Skill & Level
String username = character[USERNAME_INDEX];
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ACROBATICS, SKILLS_ACROBATICS, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.TAMING, SKILLS_TAMING, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.MINING, SKILLS_MINING, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.REPAIR, SKILLS_REPAIR, username);
@ -1232,7 +1230,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ARCHERY, SKILLS_ARCHERY, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.SWORDS, SKILLS_SWORDS, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.AXES, SKILLS_AXES, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ACROBATICS, SKILLS_ACROBATICS, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.FISHING, SKILLS_FISHING, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ALCHEMY, SKILLS_ALCHEMY, username);
@ -1243,93 +1240,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
return DatabaseType.FLATFILE;
}
public File getUsersFile() {
return usersFile;
}
@Override
public void onDisable() { }
private int getSkillIndex(PrimarySkillType skill) {
switch (skill) {
case ACROBATICS:
return SKILLS_ACROBATICS;
case ALCHEMY:
return SKILLS_ALCHEMY;
case ARCHERY:
return SKILLS_ARCHERY;
case AXES:
return SKILLS_AXES;
case EXCAVATION:
return SKILLS_EXCAVATION;
case FISHING:
return SKILLS_FISHING;
case HERBALISM:
return SKILLS_HERBALISM;
case MINING:
return SKILLS_MINING;
case REPAIR:
return SKILLS_REPAIR;
case SWORDS:
return SKILLS_SWORDS;
case TAMING:
return SKILLS_TAMING;
case UNARMED:
return SKILLS_UNARMED;
case WOODCUTTING:
return SKILLS_WOODCUTTING;
default:
throw new RuntimeException("Primary Skills only");
}
}
public void resetMobHealthSettings() {
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
in = new BufferedReader(new FileReader(usersFilePath));
StringBuilder writer = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
// Remove empty lines from the file
if (line.isEmpty()) {
continue;
}
String[] character = line.split(":");
character[HEALTHBAR] = Config.getInstance().getMobHealthbarDefault().toString();
line = org.apache.commons.lang.StringUtils.join(character, ":") + ":";
writer.append(line).append("\r\n");
}
// Write the new file
out = new FileWriter(usersFilePath);
out.write(writer.toString());
}
catch (IOException e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
}
finally {
if (in != null) {
try {
in.close();
}
catch (IOException e) {
// Ignore
}
}
if (out != null) {
try {
out.close();
}
catch (IOException e) {
// Ignore
}
}
}
}
}
}

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
@ -11,6 +9,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.player.UniqueDataType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
import com.gmail.nossr50.util.Misc;
@ -30,7 +29,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
public static final String MOBHEALTHBAR_VARCHAR = "VARCHAR(50)";
public static final String UUID_VARCHAR = "VARCHAR(36)";
public static final String USER_VARCHAR = "VARCHAR(40)";
private final String tablePrefix = Config.getInstance().getMySQLTablePrefix();
private final String tablePrefix = mcMMO.p.getGeneralConfig().getMySQLTablePrefix();
private final Map<UUID, Integer> cachedUserIDs = new HashMap<>();
@ -45,10 +44,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
private final String CHARSET_SQL = "utf8mb4"; //This is compliant with UTF-8 while "utf8" is not, confusing but this is how it is.
protected SQLDatabaseManager() {
String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName()
+ ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
if(Config.getInstance().getMySQLSSL())
if(mcMMO.p.getGeneralConfig().getMySQLSSL())
connectionString +=
"?verifyServerCertificate=false"+
"&useSSL=true"+
@ -67,16 +66,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
//throw e; // aborts onEnable() Riking if you want to do this, fully implement it.
}
debug = Config.getInstance().getMySQLDebug();
debug = mcMMO.p.getGeneralConfig().getMySQLDebug();
PoolProperties poolProperties = new PoolProperties();
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
poolProperties.setUrl(connectionString);
poolProperties.setUsername(Config.getInstance().getMySQLUserName());
poolProperties.setPassword(Config.getInstance().getMySQLUserPassword());
poolProperties.setMaxIdle(Config.getInstance().getMySQLMaxPoolSize(PoolIdentifier.MISC));
poolProperties.setMaxActive(Config.getInstance().getMySQLMaxConnections(PoolIdentifier.MISC));
poolProperties.setUsername(mcMMO.p.getGeneralConfig().getMySQLUserName());
poolProperties.setPassword(mcMMO.p.getGeneralConfig().getMySQLUserPassword());
poolProperties.setMaxIdle(mcMMO.p.getGeneralConfig().getMySQLMaxPoolSize(PoolIdentifier.MISC));
poolProperties.setMaxActive(mcMMO.p.getGeneralConfig().getMySQLMaxConnections(PoolIdentifier.MISC));
poolProperties.setInitialSize(0);
poolProperties.setMaxWait(-1);
poolProperties.setRemoveAbandoned(true);
@ -88,11 +86,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties = new PoolProperties();
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
poolProperties.setUrl(connectionString);
poolProperties.setUsername(Config.getInstance().getMySQLUserName());
poolProperties.setPassword(Config.getInstance().getMySQLUserPassword());
poolProperties.setUsername(mcMMO.p.getGeneralConfig().getMySQLUserName());
poolProperties.setPassword(mcMMO.p.getGeneralConfig().getMySQLUserPassword());
poolProperties.setInitialSize(0);
poolProperties.setMaxIdle(Config.getInstance().getMySQLMaxPoolSize(PoolIdentifier.SAVE));
poolProperties.setMaxActive(Config.getInstance().getMySQLMaxConnections(PoolIdentifier.SAVE));
poolProperties.setMaxIdle(mcMMO.p.getGeneralConfig().getMySQLMaxPoolSize(PoolIdentifier.SAVE));
poolProperties.setMaxActive(mcMMO.p.getGeneralConfig().getMySQLMaxConnections(PoolIdentifier.SAVE));
poolProperties.setMaxWait(-1);
poolProperties.setRemoveAbandoned(true);
poolProperties.setRemoveAbandonedTimeout(60);
@ -103,11 +101,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties = new PoolProperties();
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
poolProperties.setUrl(connectionString);
poolProperties.setUsername(Config.getInstance().getMySQLUserName());
poolProperties.setPassword(Config.getInstance().getMySQLUserPassword());
poolProperties.setUsername(mcMMO.p.getGeneralConfig().getMySQLUserName());
poolProperties.setPassword(mcMMO.p.getGeneralConfig().getMySQLUserPassword());
poolProperties.setInitialSize(0);
poolProperties.setMaxIdle(Config.getInstance().getMySQLMaxPoolSize(PoolIdentifier.LOAD));
poolProperties.setMaxActive(Config.getInstance().getMySQLMaxConnections(PoolIdentifier.LOAD));
poolProperties.setMaxIdle(mcMMO.p.getGeneralConfig().getMySQLMaxPoolSize(PoolIdentifier.LOAD));
poolProperties.setMaxActive(mcMMO.p.getGeneralConfig().getMySQLMaxConnections(PoolIdentifier.LOAD));
poolProperties.setMaxWait(-1);
poolProperties.setRemoveAbandoned(true);
poolProperties.setRemoveAbandonedTimeout(60);
@ -115,11 +113,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties.setValidationQuery("SELECT 1");
poolProperties.setValidationInterval(30000);
loadPool = new DataSource(poolProperties);
}
@Override
public void init() {
checkStructure();
}
public void purgePowerlessUsers() {
public int purgePowerlessUsers() {
massUpdateLock.lock();
mcMMO.p.getLogger().info("Purging powerless users...");
@ -152,11 +153,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
return purged;
}
public void purgeOldUsers() {
massUpdateLock.lock();
mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000000L) + " months...");
mcMMO.p.getLogger().info("Purging inactive users older than " + (mcMMO.p.getPurgeTime() / 2630000000L) + " months...");
Connection connection = null;
Statement statement = null;
@ -171,7 +173,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
"WHERE ((UNIX_TIMESTAMP() - lastlogin) > " + PURGE_TIME + ")");
"WHERE ((UNIX_TIMESTAMP() - lastlogin) > " + mcMMO.p.getPurgeTime() + ")");
}
catch (SQLException ex) {
printErrors(ex);
@ -331,7 +333,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?");
statement.setString(1, profile.getMobHealthbarType() == null ? Config.getInstance().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name());
statement.setString(1, profile.getMobHealthbarType() == null ? mcMMO.p.getGeneralConfig().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name());
statement.setInt(2, profile.getScoreboardTipsShown());
statement.setInt(3, id);
success = (statement.executeUpdate() != 0);
@ -818,7 +820,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement = connection.prepareStatement("SELECT table_name FROM INFORMATION_SCHEMA.TABLES"
+ " WHERE table_schema = ?"
+ " AND table_name = ?");
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "users");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -834,21 +836,21 @@ public final class SQLDatabaseManager implements DatabaseManager {
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "huds");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
createStatement = connection.createStatement();
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.p.getGeneralConfig().getMobHealthbarDefault() + "',"
+ "`scoreboardtips` int(10) NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "cooldowns");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -873,12 +875,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "skills");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
String startingLevel = "'" + AdvancedConfig.getInstance().getStartingLevel() + "'";
String totalLevel = "'" + (AdvancedConfig.getInstance().getStartingLevel() * (PrimarySkillType.values().length - PrimarySkillType.CHILD_SKILLS.size())) + "'";
String startingLevel = "'" + mcMMO.p.getAdvancedConfig().getStartingLevel() + "'";
String totalLevel = "'" + (mcMMO.p.getAdvancedConfig().getStartingLevel() * (PrimarySkillType.values().length - PrimarySkillType.CHILD_SKILLS.size())) + "'";
createStatement = connection.createStatement();
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
+ "`user_id` int(10) unsigned NOT NULL,"
@ -901,7 +903,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "experience");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -932,9 +934,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
checkDatabaseStructure(connection, updateType);
}
if (Config.getInstance().getTruncateSkills()) {
if (mcMMO.p.getGeneralConfig().getTruncateSkills()) {
for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) {
int cap = Config.getInstance().getLevelCap(skill);
int cap = mcMMO.p.getGeneralConfig().getLevelCap(skill);
if (cap != Integer.MAX_VALUE) {
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `" + skill.name().toLowerCase(Locale.ENGLISH) + "` > " + cap);
statement.executeUpdate();
@ -1083,7 +1085,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar, scoreboardtips) VALUES (?, ?, ?)");
statement.setInt(1, id);
statement.setString(2, Config.getInstance().getMobHealthbarDefault().name());
statement.setString(2, mcMMO.p.getGeneralConfig().getMobHealthbarDefault().name());
statement.setInt(3, 0);
statement.execute();
statement.close();
@ -1097,8 +1099,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException {
Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
Map<Skill, Integer> skills = new HashMap<>(); // Skill & Level
Map<Skill, Float> skillsXp = new HashMap<>(); // Skill & XP
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
Map<UniqueDataType, Integer> uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
MobHealthbarType mobHealthbarType;
@ -1158,7 +1160,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 1));
}
catch (Exception e) {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
mobHealthbarType = mcMMO.p.getGeneralConfig().getMobHealthbarDefault();
}
try {
@ -1270,7 +1272,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "'");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.p.getGeneralConfig().getMobHealthbarDefault() + "'");
}
}
@ -1579,7 +1581,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?");
statement.setString(1, Config.getInstance().getMobHealthbarDefault().toString());
statement.setString(1, mcMMO.p.getGeneralConfig().getMobHealthbarDefault().toString());
statement.executeUpdate();
}
catch (SQLException ex) {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
@ -42,7 +41,7 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
Player listeningPlayer = (Player) t;
//Party Member Check
if(Config.getInstance().isLevelUpBroadcastsPartyMembersOnly()) {
if(mcMMO.p.getGeneralConfig().isLevelUpBroadcastsPartyMembersOnly()) {
McMMOPlayer mmoListeningPlayer = UserManager.getPlayer(listeningPlayer);
if(mmoListeningPlayer == null) {
@ -68,8 +67,8 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
}
//Distance checks
if(Config.getInstance().shouldLevelUpBroadcastsRestrictDistance()) {
if(!Misc.isNear(mmoBroadcastingPlayer.getPlayer().getLocation(), listeningPlayer.getLocation(), Config.getInstance().getLevelUpBroadcastRadius())) {
if(mcMMO.p.getGeneralConfig().shouldLevelUpBroadcastsRestrictDistance()) {
if(!Misc.isNear(mmoBroadcastingPlayer.getPlayer().getLocation(), listeningPlayer.getLocation(), mcMMO.p.getGeneralConfig().getLevelUpBroadcastRadius())) {
return false;
}
}
@ -83,12 +82,12 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
return true;
} else {
//Send out to console
return Config.getInstance().shouldLevelUpBroadcastToConsole();
return mcMMO.p.getGeneralConfig().shouldLevelUpBroadcastToConsole();
}
}
private static boolean isLevelUpBroadcastsSameWorldOnly() {
return Config.getInstance().isLevelUpBroadcastsSameWorldOnly();
return mcMMO.p.getGeneralConfig().isLevelUpBroadcastsSameWorldOnly();
}
@Override

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
@ -42,7 +41,7 @@ public class PowerLevelUpBroadcastPredicate<T extends CommandSender> implements
Player listeningPlayer = (Player) t;
//Party Member Check
if(Config.getInstance().isPowerLevelUpBroadcastsPartyMembersOnly()) {
if(mcMMO.p.getGeneralConfig().isPowerLevelUpBroadcastsPartyMembersOnly()) {
McMMOPlayer mmoListeningPlayer = UserManager.getPlayer(listeningPlayer);
if(mmoListeningPlayer == null) {
@ -68,8 +67,8 @@ public class PowerLevelUpBroadcastPredicate<T extends CommandSender> implements
}
//Distance checks
if(Config.getInstance().shouldPowerLevelUpBroadcastsRestrictDistance()) {
if(!Misc.isNear(mmoBroadcastingPlayer.getPlayer().getLocation(), listeningPlayer.getLocation(), Config.getInstance().getPowerLevelUpBroadcastRadius())) {
if(mcMMO.p.getGeneralConfig().shouldPowerLevelUpBroadcastsRestrictDistance()) {
if(!Misc.isNear(mmoBroadcastingPlayer.getPlayer().getLocation(), listeningPlayer.getLocation(), mcMMO.p.getGeneralConfig().getPowerLevelUpBroadcastRadius())) {
return false;
}
}
@ -83,12 +82,12 @@ public class PowerLevelUpBroadcastPredicate<T extends CommandSender> implements
return true;
} else {
//Send out to console
return Config.getInstance().shouldPowerLevelUpBroadcastToConsole();
return mcMMO.p.getGeneralConfig().shouldPowerLevelUpBroadcastToConsole();
}
}
private static boolean isPowerLevelUpBroadcastsSameWorldOnly() {
return Config.getInstance().isPowerLevelUpBroadcastsSameWorldOnly();
return mcMMO.p.getGeneralConfig().isPowerLevelUpBroadcastsSameWorldOnly();
}
@Override

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.chat.SamePartyPredicate;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -204,7 +203,7 @@ public class Party {
public int getXpToLevel() {
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return (mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType)) * (getOnlineMembers().size() + Config.getInstance().getPartyXpCurveMultiplier());
return (mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType)) * (getOnlineMembers().size() + mcMMO.p.getGeneralConfig().getPartyXpCurveMultiplier());
}
public String getXpToLevelPercentage() {
@ -243,13 +242,13 @@ public class Party {
return;
}
if (!Config.getInstance().getPartyInformAllMembers()) {
if (!mcMMO.p.getGeneralConfig().getPartyInformAllMembers()) {
Player leader = mcMMO.p.getServer().getPlayer(this.leader.getUniqueId());
if (leader != null) {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (Config.getInstance().getLevelUpSoundsEnabled()) {
if (mcMMO.p.getGeneralConfig().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
}
@ -260,7 +259,7 @@ public class Party {
}
public boolean hasReachedLevelCap() {
return Config.getInstance().getPartyLevelCap() < getLevel() + 1;
return mcMMO.p.getGeneralConfig().getPartyLevelCap() < getLevel() + 1;
}
public void setXpShareMode(ShareMode xpShareMode) {
@ -386,7 +385,7 @@ public class Party {
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
double range = mcMMO.p.getGeneralConfig().getPartyShareRange();
for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.entity.Player;
@ -19,7 +19,7 @@ public enum PartyFeature {
}
public String getFeatureLockedLocaleString() {
return LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Party.Feature.Locked." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""), Config.getInstance().getPartyFeatureUnlockLevel(this)));
return LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Party.Feature.Locked." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""), mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(this)));
}
public boolean hasPermission(Player player) {

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.entity.Player;
@ -12,7 +12,7 @@ public class PartyTeleportRecord {
public PartyTeleportRecord() {
requestor = null;
enabled = true;
confirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
confirmRequired = mcMMO.p.getGeneralConfig().getPTPCommandConfirmRequired();
timeout = 0;
lastUse = 0;
}

View File

@ -1,9 +1,7 @@
package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.chat.author.PlayerAuthor;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
@ -200,9 +198,9 @@ public class McMMOPlayer implements Identified {
{
//Check if they've reached the power level cap just now
if(hasReachedPowerLevelCap()) {
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.PowerLevel", String.valueOf(Config.getInstance().getPowerLevelCap()));
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.PowerLevel", String.valueOf(mcMMO.p.getGeneralConfig().getPowerLevelCap()));
} else if(hasReachedLevelCap(primarySkillType)) {
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.Skill", String.valueOf(Config.getInstance().getLevelCap(primarySkillType)), primarySkillType.getName());
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.Skill", String.valueOf(mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType)), primarySkillType.getName());
}
//Updates from Party sources
@ -537,7 +535,7 @@ public class McMMOPlayer implements Identified {
if(hasReachedPowerLevelCap())
return true;
return getSkillLevel(primarySkillType) >= Config.getInstance().getLevelCap(primarySkillType);
return getSkillLevel(primarySkillType) >= mcMMO.p.getGeneralConfig().getLevelCap(primarySkillType);
}
/**
@ -546,7 +544,7 @@ public class McMMOPlayer implements Identified {
* @return true if they have reached the power level cap
*/
public boolean hasReachedPowerLevelCap() {
return this.getPowerLevel() >= Config.getInstance().getPowerLevelCap();
return this.getPowerLevel() >= mcMMO.p.getGeneralConfig().getPowerLevelCap();
}
/**
@ -597,7 +595,7 @@ public class McMMOPlayer implements Identified {
return;
}
if (!Config.getInstance().getPartyXpNearMembersNeeded() || !PartyManager.getNearMembers(this).isEmpty()) {
if (!mcMMO.p.getGeneralConfig().getPartyXpNearMembersNeeded() || !PartyManager.getNearMembers(this).isEmpty()) {
party.applyXpGain(modifyXpGain(skill, xp));
}
}
@ -666,7 +664,7 @@ public class McMMOPlayer implements Identified {
return;
}
if (Config.getInstance().getLevelUpSoundsEnabled()) {
if (mcMMO.p.getGeneralConfig().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
}
@ -787,13 +785,13 @@ public class McMMOPlayer implements Identified {
private float modifyXpGain(PrimarySkillType primarySkillType, float xp) {
//TODO: A rare situation can occur where the default Power Level cap can prevent a player with one skill edited to something silly like Integer.MAX_VALUE from gaining XP in any skill, we may need to represent power level with another data type
if ((primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType))
|| (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|| (mcMMO.p.getGeneralConfig().getPowerLevelCap() <= getPowerLevel())) {
return 0;
}
xp = (float) (xp / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
if (Config.getInstance().getToolModsEnabled()) {
if (mcMMO.p.getGeneralConfig().getToolModsEnabled()) {
CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand());
if (tool != null) {
@ -863,8 +861,8 @@ public class McMMOPlayer implements Identified {
}
//These values change depending on whether or not the server is in retro mode
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int abilityLengthVar = mcMMO.p.getAdvancedConfig().getAbilityLength();
int abilityLengthCap = mcMMO.p.getAdvancedConfig().getAbilityLengthCap();
int ticks;
@ -881,7 +879,7 @@ public class McMMOPlayer implements Identified {
//player.sendMessage(ability.getAbilityOn());
}
if (AdvancedConfig.getInstance().sendAbilityNotificationToOtherPlayers()) {
if (mcMMO.p.getAdvancedConfig().sendAbilityNotificationToOtherPlayers()) {
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayer());
}
@ -905,7 +903,7 @@ public class McMMOPlayer implements Identified {
return;
}
if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
if (mcMMO.p.getGeneralConfig().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
return;
}
@ -942,7 +940,7 @@ public class McMMOPlayer implements Identified {
}
}
if (Config.getInstance().getAbilityMessagesEnabled()) {
if (mcMMO.p.getGeneralConfig().getAbilityMessagesEnabled()) {
/*
*
* IF THE TOOL IS AN AXE
@ -1099,7 +1097,7 @@ public class McMMOPlayer implements Identified {
UserManager.remove(thisPlayer);
if(Config.getInstance().getScoreboardsEnabled())
if(mcMMO.p.getGeneralConfig().getScoreboardsEnabled())
ScoreboardManager.teardownPlayer(thisPlayer);
if (inParty()) {

View File

@ -1,18 +1,19 @@
package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.experience.SkillXpGain;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -32,14 +33,14 @@ public class PlayerProfile {
private int saveAttempts = 0;
/* Skill Data */
private final Map<PrimarySkillType, Integer> skills = new HashMap<>(); // Skill & Level
private final Map<PrimarySkillType, Float> skillsXp = new HashMap<>(); // Skill & XP
private final Map<Skill, Integer> skills = new HashMap<>(); // Skill & Level
private final Map<Skill, Float> skillsXp = new HashMap<>(); // Skill & XP
private final Map<SuperAbilityType, Integer> abilityDATS = new HashMap<>(); // Ability & Cooldown
private final Map<UniqueDataType, Integer> uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
// Store previous XP gains for diminished returns
private final DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<>();
private final HashMap<PrimarySkillType, Float> rollingSkillsXp = new HashMap<>();
private final HashMap<Skill, Float> rollingSkillsXp = new HashMap<>();
@Deprecated
public PlayerProfile(String playerName) {
@ -50,7 +51,7 @@ public class PlayerProfile {
this.uuid = uuid;
this.playerName = playerName;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
mobHealthbarType = mcMMO.p.getGeneralConfig().getMobHealthbarDefault();
scoreboardTipsShown = 0;
for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
@ -58,7 +59,7 @@ public class PlayerProfile {
}
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
skills.put(primarySkillType, AdvancedConfig.getInstance().getStartingLevel());
skills.put(primarySkillType, mcMMO.p.getAdvancedConfig().getStartingLevel());
skillsXp.put(primarySkillType, 0F);
}
@ -67,20 +68,20 @@ public class PlayerProfile {
}
@Deprecated
public PlayerProfile(String playerName, boolean isLoaded) {
public PlayerProfile(@NotNull String playerName, boolean isLoaded) {
this(playerName);
this.loaded = isLoaded;
}
public PlayerProfile(String playerName, UUID uuid, boolean isLoaded) {
public PlayerProfile(@NotNull String playerName, UUID uuid, boolean isLoaded) {
this(playerName, uuid);
this.loaded = isLoaded;
}
public PlayerProfile(String playerName, UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData) {
public PlayerProfile(@NotNull String playerName, UUID uuid, Map<Skill, Integer> levelData, Map<Skill, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, @Nullable MobHealthbarType mobHealthbarType, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData) {
this.playerName = playerName;
this.uuid = uuid;
this.mobHealthbarType = mobHealthbarType;
mobHealthbarType = mcMMO.p.getGeneralConfig().getMobHealthbarDefault();
this.scoreboardTipsShown = scoreboardTipsShown;
skills.putAll(levelData);

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
@ -33,7 +33,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public enum PrimarySkillType {
public enum PrimarySkillType implements Skill {
ACROBATICS(AcrobaticsManager.class, Color.WHITE,
ImmutableList.of(SubSkillType.ACROBATICS_DODGE, SubSkillType.ACROBATICS_ROLL)),
ALCHEMY(AlchemyManager.class, Color.FUCHSIA,
@ -122,6 +122,14 @@ public enum PrimarySkillType {
this.subSkillTypes = subSkillTypes;
}
public PrimarySkillType getPrimarySkill() {
return this;
}
public String getPrimaryKeyName() {
return StringUtils.getCapitalized(this.toString());
}
public Class<? extends SkillManager> getManagerClass() {
return managerClass;
}
@ -136,37 +144,37 @@ public enum PrimarySkillType {
* @return the max level of this skill
*/
public int getMaxLevel() {
return Config.getInstance().getLevelCap(this);
return mcMMO.p.getGeneralConfig().getLevelCap(this);
}
public boolean isSuperAbilityUnlocked(Player player) { return RankUtils.getRank(player, getAbility().getSubSkillTypeDefinition()) >= 1; }
public boolean getPVPEnabled() {
return Config.getInstance().getPVPEnabled(this);
return mcMMO.p.getGeneralConfig().getPVPEnabled(this);
}
public boolean getPVEEnabled() {
return Config.getInstance().getPVEEnabled(this);
return mcMMO.p.getGeneralConfig().getPVEEnabled(this);
}
public boolean getDoubleDropsDisabled() {
return Config.getInstance().getDoubleDropsDisabled(this);
return mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(this);
}
public boolean getHardcoreStatLossEnabled() {
return Config.getInstance().getHardcoreStatLossEnabled(this);
return mcMMO.p.getGeneralConfig().getHardcoreStatLossEnabled(this);
}
public void setHardcoreStatLossEnabled(boolean enable) {
Config.getInstance().setHardcoreStatLossEnabled(this, enable);
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(this, enable);
}
public boolean getHardcoreVampirismEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled(this);
return mcMMO.p.getGeneralConfig().getHardcoreVampirismEnabled(this);
}
public void setHardcoreVampirismEnabled(boolean enable) {
Config.getInstance().setHardcoreVampirismEnabled(this, enable);
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(this, enable);
}
public ToolType getTool() {
@ -182,7 +190,7 @@ public enum PrimarySkillType {
}
public static PrimarySkillType getSkill(String skillName) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
if (!mcMMO.p.getGeneralConfig().getLocale().equalsIgnoreCase("en_US")) {
for (PrimarySkillType type : values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) {
return type;
@ -215,42 +223,17 @@ public enum PrimarySkillType {
}
}
public static PrimarySkillType bySecondaryAbility(SubSkillType subSkillType) {
for (PrimarySkillType type : values()) {
if (type.getSkillAbilities().contains(subSkillType)) {
return type;
}
}
return null;
}
public static PrimarySkillType byAbility(SuperAbilityType ability) {
for (PrimarySkillType type : values()) {
if (type.getAbility() == ability) {
return type;
}
}
return null;
}
public String getName() {
return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
}
// public String getName() {
// return StringUtils.getCapitalized(StringUtils.getCapitalized(this.toString()));
// }
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
/* public void celebrateLevelUp(Player player) {
ParticleEffectUtils.fireworkParticleShower(player, skillColor);
}*/
public boolean shouldProcess(Entity target) {
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? getPVPEnabled() : getPVEEnabled();
}
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.text.StringUtils;
@ -135,7 +136,7 @@ public enum SubSkillType {
* If we add skills, those immutable lists need to be updated
* @return
*/
public PrimarySkillType getParentSkill() { return PrimarySkillType.bySecondaryAbility(this); }
public PrimarySkillType getParentSkill() { return Skill.bySecondaryAbility(this); }
/**
* Returns the root address for this skill in the advanced.yml file

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
@ -112,11 +111,11 @@ public enum SuperAbilityType {
}
public int getCooldown() {
return Config.getInstance().getCooldown(this);
return mcMMO.p.getGeneralConfig().getCooldown(this);
}
public int getMaxLength() {
return Config.getInstance().getMaxLength(this);
return mcMMO.p.getGeneralConfig().getMaxLength(this);
}
public String getAbilityOn() {

View File

@ -1,6 +1,18 @@
package com.gmail.nossr50.datatypes.skills.interfaces;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface Skill {
/**
@ -14,4 +26,88 @@ public interface Skill {
* @return config file key name
*/
String getPrimaryKeyName();
Class<? extends SkillManager> getManagerClass();
SuperAbilityType getAbility();
/**
* Get the max level of this skill.
*
* @return the max level of this skill
*/
int getMaxLevel();
boolean isSuperAbilityUnlocked(Player player);
boolean getPVPEnabled();
boolean getPVEEnabled();
boolean getDoubleDropsDisabled();
boolean getHardcoreStatLossEnabled();
void setHardcoreStatLossEnabled(boolean enable);
boolean getHardcoreVampirismEnabled();
void setHardcoreVampirismEnabled(boolean enable);
ToolType getTool();
List<SubSkillType> getSkillAbilities();
double getXpModifier();
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
boolean isChildSkill();
static PrimarySkillType bySecondaryAbility(SubSkillType subSkillType) {
for (PrimarySkillType type : PrimarySkillType.values()) {
if (type.getSkillAbilities().contains(subSkillType)) {
return type;
}
}
return null;
}
static PrimarySkillType byAbility(SuperAbilityType ability) {
for (PrimarySkillType type : PrimarySkillType.values()) {
if (type.getAbility() == ability) {
return type;
}
}
return null;
}
static PrimarySkillType getSkill(@NotNull String skillName) {
if (!mcMMO.p.getGeneralConfig().getLocale().equalsIgnoreCase("en_US")) {
for (PrimarySkillType type : PrimarySkillType.values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) {
return type;
}
}
}
for (PrimarySkillType type : PrimarySkillType.values()) {
if (type.name().equalsIgnoreCase(skillName)) {
return type;
}
}
if (!skillName.equalsIgnoreCase("all")) {
mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize
}
return null;
}
String getName();
boolean getPermissions(Player player);
boolean shouldProcess(Entity target);
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills.subskills.acrobatics;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -8,8 +7,11 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
@ -29,12 +31,14 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SoundCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Locale;
public class Roll extends AcrobaticsSubSkill {
@ -200,7 +204,7 @@ public class Roll extends AcrobaticsSubSkill {
return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel);
}
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold());
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.p.getAdvancedConfig().getRollDamageThreshold());
if (!isFatal(player, modifiedDamage)
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) {
@ -238,7 +242,7 @@ public class Roll extends AcrobaticsSubSkill {
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold() * 2);
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.p.getAdvancedConfig().getRollDamageThreshold() * 2);
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType);
rcs.setSkillLevel(rcs.getSkillLevel() * 2); //Double the effective odds
@ -381,7 +385,7 @@ public class Roll extends AcrobaticsSubSkill {
//
// //Chance to roll at half max skill
// RandomChanceSkill rollHalfMaxSkill = new RandomChanceSkill(null, subSkillType);
// int halfMaxSkillValue = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL)/2;
// int halfMaxSkillValue = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL)/2;
// rollHalfMaxSkill.setSkillLevel(halfMaxSkillValue);
//
// //Chance to graceful roll at full skill
@ -395,11 +399,11 @@ public class Roll extends AcrobaticsSubSkill {
// //Chance Stat Calculations
// rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
// graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
// damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
// damageThreshold = mcMMO.p.getAdvancedConfig().getRollDamageThreshold();
//
// chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
//
// double maxLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
// double maxLevel = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
//
// return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2,halfMaxSkillValue);
}
@ -436,4 +440,98 @@ public class Roll extends AcrobaticsSubSkill {
{
return player.getLocation().getBlock().getLocation();
}
public String getPrimaryKeyName() {
return getPrimarySkill().getPrimaryKeyName();
}
@Override
public Class<? extends SkillManager> getManagerClass() {
return getPrimarySkill().getManagerClass();
}
@Override
public SuperAbilityType getAbility() {
return getPrimarySkill().getAbility();
}
@Override
public int getMaxLevel() {
return getPrimarySkill().getMaxLevel();
}
@Override
public boolean isSuperAbilityUnlocked(Player player) {
return getPrimarySkill().isSuperAbilityUnlocked(player);
}
@Override
public boolean getPVPEnabled() {
return getPrimarySkill().getPVPEnabled();
}
@Override
public boolean getPVEEnabled() {
return getPrimarySkill().getPVEEnabled();
}
@Override
public boolean getDoubleDropsDisabled() {
return getPrimarySkill().getDoubleDropsDisabled();
}
@Override
public boolean getHardcoreStatLossEnabled() {
return getPrimarySkill().getHardcoreStatLossEnabled();
}
@Override
public void setHardcoreStatLossEnabled(boolean enable) {
getPrimarySkill().setHardcoreStatLossEnabled(enable);
}
@Override
public boolean getHardcoreVampirismEnabled() {
return getPrimarySkill().getHardcoreVampirismEnabled();
}
@Override
public void setHardcoreVampirismEnabled(boolean enable) {
getPrimarySkill().setHardcoreVampirismEnabled(enable);
}
@Override
public ToolType getTool() {
return getPrimarySkill().getTool();
}
@Override
public List<SubSkillType> getSkillAbilities() {
return getPrimarySkill().getSkillAbilities();
}
@Override
public double getXpModifier() {
return getPrimarySkill().getXpModifier();
}
@Override
public boolean isChildSkill() {
return getPrimarySkill().isChildSkill();
}
@Override
public String getName() {
return getPrimarySkill().getName();
}
@Override
public boolean getPermissions(Player player) {
return getPrimarySkill().getPermissions(player);
}
@Override
public boolean shouldProcess(Entity target) {
return getPrimarySkill().shouldProcess(target);
}
}

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.events.skills.secondaryabilities;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
@ -20,7 +20,7 @@ public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable
*/
@Deprecated
public SubSkillEvent(Player player, SubSkillType subSkillType) {
super(player, PrimarySkillType.bySecondaryAbility(subSkillType));
super(player, Skill.bySecondaryAbility(subSkillType));
this.subSkillType = subSkillType;
}
@ -33,7 +33,7 @@ public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable
*/
@Deprecated
public SubSkillEvent(Player player, SubSkillType subSkillType, double resultModifier) {
super(player, PrimarySkillType.bySecondaryAbility(subSkillType));
super(player, Skill.bySecondaryAbility(subSkillType));
this.subSkillType = subSkillType;
this.resultModifier = resultModifier;
}

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
@ -79,9 +78,9 @@ public class BlockListener implements Listener {
continue;
//TODO: Ignore this abomination its rewritten in 2.2
if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType())
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType())
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType()))
if(!mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType())
&& !mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType())
&& !mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType()))
continue;
//If we suspect TEs might be duped only reward block
@ -524,7 +523,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.
*/
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.hasWoodcuttingXP(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.hasWoodcuttingXP(blockState) && mcMMO.p.getGeneralConfig().getTreeFellerSoundsEnabled()) {
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
}
}
@ -579,7 +578,7 @@ public class BlockListener implements Listener {
blockState.update(true);
}
}
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || Config.getInstance().getUnarmedItemsAsUnarmed())) {
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
if (EventUtils.simulateBlockBreak(block, player, true) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -163,7 +161,7 @@ public class EntityListener implements Listener {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
//Cleanup metadata in 1 minute in case normal collection falls through
CombatUtils.delayArrowMetaCleanup((Projectile) projectile);
@ -466,7 +464,7 @@ public class EntityListener implements Listener {
}
//Party Friendly Fire
if(!Config.getInstance().getPartyFriendlyFire())
if(!mcMMO.p.getGeneralConfig().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer)
|| PartyManager.areAllies(defendingPlayer, attackingPlayer))
&& !(Permissions.friendlyFire(attackingPlayer)

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -382,17 +381,17 @@ public class InventoryListener implements Listener {
ItemStack item = event.getItem();
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
if (mcMMO.p.getGeneralConfig().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
event.setCancelled(true);
return;
}
if (Config.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
if (mcMMO.p.getGeneralConfig().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
event.setCancelled(true);
return;
}
if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
if (mcMMO.p.getGeneralConfig().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
@ -73,11 +72,11 @@ public class PlayerListener implements Listener {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) {
//Remove scoreboards
if(Config.getInstance().getScoreboardsEnabled()) {
if(mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
ScoreboardManager.teardownPlayer(event.getPlayer());
}
return;
} else if(WorldBlacklist.isWorldBlacklisted(event.getFrom().getWorld()) && Config.getInstance().getScoreboardsEnabled()) {
} else if(WorldBlacklist.isWorldBlacklisted(event.getFrom().getWorld()) && mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
//This only fires if they are travelling to a non-blacklisted world from a blacklisted world
//Setup scoreboards
@ -93,7 +92,7 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
if (!UserManager.hasPlayerDataKey(player) || mcMMO.p.getGeneralConfig().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
return;
}
@ -292,7 +291,7 @@ public class PlayerListener implements Listener {
if(event.getCaught() != null) {
Item fishingCatch = (Item) event.getCaught();
if (Config.getInstance().getFishingOverrideTreasures() &&
if (mcMMO.p.getGeneralConfig().getFishingOverrideTreasures() &&
fishingCatch.getItemStack().getType() != Material.SALMON &&
fishingCatch.getItemStack().getType() != Material.COD &&
fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH &&
@ -565,11 +564,11 @@ public class PlayerListener implements Listener {
//Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60);
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
if (mcMMO.p.getGeneralConfig().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
}
if (plugin.isXPEventEnabled() && Config.getInstance().playerJoinEventInfo()) {
if (plugin.isXPEventEnabled() && mcMMO.p.getGeneralConfig().playerJoinEventInfo()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
}
@ -652,7 +651,7 @@ public class PlayerListener implements Listener {
case RIGHT_CLICK_BLOCK:
Material type = clickedBlock.getType();
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
if (!mcMMO.p.getGeneralConfig().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (type == Repair.anvilMaterial
&& PrimarySkillType.REPAIR.getPermissions(player)
@ -700,7 +699,7 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
type = clickedBlock.getType();
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
if (!mcMMO.p.getGeneralConfig().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
@ -794,7 +793,7 @@ public class PlayerListener implements Listener {
/* ACTIVATION & ITEM CHECKS */
if (BlockUtils.canActivateTools(blockState)) {
if (Config.getInstance().getAbilitiesEnabled()) {
if (mcMMO.p.getGeneralConfig().getAbilitiesEnabled()) {
if (BlockUtils.canActivateHerbalism(blockState)) {
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
}
@ -860,7 +859,7 @@ public class PlayerListener implements Listener {
}
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled()) {
if (mcMMO.p.getGeneralConfig().getAbilitiesEnabled()) {
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
@ -892,13 +891,13 @@ public class PlayerListener implements Listener {
Material type = heldItem.getType();
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry())) {
if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry())) {
tamingManager.summonWolf();
}
else if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry())) {
else if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry())) {
tamingManager.summonOcelot();
}
else if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry())) {
else if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry())) {
tamingManager.summonHorse();
}
@ -951,7 +950,7 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
if (!mcMMO.p.getGeneralConfig().getLocale().equalsIgnoreCase("en_US")) {
String message = event.getMessage();
String command = message.substring(1).split(" ")[0];
String lowerCaseCommand = command.toLowerCase(Locale.ENGLISH);

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -45,7 +44,7 @@ public class SelfListener implements Listener {
//Reset the delay timer
RankUtils.resetUnlockDelayTimer();
if(Config.getInstance().getScoreboardsEnabled())
if(mcMMO.p.getGeneralConfig().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill);
}
}
@ -55,7 +54,7 @@ public class SelfListener implements Listener {
Player player = event.getPlayer();
if(player.isOnline()) {
if(Config.getInstance().getScoreboardsEnabled())
if(mcMMO.p.getGeneralConfig().getScoreboardsEnabled())
ScoreboardManager.handleXp(player, event.getSkill());
}
}
@ -64,7 +63,7 @@ public class SelfListener implements Listener {
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
Player player = event.getPlayer();
if(player.isOnline()) {
if(Config.getInstance().getScoreboardsEnabled())
if(mcMMO.p.getGeneralConfig().getScoreboardsEnabled())
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.locale;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.TextUtils;
import net.kyori.adventure.text.TextComponent;
@ -130,7 +129,7 @@ public final class LocaleLoader {
if (bundle == null) {
Locale.setDefault(new Locale("en", "US"));
Locale locale = null;
String[] myLocale = Config.getInstance().getLocale().split("[-_ ]");
String[] myLocale = mcMMO.p.getGeneralConfig().getLocale().split("[-_ ]");
if (myLocale.length == 1) {
locale = new Locale(myLocale[0]);
@ -140,7 +139,7 @@ public final class LocaleLoader {
}
if (locale == null) {
throw new IllegalStateException("Failed to parse locale string '" + Config.getInstance().getLocale() + "'");
throw new IllegalStateException("Failed to parse locale string '" + mcMMO.p.getGeneralConfig().getLocale() + "'");
}
Path localePath = Paths.get(mcMMO.getLocalesDirectory() + "locale_" + locale.toString() + ".properties");

View File

@ -9,7 +9,9 @@ import com.gmail.nossr50.config.mods.BlockConfigManager;
import com.gmail.nossr50.config.mods.EntityConfigManager;
import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
import com.gmail.nossr50.config.skills.salvage.SalvageConfig;
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
@ -146,8 +148,19 @@ public class mcMMO extends JavaPlugin {
public static final String databaseCommandKey = "mcMMO: Processing Database Command";
public static FixedMetadataValue metadataValue;
private long purgeTime = 2630000000L;
public static final String ULTRA_PERMISSONS = "UltraPermissons";
private GeneralConfig generalConfig;
private AdvancedConfig advancedConfig;
private RepairConfig repairConfig;
private SalvageConfig salvageConfig;
private PersistentDataConfig persistentDataConfig;
private ChatConfig chatConfig;
private CoreSkillsConfig coreSkillsConfig;
private RankConfig rankConfig;
private TreasureConfig treasureConfig;
private FishingTreasureConfig fishingTreasureConfig;
private SoundConfig soundConfig;
public mcMMO() {
p = this;
@ -159,8 +172,12 @@ public class mcMMO extends JavaPlugin {
@Override
public void onEnable() {
try {
//Init configs
generalConfig = new GeneralConfig(getDataFolder());
advancedConfig = new AdvancedConfig(getDataFolder());
//Store this value so other plugins can check it
isRetroModeEnabled = Config.getInstance().getIsRetroMode();
isRetroModeEnabled = generalConfig.getIsRetroMode();
//Platform Manager
platformManager = new PlatformManager();
@ -206,7 +223,11 @@ public class mcMMO extends JavaPlugin {
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
}
databaseManager = DatabaseManagerFactory.getDatabaseManager();
// One month in milliseconds
this.purgeTime = 2630000000L * generalConfig.getOldUsersCutoff();
databaseManager = DatabaseManagerFactory.getDatabaseManager(mcMMO.getUsersFilePath(), getLogger(), purgeTime, mcMMO.p.getAdvancedConfig().getStartingLevel());
databaseManager.init();
//Check for the newer API and tell them what to do if its missing
checkForOutdatedAPI();
@ -246,7 +267,7 @@ public class mcMMO extends JavaPlugin {
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
if (Config.getInstance().getPTPCommandWorldPermissions()) {
if (generalConfig.getPTPCommandWorldPermissions()) {
Permissions.generateWorldTeleportPermissions();
}
@ -257,11 +278,11 @@ public class mcMMO extends JavaPlugin {
//If anonymous statistics are enabled then use them
Metrics metrics;
if(Config.getInstance().getIsMetricsEnabled()) {
if(generalConfig.getIsMetricsEnabled()) {
metrics = new Metrics(this, 3894);
metrics.addCustomChart(new SimplePie("version", () -> getDescription().getVersion()));
if(Config.getInstance().getIsRetroMode())
if(generalConfig.getIsRetroMode())
metrics.addCustomChart(new SimplePie("leveling_system", () -> "Retro"));
else
metrics.addCustomChart(new SimplePie("leveling_system", () -> "Standard"));
@ -350,7 +371,7 @@ public class mcMMO extends JavaPlugin {
PartyManager.saveParties(); // Save our parties
//TODO: Needed?
if(Config.getInstance().getScoreboardsEnabled())
if(generalConfig.getScoreboardsEnabled())
ScoreboardManager.teardownAll();
formulaManager.saveFormula();
@ -360,7 +381,7 @@ public class mcMMO extends JavaPlugin {
e.printStackTrace();
}
if (Config.getInstance().getBackupsEnabled()) {
if (generalConfig.getBackupsEnabled()) {
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try {
ZipLibrary.mcMMOBackup();
@ -532,7 +553,7 @@ public class mcMMO extends JavaPlugin {
TreasureConfig.getInstance();
FishingTreasureConfig.getInstance();
HiddenConfig.getInstance();
AdvancedConfig.getInstance();
mcMMO.p.getAdvancedConfig();
PotionConfig.getInstance();
CoreSkillsConfig.getInstance();
SoundConfig.getInstance();
@ -542,19 +563,19 @@ public class mcMMO extends JavaPlugin {
List<Repairable> repairables = new ArrayList<>();
if (Config.getInstance().getToolModsEnabled()) {
if (generalConfig.getToolModsEnabled()) {
new ToolConfigManager(this);
}
if (Config.getInstance().getArmorModsEnabled()) {
if (generalConfig.getArmorModsEnabled()) {
new ArmorConfigManager(this);
}
if (Config.getInstance().getBlockModsEnabled()) {
if (generalConfig.getBlockModsEnabled()) {
new BlockConfigManager(this);
}
if (Config.getInstance().getEntityModsEnabled()) {
if (generalConfig.getEntityModsEnabled()) {
new EntityConfigManager(this);
}
@ -609,7 +630,7 @@ public class mcMMO extends JavaPlugin {
private void registerCustomRecipes() {
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
if (Config.getInstance().getChimaeraEnabled()) {
if (generalConfig.getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
}, 40);
@ -620,7 +641,7 @@ public class mcMMO extends JavaPlugin {
long second = 20;
long minute = second * 60;
long saveIntervalTicks = Math.max(minute, Config.getInstance().getSaveInterval() * minute);
long saveIntervalTicks = Math.max(minute, generalConfig.getSaveInterval() * minute);
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
@ -628,7 +649,7 @@ public class mcMMO extends JavaPlugin {
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
// Old & Powerless User remover
long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
long purgeIntervalTicks = generalConfig.getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (purgeIntervalTicks == 0) {
new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
@ -638,7 +659,7 @@ public class mcMMO extends JavaPlugin {
}
// Automatically remove old members from parties
long kickIntervalTicks = Config.getInstance().getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
long kickIntervalTicks = generalConfig.getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
@ -655,29 +676,29 @@ public class mcMMO extends JavaPlugin {
new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60);
}
if(AdvancedConfig.getInstance().allowPlayerTips())
if(mcMMO.p.getAdvancedConfig().allowPlayerTips())
{
new NotifySquelchReminderTask().runTaskTimer(this, 60, ((20 * 60) * 60));
}
}
private void checkModConfigs() {
if (!Config.getInstance().getToolModsEnabled()) {
if (!generalConfig.getToolModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom tool config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getArmorModsEnabled()) {
if (!generalConfig.getArmorModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom armor config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getBlockModsEnabled()) {
if (!generalConfig.getBlockModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom block config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getEntityModsEnabled()) {
if (!generalConfig.getEntityModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom entity config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
@ -742,4 +763,15 @@ public class mcMMO extends JavaPlugin {
serverShutdownExecuted = bool;
}
public long getPurgeTime() {
return purgeTime;
}
public @NotNull GeneralConfig getGeneralConfig() {
return generalConfig;
}
public @NotNull AdvancedConfig getAdvancedConfig() {
return advancedConfig;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.ItemShareType;
@ -61,7 +60,7 @@ public final class PartyManager {
*/
public static boolean isPartyFull(Player player, Party targetParty)
{
return !Permissions.partySizeBypass(player) && Config.getInstance().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= Config.getInstance().getPartyMaxSize();
return !Permissions.partySizeBypass(player) && mcMMO.p.getGeneralConfig().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= mcMMO.p.getGeneralConfig().getPartyMaxSize();
}
/**
@ -153,7 +152,7 @@ public final class PartyManager {
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
double range = mcMMO.p.getGeneralConfig().getPartyShareRange();
for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
@ -171,7 +170,7 @@ public final class PartyManager {
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
double range = mcMMO.p.getGeneralConfig().getPartyShareRange();
for (Player member : party.getVisibleMembers(player)) {
if (!player.equals(member)
@ -439,9 +438,9 @@ public final class PartyManager {
/*
* Don't let players join a full party
*/
if(Config.getInstance().getPartyMaxSize() > 0 && invite.getMembers().size() >= Config.getInstance().getPartyMaxSize())
if(mcMMO.p.getGeneralConfig().getPartyMaxSize() > 0 && invite.getMembers().size() >= mcMMO.p.getGeneralConfig().getPartyMaxSize())
{
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getName(), String.valueOf(Config.getInstance().getPartyMaxSize()));
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getName(), String.valueOf(mcMMO.p.getGeneralConfig().getPartyMaxSize()));
return;
}
@ -810,7 +809,7 @@ public final class PartyManager {
* @param level The current party level
*/
public static void informPartyMembersLevelUp(Party party, int levelsGained, int level) {
boolean levelUpSoundsEnabled = Config.getInstance().getLevelUpSoundsEnabled();
boolean levelUpSoundsEnabled = mcMMO.p.getGeneralConfig().getLevelUpSoundsEnabled();
for (Player member : party.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
@ -9,6 +8,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Item;
@ -44,7 +44,7 @@ public final class ShareHandler {
nearMembers.add(mcMMOPlayer.getPlayer());
int partySize = nearMembers.size();
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + (partySize * Config.getInstance().getPartyShareBonusIncrease()), Config.getInstance().getPartyShareBonusCap());
double shareBonus = Math.min(mcMMO.p.getGeneralConfig().getPartyShareBonusBase() + (partySize * mcMMO.p.getGeneralConfig().getPartyShareBonusIncrease()), mcMMO.p.getGeneralConfig().getPartyShareBonusCap());
float splitXp = (float) (xp / partySize * shareBonus);
for (Player member : nearMembers) {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.backups;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
@ -48,11 +47,11 @@ public class CleanBackupsTask extends BukkitRunnable {
int weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
int year = cal.get(Calendar.YEAR);
if (isPast24Hours(date) && Config.getInstance().getKeepLast24Hours()) {
if (isPast24Hours(date) && mcMMO.p.getGeneralConfig().getKeepLast24Hours()) {
// Keep all files from the last 24 hours
continue;
}
else if (isLastWeek(date) && !savedDays.contains(dayOfWeek) && Config.getInstance().getKeepDailyLastWeek()) {
else if (isLastWeek(date) && !savedDays.contains(dayOfWeek) && mcMMO.p.getGeneralConfig().getKeepDailyLastWeek()) {
// Keep daily backups of the past week
savedDays.add(dayOfWeek);
continue;
@ -60,7 +59,7 @@ public class CleanBackupsTask extends BukkitRunnable {
else {
List<Integer> savedWeeks = savedYearsWeeks.computeIfAbsent(year, k -> new ArrayList<>());
if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) {
if (!savedWeeks.contains(weekOfYear) && mcMMO.p.getGeneralConfig().getKeepWeeklyPastMonth()) {
// Keep one backup of each week
savedWeeks.add(weekOfYear);
continue;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
@ -30,7 +29,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
@Override
public void run() {
if (useBoard && Config.getInstance().getScoreboardsEnabled()) {
if (useBoard && mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
displayBoard();
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@ -34,7 +33,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
@Override
public void run() {
if (useBoard && Config.getInstance().getScoreboardsEnabled()) {
if (useBoard && mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
displayBoard();
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
@ -13,7 +12,7 @@ public class UserPurgeTask extends BukkitRunnable {
lock.lock();
mcMMO.getDatabaseManager().purgePowerlessUsers();
if (Config.getInstance().getOldUsersCutoff() != -1) {
if (mcMMO.p.getGeneralConfig().getOldUsersCutoff() != -1) {
mcMMO.getDatabaseManager().purgeOldUsers();
}
lock.unlock();

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@ -36,13 +36,13 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
ItemStack inHand = player.getInventory().getItemInMainHand();
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < mcMMO.p.getGeneralConfig().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
return;
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
int hurtCooldown = mcMMO.p.getGeneralConfig().getChimaeraRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
@ -42,7 +42,7 @@ public class TeleportationWarmup extends BukkitRunnable {
return;
}
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
int hurtCooldown = mcMMO.p.getGeneralConfig().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer);
@ -53,7 +53,7 @@ public class TeleportationWarmup extends BukkitRunnable {
}
}
if (Config.getInstance().getPTPCommandWorldPermissions()) {
if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
World targetWorld = targetPlayer.getWorld();
World playerWorld = teleportingPlayer.getWorld();

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
@ -14,7 +13,7 @@ import java.util.Map.Entry;
import java.util.UUID;
public class PartyAutoKickTask extends BukkitRunnable {
private final static long KICK_TIME = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
private final static long KICK_TIME = 24L * 60L * 60L * 1000L * mcMMO.p.getGeneralConfig().getAutoPartyKickTime();
@Override
public void run() {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
@ -97,16 +96,16 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
UserManager.track(mcMMOPlayer);
mcMMOPlayer.actualizeRespawnATS();
if (Config.getInstance().getScoreboardsEnabled()) {
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
ScoreboardManager.setupPlayer(player);
if (Config.getInstance().getShowStatsAfterLogin()) {
if (mcMMO.p.getGeneralConfig().getShowStatsAfterLogin()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR);
}
}
if (Config.getInstance().getShowProfileLoadedMessage()) {
if (mcMMO.p.getGeneralConfig().getShowProfileLoadedMessage()) {
player.sendMessage(LocaleLoader.getString("Profile.Loading.Success"));
}

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
@ -41,7 +39,7 @@ public class AbilityDisableTask extends BukkitRunnable {
// Fallthrough
case BERSERK:
if (Config.getInstance().getRefreshChunksEnabled()) {
if (mcMMO.p.getGeneralConfig().getRefreshChunksEnabled()) {
resendChunkRadiusAt(player);
}
// Fallthrough
@ -62,7 +60,7 @@ public class AbilityDisableTask extends BukkitRunnable {
NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff());
}
if (AdvancedConfig.getInstance().sendAbilityNotificationToOtherPlayers()) {
if (mcMMO.p.getAdvancedConfig().sendAbilityNotificationToOtherPlayers()) {
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
}
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);

View File

@ -57,7 +57,7 @@
// double damage;
//
// if (target instanceof Player) {
// damage = AdvancedConfig.getInstance().getRuptureDamagePlayer();
// damage = mcMMO.p.getAdvancedConfig().getRuptureDamagePlayer();
//
// //Above Bleed Rank 3 deals 50% more damage
// if (containerEntry.getValue().toolTier >= 4 && containerEntry.getValue().bleedRank >= 3)
@ -78,7 +78,7 @@
// }
//
// } else {
// damage = AdvancedConfig.getInstance().getRuptureDamageMobs();
// damage = mcMMO.p.getAdvancedConfig().getRuptureDamageMobs();
//
//// debugMessage+="BaseDMG=["+damage+"], ";
//

View File

@ -1,9 +1,7 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.base.Objects;
import org.bukkit.entity.LivingEntity;
@ -28,7 +26,7 @@ public class RuptureTask extends BukkitRunnable {
public RuptureTask(@NotNull McMMOPlayer ruptureSource, @NotNull LivingEntity targetEntity, double pureTickDamage, double explosionDamage) {
this.ruptureSource = ruptureSource;
this.targetEntity = targetEntity;
this.expireTick = AdvancedConfig.getInstance().getRuptureDurationSeconds(targetEntity instanceof Player) * 20;
this.expireTick = mcMMO.p.getAdvancedConfig().getRuptureDurationSeconds(targetEntity instanceof Player) * 20;
this.ruptureTick = 0;
this.damageTickTracker = 0;

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.NotificationManager;
import org.bukkit.scheduler.BukkitRunnable;
@ -24,7 +24,7 @@ public class ToolLowerTask extends BukkitRunnable {
mcMMOPlayer.setToolPreparationMode(tool, false);
if (Config.getInstance().getAbilityMessagesEnabled()) {
if (mcMMO.p.getGeneralConfig().getAbilityMessagesEnabled()) {
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool());
}
}

View File

@ -1,13 +1,12 @@
package com.gmail.nossr50.skills.acrobatics;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.mcMMO;
public final class Acrobatics {
public static double dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
public static double dodgeDamageModifier = mcMMO.p.getAdvancedConfig().getDodgeDamageModifier();
public static int dodgeXpModifier = ExperienceConfig.getInstance().getDodgeXPModifier();
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
public static boolean dodgeLightningDisabled = mcMMO.p.getGeneralConfig().getDodgeLightningDisabled();
private Acrobatics() {}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.alchemy;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AlchemyBrewTask;
@ -43,16 +42,16 @@ public final class Alchemy {
}
protected int getLevel() {
return AdvancedConfig.getInstance().getConcoctionsTierLevel(this);
return mcMMO.p.getAdvancedConfig().getConcoctionsTierLevel(this);
}
}*/
public static final int INGREDIENT_SLOT = 3;
public static int catalysisUnlockLevel = RankUtils.getUnlockLevel(SubSkillType.ALCHEMY_CATALYSIS);
public static int catalysisMaxBonusLevel = AdvancedConfig.getInstance().getCatalysisMaxBonusLevel();
public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();
public static int catalysisMaxBonusLevel = mcMMO.p.getAdvancedConfig().getCatalysisMaxBonusLevel();
public static double catalysisMinSpeed = mcMMO.p.getAdvancedConfig().getCatalysisMinSpeed();
public static double catalysisMaxSpeed = mcMMO.p.getAdvancedConfig().getCatalysisMaxSpeed();
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<>();

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.Material;
@ -19,9 +19,9 @@ import java.util.List;
public class Archery {
private static final List<TrackedEntity> trackedEntities = new ArrayList<>();
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
public static double skillShotMaxBonusDamage = mcMMO.p.getAdvancedConfig().getSkillShotDamageMax();
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
public static double dazeBonusDamage = mcMMO.p.getAdvancedConfig().getDazeBonusDamage();
public static final double DISTANCE_XP_MULTIPLIER = ExperienceConfig.getInstance().getArcheryDistanceMultiplier();
@ -72,6 +72,6 @@ public class Archery {
}
public static double getDamageBonusPercent(Player player) {
return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * (AdvancedConfig.getInstance().getSkillShotRankDamageMultiplier()) / 100.0D);
return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * (mcMMO.p.getAdvancedConfig().getSkillShotRankDamageMultiplier()) / 100.0D);
}
}

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.skills.axes;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.entity.LivingEntity;
@ -9,18 +9,18 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class Axes {
public static double axeMasteryRankDamageMultiplier = AdvancedConfig.getInstance().getAxeMasteryRankDamageMultiplier();
public static double axeMasteryRankDamageMultiplier = mcMMO.p.getAdvancedConfig().getAxeMasteryRankDamageMultiplier();
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getCriticalStrikesPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getCriticalStrikesPVEModifier();
public static double criticalHitPVPModifier = mcMMO.p.getAdvancedConfig().getCriticalStrikesPVPModifier();
public static double criticalHitPVEModifier = mcMMO.p.getAdvancedConfig().getCriticalStrikesPVEModifier();
public static double impactChance = AdvancedConfig.getInstance().getImpactChance();
public static double impactChance = mcMMO.p.getAdvancedConfig().getImpactChance();
public static double greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier();
public static double greaterImpactBonusDamage = mcMMO.p.getAdvancedConfig().getGreaterImpactBonusDamage();
public static double greaterImpactChance = mcMMO.p.getAdvancedConfig().getGreaterImpactChance();
public static double greaterImpactKnockbackMultiplier = mcMMO.p.getAdvancedConfig().getGreaterImpactModifier();
public static double skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
public static double skullSplitterModifier = mcMMO.p.getAdvancedConfig().getSkullSplitterModifier();
protected static boolean hasArmor(LivingEntity target) {
if(target == null || !target.isValid() || target.getEquipment() == null)

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.skills.axes;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
@ -127,7 +127,7 @@ public class AxesManager extends SkillManager {
}
public double getImpactDurabilityDamage() {
return AdvancedConfig.getInstance().getImpactDurabilityDamageMultiplier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT);
return mcMMO.p.getAdvancedConfig().getImpactDurabilityDamageMultiplier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT);
}
/**

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.skills.excavation;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -98,6 +98,6 @@ public class ExcavationManager extends SkillManager {
excavationBlockCheck(blockState);
excavationBlockCheck(blockState);
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.p.getGeneralConfig().getAbilityToolDamage());
}
}

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.skills.fishing;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
@ -198,11 +196,11 @@ public class FishingManager extends SkillManager {
}
public double getShakeChance() {
return AdvancedConfig.getInstance().getShakeChance(RankUtils.getRank(mmoPlayer.getPlayer(), SubSkillType.FISHING_SHAKE));
return mcMMO.p.getAdvancedConfig().getShakeChance(RankUtils.getRank(mmoPlayer.getPlayer(), SubSkillType.FISHING_SHAKE));
}
protected int getVanillaXPBoostModifier() {
return AdvancedConfig.getInstance().getFishingVanillaXPModifier(getLootTier());
return mcMMO.p.getAdvancedConfig().getFishingVanillaXPModifier(getLootTier());
}
/**
@ -273,8 +271,8 @@ public class FishingManager extends SkillManager {
int maxWaitReduction = getMasterAnglerTickMaxWaitReduction(masterAnglerRank, boatBonus, convertedLureBonus);
//Ticks for minWait and maxWait never go below this value
int bonusCapMin = AdvancedConfig.getInstance().getFishingReductionMinWaitCap();
int bonusCapMax = AdvancedConfig.getInstance().getFishingReductionMaxWaitCap();
int bonusCapMin = mcMMO.p.getAdvancedConfig().getFishingReductionMinWaitCap();
int bonusCapMax = mcMMO.p.getAdvancedConfig().getFishingReductionMaxWaitCap();
int reducedMinWaitTime = getReducedTicks(minWaitTicks, minWaitReduction, bonusCapMin);
int reducedMaxWaitTime = getReducedTicks(maxWaitTicks, maxWaitReduction, bonusCapMax);
@ -337,7 +335,7 @@ public class FishingManager extends SkillManager {
}
public int getMasterAnglerTickMaxWaitReduction(int masterAnglerRank, boolean boatBonus, int emulatedLureBonus) {
int totalBonus = AdvancedConfig.getInstance().getFishingReductionMaxWaitTicks() * masterAnglerRank;
int totalBonus = mcMMO.p.getAdvancedConfig().getFishingReductionMaxWaitTicks() * masterAnglerRank;
if(boatBonus) {
totalBonus += getFishingBoatMaxWaitReduction();
@ -349,7 +347,7 @@ public class FishingManager extends SkillManager {
}
public int getMasterAnglerTickMinWaitReduction(int masterAnglerRank, boolean boatBonus) {
int totalBonus = AdvancedConfig.getInstance().getFishingReductionMinWaitTicks() * masterAnglerRank;
int totalBonus = mcMMO.p.getAdvancedConfig().getFishingReductionMinWaitTicks() * masterAnglerRank;
if(boatBonus) {
totalBonus += getFishingBoatMinWaitReduction();
@ -359,11 +357,11 @@ public class FishingManager extends SkillManager {
}
public int getFishingBoatMinWaitReduction() {
return AdvancedConfig.getInstance().getFishingBoatReductionMinWaitTicks();
return mcMMO.p.getAdvancedConfig().getFishingBoatReductionMinWaitTicks();
}
public int getFishingBoatMaxWaitReduction() {
return AdvancedConfig.getInstance().getFishingBoatReductionMaxWaitTicks();
return mcMMO.p.getAdvancedConfig().getFishingBoatReductionMaxWaitTicks();
}
public boolean isMagicHunterEnabled() {
@ -386,7 +384,7 @@ public class FishingManager extends SkillManager {
FishingTreasure treasure = null;
boolean fishingSucceeds = false;
if (Config.getInstance().getFishingDropsEnabled() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
if (mcMMO.p.getGeneralConfig().getFishingDropsEnabled() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
treasure = getFishingTreasure();
this.fishingCatch = null;
}
@ -447,7 +445,7 @@ public class FishingManager extends SkillManager {
}
if(fishingSucceeds) {
if (Config.getInstance().getFishingExtraFish()) {
if (mcMMO.p.getGeneralConfig().getFishingExtraFish()) {
Misc.spawnItem(player.getEyeLocation(), fishingCatch.getItemStack(), ItemSpawnReason.FISHING_EXTRA_FISH);
}
@ -579,7 +577,7 @@ public class FishingManager extends SkillManager {
}
// Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck.
diceRoll *= (1.0 - luck * Config.getInstance().getFishingLureModifier() / 100);
diceRoll *= (1.0 - luck * mcMMO.p.getGeneralConfig().getFishingLureModifier() / 100);
FishingTreasure treasure = null;

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.herbalism;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.BlockSnapshot;
@ -210,7 +209,7 @@ public class HerbalismManager extends SkillManager {
public void processHerbalismBlockBreakEvent(BlockBreakEvent blockBreakEvent) {
Player player = getPlayer();
if (Config.getInstance().getHerbalismPreventAFK() && player.isInsideVehicle()) {
if (mcMMO.p.getGeneralConfig().getHerbalismPreventAFK() && player.isInsideVehicle()) {
return;
}
@ -257,7 +256,7 @@ public class HerbalismManager extends SkillManager {
//TODO: The design of Green Terra needs to change, this is a mess
if(Permissions.greenThumbPlant(getPlayer(), originalBreak.getType())) {
if(Config.getInstance().isGreenThumbReplantableCrop(originalBreak.getType())) {
if(mcMMO.p.getGeneralConfig().isGreenThumbReplantableCrop(originalBreak.getType())) {
if(!getPlayer().isSneaking()) {
greenThumbActivated = processGreenThumbPlants(originalBreak, blockBreakEvent, isGreenTerraActive());
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
@ -33,7 +32,7 @@ public class BlastMining {
}
protected int getLevel() {
return AdvancedConfig.getInstance().getBlastMiningRankLevel(this);
return mcMMO.p.getAdvancedConfig().getBlastMiningRankLevel(this);
}
@ -42,13 +41,13 @@ public class BlastMining {
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
public static double getBlastRadiusModifier(int rank) {
return AdvancedConfig.getInstance().getBlastRadiusModifier(rank);
return mcMMO.p.getAdvancedConfig().getBlastRadiusModifier(rank);
}
public static double getBlastDamageDecrease(int rank) {
return AdvancedConfig.getInstance().getBlastDamageDecrease(rank);
return mcMMO.p.getAdvancedConfig().getBlastDamageDecrease(rank);
}

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -48,7 +46,7 @@ public class MiningManager extends SkillManager {
Player player = getPlayer();
return canUseBlastMining() && player.isSneaking()
&& (ItemUtils.isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == Config.getInstance().getDetonatorItem())
&& (ItemUtils.isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == mcMMO.p.getGeneralConfig().getDetonatorItem())
&& Permissions.remoteDetonation(player);
}
@ -83,20 +81,20 @@ public class MiningManager extends SkillManager {
}
if (mmoPlayer.getAbilityMode(skill.getAbility())) {
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.p.getGeneralConfig().getAbilityToolDamage());
}
if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType()) || !canDoubleDrop())
if(!mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType()) || !canDoubleDrop())
return;
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
if(silkTouch && !AdvancedConfig.getInstance().getDoubleDropSilkTouchEnabled())
if(silkTouch && !mcMMO.p.getAdvancedConfig().getDoubleDropSilkTouchEnabled())
return;
//TODO: Make this readable
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) {
boolean useTriple = mmoPlayer.getAbilityMode(skill.getAbility()) && AdvancedConfig.getInstance().getAllowMiningTripleDrops();
boolean useTriple = mmoPlayer.getAbilityMode(skill.getAbility()) && mcMMO.p.getAdvancedConfig().getAllowMiningTripleDrops();
BlockUtils.markDropsAsBonus(blockState, useTriple);
}
}
@ -249,11 +247,11 @@ public class MiningManager extends SkillManager {
}
public static double getOreBonus(int rank) {
return AdvancedConfig.getInstance().getOreBonus(rank);
return mcMMO.p.getAdvancedConfig().getOreBonus(rank);
}
public static double getDebrisReduction(int rank) {
return AdvancedConfig.getInstance().getDebrisReduction(rank);
return mcMMO.p.getAdvancedConfig().getDebrisReduction(rank);
}
/**
@ -266,7 +264,7 @@ public class MiningManager extends SkillManager {
}
public static int getDropMultiplier(int rank) {
return AdvancedConfig.getInstance().getDropMultiplier(rank);
return mcMMO.p.getAdvancedConfig().getDropMultiplier(rank);
}
/**

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.skills.repair;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.mcMMO;
public class ArcaneForging {
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled();
public static boolean arcaneForgingDowngrades = mcMMO.p.getAdvancedConfig().getArcaneForgingDowngradeEnabled();
public static boolean arcaneForgingEnchantLoss = mcMMO.p.getAdvancedConfig().getArcaneForgingEnchantLossEnabled();
}

View File

@ -1,13 +1,12 @@
package com.gmail.nossr50.skills.repair;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
public class Repair {
public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY);
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
public static int repairMasteryMaxBonusLevel = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY);
public static double repairMasteryMaxBonus = mcMMO.p.getAdvancedConfig().getRepairMasteryMaxBonus();
public static Material anvilMaterial = Config.getInstance().getRepairAnvilMaterial();
public static Material anvilMaterial = mcMMO.p.getGeneralConfig().getRepairAnvilMaterial();
}

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.skills.repair;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -51,11 +49,11 @@ public class RepairManager extends SkillManager {
return;
}
if (Config.getInstance().getRepairAnvilMessagesEnabled()) {
if (mcMMO.p.getGeneralConfig().getRepairAnvilMessagesEnabled()) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Repair.Listener.Anvil");
}
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
if (mcMMO.p.getGeneralConfig().getRepairAnvilPlaceSoundsEnabled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
}
@ -153,7 +151,7 @@ public class RepairManager extends SkillManager {
* ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE);
// BWONG BWONG BWONG
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
if (mcMMO.p.getGeneralConfig().getRepairAnvilUseSoundsEnabled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
}
@ -175,7 +173,7 @@ public class RepairManager extends SkillManager {
Player player = getPlayer();
long lastUse = getLastAnvilUse();
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) {
if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.p.getGeneralConfig().getRepairConfirmRequired()) {
return true;
}
@ -204,7 +202,7 @@ public class RepairManager extends SkillManager {
* @return The chance of keeping the enchantment
*/
public double getKeepEnchantChance() {
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChance(getArcaneForgingRank());
return mcMMO.p.getAdvancedConfig().getArcaneForgingKeepEnchantsChance(getArcaneForgingRank());
}
/**
@ -213,7 +211,7 @@ public class RepairManager extends SkillManager {
* @return The chance of the enchantment being downgraded
*/
public double getDowngradeEnchantChance() {
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChance(getArcaneForgingRank());
return mcMMO.p.getAdvancedConfig().getArcaneForgingDowngradeChance(getArcaneForgingRank());
}
/*

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.salvage;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
public final class Salvage {
@ -12,15 +11,15 @@ public final class Salvage {
*/
private Salvage() {}
public static Material anvilMaterial = Config.getInstance().getSalvageAnvilMaterial();
public static Material anvilMaterial = mcMMO.p.getGeneralConfig().getSalvageAnvilMaterial();
/*public static int salvageMaxPercentageLevel = AdvancedConfig.getInstance().getSalvageMaxPercentageLevel();
public static double salvageMaxPercentage = AdvancedConfig.getInstance().getSalvageMaxPercentage();
/*public static int salvageMaxPercentageLevel = mcMMO.p.getAdvancedConfig().getSalvageMaxPercentageLevel();
public static double salvageMaxPercentage = mcMMO.p.getAdvancedConfig().getSalvageMaxPercentage();
public static int advancedSalvageUnlockLevel = RankUtils.getRankUnlockLevel(SubSkillType.SALVAGE_SCRAP_COLLECTOR, 1);*/
public static boolean arcaneSalvageDowngrades = AdvancedConfig.getInstance().getArcaneSalvageEnchantDowngradeEnabled();
public static boolean arcaneSalvageEnchantLoss = AdvancedConfig.getInstance().getArcaneSalvageEnchantLossEnabled();
public static boolean arcaneSalvageDowngrades = mcMMO.p.getAdvancedConfig().getArcaneSalvageEnchantDowngradeEnabled();
public static boolean arcaneSalvageEnchantLoss = mcMMO.p.getAdvancedConfig().getArcaneSalvageEnchantLossEnabled();
static int calculateSalvageableAmount(int currentDurability, short maxDurability, int baseAmount) {
double percentDamaged = (maxDurability <= 0) ? 1D : (double) (maxDurability - currentDurability) / maxDurability;

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.skills.salvage;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -53,11 +51,11 @@ public class SalvageManager extends SkillManager {
return;
}
if (Config.getInstance().getSalvageAnvilMessagesEnabled()) {
if (mcMMO.p.getGeneralConfig().getSalvageAnvilMessagesEnabled()) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Listener.Anvil");
}
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
if (mcMMO.p.getGeneralConfig().getSalvageAnvilPlaceSoundsEnabled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL);
}
@ -168,7 +166,7 @@ public class SalvageManager extends SkillManager {
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed, ItemSpawnReason.SALVAGE_MATERIALS);
// BWONG BWONG BWONG - CLUNK!
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
if (mcMMO.p.getGeneralConfig().getSalvageAnvilUseSoundsEnabled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
}
@ -220,11 +218,11 @@ public class SalvageManager extends SkillManager {
if(Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
return 100.0D;
return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank());
return mcMMO.p.getAdvancedConfig().getArcaneSalvageExtractFullEnchantsChance(getArcaneSalvageRank());
}
public double getExtractPartialEnchantChance() {
return AdvancedConfig.getInstance().getArcaneSalvageExtractPartialEnchantsChance(getArcaneSalvageRank());
return mcMMO.p.getAdvancedConfig().getArcaneSalvageExtractPartialEnchantsChance(getArcaneSalvageRank());
}
private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) {
@ -293,7 +291,7 @@ public class SalvageManager extends SkillManager {
Player player = getPlayer();
long lastUse = getLastAnvilUse();
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getSalvageConfirmRequired()) {
if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.p.getGeneralConfig().getSalvageConfirmRequired()) {
return true;
}

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.skills.smelting;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceUtil;
@ -125,7 +125,7 @@ public class SmeltingManager extends SkillManager {
*/
//Process double smelt
if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, resultItemStack.getType())
if (mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.SMELTING, resultItemStack.getType())
&& canDoubleSmeltItemStack(furnace) //Effectively two less than max stack size
&& isSecondSmeltSuccessful()) {

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.mcMMO;
public class Swords {
public static double counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier();
public static double counterAttackModifier = mcMMO.p.getAdvancedConfig().getCounterModifier();
public static double serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier();
public static double serratedStrikesModifier = mcMMO.p.getAdvancedConfig().getSerratedStrikesModifier();
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.meta.RuptureTaskMeta;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -76,7 +75,7 @@ public class SwordsManager extends SkillManager {
return; //Don't apply bleed
}
if (RandomChanceUtil.rollDice(AdvancedConfig.getInstance().getRuptureChanceToApplyOnHit(getRuptureRank()), 100)) {
if (RandomChanceUtil.rollDice(mcMMO.p.getAdvancedConfig().getRuptureChanceToApplyOnHit(getRuptureRank()), 100)) {
if (target instanceof Player) {
Player defender = (Player) target;
@ -91,8 +90,8 @@ public class SwordsManager extends SkillManager {
}
RuptureTask ruptureTask = new RuptureTask(mmoPlayer, target,
AdvancedConfig.getInstance().getRuptureTickDamage(target instanceof Player, getRuptureRank()),
AdvancedConfig.getInstance().getRuptureExplosionDamage(target instanceof Player, getRuptureRank()));
mcMMO.p.getAdvancedConfig().getRuptureTickDamage(target instanceof Player, getRuptureRank()),
mcMMO.p.getAdvancedConfig().getRuptureExplosionDamage(target instanceof Player, getRuptureRank()));
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
@ -136,7 +135,7 @@ public class SwordsManager extends SkillManager {
}
public int getRuptureBleedTicks(boolean isTargetPlayer) {
return AdvancedConfig.getInstance().getRuptureDurationSeconds(isTargetPlayer) / RuptureTask.DAMAGE_TICK_INTERVAL;
return mcMMO.p.getAdvancedConfig().getRuptureDurationSeconds(isTargetPlayer) / RuptureTask.DAMAGE_TICK_INTERVAL;
}
/**

View File

@ -1,20 +1,20 @@
package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.mcMMO;
import org.bukkit.EntityEffect;
import org.bukkit.entity.*;
public class Taming {
public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance();
public static double fastFoodServiceActivationChance = mcMMO.p.getAdvancedConfig().getFastFoodChance();
public static int goreBleedTicks = 2; //Equivalent to rank 1 in Rupture
public static double goreModifier = AdvancedConfig.getInstance().getGoreModifier();
public static double goreModifier = mcMMO.p.getAdvancedConfig().getGoreModifier();
public static double sharpenedClawsBonusDamage = AdvancedConfig.getInstance().getSharpenedClawsBonus();
public static double sharpenedClawsBonusDamage = mcMMO.p.getAdvancedConfig().getSharpenedClawsBonus();
public static double shockProofModifier = AdvancedConfig.getInstance().getShockProofModifier();
public static double shockProofModifier = mcMMO.p.getAdvancedConfig().getShockProofModifier();
public static double thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
public static double thickFurModifier = mcMMO.p.getAdvancedConfig().getThickFurModifier();
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -64,9 +62,9 @@ public class TamingManager extends SkillManager {
if(summoningItems == null) {
summoningItems = new HashMap<>();
summoningItems.put(Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry()), CallOfTheWildType.CAT);
summoningItems.put(Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry()), CallOfTheWildType.WOLF);
summoningItems.put(Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry()), CallOfTheWildType.HORSE);
summoningItems.put(mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry()), CallOfTheWildType.CAT);
summoningItems.put(mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry()), CallOfTheWildType.WOLF);
summoningItems.put(mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry()), CallOfTheWildType.HORSE);
}
//TODO: Temporary static cache, will be changed in 2.2
@ -75,11 +73,11 @@ public class TamingManager extends SkillManager {
cotwSummonDataProperties = new HashMap<>();
for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
Material itemSummonMaterial = Config.getInstance().getTamingCOTWMaterial(callOfTheWildType.getConfigEntityTypeEntry());
int itemAmountRequired = Config.getInstance().getTamingCOTWCost(callOfTheWildType.getConfigEntityTypeEntry());
int entitiesSummonedPerCOTW = Config.getInstance().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry());
int summonLifespanSeconds = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
int perPlayerMaxAmount = Config.getInstance().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry());
Material itemSummonMaterial = mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(callOfTheWildType.getConfigEntityTypeEntry());
int itemAmountRequired = mcMMO.p.getGeneralConfig().getTamingCOTWCost(callOfTheWildType.getConfigEntityTypeEntry());
int entitiesSummonedPerCOTW = mcMMO.p.getGeneralConfig().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry());
int summonLifespanSeconds = mcMMO.p.getGeneralConfig().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
int perPlayerMaxAmount = mcMMO.p.getGeneralConfig().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry());
TamingSummon tamingSummon = new TamingSummon(callOfTheWildType, itemSummonMaterial, itemAmountRequired, entitiesSummonedPerCOTW, summonLifespanSeconds, perPlayerMaxAmount);
cotwSummonDataProperties.put(callOfTheWildType, tamingSummon);
@ -273,7 +271,7 @@ public class TamingManager extends SkillManager {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
return;
if(!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
if(!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(mcMMO.p.getAdvancedConfig().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
return;
ParticleEffectUtils.playGreaterImpactEffect(target);
@ -459,7 +457,7 @@ public class TamingManager extends SkillManager {
callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
horse.setJumpStrength(Math.max(mcMMO.p.getAdvancedConfig().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, mcMMO.p.getAdvancedConfig().getMaxHorseJumpStrength())));
horse.setAdult();
//TODO: setSpeed, once available

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
@ -19,7 +18,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
this.callOfTheWildType = callOfTheWildType;
this.livingEntity = livingEntity;
int tamingCOTWLength = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
int tamingCOTWLength = mcMMO.p.getGeneralConfig().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
if (tamingCOTWLength > 0) {
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.skills.unarmed;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.entity.Player;
@ -8,7 +8,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.inventory.ItemStack;
public class Unarmed {
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
public static boolean blockCrackerSmoothBrick = mcMMO.p.getGeneralConfig().getUnarmedBlockCrackerSmoothbrickToCracked();
public static double berserkDamageModifier = 1.5;
public static void handleItemPickup(Player player, EntityPickupItemEvent event) {

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.unarmed;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -113,7 +112,7 @@ public class UnarmedManager extends SkillManager {
Item item = Misc.spawnItem(defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
if (item != null && mcMMO.p.getAdvancedConfig().getDisarmProtected()) {
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
}
@ -167,8 +166,8 @@ public class UnarmedManager extends SkillManager {
double finalBonus = bonus + 0.5 + (rank / 2);
if(AdvancedConfig.getInstance().isSteelArmDamageCustom()) {
return AdvancedConfig.getInstance().getSteelArmOverride(RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE), finalBonus);
if(mcMMO.p.getAdvancedConfig().isSteelArmDamageCustom()) {
return mcMMO.p.getAdvancedConfig().getSteelArmOverride(RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE), finalBonus);
} else {
return finalBonus;
}

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.skills.woodcutting;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -54,7 +52,7 @@ public class WoodcuttingManager extends SkillManager {
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.WOODCUTTING);
treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
treeFellerThreshold = mcMMO.p.getGeneralConfig().getTreeFellerThreshold();
}
public boolean canUseLeafBlower(ItemStack heldItem) {
@ -72,7 +70,7 @@ public class WoodcuttingManager extends SkillManager {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& RankUtils.hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer())
&& Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, material);
&& mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, material);
}
/**
@ -217,7 +215,7 @@ public class WoodcuttingManager extends SkillManager {
for (BlockState blockState : treeFellerBlocks) {
if (BlockUtils.hasWoodcuttingXP(blockState)) {
durabilityLoss += Config.getInstance().getAbilityToolDamage();
durabilityLoss += mcMMO.p.getGeneralConfig().getAbilityToolDamage();
}
}
@ -307,7 +305,7 @@ public class WoodcuttingManager extends SkillManager {
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
if(AdvancedConfig.getInstance().isKnockOnWoodXPOrbEnabled()) {
if(mcMMO.p.getAdvancedConfig().isKnockOnWoodXPOrbEnabled()) {
if(RandomChanceUtil.rollDice(10, 100)) {
int randOrbCount = Math.max(1, Misc.getRandom().nextInt(100));
Misc.spawnExperienceOrb(blockState.getLocation(), randOrbCount);

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -53,7 +52,7 @@ public final class BlockUtils {
* @return true if the player succeeded in the check
*/
public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType) {
if (Config.getInstance().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
if (mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true));
}
@ -68,10 +67,10 @@ public final class BlockUtils {
*/
public static boolean shouldBeWatched(BlockState blockState) {
return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || hasWoodcuttingXP(blockState)
|| Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType())
|| Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.EXCAVATION, blockState.getType())
|| Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, blockState.getType())
|| Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, blockState.getType());
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.MINING, blockState.getType())
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.EXCAVATION, blockState.getType())
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, blockState.getType())
|| mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(PrimarySkillType.SMELTING, blockState.getType());
}
/**

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
@ -37,7 +36,7 @@ public final class ChimaeraWing {
* @param player Player whose item usage to check
*/
public static void activationCheck(Player player) {
if (!Config.getInstance().getChimaeraEnabled()) {
if (!mcMMO.p.getGeneralConfig().getChimaeraEnabled()) {
return;
}
@ -64,13 +63,13 @@ public final class ChimaeraWing {
int amount = inHand.getAmount();
if (amount < Config.getInstance().getChimaeraUseCost()) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough",String.valueOf(Config.getInstance().getChimaeraUseCost() - amount), "Item.ChimaeraWing.Name");
if (amount < mcMMO.p.getGeneralConfig().getChimaeraUseCost()) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough",String.valueOf(mcMMO.p.getGeneralConfig().getChimaeraUseCost() - amount), "Item.ChimaeraWing.Name");
return;
}
long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
int cooldown = Config.getInstance().getChimaeraCooldown();
int cooldown = mcMMO.p.getGeneralConfig().getChimaeraCooldown();
if (cooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
@ -82,7 +81,7 @@ public final class ChimaeraWing {
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
int hurtCooldown = mcMMO.p.getGeneralConfig().getChimaeraRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
@ -95,9 +94,9 @@ public final class ChimaeraWing {
location = player.getLocation();
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
if (mcMMO.p.getGeneralConfig().getChimaeraPreventUseUnderground()) {
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - mcMMO.p.getGeneralConfig().getChimaeraUseCost())));
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail");
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0));
@ -109,7 +108,7 @@ public final class ChimaeraWing {
mcMMOPlayer.actualizeTeleportCommenceLocation(player);
long warmup = Config.getInstance().getChimaeraWarmup();
long warmup = mcMMO.p.getGeneralConfig().getChimaeraWarmup();
if (warmup > 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup));
@ -123,7 +122,7 @@ public final class ChimaeraWing {
public static void chimaeraExecuteTeleport() {
Player player = mcMMOPlayer.getPlayer();
if (Config.getInstance().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
if (mcMMO.p.getGeneralConfig().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
player.teleport(player.getBedSpawnLocation());
}
else {
@ -136,12 +135,12 @@ public final class ChimaeraWing {
}
}
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - mcMMO.p.getGeneralConfig().getChimaeraUseCost())));
player.updateInventory();
mcMMOPlayer.actualizeChimeraWingLastUse();
mcMMOPlayer.setTeleportCommenceLocation(null);
if (Config.getInstance().getChimaeraSoundEnabled()) {
if (mcMMO.p.getGeneralConfig().getChimaeraSoundEnabled()) {
SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING);
}
@ -149,7 +148,7 @@ public final class ChimaeraWing {
}
public static ItemStack getChimaeraWing(int amount) {
ItemStack itemStack = new ItemStack(Config.getInstance().getChimaeraItem(), amount);
ItemStack itemStack = new ItemStack(mcMMO.p.getGeneralConfig().getChimaeraItem(), amount);
ItemMeta itemMeta = itemStack.getItemMeta();
//noinspection ConstantConditions
@ -165,8 +164,8 @@ public final class ChimaeraWing {
}
public static ShapelessRecipe getChimaeraWingRecipe() {
Material ingredient = Config.getInstance().getChimaeraItem();
int amount = Config.getInstance().getChimaeraRecipeCost();
Material ingredient = mcMMO.p.getGeneralConfig().getChimaeraItem();
int amount = mcMMO.p.getGeneralConfig().getChimaeraRecipeCost();
ShapelessRecipe chimeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimera"), getChimaeraWing(1));
chimeraWing.addIngredient(amount, ingredient);

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.party.Party;
@ -9,6 +8,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelChangeEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
@ -409,7 +409,7 @@ public final class EventUtils {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
String skillName = primarySkillType.toString();
int playerSkillLevel = playerProfile.getSkillLevel(primarySkillType);
int threshold = Config.getInstance().getHardcoreDeathStatPenaltyLevelThreshold();
int threshold = mcMMO.p.getGeneralConfig().getHardcoreDeathStatPenaltyLevelThreshold();
if(playerSkillLevel > threshold) {
playerProfile.modifySkill(primarySkillType, Math.max(threshold, playerSkillLevel - levelChanged.get(skillName)));
playerProfile.removeXp(primarySkillType, experienceChanged.get(skillName));
@ -479,7 +479,7 @@ public final class EventUtils {
}
public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, SuperAbilityType ability) {
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, PrimarySkillType.byAbility(ability));
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, Skill.byAbility(ability));
mcMMO.p.getServer().getPluginManager().callEvent(event);
return event;

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.worldguard.WorldGuardManager;
@ -22,8 +22,8 @@ public final class HardcoreManager {
return;
}
double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
int levelThreshold = Config.getInstance().getHardcoreDeathStatPenaltyLevelThreshold();
double statLossPercentage = mcMMO.p.getGeneralConfig().getHardcoreDeathStatPenaltyPercentage();
int levelThreshold = mcMMO.p.getGeneralConfig().getHardcoreDeathStatPenaltyLevelThreshold();
if(UserManager.getPlayer(player) == null)
return;
@ -73,8 +73,8 @@ public final class HardcoreManager {
return;
}
double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
int levelThreshold = Config.getInstance().getHardcoreVampirismLevelThreshold();
double vampirismStatLeechPercentage = mcMMO.p.getGeneralConfig().getHardcoreVampirismStatLeechPercentage();
int levelThreshold = mcMMO.p.getGeneralConfig().getHardcoreVampirismLevelThreshold();
if(UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null)
return;

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.datatypes.treasure.EnchantmentWrapper;
@ -186,7 +184,7 @@ public final class ItemUtils {
* @return true if the item counts as unarmed, false otherwise
*/
public static boolean isUnarmed(ItemStack item) {
if (Config.getInstance().getUnarmedItemsAsUnarmed()) {
if (mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed()) {
return !isMinecraftTool(item);
}
@ -622,7 +620,7 @@ public final class ItemUtils {
if(itemMeta == null)
return;
itemMeta.addEnchant(Enchantment.DIG_SPEED, existingEnchantLevel + AdvancedConfig.getInstance().getEnchantBuff(), true);
itemMeta.addEnchant(Enchantment.DIG_SPEED, existingEnchantLevel + mcMMO.p.getAdvancedConfig().getEnchantBuff(), true);
itemStack.setItemMeta(itemMeta);
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.meta.OldName;
import com.gmail.nossr50.mcMMO;
@ -36,7 +35,7 @@ public final class MobHealthbarUtils {
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) {
if (mcMMO.isHealthBarPluginEnabled() || !Config.getInstance().getMobHealthbarEnabled()) {
if (mcMMO.isHealthBarPluginEnabled() || !mcMMO.p.getGeneralConfig().getMobHealthbarEnabled()) {
return;
}
@ -63,12 +62,12 @@ public final class MobHealthbarUtils {
}
boolean oldNameVisible = target.isCustomNameVisible();
String newName = createHealthDisplay(Config.getInstance().getMobHealthbarDefault(), target, damage);
String newName = createHealthDisplay(mcMMO.p.getGeneralConfig().getMobHealthbarDefault(), target, damage);
target.setCustomName(newName);
target.setCustomNameVisible(true);
int displayTime = Config.getInstance().getMobHealthbarTime();
int displayTime = mcMMO.p.getGeneralConfig().getMobHealthbarTime();
if (displayTime != -1) {
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig;
import com.gmail.nossr50.config.mods.CustomEntityConfig;
@ -89,67 +88,67 @@ public class ModManager {
}
public boolean isCustomBoots(Material material) {
return Config.getInstance().getArmorModsEnabled() && customBoots.contains(material);
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customBoots.contains(material);
}
public boolean isCustomChestplate(Material material) {
return Config.getInstance().getArmorModsEnabled() && customChestplates.contains(material);
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customChestplates.contains(material);
}
public boolean isCustomHelmet(Material material) {
return Config.getInstance().getArmorModsEnabled() && customHelmets.contains(material);
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customHelmets.contains(material);
}
public boolean isCustomLeggings(Material material) {
return Config.getInstance().getArmorModsEnabled() && customLeggings.contains(material);
return mcMMO.p.getGeneralConfig().getArmorModsEnabled() && customLeggings.contains(material);
}
public boolean isCustomAxe(Material material) {
return Config.getInstance().getToolModsEnabled() && customAxes.contains(material);
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customAxes.contains(material);
}
public boolean isCustomBow(Material material) {
return Config.getInstance().getToolModsEnabled() && customBows.contains(material);
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customBows.contains(material);
}
public boolean isCustomHoe(Material material) {
return Config.getInstance().getToolModsEnabled() && customHoes.contains(material);
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customHoes.contains(material);
}
public boolean isCustomPickaxe(Material material) {
return Config.getInstance().getToolModsEnabled() && customPickaxes.contains(material);
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customPickaxes.contains(material);
}
public boolean isCustomShovel(Material material) {
return Config.getInstance().getToolModsEnabled() && customShovels.contains(material);
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customShovels.contains(material);
}
public boolean isCustomSword(Material material) {
return Config.getInstance().getToolModsEnabled() && customSwords.contains(material);
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && customSwords.contains(material);
}
public boolean isCustomOre(Material data) {
return Config.getInstance().getBlockModsEnabled() && customOres.contains(data);
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customOres.contains(data);
}
public boolean isCustomLog(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customLogs.contains(state.getType());
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customLogs.contains(state.getType());
}
public boolean isCustomAbilityBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
}
public boolean isCustomExcavationBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
}
public boolean isCustomHerbalismBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
}
public boolean isCustomMiningBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getType());
return mcMMO.p.getGeneralConfig().getBlockModsEnabled() && customMiningBlocks.contains(state.getType());
}
public CustomBlock getBlock(BlockState state) {
@ -167,7 +166,7 @@ public class ModManager {
* @return true if the item is a custom tool, false otherwise
*/
public boolean isCustomTool(ItemStack item) {
return Config.getInstance().getToolModsEnabled() && item != null && customToolMap.containsKey(item.getType());
return mcMMO.p.getGeneralConfig().getToolModsEnabled() && item != null && customToolMap.containsKey(item.getType());
}
/**
@ -185,7 +184,7 @@ public class ModManager {
}
public boolean isCustomEntity(Entity entity) {
if (!Config.getInstance().getEntityModsEnabled()) {
if (!mcMMO.p.getGeneralConfig().getEntityModsEnabled()) {
return false;
}
@ -227,7 +226,7 @@ public class ModManager {
}
public void addCustomEntity(Entity entity) {
if (!Config.getInstance().getEntityModsEnabled()) {
if (!mcMMO.p.getGeneralConfig().getEntityModsEnabled()) {
return;
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
@ -70,11 +69,11 @@ public final class Motd {
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Enabled", statLossInfo + seperator + vampirismInfo));
if (deathStatLossEnabled) {
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.DeathStatLoss.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage()));
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.DeathStatLoss.Stats", mcMMO.p.getGeneralConfig().getHardcoreDeathStatPenaltyPercentage()));
}
if (vampirismEnabled) {
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Vampirism.Stats", Config.getInstance().getHardcoreVampirismStatLeechPercentage()));
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Vampirism.Stats", mcMMO.p.getGeneralConfig().getHardcoreVampirismStatLeechPercentage()));
}
}

Some files were not shown because too many files have changed in this diff Show More