Change player locale on event

This commit is contained in:
Hannes Greule 2020-08-17 00:29:30 +02:00
parent 9b086b3f2a
commit 72507aba4b

View File

@ -126,6 +126,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLocaleChangeEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
@ -148,6 +149,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -1624,4 +1626,10 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
} }
} }
@EventHandler public void onLocaleChange(final PlayerLocaleChangeEvent event) {
BukkitPlayer player = BukkitUtil.adapt(event.getPlayer());
// we're stripping the country code as we con't want to differ between countries
player.setLocale(Locale.forLanguageTag(event.getLocale().substring(0, 2)));
}
} }