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
|
||||
*/
|
||||
void resetElement(@NonNull GuiElement... element);
|
||||
void resetElement(@NonNull GuiElement @Nullable... element);
|
||||
|
||||
/**
|
||||
* 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...)},
|
||||
* and one can reset their visibility using {@link CameraData#resetElement(GuiElement...)}.
|
||||
*/
|
||||
public enum GuiElement {
|
||||
PAPER_DOLL,
|
||||
ARMOR,
|
||||
TOOL_TIPS,
|
||||
TOUCH_CONTROLS,
|
||||
CROSSHAIR,
|
||||
HOTBAR,
|
||||
HEALTH,
|
||||
PROGRESS_BAR,
|
||||
FOOD_BAR,
|
||||
AIR_BUBBLES_BAR,
|
||||
VEHICLE_HEALTH,
|
||||
EFFECTS_BAR,
|
||||
ITEM_TEXT_POPUP
|
||||
public class GuiElement {
|
||||
public static final GuiElement PAPER_DOLL = new GuiElement(0);
|
||||
public static final GuiElement ARMOR = new GuiElement(1);
|
||||
public static final GuiElement TOOL_TIPS = new GuiElement(2);
|
||||
public static final GuiElement TOUCH_CONTROLS = new GuiElement(3);
|
||||
public static final GuiElement CROSSHAIR = new GuiElement(4);
|
||||
public static final GuiElement HOTBAR = new GuiElement(5);
|
||||
public static final GuiElement HEALTH = new GuiElement(6);
|
||||
public static final GuiElement PROGRESS_BAR = new GuiElement(7);
|
||||
public static final GuiElement FOOD_BAR = new GuiElement(8);
|
||||
public static final GuiElement AIR_BUBBLES_BAR = new GuiElement(9);
|
||||
public static final GuiElement VEHICLE_HEALTH = new GuiElement(10);
|
||||
public static final GuiElement EFFECTS_BAR = new GuiElement(11);
|
||||
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
|
||||
public void hideElement(GuiElement... elements) {
|
||||
Objects.requireNonNull(elements);
|
||||
SetHudPacket packet = new SetHudPacket();
|
||||
packet.setVisibility(HudVisibility.HIDE);
|
||||
Set<HudElement> elementSet = packet.getElements();
|
||||
|
||||
for (GuiElement element : elements) {
|
||||
this.hiddenHudElements.add(element);
|
||||
elementSet.add(HUD_ELEMENT_VALUES[element.ordinal()]);
|
||||
elementSet.add(HUD_ELEMENT_VALUES[element.id()]);
|
||||
}
|
||||
|
||||
session.sendUpstreamPacket(packet);
|
||||
|
|
@ -278,10 +279,10 @@ public class GeyserCameraData implements CameraData {
|
|||
packet.setVisibility(HudVisibility.RESET);
|
||||
Set<HudElement> elementSet = packet.getElements();
|
||||
|
||||
if (elements.length != 0) {
|
||||
if (elements != null && elements.length != 0) {
|
||||
for (GuiElement element : elements) {
|
||||
this.hiddenHudElements.remove(element);
|
||||
elementSet.add(HUD_ELEMENT_VALUES[element.ordinal()]);
|
||||
elementSet.add(HUD_ELEMENT_VALUES[element.id()]);
|
||||
}
|
||||
} else {
|
||||
this.hiddenHudElements.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue