config convert v6
This commit is contained in:
parent
052d2393aa
commit
6fefa8701e
@ -18,7 +18,7 @@ public class ConfigSelect {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (yamlConfiguration.contains("ConfigVersion")) {
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < (Integer) Config.configVersion.value && new File(Main.getPath(), "config.yml").exists()) {
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
@ -26,13 +26,13 @@ public class ConfigSelect {
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < 5) {
|
||||
ConfigConverterV5.convert();
|
||||
selectConfig();
|
||||
return;
|
||||
config = new File(Main.getPath(), "config.yml");
|
||||
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
}
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < 6) {
|
||||
ConfigConverterV6.convert();
|
||||
selectConfig();
|
||||
return;
|
||||
new ConfigConverterV6();
|
||||
config = new File(Main.getPath(), "config.yml");
|
||||
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class ConfigCreate {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (!config.exists()) T2Cconfig.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
||||
// if (!config.exists()) T2Cconfig.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Plugin.Debug", false, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration);
|
||||
|
@ -19,16 +19,16 @@ public class SelectConfig {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < 5) {
|
||||
ConfigConverterV5.convert();
|
||||
}
|
||||
}
|
||||
// if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
|
||||
// T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
// T2Csend.console(Util.getPrefix() + " ");
|
||||
// T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
// T2Csend.console(Util.getPrefix() + " ");
|
||||
// T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
// if (yamlConfiguration.getInt("ConfigVersion") < 5) {
|
||||
// ConfigConverterV5.convert();
|
||||
// }
|
||||
// }
|
||||
|
||||
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
||||
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
|
||||
@ -253,7 +253,7 @@ public class SelectConfig {
|
||||
public static void setConfigVersion() {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
|
||||
// yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
|
@ -8,111 +8,127 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class ConfigConverterV6 {
|
||||
private static final File configOld = new File(Main.getPath(), "config.yml");
|
||||
private static final YamlConfiguration yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
|
||||
|
||||
public static void convert() throws IOException {
|
||||
public ConfigConverterV6() {
|
||||
try {
|
||||
convert();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private File configOldRename;
|
||||
private YamlConfiguration yamlConfigurationOld;
|
||||
|
||||
private void convert() throws IOException {
|
||||
|
||||
|
||||
File oldF = new File("plugins/T2C-CommandGUI/config.yml");
|
||||
File newF = new File("plugins/T2C-CommandGUI/configV5.yml");
|
||||
oldF.renameTo(newF);
|
||||
|
||||
configOldRename = new File(Main.getPath(), "configV5.yml");
|
||||
yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOldRename);
|
||||
set(Config.debug, "Plugin.Debug");
|
||||
|
||||
set(Config.updateCheckOnJoin, "Plugin.updateCheck.onJoin");
|
||||
set(Config.updateCheckSeePreReleaseUpdates , "Plugin.updateCheck.seePreReleaseUpdates");
|
||||
set(Config.updateCheckTimeInterval , "Plugin.updateCheck.timeInterval");
|
||||
set(Config.helpAlias , "Plugin.HelpAlias");
|
||||
set(Config.adminSubCommand , "Plugin.AdminSubCommand");
|
||||
set(Config. language, "Plugin.language");
|
||||
set(Config. currency, "Plugin.Currency");
|
||||
set(Config.defaultGUI , "Plugin.DefaultGUI");
|
||||
set(Config.updateCheckSeePreReleaseUpdates, "Plugin.updateCheck.seePreReleaseUpdates");
|
||||
set(Config.updateCheckTimeInterval, "Plugin.updateCheck.timeInterval");
|
||||
set(Config.helpAlias, "Plugin.HelpAlias");
|
||||
set(Config.adminSubCommand, "Plugin.AdminSubCommand");
|
||||
set(Config.language, "Plugin.language");
|
||||
set(Config.currency, "Plugin.Currency");
|
||||
set(Config.defaultGUI, "Plugin.DefaultGUI");
|
||||
|
||||
set(Config.storage , "Storage.Type");
|
||||
set(Config. mysqlIp, "Storage.MySQL.IP");
|
||||
set(Config. mysqlPort, "Storage.MySQL.Port");
|
||||
set(Config.mysqlDatabase , "Storage.MySQL.Database");
|
||||
set(Config. mysqlUser, "Storage.MySQL.User");
|
||||
set(Config. mysqlPassword, "Storage.MySQL.Password");
|
||||
set(Config. mysqlSSL, "Storage.MySQL.SSL");
|
||||
set(Config.storage, "Storage.Type");
|
||||
set(Config.mysqlIp, "Storage.MySQL.IP");
|
||||
set(Config.mysqlPort, "Storage.MySQL.Port");
|
||||
set(Config.mysqlDatabase, "Storage.MySQL.Database");
|
||||
set(Config.mysqlUser, "Storage.MySQL.User");
|
||||
set(Config.mysqlPassword, "Storage.MySQL.Password");
|
||||
set(Config.mysqlSSL, "Storage.MySQL.SSL");
|
||||
|
||||
set(Config. useItemEnable, "UseItem.Enable");
|
||||
set(Config.useItemAllowToggle , "UseItem.AllowToggle");
|
||||
set(Config.useItemAllowSetSlot , "UseItem.AllowSetSlot");
|
||||
set(Config. useItemBlockMoveAndDrop, "UseItem.BlockMoveAndDrop");
|
||||
set(Config. useItemOpenGUI, "UseItem.OpenGUI");
|
||||
set(Config. useItemPermission, "UseItem.Permission.NeededToUse");
|
||||
set(Config. useItemKeepAtCommandClear, "UseItem.KeepAtCommandClear");
|
||||
set(Config.useItemEnable, "UseItem.Enable");
|
||||
set(Config.useItemAllowToggle, "UseItem.AllowToggle");
|
||||
set(Config.useItemAllowSetSlot, "UseItem.AllowSetSlot");
|
||||
set(Config.useItemBlockMoveAndDrop, "UseItem.BlockMoveAndDrop");
|
||||
set(Config.useItemOpenGUI, "UseItem.OpenGUI");
|
||||
set(Config.useItemPermission, "UseItem.Permission.NeededToUse");
|
||||
set(Config.useItemKeepAtCommandClear, "UseItem.KeepAtCommandClear");
|
||||
|
||||
set(Config. useItemInventorySlotFreeSlot, "UseItem.InventorySlot.FreeSlot");
|
||||
set(Config. useItemInventorySlot, "UseItem.InventorySlot.Slot");
|
||||
set(Config.useItemInventorySlotEnforce , "UseItem.InventorySlot.SlotEnforce");
|
||||
set(Config.useItemMaterial , "UseItem.Item.Material");
|
||||
|
||||
set(Config.useItemPlayerHeadEnable , "UseItem.Item.PlayerHead.Enable");
|
||||
set(Config. useItemBase64Enable, "UseItem.Item.PlayerHead.Base64.Enable");
|
||||
set(Config.useItemBase64value , "UseItem.Item.PlayerHead.Base64.Base64Value");
|
||||
set(Config.useItemPlayerWhoHasOpenedTheGUI , "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
|
||||
set(Config. useItemPlayerName, "UseItem.Item.PlayerHead.PlayerName");
|
||||
set(Config. useItemName, "UseItem.Item.Name");
|
||||
set(Config.useItemLore , "UseItem.Item.Lore");
|
||||
set(Config. useItemGiveOnEveryJoin, "UseItem.Join.GiveOnEveryJoin");
|
||||
set(Config. useItemGiveOnlyOnFirstJoin, "UseItem.Join.GiveOnlyOnFirstJoin");
|
||||
set(Config. cursorToGUIItemOnLogin, "UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable");
|
||||
set(Config. cursorToGUIItemOnlyOnFirstLogin, "UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin");
|
||||
set(Config. useItemServerChange, "UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange");
|
||||
set(Config.useItemInventorySlotFreeSlot, "UseItem.InventorySlot.FreeSlot");
|
||||
set(Config.useItemInventorySlot, "UseItem.InventorySlot.Slot");
|
||||
set(Config.useItemInventorySlotEnforce, "UseItem.InventorySlot.SlotEnforce");
|
||||
set(Config.useItemMaterial, "UseItem.Item.Material");
|
||||
|
||||
set(Config. toggleItemOnOrYesBase64, "Toggle.Items.OnOrYes.Item.Base64.Enable");
|
||||
set(Config.toggleItemOnOrYesBase64Value , "Toggle.Items.OnOrYes.Item.Base64.Base64Value");
|
||||
set(Config.toggleItemOnOrYesMaterial , "Toggle.Items.OnOrYes.Item.Material");
|
||||
set(Config.useItemPlayerHeadEnable, "UseItem.Item.PlayerHead.Enable");
|
||||
set(Config.useItemBase64Enable, "UseItem.Item.PlayerHead.Base64.Enable");
|
||||
set(Config.useItemBase64value, "UseItem.Item.PlayerHead.Base64.Base64Value");
|
||||
set(Config.useItemPlayerWhoHasOpenedTheGUI, "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
|
||||
set(Config.useItemPlayerName, "UseItem.Item.PlayerHead.PlayerName");
|
||||
set(Config.useItemName, "UseItem.Item.Name");
|
||||
set(Config.useItemLore, "UseItem.Item.Lore");
|
||||
set(Config.useItemGiveOnEveryJoin, "UseItem.Join.GiveOnEveryJoin");
|
||||
set(Config.useItemGiveOnlyOnFirstJoin, "UseItem.Join.GiveOnlyOnFirstJoin");
|
||||
set(Config.cursorToGUIItemOnLogin, "UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable");
|
||||
set(Config.cursorToGUIItemOnlyOnFirstLogin, "UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin");
|
||||
set(Config.useItemServerChange, "UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange");
|
||||
|
||||
set(Config.toggleItemOffOrNoBase64 , "Toggle.Items.OffOrNo.Item.Base64.Enable");
|
||||
set(Config. toggleItemOffOrNoBase64Value, "Toggle.Items.OffOrNo.Item.Base64.Base64Value");
|
||||
set(Config.toggleItemOffOrNoMaterial , "Toggle.Items.OffOrNo.Item.Material");
|
||||
set(Config.toggleItemOnOrYesBase64, "Toggle.Items.OnOrYes.Item.Base64.Enable");
|
||||
set(Config.toggleItemOnOrYesBase64Value, "Toggle.Items.OnOrYes.Item.Base64.Base64Value");
|
||||
set(Config.toggleItemOnOrYesMaterial, "Toggle.Items.OnOrYes.Item.Material");
|
||||
|
||||
set(Config.togglePermTrue , "Toggle.Permission.Commands.True");
|
||||
set(Config.togglePermFalse , "Toggle.Permission.Commands.False");
|
||||
set(Config.toggleItemOffOrNoBase64, "Toggle.Items.OffOrNo.Item.Base64.Enable");
|
||||
set(Config.toggleItemOffOrNoBase64Value, "Toggle.Items.OffOrNo.Item.Base64.Base64Value");
|
||||
set(Config.toggleItemOffOrNoMaterial, "Toggle.Items.OffOrNo.Item.Material");
|
||||
|
||||
set(Config. placeholderTrue, "Placeholder.True");
|
||||
set(Config. placeholderFalse, "Placeholder.False");
|
||||
set(Config.togglePermTrue, "Toggle.Permission.Commands.True");
|
||||
set(Config.togglePermFalse, "Toggle.Permission.Commands.False");
|
||||
|
||||
set(Config. soundEnable, "Sound.Enable");
|
||||
set(Config. soundOpenInventoryEnable, "Sound.OpenInventory.Enable");
|
||||
set(Config. soundOpenInventoryInput, "Sound.OpenInventory.Sound");
|
||||
set(Config. soundClickEnable, "Sound.Click.Enable");
|
||||
set(Config. soundClickInput, "Sound.Click.Sound");
|
||||
set(Config.soundNoMoneyEnable , "Sound.NoMoney.Enable");
|
||||
set(Config.soundNoMoneyInput , "Sound.NoMoney.Sound");
|
||||
set(Config.placeholderTrue, "Placeholder.True");
|
||||
set(Config.placeholderFalse, "Placeholder.False");
|
||||
|
||||
set(Config. soundNoInventorySpaceEnable, "Sound.NoInventorySpace.Enable");
|
||||
set(Config.soundNoInventorySpaceInput , "Sound.NoInventorySpace.Sound");
|
||||
set(Config.soundGiveEnable , "Sound.Give.Enable");
|
||||
set(Config.soundGiveInput , "Sound.Give.Sound");
|
||||
set(Config. soundPlayerNotFoundEnable, "Sound.PlayerNotFound.Enable");
|
||||
set(Config. soundPlayerNotFoundInput, "Sound.PlayerNotFound.Sound");
|
||||
set(Config.soundEnable, "Sound.Enable");
|
||||
set(Config.soundOpenInventoryEnable, "Sound.OpenInventory.Enable");
|
||||
set(Config.soundOpenInventoryInput, "Sound.OpenInventory.Sound");
|
||||
set(Config.soundClickEnable, "Sound.Click.Enable");
|
||||
set(Config.soundClickInput, "Sound.Click.Sound");
|
||||
set(Config.soundNoMoneyEnable, "Sound.NoMoney.Enable");
|
||||
set(Config.soundNoMoneyInput, "Sound.NoMoney.Sound");
|
||||
|
||||
set(Config. useItemGameModeChangeEnable, "Advanced.UseItem.GameMode.Change.Enable");
|
||||
set(Config. useItemGameModeChangeDelayInTicks, "Advanced.UseItem.GameMode.Change.DelayInTicks");
|
||||
set(Config. useItemGameModeProtection, "Advanced.UseItem.GameMode.Protection.Enable");
|
||||
set(Config.useItemGameModeRemoveItemWhenItIsDisabled , "Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
|
||||
set(Config. useItemGameModeMode, "Advanced.UseItem.GameMode.Protection.Mode");
|
||||
set(Config.soundNoInventorySpaceEnable, "Sound.NoInventorySpace.Enable");
|
||||
set(Config.soundNoInventorySpaceInput, "Sound.NoInventorySpace.Sound");
|
||||
set(Config.soundGiveEnable, "Sound.Give.Enable");
|
||||
set(Config.soundGiveInput, "Sound.Give.Sound");
|
||||
set(Config.soundPlayerNotFoundEnable, "Sound.PlayerNotFound.Enable");
|
||||
set(Config.soundPlayerNotFoundInput, "Sound.PlayerNotFound.Sound");
|
||||
|
||||
set(Config.useItemGameModeList , "Advanced.UseItem.GameMode.Protection.List");
|
||||
set(Config.useItemGameModeChangeEnable, "Advanced.UseItem.GameMode.Change.Enable");
|
||||
set(Config.useItemGameModeChangeDelayInTicks, "Advanced.UseItem.GameMode.Change.DelayInTicks");
|
||||
set(Config.useItemGameModeProtection, "Advanced.UseItem.GameMode.Protection.Enable");
|
||||
set(Config.useItemGameModeRemoveItemWhenItIsDisabled, "Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
|
||||
set(Config.useItemGameModeMode, "Advanced.UseItem.GameMode.Protection.Mode");
|
||||
|
||||
set(Config.useItemWorldChangeEnable , "Advanced.UseItem.World.Change.Enable");
|
||||
set(Config.useItemWorldChangeDelayInTicks , "Advanced.UseItem.World.Change.DelayInTicks");
|
||||
set(Config.useItemWorldProtection , "Advanced.UseItem.World.Protection.Enable");
|
||||
set(Config.useItemWorldRemoveItemWhenItIsDisabled , "Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled");
|
||||
set(Config. useItemWorldMode, "Advanced.UseItem.World.Protection.Mode");
|
||||
set(Config. useItemWorldList, "Advanced.UseItem.World.Protection.List");
|
||||
set(Config.useItemGameModeList, "Advanced.UseItem.GameMode.Protection.List");
|
||||
|
||||
set(Config.disableInfoBySneak , "Advanced.UseItem.DisableInfoBySneak");
|
||||
set(Config.useItemWorldChangeEnable, "Advanced.UseItem.World.Change.Enable");
|
||||
set(Config.useItemWorldChangeDelayInTicks, "Advanced.UseItem.World.Change.DelayInTicks");
|
||||
set(Config.useItemWorldProtection, "Advanced.UseItem.World.Protection.Enable");
|
||||
set(Config.useItemWorldRemoveItemWhenItIsDisabled, "Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled");
|
||||
set(Config.useItemWorldMode, "Advanced.UseItem.World.Protection.Mode");
|
||||
set(Config.useItemWorldList, "Advanced.UseItem.World.Protection.List");
|
||||
|
||||
set(Config.disableInfoBySneak, "Advanced.UseItem.DisableInfoBySneak");
|
||||
|
||||
|
||||
set(Config.useItemItemBlockBlacklist , "Advanced.UseItem.ItemBlockBlacklist");
|
||||
|
||||
|
||||
configOld.renameTo(new File(Main.getPath(), "configV5.yml"));
|
||||
set(Config.useItemItemBlockBlacklist, "Advanced.UseItem.ItemBlockBlacklist");
|
||||
}
|
||||
|
||||
private static void set(Config obj, String path) {
|
||||
private void set(Config obj, String path) {
|
||||
if (!yamlConfigurationOld.contains(path)) return;
|
||||
obj.value = yamlConfigurationOld.get(path);
|
||||
}
|
||||
|
@ -58,11 +58,7 @@ public class Load {
|
||||
|
||||
|
||||
if (!new File(Main.getPath(), "config.yml").exists()) {
|
||||
try {
|
||||
plugin.saveResource("configDeclaration.yml", false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
CreateGUI.configCreate();
|
||||
} catch (Exception e) {
|
||||
@ -80,6 +76,11 @@ public class Load {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
plugin.saveResource("configDeclaration.yml", true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
plugin.saveResource("GUIs/guiDeclaration.yml", true);
|
||||
} catch (Exception e) {
|
||||
|
@ -34,7 +34,4 @@ public class Util {
|
||||
return net.t2code.t2codelib.Util.getDiscord();
|
||||
}
|
||||
|
||||
public static Integer getConfigVersion() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user