Fix all lang lists being empty

This commit is contained in:
Heliosares
2023-03-05 21:26:50 -05:00
parent c5b8921ac0
commit d3df5d62ef
7 changed files with 111 additions and 120 deletions

View File

@@ -2,7 +2,9 @@
# If there is an included language file for this language and the included version is higher,
# the file in the plugin directory will be replaced with the included file.
# If you don't want your language file being reset with new versions, set this version number to 99999
version: 4
color:
p: '9'
s: 'f'
@@ -85,25 +87,25 @@ command:
nohelp: '&cThis command does not have a help page.'
header: '&s----- &pAuxProtect Help &s-----'
help:
- '&p/$prefix lookup <params> &s- Perform a lookup'
- '&p/$prefix purge <params> &s- Perform a database purge'
- '&p/$prefix info &s- Version and credit information'
- '&p/$prefix help [command] &s- Show this message, or more information on a subcommand'
- '&s'
- '&tSee the Wiki for more: https://github.com/Heliosares/AuxProtect/wiki'
- '&p/$prefix lookup <params> &s- Perform a lookup'
- '&p/$prefix purge <params> &s- Perform a database purge'
- '&p/$prefix info &s- Version and credit information'
- '&p/$prefix help [command] &s- Show this message, or more information on a subcommand'
- '&s'
- '&tSee the Wiki for more: https://github.com/Heliosares/AuxProtect/wiki'
lookup:
- '&s/$prefix &plookup &s<params>'
- '&pParams:'
- '&pTime: &sIn seconds, minutes, hours, days, or weeks, represented by the first letter (i.e ''s'' for seconds).'
- '&pBefore/After: &sUsed to set a range for time lookup.'
- '&pAction: &sType of world interaction log, see tab completion for options.'
- '&pTarget: &sSpecify the parameter an action was performed to. You can use an asterisk as a wildcard and a dash as a space in this parameter.'
- '&pRadius: &sSpecify the square block radius for a lookup.'
- '&sAll parameters can be inverted using &p''!'' &s(i.e radius:5,!2 would do a lookup within 5 blocks of the player, but NOT within 2 blocks.)'
- '&s/$prefix &plookup &s<params>'
- '&pParams:'
- '&pTime: &sIn seconds, minutes, hours, days, or weeks, represented by the first letter (i.e ''s'' for seconds).'
- '&pBefore/After: &sUsed to set a range for time lookup.'
- '&pAction: &sType of world interaction log, see tab completion for options.'
- '&pTarget: &sSpecify the parameter an action was performed to. You can use an asterisk as a wildcard and a dash as a space in this parameter.'
- '&pRadius: &sSpecify the square block radius for a lookup.'
- '&sAll parameters can be inverted using &p''!'' &s(i.e radius:5,!2 would do a lookup within 5 blocks of the player, but NOT within 2 blocks.)'
purge:
- '&s/$prefix &ppurge &s<table | all> <time>'
- '&sSee tab completion for list of valid tables.'
- '&sMinimum time is 2 weeks.'
- '&s/$prefix &ppurge &s<table | all> <time>'
- '&sSee tab completion for list of valid tables.'
- '&sMinimum time is 2 weeks.'
playernotfound: '&cPlayer not found.'
lookup-playernotfound: '&cPlayer <target> not found.'
lookup-unknownaction: '&cUnknown action: <action>.'
@@ -143,30 +145,30 @@ inv-recover-menu:
force:
label: '&2&lForce Recover Inventory'
hover:
- ''
- '&a&lDouble Click'
- ''
- '&tThis will &c&loverwrite &7the player''s'
- '&7current inventory and exp with'
- '&7what is in the view above.'
- ''
- '&a&lDouble Click'
- ''
- '&tThis will &c&loverwrite &7the player''s'
- '&7current inventory and exp with'
- '&7what is in the view above.'
force-unavailable:
label: '&8&lForce Recover Inventory Unavailable'
hover:
- '&cPlayer must be online to'
- '&cforce recover their inventory'
- '&cPlayer must be online to'
- '&cforce recover their inventory'
recover:
label: '&a&lRecover Inventory'
hover:
- ''
- '&tThis will give the player a'
- '&tprompt to claim this inventory as'
- '&t if they were opening a chest with'
- '&t the above contents. They will also get'
- '&tthe exp stated here.'
- ''
- '&cThis will not overwrite anything and may'
- '&cduplicate items &tif they weren''t'
- '&tactually lost originally.'
- ''
- '&tThis will give the player a'
- '&tprompt to claim this inventory as'
- '&t if they were opening a chest with'
- '&t the above contents. They will also get'
- '&tthe exp stated here.'
- ''
- '&cThis will not overwrite anything and may'
- '&cduplicate items &tif they weren''t'
- '&tactually lost originally.'
close: '&c&lClose'
ender-chest: '&8&lView Enderchest'
xp:

View File

@@ -1,7 +1,9 @@
#
#
# Russian translation courtesy of l_MrBoom_l
#
version: 4
color:
p: '9'
s: 'f'
@@ -80,25 +82,25 @@ command:
nohelp: '&cДля этой команды нет страницы справки.'
header: '&s----- &pСправка по AuxProtect &s-----'
help:
- '&p/$prefix lookup <параметры> &s- Произвести поиск'
- '&p/$prefix purge <параметры> &s- Произвести очистку базы данных'
- '&p/$prefix info &s- Версия и информация об авторах'
- '&p/$prefix help [команда] &s- Показать это сообщение или более подробную информации об указанной субкоманде'
- '&s'
- '&tЧитайте вики, чтобы узнать больше: https://github.com/Heliosares/AuxProtect/wiki'
- '&p/$prefix lookup <параметры> &s- Произвести поиск'
- '&p/$prefix purge <параметры> &s- Произвести очистку базы данных'
- '&p/$prefix info &s- Версия и информация об авторах'
- '&p/$prefix help [команда] &s- Показать это сообщение или более подробную информации об указанной субкоманде'
- '&s'
- '&tЧитайте вики, чтобы узнать больше: https://github.com/Heliosares/AuxProtect/wiki'
lookup:
- '&s/$prefix &plookup &s<параметры>'
- '&pПараметры:'
- '&pВремя (time): &sВ секундах (s), минутах (m), часах (h), днях (d) или неделях (w).'
- '&pДо (before) / после (after): &sИспользуется для указания временного диапазона поиска.'
- '&pДействие (action): &sТип взаимодейтвия с миром, смотрите варианты в авто-продолжении.'
- '&pЦель (target): &sУказание цели, по отношению к которой это действие было выполнено. В этом параметре вы можете использовать звёздочку в качестве знака подстановки и тире в качестве пробела.'
- '&pРадиус (radius): &sУказание квадратного блочного радиуса для поиска.'
- '&sВсе параметры можно инвертировать с помощью &p''!'' &s(например, radius:5,!2 проводит поиск в радиусе 5 блоков от игрока, но НЕ в радиусе 2 блоков, т.е. в радиусе от 2 до 5)'
- '&s/$prefix &plookup &s<параметры>'
- '&pПараметры:'
- '&pВремя (time): &sВ секундах (s), минутах (m), часах (h), днях (d) или неделях (w).'
- '&pДо (before) / после (after): &sИспользуется для указания временного диапазона поиска.'
- '&pДействие (action): &sТип взаимодейтвия с миром, смотрите варианты в авто-продолжении.'
- '&pЦель (target): &sУказание цели, по отношению к которой это действие было выполнено. В этом параметре вы можете использовать звёздочку в качестве знака подстановки и тире в качестве пробела.'
- '&pРадиус (radius): &sУказание квадратного блочного радиуса для поиска.'
- '&sВсе параметры можно инвертировать с помощью &p''!'' &s(например, radius:5,!2 проводит поиск в радиусе 5 блоков от игрока, но НЕ в радиусе 2 блоков, т.е. в радиусе от 2 до 5)'
purge:
- '&s/$prefix &ppurge &s<таблица | all> <время>'
- '&sСмотрите все доступные таблицы в авто-продолжении'
- '&sМинимальное время 2 недели.'
- '&s/$prefix &ppurge &s<таблица | all> <время>'
- '&sСмотрите все доступные таблицы в авто-продолжении'
- '&sМинимальное время 2 недели.'
ap:
backup-created: 'Backup created: <file>'
developed-by: Developed by
@@ -225,25 +227,25 @@ inv-recover-menu:
ender-chest: '&8&lView Enderchest'
force:
hover:
- ''
- '&a&lDouble Click'
- ''
- '&tThis will &c&loverwrite &7the player''s'
- '&7current inventory and exp with'
- '&7what is in the view above.'
- ''
- '&a&lDouble Click'
- ''
- '&tThis will &c&loverwrite &7the player''s'
- '&7current inventory and exp with'
- '&7what is in the view above.'
label: '&2&lForce Recover Inventory'
recover:
hover:
- ''
- '&tThis will give the player a'
- '&tprompt to claim this inventory as'
- '&t if they were opening a chest with'
- '&t the above contents. They will also get'
- '&tthe exp stated here.'
- ''
- '&cThis will not overwrite anything and may'
- '&cduplicate items &tif they weren''t'
- '&tactually lost originally.'
- ''
- '&tThis will give the player a'
- '&tprompt to claim this inventory as'
- '&t if they were opening a chest with'
- '&t the above contents. They will also get'
- '&tthe exp stated here.'
- ''
- '&cThis will not overwrite anything and may'
- '&cduplicate items &tif they weren''t'
- '&tactually lost originally.'
label: '&a&lRecover Inventory'
xp:
error: '&8No XP data'

View File

@@ -123,7 +123,11 @@ public class SpigotConfigAdapter extends ConfigAdapter {
super.load();
try {
if (file != null) config = YamlConfiguration.loadConfiguration(file.get());
else if (in != null) config = YamlConfiguration.loadConfiguration(new InputStreamReader(in));
else if (in != null) {
try (InputStreamReader inputStream = new InputStreamReader(in)) {
config = YamlConfiguration.loadConfiguration(inputStream);
}
}
} catch (Exception e) {
AuxProtectAPI.getInstance().warning("Error while loading " + path + ":");
throw e;
@@ -131,7 +135,9 @@ public class SpigotConfigAdapter extends ConfigAdapter {
if (defaults != null) {
try (InputStream in = defaults.apply(path)) {
if (in != null) {
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in)));
try (InputStreamReader inputStream = new InputStreamReader(in)) {
config.setDefaults(YamlConfiguration.loadConfiguration(inputStream));
}
}
}
}

View File

@@ -75,7 +75,7 @@ public class AuxProtectBungee extends Plugin implements IAuxProtect {
Language.load(this,
() -> new BungeeConfigAdapter(getDataFolder(),
"lang/" + config.getConfig().getString("lang") + ".yml", null,
this::getResourceAsStream, false));
this::getResourceAsStream, false), () -> new BungeeConfigAdapter(getResource("lang/en-us.yml")));
} catch (FileNotFoundException e1) {
warning("Language file not found");

View File

@@ -3,26 +3,26 @@ package dev.heliosares.auxprotect.core;
import dev.heliosares.auxprotect.adapters.config.ConfigAdapter;
import dev.heliosares.auxprotect.api.AuxProtectAPI;
import dev.heliosares.auxprotect.utils.ColorTranslate;
import net.md_5.bungee.api.ChatColor;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
public class Language {
private static Supplier<ConfigAdapter> langSupplier;
private static Supplier<ConfigAdapter> langDefaultSupplier;
private static IAuxProtect plugin;
private static ConfigAdapter lang;
private static String c1;
private static String c2;
private static String c3;
public static void load(IAuxProtect plugin, Supplier<ConfigAdapter> langSupplier) throws IOException {
public static void load(IAuxProtect plugin, Supplier<ConfigAdapter> langSupplier, Supplier<ConfigAdapter> englishLangSupplier) throws IOException {
Language.plugin = plugin;
Language.langSupplier = langSupplier;
Language.langDefaultSupplier = englishLangSupplier;
reload();
}
@@ -30,7 +30,7 @@ public class Language {
lang = langSupplier.get();
lang.load();
int resourceVersion = lang.getDefaults().getInt("version", -1);
int resourceVersion = lang.getDefaults().getInt("version");
int fileVersion = lang.getInt("version");
if (resourceVersion > 0 && resourceVersion > fileVersion) {
@@ -51,12 +51,21 @@ public class Language {
c2 = "&" + lang.getString("color.s");
c3 = "&" + lang.getString("color.t");
boolean modified = false;
ConfigAdapter englishLang = null;
for (L l : L.values()) {
if (lang.getString(l.name) == null) {
//lang.set(l.name, "");
Object line = lang.get(l.name);
if (line == null || line instanceof String str && str.isEmpty()) {
if (englishLang == null) {
englishLang = langDefaultSupplier.get();
englishLang.load();
}
lang.set(l.name, englishLang.get(l.name));
modified = true;
plugin.warning("Lang file does not contain " + l.name);
}
}
if (modified) lang.save();
}
}
@@ -254,7 +263,7 @@ public class Language {
public List<String> translateSubcategoryList(String subcategory) {
List<String> message = null;
String name = this.name();
String name = this.name;
if (subcategory != null && subcategory.length() > 0) {
name += "." + subcategory.toLowerCase();
}
@@ -265,7 +274,7 @@ public class Language {
if (message == null || message.size() == 0) {
return null;
}
return message.stream().map(Language::convert).collect(Collectors.toList());
return message.stream().map(Language::convert).toList();
}
}

View File

@@ -118,7 +118,7 @@ public class AuxProtectSpigot extends JavaPlugin implements IAuxProtect {
try {
Language.load(this, () -> new SpigotConfigAdapter(this.getRootDirectory(),
"lang/" + config.getConfig().getString("lang") + ".yml", null, this::getResource, false));
"lang/" + config.getConfig().getString("lang") + ".yml", null, this::getResource, false), () -> new SpigotConfigAdapter(getResource("lang/en-us.yml")));
} catch (FileNotFoundException e1) {
warning("Language file not found");
} catch (IOException e1) {
@@ -137,7 +137,7 @@ public class AuxProtectSpigot extends JavaPlugin implements IAuxProtect {
debug("Compatability version: " + SERVER_VERSION, 1);
File sqliteFile = null;
String uri = "";
String uri;
if (getAPConfig().isMySQL()) {
uri = String.format("jdbc:mysql://%s:%s/%s", getAPConfig().getHost(), getAPConfig().getPort(),
getAPConfig().getDatabase());
@@ -223,18 +223,6 @@ public class AuxProtectSpigot extends JavaPlugin implements IAuxProtect {
getServer().getScheduler().runTaskLater(AuxProtectSpigot.this, () -> Telemetry.init(AuxProtectSpigot.this, 14232), delay);
/*
* for (Object command : getConfig().getList("purge-cmds")) { String cmd =
* (String) command; String[] argsOld = cmd.split(" "); String[] args = new
* String[argsOld.length + 1]; args[0] = "purge"; for (int i = 0; i <
* argsOld.length; i++) { args[i + 1] = argsOld[i]; }
* PurgeCommand.purge(AuxProtect.this, new MySender(Bukkit.getConsoleSender()),
* args); }
*
* sqlManager.purgeUIDs();
*
* try { sqlManager.vacuum(); } catch (SQLException e) { print(e); }
*/
}
}.runTaskAsynchronously(this);
@@ -254,40 +242,24 @@ public class AuxProtectSpigot extends JavaPlugin implements IAuxProtect {
// this feels cursed to run setupEconomy() like this...
Telemetry.reportHook(this, "Vault", setupEconomy());
boolean shop = hook(() -> {
return new ShopGUIPlusListener(this);
}, "ShopGuiPlus");
shop = hook(() -> {
return new EconomyShopGUIListener(this);
}, "EconomyShopGUI", "EconomyShopGUI-Premium") || shop;
shop = hook(() -> {
return new DynamicShopListener(this);
}, "DynamicShop") || shop;
shop = hook(() -> {
return new ChestShopListener(this);
}, "ChestShop") || shop;
boolean shop = hook(() -> new ShopGUIPlusListener(this), "ShopGuiPlus");
shop = hook(() -> new EconomyShopGUIListener(this), "EconomyShopGUI", "EconomyShopGUI-Premium") || shop;
shop = hook(() -> new DynamicShopListener(this), "DynamicShop") || shop;
shop = hook(() -> new ChestShopListener(this), "ChestShop") || shop;
if (!shop) {
EntryAction.SHOP.setEnabled(false);
}
if (!hook(() -> {
return new AuctionHouseListener(this);
}, "AuctionHouse")) {
if (!hook(() -> new AuctionHouseListener(this), "AuctionHouse")) {
EntryAction.AUCTIONBUY.setEnabled(false);
EntryAction.AUCTIONLIST.setEnabled(false);
}
if (!hook(() -> {
return new JobsListener(this);
}, "Jobs")) {
if (!hook(() -> new JobsListener(this), "Jobs")) {
EntryAction.JOBS.setEnabled(false);
}
if (!hook(() -> {
return new EssentialsListener(this);
}, "Essentials")) {
if (!hook(() -> new EssentialsListener(this), "Essentials")) {
EntryAction.PAY.setEnabled(false);
}
if (!hook(() -> {
return new TownyListener(this);
}, "Towny")) {
if (!hook(() -> new TownyListener(this), "Towny")) {
for (EntryAction action : EntryAction.values()) {
if (action.getTable() == Table.AUXPROTECT_TOWNY) {
action.setEnabled(false);
@@ -536,7 +508,7 @@ public class AuxProtectSpigot extends JavaPlugin implements IAuxProtect {
}
private boolean hook(Supplier<Listener> listener, String... names) {
boolean hook = false;
boolean hook;
try {
Plugin plugin = null;
for (String name : names) {

View File

@@ -50,7 +50,7 @@ public class Pane implements InventoryHolder {
addButton(slot, type, action, name, null);
}
public void addButton(int slot, Material type, Runnable action, String name, @Nullable List<String> lore) {
public void addButton(int slot, Material type, Runnable action, @Nullable String name, @Nullable List<String> lore) {
if (inventory == null) {
return;
}