3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 00:23:03 +01:00

Option to specify the "unusable inventory space" item (#3402)

Adds an "unusable-space-block" setting in the config.yml to specify an item to indicate unavailable spaces in a bedrock inventory.
If the item is invalid, a barrier block is used & an error gets printed
Dieser Commit ist enthalten in:
onebeastchris 2022-11-24 03:33:55 +01:00 committet von GitHub
Ursprung 70a8272bc2
Commit 1a1837619c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 22 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -111,6 +111,8 @@ public interface GeyserConfiguration {
boolean isNotifyOnNewBedrockUpdate(); boolean isNotifyOnNewBedrockUpdate();
String getUnusableSpaceBlock();
IMetricsInfo getMetrics(); IMetricsInfo getMetrics();
int getPendingAuthenticationTimeout(); int getPendingAuthenticationTimeout();

Datei anzeigen

@ -154,6 +154,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("notify-on-new-bedrock-update") @JsonProperty("notify-on-new-bedrock-update")
private boolean notifyOnNewBedrockUpdate = true; private boolean notifyOnNewBedrockUpdate = true;
@JsonProperty("unusable-space-block")
private String unusableSpaceBlock = "minecraft:barrier";
private MetricsInfo metrics = new MetricsInfo(); private MetricsInfo metrics = new MetricsInfo();
@JsonProperty("pending-authentication-timeout") @JsonProperty("pending-authentication-timeout")

Datei anzeigen

@ -38,6 +38,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.ContainerId;
import com.nukkitx.protocol.bedrock.data.inventory.ItemData; import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket; import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
import com.nukkitx.protocol.bedrock.packet.PlayerHotbarPacket; import com.nukkitx.protocol.bedrock.packet.PlayerHotbarPacket;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.inventory.Container; import org.geysermc.geyser.inventory.Container;
import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.inventory.Inventory; import org.geysermc.geyser.inventory.Inventory;
@ -184,11 +185,22 @@ public class InventoryUtils {
root.put("display", display.build()); root.put("display", display.build());
return protocolVersion -> ItemData.builder() return protocolVersion -> ItemData.builder()
.id(Registries.ITEMS.forVersion(protocolVersion).getStoredItems().barrier().getBedrockId()) .id(getUnusableSpaceBlockID(protocolVersion))
.count(1) .count(1)
.tag(root.build()).build(); .tag(root.build()).build();
} }
private static int getUnusableSpaceBlockID(int protocolVersion) {
String unusableSpaceBlock = GeyserImpl.getInstance().getConfig().getUnusableSpaceBlock();
ItemMapping unusableSpaceBlockID = Registries.ITEMS.forVersion(protocolVersion).getMapping(unusableSpaceBlock);
if (unusableSpaceBlockID != null) {
return unusableSpaceBlockID.getBedrockId();
} else {
GeyserImpl.getInstance().getLogger().error("Invalid value" + unusableSpaceBlock + ". Resorting to barrier block.");
return Registries.ITEMS.forVersion(protocolVersion).getStoredItems().barrier().getBedrockId();
}
}
/** /**
* See {@link #findOrCreateItem(GeyserSession, String)}. This is for finding a specified {@link ItemStack}. * See {@link #findOrCreateItem(GeyserSession, String)}. This is for finding a specified {@link ItemStack}.
* *

Datei anzeigen

@ -183,6 +183,10 @@ log-player-ip-addresses: true
# auto-update. # auto-update.
notify-on-new-bedrock-update: true notify-on-new-bedrock-update: true
# Which item to use to mark unavailable slots in a Bedrock player inventory. Examples of this are the 2x2 crafting grid while in creative,
# or custom inventory menus with sizes different from the usual 3x9. A barrier block is the default item.
unusable-space-block: minecraft:barrier
# bStats is a stat tracker that is entirely anonymous and tracks only basic information # bStats is a stat tracker that is entirely anonymous and tracks only basic information
# about Geyser, such as how many people are online, how many servers are using Geyser, # about Geyser, such as how many people are online, how many servers are using Geyser,
# what OS is being used, etc. You can learn more about bStats here: https://bstats.org/. # what OS is being used, etc. You can learn more about bStats here: https://bstats.org/.