new config system pt 1

This commit is contained in:
nossr50 2019-02-13 22:08:20 -08:00
parent 3a7b6fef7d
commit 9a91daf910
30 changed files with 809 additions and 1145 deletions

View File

@ -2,7 +2,7 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.Config; import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.core.config.WorldBlacklist; import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
@ -552,7 +552,7 @@ public class BlockListener implements Listener {
} }
public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) { public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) { if (ChunkConversionOptions.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) { if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
SkillUtils.removeAbilityBuff(heldItem); SkillUtils.removeAbilityBuff(heldItem);
} }

View File

@ -413,7 +413,7 @@ public class mcMMO extends JavaPlugin {
private void loadConfigFiles() { private void loadConfigFiles() {
// Force the loading of config files // Force the loading of config files
TreasureConfig.getInstance(); TreasureConfig.getInstance();
HiddenConfig.getInstance(); ChunkConversionOptions.getInstance();
AdvancedConfig.getInstance(); AdvancedConfig.getInstance();
PotionConfig.getInstance(); PotionConfig.getInstance();
CoreSkillsConfig.getInstance(); CoreSkillsConfig.getInstance();

View File

@ -1,17 +1,28 @@
package com.gmail.nossr50.core; package com.gmail.nossr50.core;
import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.mcmmo.event.EventCommander; import com.gmail.nossr50.core.mcmmo.event.EventCommander;
import com.gmail.nossr50.core.mcmmo.plugin.Plugin; import com.gmail.nossr50.core.mcmmo.plugin.Plugin;
import com.gmail.nossr50.core.mcmmo.server.Server; import com.gmail.nossr50.core.mcmmo.server.Server;
import com.gmail.nossr50.core.mcmmo.tasks.TaskScheduler;
import com.gmail.nossr50.core.platform.Platform;
import com.gmail.nossr50.core.util.experience.FormulaManager;
import com.gmail.nossr50.core.util.upgrade.UpgradeManager;
import java.io.File;
import java.util.logging.Logger; import java.util.logging.Logger;
public class McmmoCore { public class McmmoCore {
//TODO: Wire all this stuff //TODO: Wire all this stuff
public static Plugin p; public static Plugin p;
private static EventCommander eventCommander; private static EventCommander eventCommander;
private static Server server;
private static Logger logger; private static Logger logger;
private static Platform platform;
//Why do all these things need to be here? Sigh...
private static DatabaseManager databaseManager;
private static UpgradeManager upgradeManager;
private static FormulaManager formulaManager;
/** /**
* Returns our Logger * Returns our Logger
@ -27,6 +38,27 @@ public class McmmoCore {
} }
public static Server getServer() { public static Server getServer() {
return server; return platform.getServer();
} }
public static TaskScheduler getTaskScheduler()
{
return platform.getScheduler();
}
public static java.io.InputStream getResource(String path)
{
return platform.getResource(path);
}
public static File getDataFolderPath()
{
return platform.getDataFolderPath();
}
public static DatabaseManager getDatabaseManager() { return databaseManager; }
public static UpgradeManager getUpgradeManager() { return upgradeManager; }
public static FormulaManager getFormulaManager() { return formulaManager; }
} }

View File

@ -5,3 +5,4 @@ This file is just going to take note of all the caveats of mcMMO code as I abstr
2) mcMMO uses a a global reference of its Plugin class for Bukkit in order to schedule tasks 2) mcMMO uses a a global reference of its Plugin class for Bukkit in order to schedule tasks
3) Need to configure the logger

View File

@ -1,132 +0,0 @@
package com.gmail.nossr50.core.config;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName);
}
public AutoUpdateConfigLoader(String fileName) {
super(fileName);
}
@Override
protected void loadFile() {
super.loadFile();
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResourceAsReader(fileName));
Set<String> configKeys = config.getKeys(true);
Set<String> internalConfigKeys = internalConfig.getKeys(true);
boolean needSave = false;
Set<String> oldKeys = new HashSet<String>(configKeys);
oldKeys.removeAll(internalConfigKeys);
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
newKeys.removeAll(configKeys);
// Don't need a re-save if we have old keys sticking around?
// Would be less saving, but less... correct?
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
needSave = true;
}
for (String key : oldKeys) {
plugin.debug("Detected potentially unused key: " + key);
//config.set(key, null);
}
for (String key : newKeys) {
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}
if (needSave) {
// Get Bukkit's version of an acceptable config with new keys, and no old keys
String output = config.saveToString();
// Convert to the superior 4 space indentation
output = output.replace(" ", " ");
// Rip out Bukkit's attempt to save comments at the top of the file
while (output.replaceAll("[//s]", "").startsWith("#")) {
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
}
// Read the internal config to get comments, then put them in the new one
try {
// Read internal
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
LinkedHashMap<String, String> comments = new LinkedHashMap<String, String>();
String temp = "";
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("#")) {
temp += line + "\n";
} else if (line.contains(":")) {
line = line.substring(0, line.indexOf(":") + 1);
if (!temp.isEmpty()) {
if (comments.containsKey(line)) {
int index = 0;
while (comments.containsKey(line + index)) {
index++;
}
line = line + index;
}
comments.put(line, temp);
temp = "";
}
}
}
// Dump to the new one
HashMap<String, Integer> indexed = new HashMap<String, Integer>();
for (String key : comments.keySet()) {
String actualkey = key.substring(0, key.indexOf(":") + 1);
int index = 0;
if (indexed.containsKey(actualkey)) {
index = indexed.get(actualkey);
}
boolean isAtTop = !output.contains("\n" + actualkey);
index = output.indexOf((isAtTop ? "" : "\n") + actualkey, index);
if (index >= 0) {
output = output.substring(0, index) + "\n" + comments.get(key) + output.substring(isAtTop ? index : index + 1);
indexed.put(actualkey, index + comments.get(key).length() + actualkey.length() + 1);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// Save it
try {
String saveName = fileName;
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
saveName += ".new";
}
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
writer.write(output);
writer.flush();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,38 @@
package com.gmail.nossr50.core.config;
/**
* This class is used to define settings for upgrading EXTREMELY OLD versions of mcMMO to newer versions
* It could probably be deleted
*/
public class ChunkConversionOptions {
private static final boolean chunkletsEnabled = true;
private static final int conversionRate = 1;
private static final boolean useEnchantmentBuffs = true;
private static final int uuidConvertAmount = 5;
private static final int mojangRateLimit = 50000;
private static final long mojangLimitPeriod = 600000;
public static boolean getChunkletsEnabled() {
return chunkletsEnabled;
}
public static int getConversionRate() {
return conversionRate;
}
public static boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
public static int getUUIDConvertAmount() {
return uuidConvertAmount;
}
public static int getMojangRateLimit() {
return mojangRateLimit;
}
public static long getMojangLimitPeriod() {
return mojangLimitPeriod;
}
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.core.config; package com.gmail.nossr50.core.config;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.data.database.SQLDatabaseManager; import com.gmail.nossr50.core.data.database.SQLDatabaseManager;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.skills.MobHealthbarType; import com.gmail.nossr50.core.skills.MobHealthbarType;
@ -11,11 +12,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class Config extends AutoUpdateConfigLoader { public class Config extends ConfigurableLoader {
private static Config instance; private static Config instance;
private Config() { private Config() {
super("config.yml"); super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "config.yml");
validate(); validate();
} }

View File

@ -1,86 +0,0 @@
package com.gmail.nossr50.core.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.List;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
protected String fileName;
protected FileConfiguration config;
private File configFile;
public ConfigLoader(String relativePath, String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
loadFile();
}
public ConfigLoader(String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), fileName);
loadFile();
}
protected void loadFile() {
if (!configFile.exists()) {
plugin.debug("Creating mcMMO " + fileName + " File...");
try {
plugin.saveResource(fileName, false); // Normal files
} catch (IllegalArgumentException ex) {
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
} else {
plugin.debug("Loading mcMMO " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
}
protected abstract void loadKeys();
protected boolean validateKeys() {
return true;
}
protected boolean noErrorsInConfig(List<String> issues) {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return issues.isEmpty();
}
protected void validate() {
if (validateKeys()) {
plugin.debug("No errors found in " + fileName + "!");
} else {
plugin.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
plugin.getServer().getPluginManager().disablePlugin(plugin);
plugin.noErrorsInConfigFiles = false;
}
}
public File getFile() {
return configFile;
}
public void backup() {
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
configFile.renameTo(new File(configFile.getPath() + ".old"));
if (plugin.getResource(fileName) != null) {
plugin.saveResource(fileName, true);
}
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
loadFile();
loadKeys();
}
}

View File

@ -1,4 +1,312 @@
package com.gmail.nossr50.core.config; package com.gmail.nossr50.core.config;
public class ConfigurableLoader { import com.gmail.nossr50.core.McmmoCore;
import com.google.common.io.Files;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.yaml.snakeyaml.DumperOptions;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* Handles loading and cacheing configuration settings from a configurable compatible config file
*/
//@ConfigSerializable
public abstract class ConfigurableLoader implements DefaultKeys, VersionedConfig {
/* PATH VARS */
public final File DIRECTORY_DATA_FOLDER; //Directory that the file is in
public final String FILE_RELATIVE_PATH; //Relative Path to the file
protected final String DIRECTORY_DEFAULTS = "defaults";
/* LOADERS */
private YAMLConfigurationLoader defaultCopyLoader;
private YAMLConfigurationLoader userCopyLoader;
/* CONFIG FILES */
private File resourceConfigCopy; //Copy of the default config from the JAR (file is copied so that admins can easily compare to defaults)
private File resourceUserCopy; //File in the /$MCMMO_ROOT/mcMMO/ directory that may contain user edited settings
/* ROOT NODES */
private ConfigurationNode userRootNode = null;
private ConfigurationNode defaultRootNode = null;
/* CONFIG MANAGER */
private ConfigurationLoader<CommentedConfigurationNode> configManager;
//TODO: Needed?
//private ConfigurationLoader<CommentedConfigurationNode> configManager;
public ConfigurableLoader(File pathToDataFolder, String relativePath) {
/*
* These must be at the top
*/
mkdirDefaults(); // Make our default config dir
DIRECTORY_DATA_FOLDER = pathToDataFolder; //Data Folder for our plugin
FILE_RELATIVE_PATH = relativePath; //Relative path to config from a parent folder
//Attempt IO Operations
try {
//Makes sure we have valid Files corresponding to this config
initConfigFiles();
//Init Config Loaders
initConfigLoaders();
//Load Config Nodes
loadConfig();
//Attempt to update user file, and then load it into memory
readConfig();
} catch (IOException e) {
e.printStackTrace();
}
/*
* Print Errors about Keys
*/
List<String> validKeyErrors = validateKeys(); // Validate Keys
if(validKeyErrors != null && validKeyErrors.size() > 0)
{
for(String error : validKeyErrors)
{
McmmoCore.getLogger().severe(error);
}
}
}
/**
* Initializes the default copy File and the user config File
* @throws IOException
*/
private void initConfigFiles() throws IOException {
//Init our config copy
resourceConfigCopy = initDefaultConfig();
//Init the user file
resourceUserCopy = initUserConfig();
}
/**
* Loads the root node for the default config File and user config File
*/
private void loadConfig()
{
try {
final ConfigurationNode defaultConfig = this.defaultCopyLoader.load();
defaultRootNode = defaultConfig;
final ConfigurationNode userConfig = this.userCopyLoader.load();
userRootNode = userConfig;
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Initializes the YAMLConfigurationLoaders for this config
*/
private void initConfigLoaders()
{
this.defaultCopyLoader = YAMLConfigurationLoader.builder().setPath(resourceConfigCopy.toPath()).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
this.userCopyLoader = YAMLConfigurationLoader.builder().setPath(resourceUserCopy.toPath()).setFlowStyle(DumperOptions.FlowStyle.FLOW).build();
}
/**
* Copies a new file from the JAR to the defaults directory and uses that new file to initialize our resourceConfigCopy
* @see ConfigurableLoader#resourceConfigCopy
* @throws IOException
*/
private File initDefaultConfig() throws IOException {
return copyDefaultFromJar(getDefaultConfigCopyRelativePath(), true);
}
/**
* Attemps to load the config file if it exists, if it doesn't it copies a new one from within the JAR
* @return user config File
* @see ConfigurableLoader#resourceUserCopy
* @throws IOException
*/
private File initUserConfig() throws IOException {
File userCopy = new File(DIRECTORY_DATA_FOLDER, FILE_RELATIVE_PATH); //Load the user file;
if(userCopy.exists())
{
// Yay
return userCopy;
}
else
{
//If it's gone we copy default files
//Note that we don't copy the values from the default copy put in /defaults/ that file exists only as a reference to admins and is unreliable
return copyDefaultFromJar(FILE_RELATIVE_PATH, false);
}
}
/**
* Used to make a new config file at a specified relative output path inside the data directory by copying the matching file found in that same relative path within the JAR
* @param relativeOutputPath the path to the output file
* @param deleteOld whether or not to delete the existing output file on disk
* @return a copy of the default config within the JAR
* @throws IOException
*/
private File copyDefaultFromJar(String relativeOutputPath, boolean deleteOld) throws IOException
{
/*
* Gen a Default config from inside the JAR
*/
McmmoCore.getLogger().info("Preparing to copy internal resource file (in JAR) - "+FILE_RELATIVE_PATH);
InputStream inputStream = McmmoCore.getResource(FILE_RELATIVE_PATH);
byte[] buffer = new byte[inputStream.available()];
inputStream.read(buffer);
//This is a copy of the default file, which we will overwrite every time mcMMO loads
File targetFile = new File(DIRECTORY_DATA_FOLDER, relativeOutputPath);
//Wipe old default file on disk
if (targetFile.exists() && deleteOld)
{
McmmoCore.getLogger().info("Updating file " + relativeOutputPath);
targetFile.delete(); //Necessary?
}
if(!targetFile.exists())
{
targetFile.getParentFile().mkdirs();
targetFile.createNewFile(); //New File Boys
}
Files.write(buffer, targetFile);
McmmoCore.getLogger().info("Created config file - " + relativeOutputPath);
inputStream.close(); //Close the input stream
return targetFile;
}
/**
* The path to the defaults directory
* @return the path to the defaults directory
*/
private String getDefaultConfigCopyRelativePath() {
return DIRECTORY_DEFAULTS + File.separator + FILE_RELATIVE_PATH;
}
/**
* Creates the defaults directory
*/
private void mkdirDefaults() {
//Make Default Subdirectory
File defaultsDir = new File (DIRECTORY_DATA_FOLDER, "defaults");
if(!defaultsDir.exists())
defaultsDir.mkdir();
}
/**
* Configs are versioned based on when they had significant changes to keys
* @return current Config Version String
*/
public String getVersion()
{
return String.valueOf(getConfigVersion());
}
/**
* Attempts to read the loaded config file
* Config will have any necessary updates applied
* Config will be compared to the default config to see if it is missing any nodes
* Config will have any missing nodes inserted with their default value
*/
public void readConfig() {
McmmoCore.getLogger().info("Attempting to read " + FILE_RELATIVE_PATH + ".");
int version = this.userRootNode.getNode("ConfigVersion").getInt();
McmmoCore.getLogger().info(FILE_RELATIVE_PATH + " version is " + version);
//Update our config
updateConfig();
}
/**
* Compares the users config file to the default and adds any missing nodes and applies any necessary updates
*/
private void updateConfig()
{
McmmoCore.getLogger().info(defaultRootNode.getChildrenMap().size() +" items in default children map");
McmmoCore.getLogger().info(userRootNode.getChildrenMap().size() +" items in default root map");
// Merge Values from default
userRootNode = userRootNode.mergeValuesFrom(defaultRootNode);
// Update config version
updateConfigVersion();
//Attempt to save
try {
saveUserCopy();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Saves the current state information of the config to the users copy (which they may edit)
* @throws IOException
*/
private void saveUserCopy() throws IOException
{
McmmoCore.getLogger().info("Saving new node");
userCopyLoader.save(userRootNode);
}
/**
* Performs any necessary operations to update this config
*/
private void updateConfigVersion() {
// Set a version for our config
this.userRootNode.getNode("ConfigVersion").setValue(getConfigVersion());
McmmoCore.getLogger().info("Updated config to ["+getConfigVersion()+"] - " + FILE_RELATIVE_PATH);
}
/**
* Returns the root node of this config
* @return the root node of this config
*/
protected ConfigurationNode getUserRootNode() {
return userRootNode;
}
int getIntValue(String... path)
{
return userRootNode.getNode(path).getInt();
}
double getDoubleValue(String... path)
{
return userRootNode.getNode(path).getDouble();
}
boolean getBooleanValue(String... path)
{
return userRootNode.getNode(path).getBoolean();
}
String getStringValue(String... path)
{
return userRootNode.getNode(path).getString();
}
} }

View File

@ -1,14 +1,15 @@
package com.gmail.nossr50.core.config; package com.gmail.nossr50.core.config;
import com.gmail.nossr50.core.mcmmo.skills.PrimarySkillType; import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.mcmmo.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.util.StringUtils;
public class CoreSkillsConfig extends AutoUpdateConfigLoader { public class CoreSkillsConfig extends ConfigurableLoader {
private static CoreSkillsConfig instance; private static CoreSkillsConfig instance;
public CoreSkillsConfig() { public CoreSkillsConfig() {
super("coreskills.yml"); super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"coreskills.yml");
validate(); validate();
} }

View File

@ -0,0 +1,10 @@
package com.gmail.nossr50.core.config;
import java.util.List;
/**
* This is for config validation
*/
public interface DefaultKeys {
List<String> validateKeys();
}

View File

@ -1,68 +0,0 @@
package com.gmail.nossr50.core.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.InputStreamReader;
public class HiddenConfig {
private static HiddenConfig instance;
private String fileName;
private YamlConfiguration config;
private boolean chunkletsEnabled;
private int conversionRate;
private boolean useEnchantmentBuffs;
private int uuidConvertAmount;
private int mojangRateLimit;
private long mojangLimitPeriod;
public HiddenConfig(String fileName) {
this.fileName = fileName;
load();
}
public static HiddenConfig getInstance() {
if (instance == null) {
instance = new HiddenConfig("hidden.yml");
}
return instance;
}
public void load() {
InputStreamReader reader = mcMMO.p.getResourceAsReader(fileName);
if (reader != null) {
config = YamlConfiguration.loadConfiguration(reader);
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
uuidConvertAmount = config.getInt("Options.UUIDConvertAmount", 5);
mojangRateLimit = config.getInt("Options.MojangRateLimit", 50000);
mojangLimitPeriod = config.getLong("Options.MojangLimitPeriod", 600000);
}
}
public boolean getChunkletsEnabled() {
return chunkletsEnabled;
}
public int getConversionRate() {
return conversionRate;
}
public boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
public int getUUIDConvertAmount() {
return uuidConvertAmount;
}
public int getMojangRateLimit() {
return mojangRateLimit;
}
public long getMojangLimitPeriod() {
return mojangLimitPeriod;
}
}

View File

@ -0,0 +1,12 @@
package com.gmail.nossr50.core.config;
/**
* Represents a config that is version checked
*/
public interface VersionedConfig {
/**
* The version of this config
* @return
*/
double getConfigVersion();
}

View File

@ -1,13 +1,9 @@
package com.gmail.nossr50.config.skills.alchemy; package com.gmail.nossr50.core.config.skills.alchemy;
import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.core.mcmmo.colors.ChatColor;
import com.gmail.nossr50.core.mcmmo.skills.alchemy.AlchemyPotion; import com.gmail.nossr50.core.mcmmo.item.ItemStack;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyPotion;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.core.data.blockmeta; package com.gmail.nossr50.core.data.blockmeta;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.config.ChunkConversionOptions;
public class ChunkletManagerFactory { public class ChunkletManagerFactory {
public static ChunkletManager getChunkletManager() { public static ChunkletManager getChunkletManager() {
HiddenConfig hConfig = HiddenConfig.getInstance(); ChunkConversionOptions hConfig = ChunkConversionOptions.getInstance();
if (hConfig.getChunkletsEnabled()) { if (hConfig.getChunkletsEnabled()) {
return new HashChunkletManager(); return new HashChunkletManager();

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.core.data.blockmeta.chunkmeta; package com.gmail.nossr50.core.data.blockmeta.chunkmeta;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.config.ChunkConversionOptions;
public class ChunkManagerFactory { public class ChunkManagerFactory {
public static ChunkManager getChunkManager() { public static ChunkManager getChunkManager() {
HiddenConfig hConfig = HiddenConfig.getInstance(); ChunkConversionOptions hConfig = ChunkConversionOptions.getInstance();
if (hConfig.getChunkletsEnabled()) { if (hConfig.getChunkletsEnabled()) {
return new HashChunkManager(); return new HashChunkManager();

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.core.data.blockmeta.conversion; package com.gmail.nossr50.core.data.blockmeta.conversion;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
@ -19,7 +19,7 @@ public class BlockStoreConversionMain implements Runnable {
this.world = world; this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler(); this.scheduler = mcMMO.p.getServer().getScheduler();
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data"); this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()]; this.converters = new BlockStoreConversionXDirectory[ChunkConversionOptions.getInstance().getConversionRate()];
} }
public void start() { public void start() {
@ -52,7 +52,7 @@ public class BlockStoreConversionMain implements Runnable {
this.xDirs = this.dataDir.listFiles(); this.xDirs = this.dataDir.listFiles();
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) { for (this.i = 0; (this.i < ChunkConversionOptions.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) {
if (this.converters[this.i] == null) { if (this.converters[this.i] == null) {
this.converters[this.i] = new BlockStoreConversionXDirectory(); this.converters[this.i] = new BlockStoreConversionXDirectory();
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.core.data.blockmeta.conversion; package com.gmail.nossr50.core.data.blockmeta.conversion;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
@ -21,7 +21,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
public void start(org.bukkit.World world, File dataDir) { public void start(org.bukkit.World world, File dataDir) {
this.world = world; this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler(); this.scheduler = mcMMO.p.getServer().getScheduler();
this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()]; this.converters = new BlockStoreConversionZDirectory[ChunkConversionOptions.getInstance().getConversionRate()];
this.dataDir = dataDir; this.dataDir = dataDir;
if (this.taskID >= 0) { if (this.taskID >= 0) {
@ -53,7 +53,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
this.zDirs = this.dataDir.listFiles(); this.zDirs = this.dataDir.listFiles();
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) { for (this.i = 0; (this.i < ChunkConversionOptions.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
if (this.converters[this.i] == null) { if (this.converters[this.i] == null) {
this.converters[this.i] = new BlockStoreConversionZDirectory(); this.converters[this.i] = new BlockStoreConversionZDirectory();
} }

View File

@ -1,21 +1,23 @@
package com.gmail.nossr50.core.data.blockmeta.conversion; package com.gmail.nossr50.core.data.blockmeta.conversion;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.data.blockmeta.ChunkletStore; import com.gmail.nossr50.core.data.blockmeta.ChunkletStore;
import com.gmail.nossr50.core.data.blockmeta.HashChunkletManager; import com.gmail.nossr50.core.data.blockmeta.HashChunkletManager;
import com.gmail.nossr50.core.data.blockmeta.PrimitiveChunkletStore; import com.gmail.nossr50.core.data.blockmeta.PrimitiveChunkletStore;
import com.gmail.nossr50.core.data.blockmeta.PrimitiveExChunkletStore; import com.gmail.nossr50.core.data.blockmeta.PrimitiveExChunkletStore;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.HashChunkManager; import com.gmail.nossr50.core.data.blockmeta.chunkmeta.HashChunkManager;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.PrimitiveChunkStore; import com.gmail.nossr50.core.data.blockmeta.chunkmeta.PrimitiveChunkStore;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.mcmmo.tasks.TaskScheduler;
import org.bukkit.scheduler.BukkitScheduler; import com.gmail.nossr50.core.mcmmo.world.World;
import java.io.File; import java.io.File;
public class BlockStoreConversionZDirectory implements Runnable { public class BlockStoreConversionZDirectory implements Runnable {
public int taskID, cx, cz, x, y, z, y2, xPos, zPos, cxPos, czPos; public int taskID, cx, cz, x, y, z, y2, xPos, zPos, cxPos, czPos;
private String cxs, czs, chunkletName, chunkName; private String cxs, czs, chunkletName, chunkName;
private org.bukkit.World world; private World world;
private BukkitScheduler scheduler; //private BukkitScheduler scheduler;
private TaskScheduler scheduler;
private File xDir, dataDir; private File xDir, dataDir;
private HashChunkletManager manager; private HashChunkletManager manager;
private HashChunkManager newManager; private HashChunkManager newManager;
@ -29,9 +31,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
this.taskID = -1; this.taskID = -1;
} }
public void start(org.bukkit.World world, File xDir, File dataDir) { public void start(World world, File xDir, File dataDir) {
this.world = world; this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler(); this.scheduler = McmmoCore.getTaskScheduler();
this.manager = new HashChunkletManager(); this.manager = new HashChunkletManager();
this.newManager = (HashChunkManager) mcMMO.getPlaceStore(); this.newManager = (HashChunkManager) mcMMO.getPlaceStore();
this.dataDir = dataDir; this.dataDir = dataDir;
@ -41,7 +43,8 @@ public class BlockStoreConversionZDirectory implements Runnable {
return; return;
} }
this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); // Bukkit - this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId();
this.taskID = scheduler.scheduleTask(this, 1).getTaskId();
return; return;
} }

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.core.data.database; package com.gmail.nossr50.core.data.database;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.core.mcmmo.database.DatabaseType; import com.gmail.nossr50.core.datatypes.database.DatabaseType;
import com.gmail.nossr50.core.mcmmo.database.PlayerStat; import com.gmail.nossr50.core.datatypes.database.PlayerStat;
import com.gmail.nossr50.core.mcmmo.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.mcmmo.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.core.mcmmo;
/**
* Custom Definitions for Block's Type
* Unlike Bukkit's Material system, this matches a block by its state information
* For example, an Oak Log in older versions of MC was simply a block with state information of being variant oak
* To account for all the differences between version we have our own custom constants that will match based on platform
*/
public enum BlockTypes {
}

View File

@ -0,0 +1,13 @@
package com.gmail.nossr50.core.mcmmo.commands;
/**
* Command senders are either Players or the CLI
*/
public interface CommandSender {
/**
* Send a message to the CommandSender
* @param msg the message to send
*/
void sendMessage(String msg);
}

View File

@ -20,4 +20,10 @@ public interface PluginTask {
* Schedule this task (begins ASAP) * Schedule this task (begins ASAP)
*/ */
void scheduleTask(); void scheduleTask();
/**
* Get the ID of this task
* @return the id of this task
*/
int getTaskId();
} }

View File

@ -0,0 +1,25 @@
package com.gmail.nossr50.core.mcmmo.tasks;
/**
* Schedules tasks for a platform
*/
public interface TaskScheduler {
/**
* Schedules the specified task
* @param pluginTask the task to schedule
*/
PluginTask scheduleTask(PluginTask pluginTask);
/**
* Schedules the specified task
* @param runnable the runnable to schedule
*/
PluginTask scheduleTask(Runnable runnable);
/**
* Schedules the specified task
* @param runnable the runnable to schedule
* @param tickDelay the delay for this task in ticks
*/
PluginTask scheduleTask(Runnable runnable, int tickDelay);
}

View File

@ -1,11 +1,22 @@
package com.gmail.nossr50.core.platform; package com.gmail.nossr50.core.platform;
import com.gmail.nossr50.core.mcmmo.server.Server;
import com.gmail.nossr50.core.mcmmo.tasks.TaskScheduler;
import java.io.File;
/** /**
* Represents the current API Platform * Represents the current API Platform
* mcMMO supports multiple platforms, so that abstraction is handled through this interface * mcMMO supports multiple platforms, so that abstraction is handled through this interface
*/ */
public interface Platform { public interface Platform {
/**
* Gets the MC Server implementation for this Platform
* @return the MC server object
*/
Server getServer();
/** /**
* Gets the name of the Platform * Gets the name of the Platform
* *
@ -40,4 +51,24 @@ public interface Platform {
* @return this PlatformSoftwareType * @return this PlatformSoftwareType
*/ */
PlatformSoftwareType getPlatformSoftwareType(); PlatformSoftwareType getPlatformSoftwareType();
/**
* Gets the task Scheduler
* @return the task scheduler
*/
TaskScheduler getScheduler();
/**
* Gets a resource stream from inside the JAR at a specified path
* @param path the path inside the JAR where the resource stream is found
* @return the resource stream
*/
java.io.InputStream getResource(String path);
/**
* Gets the path of the Data folder for this platform
* @return this platform's data folder
*/
File getDataFolderPath();
} }

View File

@ -1,19 +1,18 @@
package com.gmail.nossr50.core.runnables.database; package com.gmail.nossr50.core.runnables.database;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.database.DatabaseManager; import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.datatypes.experience.FormulaType; import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.mcmmo.commands.CommandSender;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.util.Misc;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
public class FormulaConversionTask extends BukkitRunnable { public class FormulaConversionTask implements Runnable {
private CommandSender sender; private CommandSender sender;
private FormulaType formulaType; private FormulaType formulaType;
@ -26,16 +25,16 @@ public class FormulaConversionTask extends BukkitRunnable {
public void run() { public void run() {
int convertedUsers = 0; int convertedUsers = 0;
long startMillis = System.currentTimeMillis(); long startMillis = System.currentTimeMillis();
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) { for (String playerName : McmmoCore.getDatabaseManager().getStoredUsers()) {
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
PlayerProfile profile; PlayerProfile profile;
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); profile = McmmoCore.getDatabaseManager().loadPlayerProfile(playerName, false);
if (!profile.isLoaded()) { if (!profile.isLoaded()) {
mcMMO.p.debug("Profile not loaded."); McmmoCore.getLogger().severe("Profile not loaded.");
continue; continue;
} }
@ -49,28 +48,28 @@ public class FormulaConversionTask extends BukkitRunnable {
convertedUsers++; convertedUsers++;
Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis); Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis);
} }
mcMMO.getFormulaManager().setPreviousFormulaType(formulaType); McmmoCore.getFormulaManager().setPreviousFormulaType(formulaType);
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", formulaType.toString())); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", formulaType.toString()));
} }
private void editValues(PlayerProfile profile) { private void editValues(PlayerProfile profile) {
mcMMO.p.debug("========================================================================"); McmmoCore.getLogger().info("========================================================================");
mcMMO.p.debug("Conversion report for " + profile.getPlayerName() + ":"); McmmoCore.getLogger().info("Conversion report for " + profile.getPlayerName() + ":");
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
int oldLevel = profile.getSkillLevel(primarySkillType); int oldLevel = profile.getSkillLevel(primarySkillType);
int oldXPLevel = profile.getSkillXpLevel(primarySkillType); int oldXPLevel = profile.getSkillXpLevel(primarySkillType);
int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel); int totalOldXP = McmmoCore.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel);
if (totalOldXP == 0) { if (totalOldXP == 0) {
continue; continue;
} }
int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / ExperienceConfig.getInstance().getExpModifier()), formulaType); int[] newExperienceValues = McmmoCore.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / ExperienceConfig.getInstance().getExpModifier()), formulaType);
int newLevel = newExperienceValues[0]; int newLevel = newExperienceValues[0];
int newXPlevel = newExperienceValues[1]; int newXPlevel = newExperienceValues[1];
mcMMO.p.debug(" Skill: " + primarySkillType.toString()); /*McmmoCore.getLogger().info(" Skill: " + primarySkillType.toString());
mcMMO.p.debug(" OLD:"); mcMMO.p.debug(" OLD:");
mcMMO.p.debug(" Level: " + oldLevel); mcMMO.p.debug(" Level: " + oldLevel);
@ -80,7 +79,7 @@ public class FormulaConversionTask extends BukkitRunnable {
mcMMO.p.debug(" NEW:"); mcMMO.p.debug(" NEW:");
mcMMO.p.debug(" Level " + newLevel); mcMMO.p.debug(" Level " + newLevel);
mcMMO.p.debug(" XP " + newXPlevel); mcMMO.p.debug(" XP " + newXPlevel);
mcMMO.p.debug("------------------------------------------------------------------------"); mcMMO.p.debug("------------------------------------------------------------------------");*/
profile.modifySkill(primarySkillType, newLevel); profile.modifySkill(primarySkillType, newLevel);
profile.setSkillXpLevel(primarySkillType, newXPlevel); profile.setSkillXpLevel(primarySkillType, newXPlevel);

View File

@ -1,12 +1,11 @@
package com.gmail.nossr50.core.runnables.database; package com.gmail.nossr50.core.runnables.database;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.core.data.database.DatabaseManager; import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.datatypes.database.UpgradeType; import com.gmail.nossr50.core.datatypes.database.UpgradeType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.core.util.uuid.UUIDFetcher;
import com.gmail.nossr50.util.uuid.UUIDFetcher;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -14,19 +13,17 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
public class UUIDUpdateAsyncTask extends BukkitRunnable { public class UUIDUpdateAsyncTask implements Runnable {
private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100); private static final int MAX_LOOKUP = Math.max(ChunkConversionOptions.getUUIDConvertAmount(), 100);
private static final int RATE_LIMIT = HiddenConfig.getInstance().getMojangRateLimit(); private static final int RATE_LIMIT = ChunkConversionOptions.getMojangRateLimit();
private static final long LIMIT_PERIOD = HiddenConfig.getInstance().getMojangLimitPeriod(); private static final long LIMIT_PERIOD = ChunkConversionOptions.getMojangLimitPeriod();
private static final int BATCH_SIZE = MAX_LOOKUP * 3; private static final int BATCH_SIZE = MAX_LOOKUP * 3;
private mcMMO plugin;
private List<String> userNames; private List<String> userNames;
private int size; private int size;
private int checkedUsers; private int checkedUsers;
private long startMillis; private long startMillis;
public UUIDUpdateAsyncTask(mcMMO plugin, List<String> userNames) { public UUIDUpdateAsyncTask(List<String> userNames) {
this.plugin = plugin;
this.userNames = userNames; this.userNames = userNames;
this.checkedUsers = 0; this.checkedUsers = 0;
@ -37,7 +34,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
public void run() { public void run() {
size = userNames.size(); size = userNames.size();
plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size); McmmoCore.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size);
List<String> userNamesSection; List<String> userNamesSection;
Map<String, UUID> fetchedUUIDs = new HashMap<String, UUID>(); Map<String, UUID> fetchedUUIDs = new HashMap<String, UUID>();
@ -76,7 +73,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
continue; continue;
} }
plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e); McmmoCore.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e);
return; return;
} }
@ -86,14 +83,14 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
if (fetchedUUIDs.size() >= BATCH_SIZE) { if (fetchedUUIDs.size() >= BATCH_SIZE) {
mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); McmmoCore.getDatabaseManager().saveUserUUIDs(fetchedUUIDs);
fetchedUUIDs = new HashMap<String, UUID>(); fetchedUUIDs = new HashMap<String, UUID>();
} }
} }
if (fetchedUUIDs.size() == 0 || mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { if (fetchedUUIDs.size() == 0 || McmmoCore.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); McmmoCore.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
plugin.getLogger().info("UUID upgrade completed!"); McmmoCore.getLogger().info("UUID upgrade completed!");
} }
} }
} }

View File

@ -1,21 +1,20 @@
package com.gmail.nossr50.core.runnables.database; package com.gmail.nossr50.core.runnables.database;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.config.Config; import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
public class UserPurgeTask extends BukkitRunnable { public class UserPurgeTask implements Runnable {
private ReentrantLock lock = new ReentrantLock(); private ReentrantLock lock = new ReentrantLock();
@Override @Override
public void run() { public void run() {
lock.lock(); lock.lock();
mcMMO.getDatabaseManager().purgePowerlessUsers(); McmmoCore.getDatabaseManager().purgePowerlessUsers();
if (Config.getInstance().getOldUsersCutoff() != -1) { if (Config.getInstance().getOldUsersCutoff() != -1) {
mcMMO.getDatabaseManager().purgeOldUsers(); McmmoCore.getDatabaseManager().purgeOldUsers();
} }
lock.unlock(); lock.unlock();
} }

View File

@ -2,7 +2,7 @@ package com.gmail.nossr50.core.util.skills;
import com.gmail.nossr50.core.config.AdvancedConfig; import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.config.Config; import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.core.config.HiddenConfig; import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.experience.XPGainSource; import com.gmail.nossr50.core.datatypes.experience.XPGainSource;
@ -128,7 +128,7 @@ public class SkillUtils {
} }
public static void handleAbilitySpeedIncrease(Player player) { public static void handleAbilitySpeedIncrease(Player player) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) { if (ChunkConversionOptions.getInstance().useEnchantmentBuffs()) {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (heldItem == null || heldItem.getType() == Material.AIR) { if (heldItem == null || heldItem.getType() == Material.AIR) {
@ -184,7 +184,7 @@ public class SkillUtils {
} }
public static void handleAbilitySpeedDecrease(Player player) { public static void handleAbilitySpeedDecrease(Player player) {
if (!HiddenConfig.getInstance().useEnchantmentBuffs()) { if (!ChunkConversionOptions.getInstance().useEnchantmentBuffs()) {
return; return;
} }