Merge pull request #169 from Dreeam-qwq/fix/i18n-opt

Remove locale data from locale map when player quit to save ram
This commit is contained in:
DGun Otto 2024-06-10 06:51:49 +08:00 committed by GitHub
commit 4700e2ae90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -16,9 +16,11 @@ import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.TeleportUtils;
import fr.xephi.authme.util.message.I18NUtils;
import fr.xephi.authme.util.message.MiniMessageUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -248,6 +250,11 @@ public class PlayerListener implements Listener {
}
}
// Remove data from locale map when player quit
if (settings.getProperty(PluginSettings.I18N_MESSAGES)) {
I18NUtils.removeLocale(player.getUniqueId());
}
if (antiBotService.wasPlayerKicked(player.getName())) {
return;
}

View File

@ -60,6 +60,10 @@ public class I18NUtils {
PLAYER_LOCALE.put(uuid, locale);
}
public static void removeLocale(UUID uuid) {
PLAYER_LOCALE.remove(uuid);
}
/**
* Returns the AuthMe messages file language code, by given locale and settings.
* Dreeam - Hard mapping, based on mc1.20.6, 5/29/2024