mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Ensure positive chunk view distance from the client
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
ffbc8e5f27
commit
025052102d
@ -5,14 +5,11 @@ import net.minestom.server.event.EventDispatcher;
|
|||||||
import net.minestom.server.event.player.PlayerSettingsChangeEvent;
|
import net.minestom.server.event.player.PlayerSettingsChangeEvent;
|
||||||
import net.minestom.server.network.packet.client.play.ClientSettingsPacket;
|
import net.minestom.server.network.packet.client.play.ClientSettingsPacket;
|
||||||
|
|
||||||
public class SettingsListener {
|
public final class SettingsListener {
|
||||||
|
|
||||||
public static void listener(ClientSettingsPacket packet, Player player) {
|
public static void listener(ClientSettingsPacket packet, Player player) {
|
||||||
Player.PlayerSettings settings = player.getSettings();
|
Player.PlayerSettings settings = player.getSettings();
|
||||||
settings.refresh(packet.locale, packet.viewDistance, packet.chatMessageType, packet.chatColors, packet.displayedSkinParts, packet.mainHand);
|
final byte viewDistance = (byte) Math.abs(packet.viewDistance);
|
||||||
|
settings.refresh(packet.locale, viewDistance, packet.chatMessageType, packet.chatColors, packet.displayedSkinParts, packet.mainHand);
|
||||||
PlayerSettingsChangeEvent playerSettingsChangeEvent = new PlayerSettingsChangeEvent(player);
|
EventDispatcher.call(new PlayerSettingsChangeEvent(player));
|
||||||
EventDispatcher.call(playerSettingsChangeEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user