mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-08 19:38:17 +01:00
Update Config and Language class to fully use the new base
This commit is contained in:
parent
a97ba36ebc
commit
53e99e1aef
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 GeorgH93
|
* Copyright (C) 2022 GeorgH93
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,34 +17,34 @@
|
|||||||
|
|
||||||
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
||||||
|
|
||||||
import at.pcgamingfreaks.Bukkit.Configuration;
|
|
||||||
import at.pcgamingfreaks.Bukkit.MCVersion;
|
import at.pcgamingfreaks.Bukkit.MCVersion;
|
||||||
import at.pcgamingfreaks.Bukkit.MinecraftMaterial;
|
import at.pcgamingfreaks.Bukkit.MinecraftMaterial;
|
||||||
import at.pcgamingfreaks.Bukkit.Util.Utils;
|
import at.pcgamingfreaks.Bukkit.Util.Utils;
|
||||||
|
import at.pcgamingfreaks.Config.Configuration;
|
||||||
|
import at.pcgamingfreaks.Config.ILanguageConfiguration;
|
||||||
|
import at.pcgamingfreaks.Config.YamlFileManager;
|
||||||
import at.pcgamingfreaks.ConsoleColor;
|
import at.pcgamingfreaks.ConsoleColor;
|
||||||
import at.pcgamingfreaks.Database.DatabaseConnectionConfiguration;
|
import at.pcgamingfreaks.Database.DatabaseConnectionConfiguration;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.WorldBlacklistMode;
|
import at.pcgamingfreaks.Minepacks.Bukkit.API.WorldBlacklistMode;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.OldFileUpdater;
|
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.OldFileUpdater;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.MagicValues;
|
import at.pcgamingfreaks.Minepacks.Bukkit.MagicValues;
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.ShrinkApproach;
|
import at.pcgamingfreaks.Minepacks.Bukkit.ShrinkApproach;
|
||||||
import at.pcgamingfreaks.YamlFileManager;
|
import at.pcgamingfreaks.Version;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Config extends Configuration implements DatabaseConnectionConfiguration
|
public class Config extends Configuration implements DatabaseConnectionConfiguration, ILanguageConfiguration
|
||||||
{
|
{
|
||||||
private static final int CONFIG_VERSION = 32, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
|
private static final Version CONFIG_VERSION = new Version(32), PRE_V2_VERSION = new Version(20);
|
||||||
|
|
||||||
public Config(JavaPlugin plugin)
|
public Config(Minepacks plugin)
|
||||||
{
|
{
|
||||||
super(plugin, CONFIG_VERSION, UPGRADE_THRESHOLD);
|
super(plugin, CONFIG_VERSION);
|
||||||
languageKey = "Language.Language";
|
|
||||||
languageUpdateKey = "Language.UpdateMode";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,16 +56,16 @@ protected void doUpdate()
|
|||||||
@Override
|
@Override
|
||||||
protected void doUpgrade(@NotNull YamlFileManager oldConfig)
|
protected void doUpgrade(@NotNull YamlFileManager oldConfig)
|
||||||
{
|
{
|
||||||
if(oldConfig.getVersion() < PRE_V2_VERSION) // Pre V2.0 config file
|
if(oldConfig.getVersion().olderThan(PRE_V2_VERSION)) // Pre V2.0 config file
|
||||||
{
|
{
|
||||||
OldFileUpdater.updateConfig(oldConfig.getYamlE(), getConfigE());
|
OldFileUpdater.updateConfig(oldConfig.getYamlE(), getConfigE());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Map<String, String> remappedKeys = new HashMap<>();
|
Map<String, String> remappedKeys = new HashMap<>();
|
||||||
if(oldConfig.getVersion() <= 23) remappedKeys.put("ItemFilter.Materials", "ItemFilter.Blacklist");
|
if(oldConfig.getVersion().olderOrEqualThan(new Version(23))) remappedKeys.put("ItemFilter.Materials", "ItemFilter.Blacklist");
|
||||||
if(oldConfig.getVersion() <= 28) remappedKeys.put("Misc.AutoUpdate.Enabled", "Misc.AutoUpdate");
|
if(oldConfig.getVersion().olderOrEqualThan(new Version(28))) remappedKeys.put("Misc.AutoUpdate.Enabled", "Misc.AutoUpdate");
|
||||||
if(oldConfig.getVersion() <= 30)
|
if(oldConfig.getVersion().olderOrEqualThan(new Version(30)))
|
||||||
{
|
{
|
||||||
remappedKeys.put("WorldSettings.FilteredWorlds", "WorldSettings.Blacklist");
|
remappedKeys.put("WorldSettings.FilteredWorlds", "WorldSettings.Blacklist");
|
||||||
remappedKeys.put("WorldSettings.BockMode", "WorldSettings.BlacklistMode");
|
remappedKeys.put("WorldSettings.BockMode", "WorldSettings.BlacklistMode");
|
||||||
@ -130,7 +130,7 @@ public boolean useOnlineUUIDs()
|
|||||||
{
|
{
|
||||||
logger.warning("When using BungeeCord please make sure to set the UUID_Type config option explicitly!");
|
logger.warning("When using BungeeCord please make sure to set the UUID_Type config option explicitly!");
|
||||||
}
|
}
|
||||||
return plugin.getServer().getOnlineMode();
|
return Bukkit.getServer().getOnlineMode();
|
||||||
}
|
}
|
||||||
return type.equals("online");
|
return type.equals("online");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 GeorgH93
|
* Copyright (C) 2022 GeorgH93
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,34 +17,32 @@
|
|||||||
|
|
||||||
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.Bukkit.Message.Message;
|
||||||
|
import at.pcgamingfreaks.Config.YamlFileManager;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.OldFileUpdater;
|
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.OldFileUpdater;
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||||
import at.pcgamingfreaks.Version;
|
import at.pcgamingfreaks.Version;
|
||||||
import at.pcgamingfreaks.YamlFileManager;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Language extends at.pcgamingfreaks.Bukkit.Language
|
public class Language extends at.pcgamingfreaks.Bukkit.Config.Language
|
||||||
{
|
{
|
||||||
private static final Version LANG_VERSION = new Version(19), UPGRADE_THRESHOLD = LANG_VERSION;
|
private static final Version LANG_VERSION = new Version(19);
|
||||||
|
|
||||||
public Language(JavaPlugin plugin)
|
public Language(Minepacks plugin)
|
||||||
{
|
{
|
||||||
super(plugin, LANG_VERSION, UPGRADE_THRESHOLD);
|
super(plugin, LANG_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doUpdate() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doUpgrade(@NotNull YamlFileManager oldLang)
|
protected void doUpgrade(@NotNull YamlFileManager oldLang)
|
||||||
{
|
{
|
||||||
if(oldLang.getVersion() < 10) // Pre v2.0 versions
|
if(oldLang.getVersion().olderThan(new Version(10))) // Pre v2.0 versions
|
||||||
{
|
{
|
||||||
OldFileUpdater.updateLanguage(oldLang.getYamlE(), getYaml(), plugin.getLogger());
|
OldFileUpdater.updateLanguage(oldLang.getYamlE(), getYaml(), getLogger());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -62,4 +60,12 @@ public String[] getCommandAliases(final String command, final @NotNull String...
|
|||||||
List<String> aliases = getLangE().getStringList("Command." + command, new ArrayList<>(0));
|
List<String> aliases = getLangE().getStringList("Command." + command, new ArrayList<>(0));
|
||||||
return (aliases.size() > 0) ? aliases.toArray(new String[0]) : defaults;
|
return (aliases.size() > 0) ? aliases.toArray(new String[0]) : defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Message getMessage(@NotNull String path)
|
||||||
|
{
|
||||||
|
Message msg = super.getMessage(path);
|
||||||
|
msg.enableStringFormat(); // TODO use new placeholder system instead!
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user