mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
address review
This commit is contained in:
parent
49167b041f
commit
b11ee02c4c
3 changed files with 29 additions and 18 deletions
|
|
@ -162,7 +162,7 @@ public interface CameraData {
|
||||||
*
|
*
|
||||||
* @param element the {@link GuiElement} to reset
|
* @param element the {@link GuiElement} to reset
|
||||||
*/
|
*/
|
||||||
void resetElement(@NonNull GuiElement... element);
|
void resetElement(@NonNull GuiElement @Nullable... element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether a {@link GuiElement} is currently hidden.
|
* Determines whether a {@link GuiElement} is currently hidden.
|
||||||
|
|
|
||||||
|
|
@ -30,18 +30,28 @@ package org.geysermc.geyser.api.bedrock.camera;
|
||||||
* These can be hidden using {@link CameraData#hideElement(GuiElement...)},
|
* These can be hidden using {@link CameraData#hideElement(GuiElement...)},
|
||||||
* and one can reset their visibility using {@link CameraData#resetElement(GuiElement...)}.
|
* and one can reset their visibility using {@link CameraData#resetElement(GuiElement...)}.
|
||||||
*/
|
*/
|
||||||
public enum GuiElement {
|
public class GuiElement {
|
||||||
PAPER_DOLL,
|
public static final GuiElement PAPER_DOLL = new GuiElement(0);
|
||||||
ARMOR,
|
public static final GuiElement ARMOR = new GuiElement(1);
|
||||||
TOOL_TIPS,
|
public static final GuiElement TOOL_TIPS = new GuiElement(2);
|
||||||
TOUCH_CONTROLS,
|
public static final GuiElement TOUCH_CONTROLS = new GuiElement(3);
|
||||||
CROSSHAIR,
|
public static final GuiElement CROSSHAIR = new GuiElement(4);
|
||||||
HOTBAR,
|
public static final GuiElement HOTBAR = new GuiElement(5);
|
||||||
HEALTH,
|
public static final GuiElement HEALTH = new GuiElement(6);
|
||||||
PROGRESS_BAR,
|
public static final GuiElement PROGRESS_BAR = new GuiElement(7);
|
||||||
FOOD_BAR,
|
public static final GuiElement FOOD_BAR = new GuiElement(8);
|
||||||
AIR_BUBBLES_BAR,
|
public static final GuiElement AIR_BUBBLES_BAR = new GuiElement(9);
|
||||||
VEHICLE_HEALTH,
|
public static final GuiElement VEHICLE_HEALTH = new GuiElement(10);
|
||||||
EFFECTS_BAR,
|
public static final GuiElement EFFECTS_BAR = new GuiElement(11);
|
||||||
ITEM_TEXT_POPUP
|
public static final GuiElement ITEM_TEXT_POPUP = new GuiElement(12);
|
||||||
|
|
||||||
|
private GuiElement(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
public int id() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -260,13 +260,14 @@ public class GeyserCameraData implements CameraData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hideElement(GuiElement... elements) {
|
public void hideElement(GuiElement... elements) {
|
||||||
|
Objects.requireNonNull(elements);
|
||||||
SetHudPacket packet = new SetHudPacket();
|
SetHudPacket packet = new SetHudPacket();
|
||||||
packet.setVisibility(HudVisibility.HIDE);
|
packet.setVisibility(HudVisibility.HIDE);
|
||||||
Set<HudElement> elementSet = packet.getElements();
|
Set<HudElement> elementSet = packet.getElements();
|
||||||
|
|
||||||
for (GuiElement element : elements) {
|
for (GuiElement element : elements) {
|
||||||
this.hiddenHudElements.add(element);
|
this.hiddenHudElements.add(element);
|
||||||
elementSet.add(HUD_ELEMENT_VALUES[element.ordinal()]);
|
elementSet.add(HUD_ELEMENT_VALUES[element.id()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.sendUpstreamPacket(packet);
|
session.sendUpstreamPacket(packet);
|
||||||
|
|
@ -278,10 +279,10 @@ public class GeyserCameraData implements CameraData {
|
||||||
packet.setVisibility(HudVisibility.RESET);
|
packet.setVisibility(HudVisibility.RESET);
|
||||||
Set<HudElement> elementSet = packet.getElements();
|
Set<HudElement> elementSet = packet.getElements();
|
||||||
|
|
||||||
if (elements.length != 0) {
|
if (elements != null && elements.length != 0) {
|
||||||
for (GuiElement element : elements) {
|
for (GuiElement element : elements) {
|
||||||
this.hiddenHudElements.remove(element);
|
this.hiddenHudElements.remove(element);
|
||||||
elementSet.add(HUD_ELEMENT_VALUES[element.ordinal()]);
|
elementSet.add(HUD_ELEMENT_VALUES[element.id()]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.hiddenHudElements.clear();
|
this.hiddenHudElements.clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue