Implement Player Client Options API
== AT == public net.minecraft.world.entity.player.Player DATA_PLAYER_MODE_CUSTOMISATION public net.minecraft.server.level.ServerPlayer particleStatus
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package com.destroystokyo.paper;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class PaperSkinParts implements SkinParts {
|
||||
|
||||
private final int raw;
|
||||
|
||||
public PaperSkinParts(int raw) {
|
||||
this.raw = raw;
|
||||
}
|
||||
|
||||
public boolean hasCapeEnabled() {
|
||||
return (raw & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasJacketEnabled() {
|
||||
return (raw >> 1 & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasLeftSleeveEnabled() {
|
||||
return (raw >> 2 & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasRightSleeveEnabled() {
|
||||
return (raw >> 3 & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasLeftPantsEnabled() {
|
||||
return (raw >> 4 & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasRightPantsEnabled() {
|
||||
return (raw >> 5 & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasHatsEnabled() {
|
||||
return (raw >> 6 & 1) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRaw() {
|
||||
return raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PaperSkinParts that = (PaperSkinParts) o;
|
||||
return raw == that.raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(raw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(", ", PaperSkinParts.class.getSimpleName() + "[", "]")
|
||||
.add("raw=" + raw)
|
||||
.add("cape=" + hasCapeEnabled())
|
||||
.add("jacket=" + hasJacketEnabled())
|
||||
.add("leftSleeve=" + hasLeftSleeveEnabled())
|
||||
.add("rightSleeve=" + hasRightSleeveEnabled())
|
||||
.add("leftPants=" + hasLeftPantsEnabled())
|
||||
.add("rightPants=" + hasRightPantsEnabled())
|
||||
.add("hats=" + hasHatsEnabled())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -658,6 +658,30 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getClientOption(com.destroystokyo.paper.ClientOption<T> type) {
|
||||
if (com.destroystokyo.paper.ClientOption.SKIN_PARTS == type) {
|
||||
return type.getType().cast(new com.destroystokyo.paper.PaperSkinParts(this.getHandle().getEntityData().get(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION)));
|
||||
} else if (com.destroystokyo.paper.ClientOption.CHAT_COLORS_ENABLED == type) {
|
||||
return type.getType().cast(this.getHandle().canChatInColor());
|
||||
} else if (com.destroystokyo.paper.ClientOption.CHAT_VISIBILITY == type) {
|
||||
return type.getType().cast(com.destroystokyo.paper.ClientOption.ChatVisibility.valueOf(this.getHandle().getChatVisibility().name()));
|
||||
} else if (com.destroystokyo.paper.ClientOption.LOCALE == type) {
|
||||
return type.getType().cast(this.getLocale());
|
||||
} else if (com.destroystokyo.paper.ClientOption.MAIN_HAND == type) {
|
||||
return type.getType().cast(this.getMainHand());
|
||||
} else if (com.destroystokyo.paper.ClientOption.VIEW_DISTANCE == type) {
|
||||
return type.getType().cast(this.getClientViewDistance());
|
||||
} else if (com.destroystokyo.paper.ClientOption.TEXT_FILTERING_ENABLED == type) {
|
||||
return type.getType().cast(this.getHandle().isTextFilteringEnabled());
|
||||
} else if (com.destroystokyo.paper.ClientOption.ALLOW_SERVER_LISTINGS == type) {
|
||||
return type.getType().cast(this.getHandle().allowsListing());
|
||||
} else if (com.destroystokyo.paper.ClientOption.PARTICLE_VISIBILITY == type) {
|
||||
return type.getType().cast(com.destroystokyo.paper.ClientOption.ParticleVisibility.valueOf(this.getHandle().particleStatus.name()));
|
||||
}
|
||||
throw new RuntimeException("Unknown settings type");
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user