Archiviert
1
0

Add SettingsChangedListener

Dieser Commit ist enthalten in:
yoyosource 2022-05-21 13:04:30 +02:00
Ursprung 1204a5ccda
Commit 8aed828f82
4 geänderte Dateien mit 60 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -158,6 +158,7 @@ public class BungeeCore extends Plugin {
new SessionManager();
new SpigotReceiver();
new TablistManager();
new SettingsChangedListener();
getProxy().getScheduler().schedule(this, () -> {
SteamwarUser.clearCache();

Datei anzeigen

@ -61,6 +61,14 @@ public class ConnectionListener extends BasicListener {
ProxiedPlayer player = event.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (!user.isManualLocale()) {
Locale locale = player.getLocale();
if (locale == null) {
locale = Locale.getDefault();
}
user.setLocale(locale, false);
}
player.removeGroups("Admin", "team");
if(user.getUserGroup().isAdminGroup())

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.SettingsChangedEvent;
import net.md_5.bungee.event.EventHandler;
import java.util.Locale;
public class SettingsChangedListener extends BasicListener {
@EventHandler
public void onSettingsChanged(SettingsChangedEvent event) {
ProxiedPlayer player = event.getPlayer();
SteamwarUser steamwarUser = SteamwarUser.get(player);
if (steamwarUser.isManualLocale())
return;
Locale locale = player.getLocale();
if (locale == null) {
locale = Locale.getDefault();
}
steamwarUser.setLocale(locale, false);
}
}

Datei anzeigen

@ -389,9 +389,13 @@ public class SteamwarUser {
}
public void setLocale(Locale locale, boolean manualLocale) {
if (this.locale.equals(locale) && this.manualLocale == manualLocale)
return;
boolean needsUpdate = !this.locale.equals(locale);
this.locale = locale;
this.manualLocale = manualLocale;
updateLocale.update(locale.getLanguage(), manualLocale, id);
if (needsUpdate)
new LocaleInvalidationPacket(id).send(getPlayer());
}
}