Skip to content

Commit

Permalink
Remove old config/language file converter
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Dec 11, 2021
1 parent 081ad95 commit b39183c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 344 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package at.pcgamingfreaks.MarriageMaster.Bukkit.Database;

import at.pcgamingfreaks.Bukkit.Configuration;
import at.pcgamingfreaks.Bukkit.MinecraftMaterial;
import at.pcgamingfreaks.Bukkit.Util.Utils;
import at.pcgamingfreaks.MarriageMaster.Bukkit.Database.Helper.OldFileUpdater;
import at.pcgamingfreaks.ConsoleColor;
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Bukkit.Range;
import at.pcgamingfreaks.MarriageMaster.Bukkit.SpecialInfoWorker.UpgradedInfo;
Expand Down Expand Up @@ -71,7 +71,7 @@ protected void doUpgrade(final @NotNull at.pcgamingfreaks.YamlFileManager oldCon
{
if(oldConfig.version().olderThan(new Version(MagicValues.CONFIG_PRE_V2_VERSIONS)))
{
OldFileUpdater.updateConfig(oldConfig.getYaml(), this.getConfigE());
getLogger().warning(ConsoleColor.RED + "Your config file is from v1.x and is not compatible with versions newer than 2.5!" + ConsoleColor.RESET);
new UpgradedInfo(MarriageMaster.getInstance());
}
else
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package at.pcgamingfreaks.MarriageMaster.Bukkit.Database;

import at.pcgamingfreaks.MarriageMaster.Bukkit.Database.Helper.OldFileUpdater;
import at.pcgamingfreaks.ConsoleColor;
import at.pcgamingfreaks.MarriageMaster.Database.ILanguage;
import at.pcgamingfreaks.MarriageMaster.MagicValues;
import at.pcgamingfreaks.Message.MessageColor;
Expand Down Expand Up @@ -47,7 +47,7 @@ protected void doUpgrade(@NotNull at.pcgamingfreaks.YamlFileManager oldLang)
{
if(oldLang.version().olderThan(new Version(MagicValues.LANG_PRE_V2_VERSIONS)))
{
OldFileUpdater.updateLanguage(oldLang.getYamlE(), getLang());
getLogger().warning(ConsoleColor.RED + "Your language file is from v1.x and is not compatible with versions newer than 2.5!" + ConsoleColor.RESET);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 GeorgH93
* Copyright (C) 2021 GeorgH93
*
* 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
Expand All @@ -12,7 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package at.pcgamingfreaks.MarriageMaster.Bukkit.SpecialInfoWorker;
Expand All @@ -38,8 +38,8 @@ public UpgradedInfo(MarriageMaster plugin)
// I don't load this message from the config. He just upgraded, the messages in the config would probably be exactly the same.
messagePluginUpgraded = new MessageBuilder("Marriage Master", MessageColor.GOLD).append(" has been upgraded to ", MessageColor.AQUA)
.append(MarriageMaster.getInstance().getDescription().getVersion(), MessageColor.BLUE, MessageFormat.BOLD).append(".", MessageColor.AQUA).appendNewLine()
.append("All of your settings and changes to the language file have been copied into the new format.", MessageColor.AQUA).appendNewLine()
.append("However it's recommended to manually check them to make sure that all of your settings are still how you like them (there are many new options).", MessageColor.AQUA).getMessage();
.append("Your config and language files have been backuped, since they are not compatible with this version of the plugin!", MessageColor.AQUA).appendNewLine()
.append("You can try to use v2.5 to convert them to the new format or apply your changes manually.", MessageColor.AQUA).getMessage();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package at.pcgamingfreaks.MarriageMaster.Bungee.Database;

import at.pcgamingfreaks.Bungee.Configuration;
import at.pcgamingfreaks.ConsoleColor;
import at.pcgamingfreaks.MarriageMaster.Bungee.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Bungee.SpecialInfoWorker.UpgradedInfo;
import at.pcgamingfreaks.MarriageMaster.Database.DatabaseConfiguration;
Expand All @@ -33,50 +34,15 @@ public class Config extends Configuration implements DatabaseConfiguration
{
public Config(Plugin plugin)
{
super(plugin, MagicValues.BUNGEE_CONFIG_VERSION, MagicValues.BUNGEE_CONFIG_VERSION);
super(plugin, new Version(MagicValues.BUNGEE_CONFIG_VERSION));
}

@Override
protected void doUpgrade(YamlFileManager oldConfig)
{
if(oldConfig.version().olderThan(new Version(MagicValues.CONFIG_PRE_V2_VERSIONS)))
{
try
{
getConfigE().set("Language.Language", oldConfig.getYamlE().getString("Language", "en"));
getConfigE().set("InfoOnPartnerJoinLeave.Enable", oldConfig.getYamlE().getBoolean("InformOnPartnerJoin", true));
getConfigE().set("InfoOnPartnerJoinLeave.JoinDelay", oldConfig.getYamlE().getInt("DelayMessageForJoiningPlayer", 0));
getConfigE().set("Database.UseUUIDs", oldConfig.getYamlE().getBoolean("UseUUIDs", true));
getConfigE().set("Database.UUID_Type", oldConfig.getYamlE().getString("UUID_Type", "auto"));
getConfigE().set("Database.Type", oldConfig.getYamlE().getString("Database.Type", "SQLite"));
getConfigE().set("Database.SQL.Host", oldConfig.getYamlE().getString("Database.MySQL.Host", "localhost"));
getConfigE().set("Database.SQL.Database", oldConfig.getYamlE().getString("Database.MySQL.Database", "minecraft"));
getConfigE().set("Database.SQL.User", oldConfig.getYamlE().getString("Database.MySQL.User", "minecraft"));
getConfigE().set("Database.SQL.Password", oldConfig.getYamlE().getString("Database.MySQL.Password", "minecraft"));
getConfigE().set("Database.SQL.MaxConnections", oldConfig.getYamlE().getInt("Database.MySQL.MaxConnections", 4));
getConfigE().set("Database.SQL.Tables.User", oldConfig.getYamlE().getString("Database.Tables.User", "marry_players"));
getConfigE().set("Database.SQL.Tables.Priests", oldConfig.getYamlE().getString("Database.Tables.Priests", "marry_priests"));
getConfigE().set("Database.SQL.Tables.Partner", oldConfig.getYamlE().getString("Database.Tables.Partner", "marry_partners"));
getConfigE().set("Database.SQL.Tables.Home", oldConfig.getYamlE().getString("Database.Tables.Home", "marry_home"));
getConfigE().set("Marriage.Surnames.Enable", oldConfig.getYamlE().getBoolean("Surname", false));
getConfigE().set("Marriage.Surnames.AllowColors", oldConfig.getYamlE().getBoolean("AllowSurnameColors", false));
getConfigE().set("Marriage.Surnames.AllowedCharacters", oldConfig.getYamlE().getString("AllowedSurnameCharacters", "A-Za-z"));
getConfigE().set("Misc.AutoUpdate", oldConfig.getYamlE().getBoolean("Misc.AutoUpdate", true));
getConfigE().set("Chat.Global", oldConfig.getYamlE().getBoolean("Chat.Global", true));
getConfigE().set("Teleport.Delayed", oldConfig.getYamlE().getBoolean("TP.Delayed", false));
getConfigE().set("Teleport.Global", oldConfig.getYamlE().getBoolean("TP.Global", true));
getConfigE().set("Teleport.BlockedFrom", oldConfig.getYamlE().getStringList("TP.BlockedFrom", new ArrayList<>(0)));
getConfigE().set("Teleport.BlockedTo", oldConfig.getYamlE().getStringList("TP.BlockedTo", new ArrayList<>(0)));
getConfigE().set("Home.Delayed", oldConfig.getYamlE().getBoolean("Home.Delayed", false));
getConfigE().set("Home.Global", oldConfig.getYamlE().getBoolean("Home.Global", true));
getConfigE().set("Home.BlockedFrom", oldConfig.getYamlE().getStringList("Home.BlockedFrom", new ArrayList<>(0)));
getConfigE().set("Database.SQL.Tables.Fields.PriestID", "priest_id");
}
catch(Exception e)
{
plugin.getLogger().warning("There was a problem upgrading the old config file into the new config file.");
e.printStackTrace();
}
getLogger().warning(ConsoleColor.RED + "Your config file is from v1.x and is not compatible with versions newer than 2.5!" + ConsoleColor.RESET);
new UpgradedInfo(MarriageMaster.getInstance());
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 GeorgH93
* Copyright (C) 2021 GeorgH93
*
* 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
Expand All @@ -12,14 +12,15 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package at.pcgamingfreaks.MarriageMaster.Bungee.Database;

import at.pcgamingfreaks.MarriageMaster.Database.ILanguage;
import at.pcgamingfreaks.MarriageMaster.MagicValues;
import at.pcgamingfreaks.Message.MessageColor;
import at.pcgamingfreaks.Version;
import at.pcgamingfreaks.YamlFileManager;

import net.md_5.bungee.api.plugin.Plugin;
Expand All @@ -33,7 +34,7 @@ public class Language extends at.pcgamingfreaks.Bungee.Language implements ILang
{
public Language(final @NotNull Plugin plugin)
{
super(plugin, MagicValues.LANG_VERSION, MagicValues.LANG_VERSION);
super(plugin, new Version(MagicValues.LANG_VERSION), new Version(MagicValues.LANG_VERSION));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 GeorgH93
* Copyright (C) 2021 GeorgH93
*
* 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
Expand All @@ -12,7 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package at.pcgamingfreaks.MarriageMaster.Bungee.SpecialInfoWorker;
Expand Down Expand Up @@ -42,8 +42,8 @@ public UpgradedInfo(MarriageMaster plugin)
// I don't load this message from the config. He just upgraded, the messages in the config would probably be exactly the same.
messagePluginUpgraded = new MessageBuilder("Marriage Master", MessageColor.GOLD).append(" has been upgraded to ", MessageColor.AQUA)
.append(plugin.getDescription().getVersion(), MessageColor.BLUE, MessageFormat.BOLD).append(".", MessageColor.AQUA).appendNewLine()
.append("All of your settings and changes to the language file have been copied into the new files.", MessageColor.AQUA).appendNewLine()
.append("However it's recommended to manually check them to make sure that all of your settings are how you like them (there are many new options).", MessageColor.AQUA).getMessage();
.append("Your config and language files have been backuped, since they are not compatible with this version of the plugin", MessageColor.AQUA).appendNewLine()
.append("You can try to use v2.5 to convert them to the new format or apply your changes manually.", MessageColor.AQUA).getMessage();
}

@SuppressWarnings("unused")
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>

<properties>
<revision>2.5.2.1</revision>
<revision>2.5.3</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
Expand Down

0 comments on commit b39183c

Please sign in to comment.