From 72507aba4b689a4a951beb46a256cbcb4ae281af Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Mon, 17 Aug 2020 00:29:30 +0200 Subject: [PATCH] Change player locale on event --- .../plotsquared/bukkit/listener/PlayerEventListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index 7e0b06018..713780bcb 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -126,6 +126,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLocaleChangeEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; @@ -148,6 +149,7 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.UUID; 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))); + } }