From 6dd239457438983c1f98f342d4aafb4b28c8cee7 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Tue, 7 Jan 2020 21:27:27 +0100 Subject: [PATCH] Add UUID type config option --- pom.xml | 2 +- resources/config.yml | 3 + resources/lang/ru.yml | 204 +++++++++--------- .../Minepacks/Bukkit/Database/Config.java | 10 + .../Minepacks/Bukkit/Database/Database.java | 5 +- .../Minepacks/Bukkit/Database/Files.java | 4 +- .../Minepacks/Bukkit/Database/SQL.java | 4 +- .../Bukkit/Listener/DisableShulkerboxes.java | 5 +- 8 files changed, 125 insertions(+), 112 deletions(-) diff --git a/pom.xml b/pom.xml index b8f7db81..448f47d0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 at.pcgamingfreaks Minepacks - 2.1 + 2.1.1 scm:git:git@github.com:GeorgH93/Minepacks.git diff --git a/resources/config.yml b/resources/config.yml index 7cdb6ffd..cc7d931f 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -66,6 +66,9 @@ Database: # true: format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # false: format: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx UseUUIDSeparators: false + # Options: auto, online, offline | auto will decide based on the server online mode option. + # If you are using BungeeCord, set it to whatever you use on your BungeeCord server!!! + UUID_Type: auto # Settings only for MySQL SQL: Host: localhost:3306 diff --git a/resources/lang/ru.yml b/resources/lang/ru.yml index cd76ee32..65fa78cc 100644 --- a/resources/lang/ru.yml +++ b/resources/lang/ru.yml @@ -1,102 +1,102 @@ -# To simplify the customisation and the translation process please check out the editor: http://ptp.pcgamingfreaks.at - -Language: - NotFromConsole: "&cЭту команду нельзя использовать в консоле." - Ingame: - NoPermission: "&cУ вас недостаточно прав для этого." - WorldDisabled: "&cИспользовать рюкзак не разрешено в этом мире." - NaN: "[\"\",{\"text\":\"Введенное значение не является числом!\",\"color\":\"red\"}]" - OwnBackpackClose: "Рюкзак закрыт!" - OwnBackpackClose_SendMethod: "action_bar" - #Parameter: {OwnerName}, {OwnerDisplayName} - PlayerBackpackClose: "Рюкзак {OwnerName} закрыь!" - PlayerBackpackClose_SendMethod: "action_bar" - InvalidBackpack: "Недействительный рюкзак." - NotAllowedInBackpack: "&c{ItemName} нельзя положить в рюкзак." - NotAllowedInBackpack_SendMethod: "action_bar" - DontRemoveShortcut: "&cВы не можете удалить иконку рюкзака из своего инвентаря!" - DontRemoveShortcut_SendMethod: "action_bar" - Open: - #Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened - Cooldown: "[{\"text\":\"Пожалуйста подождите \",\"color\":\"dark_green\"},{\"text\":\"{TimeSpanLeft}\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"{TimeLeft} секунд\"}},{\"text\":\", перед тем как снова открыть свой рюкзак.\"}]" - #Parameter: {CurrentGameMode}, {AllowedGameModes} - WrongGameMode: "Вам не разрешено открывать рюкзак в текущем режиме игры." - Clean: - BackpackCleaned: "Рюкзак очищен." - Help: - Header: "&6### Команды Minepacks ###" - Footer: "&6#############################" - Reload: - Reloading: "&1Перезагрузка ..." - Reloaded: "&1Плагин успешно перезагружен!" - Update: - CheckingForUpdates: "&1Проверка обновлений..." - Updated: "[\"\",{\"text\":\"Плагин обновлён и будет загружен после следующей перезагрузки.\",\"color\":\"yellow\"}]" - NoUpdate: "[\"\",{\"text\":\"Нет доступных обновлений.\",\"color\":\"gold\"}]" - UpdateFail: "[\"\",{\"text\":\"При проверке обновлений произошла ошибка! Пожалуйста проверьте консоль!\",\"color\":\"red\"}]" - # You can change this message if you like to, but don't cry if the link isn't linking to the plugin anymore! - UpdateAvailable: "[{\"text\":\"Доступно обновление! Пожалуйста, посетите сайт \\\"\",\"color\":\"green\"},{\"text\":\"https://www.spigotmc.org/resources/19286/\",\"color\":\"yellow\",\"underlined\":true,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.spigotmc.org/resources/19286/\"}},{\"text\":\"\\\" чтобы скачать его!\"}]" - Backup: - Created: "Рюкзак был успешно скопирован." - NoBackpack: "У игрока нет рюкзака, либо он пустой." - Restore: - BackupsPerPage: 10 - Headline: "[\"\",{\"text\":\"Резервные копии\",\"color\":\"yellow\"},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"страница {CurrentPage}/{MaxPage}\",\"color\":\"gold\"}]" - Footer: "[{\"text\":\"<<< Предыдущая <<<\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"}},{\"text\":\" Страница {CurrentPage}/{MaxPage} \",\"color\":\"gold\"},{\"text\":\">>> Следующая >>>\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"}}]" - BackupEntry: "[\"\",{\"text\":\"{BackupIdentifier}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand} {BackupIdentifier}\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Пользователь: {BackupPlayerName} ({BackupPlayerUUID})\\nСоздана: {BackupDate}\"}}]" - NoValidBackup: "Резервная копия {BackupIdentifier} не найдена" - NoUserToRestoreToFound: "Не найдено действительного пользователя или копии для восстановления" - # No Json!!! - ParameterBackupName: "backup_name" - # No Json!!! - DateFormat: "dd.MM.yy HH:mm:ss" - Restored: "Резервная копия успешно восстановлена." - Commands: - HelpFormat: "[\"\",{\"text\":\"/{MainCommand} {SubCommand} {Parameters}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand}\"}},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"{Description}\",\"color\":\"aqua\"}]" - PlayerNameVariable: "player_name" - Description: - Backpack: "Открыть ваш рюкзак." - Clean: "Очистить ваш рюкзак." - CleanOthers: "Очистить рюкзак другого игрока." - OpenOthers: "Открыть рюкзак другого игрока." - Reload: "Перезагрузить конфигурацию плагина." - Update: "Проверить плагин на наличие новых версий." - Version: "Посмотреть информацию о плагине и о его зависимостях." - Backup: "Создать резервную копию рюкзака игрока." - Restore: "Восстановить резервную копию." - RestoreList: "Посмотреть список всех доступных резервных копий." - Help: "Посмотреть все команды и их описание." - Migrate: "Изменить тип используемой базы данных." - -Command: - Backpack: - - backpack - - bp - Open: - - open - Clean: - - clean - - clear - - empty - Reload: - - reload - - restart - Update: - - update - Backup: - - backup - Restore: - - restore - ListBackups: - - listbackups - Version: - - version - Help: - - help - -# Will be shown in the console during startup -LanguageName: "russian" -Author: "MrZillaGold" - -# Language file version. Don't touch it! -Version: 17 +# To simplify the customisation and the translation process please check out the editor: http://ptp.pcgamingfreaks.at + +Language: + NotFromConsole: "&cЭту команду нельзя использовать в консоле." + Ingame: + NoPermission: "&cУ вас недостаточно прав для этого." + WorldDisabled: "&cИспользовать рюкзак не разрешено в этом мире." + NaN: "[\"\",{\"text\":\"Введенное значение не является числом!\",\"color\":\"red\"}]" + OwnBackpackClose: "Рюкзак закрыт!" + OwnBackpackClose_SendMethod: "action_bar" + #Parameter: {OwnerName}, {OwnerDisplayName} + PlayerBackpackClose: "Рюкзак {OwnerName} закрыь!" + PlayerBackpackClose_SendMethod: "action_bar" + InvalidBackpack: "Недействительный рюкзак." + NotAllowedInBackpack: "&c{ItemName} нельзя положить в рюкзак." + NotAllowedInBackpack_SendMethod: "action_bar" + DontRemoveShortcut: "&cВы не можете удалить иконку рюкзака из своего инвентаря!" + DontRemoveShortcut_SendMethod: "action_bar" + Open: + #Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened + Cooldown: "[{\"text\":\"Пожалуйста подождите \",\"color\":\"dark_green\"},{\"text\":\"{TimeSpanLeft}\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"{TimeLeft} секунд\"}},{\"text\":\", перед тем как снова открыть свой рюкзак.\"}]" + #Parameter: {CurrentGameMode}, {AllowedGameModes} + WrongGameMode: "Вам не разрешено открывать рюкзак в текущем режиме игры." + Clean: + BackpackCleaned: "Рюкзак очищен." + Help: + Header: "&6### Команды Minepacks ###" + Footer: "&6#############################" + Reload: + Reloading: "&1Перезагрузка ..." + Reloaded: "&1Плагин успешно перезагружен!" + Update: + CheckingForUpdates: "&1Проверка обновлений..." + Updated: "[\"\",{\"text\":\"Плагин обновлён и будет загружен после следующей перезагрузки.\",\"color\":\"yellow\"}]" + NoUpdate: "[\"\",{\"text\":\"Нет доступных обновлений.\",\"color\":\"gold\"}]" + UpdateFail: "[\"\",{\"text\":\"При проверке обновлений произошла ошибка! Пожалуйста проверьте консоль!\",\"color\":\"red\"}]" + # You can change this message if you like to, but don't cry if the link isn't linking to the plugin anymore! + UpdateAvailable: "[{\"text\":\"Доступно обновление! Пожалуйста, посетите сайт \\\"\",\"color\":\"green\"},{\"text\":\"https://www.spigotmc.org/resources/19286/\",\"color\":\"yellow\",\"underlined\":true,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.spigotmc.org/resources/19286/\"}},{\"text\":\"\\\" чтобы скачать его!\"}]" + Backup: + Created: "Рюкзак был успешно скопирован." + NoBackpack: "У игрока нет рюкзака, либо он пустой." + Restore: + BackupsPerPage: 10 + Headline: "[\"\",{\"text\":\"Резервные копии\",\"color\":\"yellow\"},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"страница {CurrentPage}/{MaxPage}\",\"color\":\"gold\"}]" + Footer: "[{\"text\":\"<<< Предыдущая <<<\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"}},{\"text\":\" Страница {CurrentPage}/{MaxPage} \",\"color\":\"gold\"},{\"text\":\">>> Следующая >>>\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"}}]" + BackupEntry: "[\"\",{\"text\":\"{BackupIdentifier}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand} {BackupIdentifier}\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Пользователь: {BackupPlayerName} ({BackupPlayerUUID})\\nСоздана: {BackupDate}\"}}]" + NoValidBackup: "Резервная копия {BackupIdentifier} не найдена" + NoUserToRestoreToFound: "Не найдено действительного пользователя или копии для восстановления" + # No Json!!! + ParameterBackupName: "backup_name" + # No Json!!! + DateFormat: "dd.MM.yy HH:mm:ss" + Restored: "Резервная копия успешно восстановлена." + Commands: + HelpFormat: "[\"\",{\"text\":\"/{MainCommand} {SubCommand} {Parameters}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand}\"}},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"{Description}\",\"color\":\"aqua\"}]" + PlayerNameVariable: "player_name" + Description: + Backpack: "Открыть ваш рюкзак." + Clean: "Очистить ваш рюкзак." + CleanOthers: "Очистить рюкзак другого игрока." + OpenOthers: "Открыть рюкзак другого игрока." + Reload: "Перезагрузить конфигурацию плагина." + Update: "Проверить плагин на наличие новых версий." + Version: "Посмотреть информацию о плагине и о его зависимостях." + Backup: "Создать резервную копию рюкзака игрока." + Restore: "Восстановить резервную копию." + RestoreList: "Посмотреть список всех доступных резервных копий." + Help: "Посмотреть все команды и их описание." + Migrate: "Изменить тип используемой базы данных." + +Command: + Backpack: + - backpack + - bp + Open: + - open + Clean: + - clean + - clear + - empty + Reload: + - reload + - restart + Update: + - update + Backup: + - backup + Restore: + - restore + ListBackups: + - listbackups + Version: + - version + Help: + - help + +# Will be shown in the console during startup +LanguageName: "russian" +Author: "MrZillaGold" + +# Language file version. Don't touch it! +Version: 17 diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java index 0f1138f4..d027ed55 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java @@ -117,6 +117,16 @@ public boolean getUseUUIDs() return uuid; } + public boolean useOnlineUUIDs() + { + String type = getConfigE().getString("Database.UUID_Type", "auto").toLowerCase(Locale.ENGLISH); + if(type.equals("auto")) + { + return plugin.getServer().getOnlineMode(); + } + return type.equals("online"); + } + public boolean getUseUUIDSeparators() { return getConfigE().getBoolean("Database.UseUUIDSeparators", false); diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java index d790e179..35e670d8 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 GeorgH93 + * Copyright (C) 2020 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 @@ -50,7 +50,7 @@ public abstract class Database implements Listener protected final Minepacks plugin; protected final InventorySerializer itsSerializer; - protected final boolean useUUIDs, bungeeCordMode; + protected final boolean useUUIDs, onlineUUIDs, bungeeCordMode; protected boolean useUUIDSeparators, asyncSave = true; protected long maxAge; private final Map backpacks = new ConcurrentHashMap<>(); @@ -63,6 +63,7 @@ public Database(Minepacks mp) itsSerializer = new InventorySerializer(plugin.getLogger()); useUUIDSeparators = plugin.getConfiguration().getUseUUIDSeparators(); useUUIDs = plugin.getConfiguration().getUseUUIDs(); + onlineUUIDs = plugin.getConfiguration().useOnlineUUIDs(); bungeeCordMode = plugin.getConfiguration().isBungeeCordModeEnabled(); maxAge = plugin.getConfiguration().getAutoCleanupMaxInactiveDays(); unCacheStrategie = bungeeCordMode ? new OnDisconnect(this) : UnCacheStrategie.getUnCacheStrategie(this); diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java index 976799e1..f98da9d6 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2018 GeorgH93 + * Copyright (C) 2020 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 @@ -83,7 +83,7 @@ private void checkFiles() { if(len <= 16) // It's a player name { - if(!file.renameTo(new File(saveFolder, UUIDConverter.getUUIDFromName(file.getName().substring(0, len), true, useUUIDSeparators) + EXT))) + if(!file.renameTo(new File(saveFolder, UUIDConverter.getUUIDFromName(file.getName().substring(0, len), onlineUUIDs, useUUIDSeparators) + EXT))) { plugin.getLogger().warning("Failed to rename file (" + file.getAbsolutePath() + ")."); } diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQL.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQL.java index 5fb8a349..a56de3a2 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQL.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQL.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 GeorgH93 + * Copyright (C) 2020 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 @@ -152,7 +152,7 @@ public UpdateData(String uuid, int id) { if(toConvert.size() > 0) { - Map newUUIDs = UUIDConverter.getUUIDsFromNames(toConvert.keySet(), true, useUUIDSeparators); + Map newUUIDs = UUIDConverter.getUUIDsFromNames(toConvert.keySet(), onlineUUIDs, useUUIDSeparators); for(Map.Entry entry : newUUIDs.entrySet()) { UpdateData updateData = toConvert.get(entry.getKey().toLowerCase(Locale.ROOT)); diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/DisableShulkerboxes.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/DisableShulkerboxes.java index 1ed7bf61..eea6e73e 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/DisableShulkerboxes.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/DisableShulkerboxes.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 GeorgH93 + * Copyright (C) 2020 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 @@ -20,7 +20,6 @@ import at.pcgamingfreaks.Bukkit.MCVersion; import at.pcgamingfreaks.Bukkit.Utils; import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks; -import at.pcgamingfreaks.Reflection; import org.bukkit.Material; import org.bukkit.block.Block; @@ -64,7 +63,7 @@ public class DisableShulkerboxes extends MinepacksListener SHULKER_BOX_MATERIALS.add(Material.YELLOW_SHULKER_BOX); if(MCVersion.isOlderThan(MCVersion.MC_1_13)) { - SHULKER_BOX_MATERIALS.add((Material) Reflection.getEnum(Material.class, "SILVER_SHULKER_BOX")); + SHULKER_BOX_MATERIALS.add(Material.valueOf("SILVER_SHULKER_BOX")); } else {