Archived
0

public variable to enum in PlayerSettings

This commit is contained in:
2018-08-12 19:48:57 +03:00
parent 7b61aa7707
commit b8a71c070c
2 changed files with 34 additions and 9 deletions

View File

@@ -5,21 +5,45 @@
package mc.core.player;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Getter
@Setter
public class PlayerSettings {
public static final int CHAT_ENABLED = 0,
CHAT_COMMANDS_ONLY = 1,
CHAT_HIDDEN = 2;
@RequiredArgsConstructor
public enum ChatMode {
ENABLED(0),
COMMANDS_ONLY(1),
HIDDEN(2);
public static final int HAND_LEFT = 0,
HAND_RIGHT = 1;
public static ChatMode getById(int id) {
if (id == 0) return ENABLED;
else if (id == 1) return COMMANDS_ONLY;
else return HIDDEN;
}
@Getter
private final int id;
}
@RequiredArgsConstructor
public enum Hand {
LEFT(0),
RIGHT(1);
public static Hand getById(int id) {
if (id == 0) return LEFT;
else return RIGHT;
}
@Getter
private final int id;
}
private String locate = "en_US";
private int viewDistance = 8;
private int chatMode = CHAT_ENABLED;
private ChatMode chatMode = ChatMode.ENABLED;
private boolean chatColors = true;
private boolean capeEnabled = true,
jacketEnabled = true,
@@ -28,5 +52,5 @@ public class PlayerSettings {
leftPantsLegEnabled = true,
rightPantsLegEnabled = true,
hatEnabled = true;
private int mainHand = HAND_RIGHT;
private Hand mainHand = Hand.RIGHT;
}

View File

@@ -13,6 +13,7 @@ import mc.core.events.EventBusGetter;
import mc.core.network.proto_1_12_2.TeleportManager;
import mc.core.network.proto_1_12_2.packets.*;
import mc.core.player.Player;
import mc.core.player.PlayerSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -32,7 +33,7 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
player.getSettings().setLocate(packet.getLocale());
player.getSettings().setViewDistance(packet.getViewDistance());
player.getSettings().setChatMode(packet.getChatMode());
player.getSettings().setChatMode(PlayerSettings.ChatMode.getById(packet.getChatMode()));
player.getSettings().setChatColors(packet.isChatColors());
player.getSettings().setCapeEnabled(packet.isCapeEnabled());
@@ -43,7 +44,7 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
player.getSettings().setRightPantsLegEnabled(packet.isRightPantsLegEnabled());
player.getSettings().setHatEnabled(packet.isHatEnabled());
player.getSettings().setMainHand(packet.getMainHand());
player.getSettings().setMainHand(PlayerSettings.Hand.getById(packet.getMainHand()));
}
@Handler