Player(Client) settings
This commit is contained in:
@@ -38,6 +38,7 @@ public class InMemoryPlayerManager implements PlayerManager, Runnable {
|
|||||||
player.setName(name);
|
player.setName(name);
|
||||||
player.getLocation().set(defaultLocation);
|
player.getLocation().set(defaultLocation);
|
||||||
player.getLook().set(defaultLook);
|
player.getLook().set(defaultLook);
|
||||||
|
player.setSettings(new PlayerSettings());
|
||||||
|
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
players.add(player);
|
players.add(player);
|
||||||
|
|||||||
@@ -24,4 +24,7 @@ public interface Player {
|
|||||||
|
|
||||||
boolean isFlying();
|
boolean isFlying();
|
||||||
void setFlying(boolean value);
|
void setFlying(boolean value);
|
||||||
|
|
||||||
|
PlayerSettings getSettings();
|
||||||
|
void setSettings(PlayerSettings settings);
|
||||||
}
|
}
|
||||||
|
|||||||
32
core/src/main/java/mc/core/player/PlayerSettings.java
Normal file
32
core/src/main/java/mc/core/player/PlayerSettings.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-06-23
|
||||||
|
*/
|
||||||
|
package mc.core.player;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PlayerSettings {
|
||||||
|
public static final int CHAT_ENABLED = 0,
|
||||||
|
CHAT_COMMANDS_ONLY = 1,
|
||||||
|
CHAT_HIDDEN = 2;
|
||||||
|
|
||||||
|
public static final int HAND_LEFT = 0,
|
||||||
|
HAND_RIGHT = 1;
|
||||||
|
|
||||||
|
private String locate = "en_US";
|
||||||
|
private int viewDistance = 8;
|
||||||
|
private int chatMode = CHAT_ENABLED;
|
||||||
|
private boolean chatColors = true;
|
||||||
|
private boolean capeEnabled = true,
|
||||||
|
jacketEnabled = true,
|
||||||
|
leftSleeveEnabled = true,
|
||||||
|
rightSleeveEnabled = true,
|
||||||
|
leftPantsLegEnabled = true,
|
||||||
|
rightPantsLegEnabled = true,
|
||||||
|
hatEnabled = true;
|
||||||
|
private int mainHand = HAND_RIGHT;
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ public class SimplePlayer implements Player {
|
|||||||
private Location location = new Location(0, 0, 0);
|
private Location location = new Location(0, 0, 0);
|
||||||
private Look look = new Look(0, 0);
|
private Look look = new Look(0, 0);
|
||||||
private boolean flying = false;
|
private boolean flying = false;
|
||||||
|
private PlayerSettings settings;
|
||||||
|
|
||||||
public void setLocation(Location location) {
|
public void setLocation(Location location) {
|
||||||
this.location.set(location);
|
this.location.set(location);
|
||||||
|
|||||||
@@ -161,4 +161,25 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
|||||||
channel.writeAndFlush(pkt4);
|
channel.writeAndFlush(pkt4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PacketListener
|
||||||
|
private void onClientSettings(Channel channel, ClientSettingsPacket packet) {
|
||||||
|
if (!channel.attr(ATTR_STATE).get().equals(State.PLAY)) return;
|
||||||
|
|
||||||
|
Player player = channel.attr(ATTR_PLAYER).get();
|
||||||
|
player.getSettings().setLocate(packet.getLocale());
|
||||||
|
player.getSettings().setViewDistance(packet.getViewDistance());
|
||||||
|
player.getSettings().setChatMode(packet.getChatMode());
|
||||||
|
player.getSettings().setChatColors(packet.isChatColors());
|
||||||
|
|
||||||
|
player.getSettings().setCapeEnabled(packet.isCapeEnabled());
|
||||||
|
player.getSettings().setJacketEnabled(packet.isJacketEnabled());
|
||||||
|
player.getSettings().setLeftSleeveEnabled(packet.isLeftSleeveEnabled());
|
||||||
|
player.getSettings().setRightSleeveEnabled(packet.isRightSleeveEnabled());
|
||||||
|
player.getSettings().setLeftPantsLegEnabled(packet.isLeftPantsLegEnabled());
|
||||||
|
player.getSettings().setRightPantsLegEnabled(packet.isRightPantsLegEnabled());
|
||||||
|
player.getSettings().setHatEnabled(packet.isHatEnabled());
|
||||||
|
|
||||||
|
player.getSettings().setMainHand(packet.getMainHand());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user