public variable to enum in PlayerSettings
This commit is contained in:
@@ -5,21 +5,45 @@
|
|||||||
package mc.core.player;
|
package mc.core.player;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class PlayerSettings {
|
public class PlayerSettings {
|
||||||
public static final int CHAT_ENABLED = 0,
|
@RequiredArgsConstructor
|
||||||
CHAT_COMMANDS_ONLY = 1,
|
public enum ChatMode {
|
||||||
CHAT_HIDDEN = 2;
|
ENABLED(0),
|
||||||
|
COMMANDS_ONLY(1),
|
||||||
|
HIDDEN(2);
|
||||||
|
|
||||||
public static final int HAND_LEFT = 0,
|
public static ChatMode getById(int id) {
|
||||||
HAND_RIGHT = 1;
|
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 String locate = "en_US";
|
||||||
private int viewDistance = 8;
|
private int viewDistance = 8;
|
||||||
private int chatMode = CHAT_ENABLED;
|
private ChatMode chatMode = ChatMode.ENABLED;
|
||||||
private boolean chatColors = true;
|
private boolean chatColors = true;
|
||||||
private boolean capeEnabled = true,
|
private boolean capeEnabled = true,
|
||||||
jacketEnabled = true,
|
jacketEnabled = true,
|
||||||
@@ -28,5 +52,5 @@ public class PlayerSettings {
|
|||||||
leftPantsLegEnabled = true,
|
leftPantsLegEnabled = true,
|
||||||
rightPantsLegEnabled = true,
|
rightPantsLegEnabled = true,
|
||||||
hatEnabled = true;
|
hatEnabled = true;
|
||||||
private int mainHand = HAND_RIGHT;
|
private Hand mainHand = Hand.RIGHT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.TeleportManager;
|
||||||
import mc.core.network.proto_1_12_2.packets.*;
|
import mc.core.network.proto_1_12_2.packets.*;
|
||||||
import mc.core.player.Player;
|
import mc.core.player.Player;
|
||||||
|
import mc.core.player.PlayerSettings;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
|
|||||||
|
|
||||||
player.getSettings().setLocate(packet.getLocale());
|
player.getSettings().setLocate(packet.getLocale());
|
||||||
player.getSettings().setViewDistance(packet.getViewDistance());
|
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().setChatColors(packet.isChatColors());
|
||||||
|
|
||||||
player.getSettings().setCapeEnabled(packet.isCapeEnabled());
|
player.getSettings().setCapeEnabled(packet.isCapeEnabled());
|
||||||
@@ -43,7 +44,7 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
|
|||||||
player.getSettings().setRightPantsLegEnabled(packet.isRightPantsLegEnabled());
|
player.getSettings().setRightPantsLegEnabled(packet.isRightPantsLegEnabled());
|
||||||
player.getSettings().setHatEnabled(packet.isHatEnabled());
|
player.getSettings().setHatEnabled(packet.isHatEnabled());
|
||||||
|
|
||||||
player.getSettings().setMainHand(packet.getMainHand());
|
player.getSettings().setMainHand(PlayerSettings.Hand.getById(packet.getMainHand()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
|
|||||||
Reference in New Issue
Block a user