public variable to enum in TitlePacket
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
package mc.core.network.proto_1_12_2.packets;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@@ -18,22 +19,29 @@ import mc.core.text.Text;
|
||||
public class TitlePacket implements SCPacket {
|
||||
private static final int TICKS_PER_SEC = 20,
|
||||
MIN_MS = (1000 / TICKS_PER_SEC);
|
||||
public static final int SET_TITLE = 0,
|
||||
SET_SUBTITLE = 1,
|
||||
SET_ACTION_BAR = 2,
|
||||
SET_DISPLAY_TIME = 3,
|
||||
HIDE = 4,
|
||||
RESET = 5;
|
||||
|
||||
private final int action;
|
||||
@RequiredArgsConstructor
|
||||
public enum Action {
|
||||
SET_TITLE(0),
|
||||
SET_SUBTITLE(1),
|
||||
SET_ACTION_BAR(2),
|
||||
SET_DISPLAY_TIME(3),
|
||||
HIDE(4),
|
||||
RESET(5);
|
||||
|
||||
@Getter
|
||||
private final int id;
|
||||
}
|
||||
|
||||
private final Action action;
|
||||
private Text text = null;
|
||||
private Integer fadeInTime = null;
|
||||
private Integer stayTime = null;
|
||||
private Integer fadeOutTime = null;
|
||||
|
||||
public TitlePacket(int action, Object... values) {
|
||||
if (values.length == 0 && (action != HIDE && action != RESET)) {
|
||||
this.action = HIDE;
|
||||
public TitlePacket(Action action, Object... values) {
|
||||
if (values.length == 0 && (action != Action.HIDE && action != Action.RESET)) {
|
||||
this.action = Action.HIDE;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,9 +100,9 @@ public class TitlePacket implements SCPacket {
|
||||
|
||||
@Override
|
||||
public void writeSelf(NetOutputStream netStream) {
|
||||
netStream.writeVarInt(this.action);
|
||||
netStream.writeVarInt(action.id);
|
||||
|
||||
switch (this.action) {
|
||||
switch (action) {
|
||||
case SET_TITLE:
|
||||
case SET_SUBTITLE:
|
||||
case SET_ACTION_BAR:
|
||||
|
||||
Reference in New Issue
Block a user