New upgrade code

This commit is contained in:
GeorgH93 2015-09-16 14:45:51 +02:00
parent 53f27ee07a
commit 886b73de28
5 changed files with 19 additions and 7 deletions

View File

@ -16,6 +16,8 @@ command_cooldown: -1
# Defines if the content of the backpack get droped on the death of a player.
# If enabled, it can be disabled for individual players with the "backpack.KeepOnDeath" permission.
drop_on_death: true
# Defines if the message that the backpack has been closed should be shown
show_close_message: true
# Controlls for the auto pickup on full inventory function
full_inventory:

View File

@ -23,6 +23,8 @@
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Set;
public class Config extends Configuration
{
private static final int CONFIG_VERSION = 9;
@ -45,6 +47,18 @@ protected void doUpdate(int version)
// Nothing to update yet
}
@Override
protected void doUpgrade(Configuration oldConfiguration)
{
Set<String> keys = oldConfiguration.getConfig().getKeys(true);
for(String key : keys)
{
if(key.equals("Database.UseUUIDs") || key.equals("UseUUIDs")) continue;
config.set(key, oldConfiguration.getConfig().get(key));
}
config.set("Database.UseUUIDs", Bukkit.getServer().getOnlineMode() && isBukkitVersionUUIDCompatible());
}
// Getter
public int getAutoCleanupMaxInactiveDays()
{
@ -96,13 +110,9 @@ public boolean getUpdatePlayer()
return config.getBoolean("Database.UpdatePlayer", true);
}
public boolean UseUUIDs()
public boolean getUseUUIDs()
{
if(config.isSet("Database.UseUUIDs"))
{
return config.getBoolean("Database.UseUUIDs");
}
return config.getBoolean("UseUUIDs");
return config.getBoolean("Database.UseUUIDs");
}
public boolean getUseUUIDSeparators()

View File

@ -40,7 +40,7 @@ public Database(MinePacks mp)
{
plugin = mp;
UseUUIDSeparators = plugin.config.getUseUUIDSeparators();
UseUUIDs = plugin.config.UseUUIDs();
UseUUIDs = plugin.config.getUseUUIDs();
maxAge = plugin.config.getAutoCleanupMaxInactiveDays();
}