mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00: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
This commit is contained in:
parent
70a8272bc2
commit
1a1837619c
4 changed files with 22 additions and 1 deletions
|
@ -111,6 +111,8 @@ public interface GeyserConfiguration {
|
||||||
|
|
||||||
boolean isNotifyOnNewBedrockUpdate();
|
boolean isNotifyOnNewBedrockUpdate();
|
||||||
|
|
||||||
|
String getUnusableSpaceBlock();
|
||||||
|
|
||||||
IMetricsInfo getMetrics();
|
IMetricsInfo getMetrics();
|
||||||
|
|
||||||
int getPendingAuthenticationTimeout();
|
int getPendingAuthenticationTimeout();
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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/.
|
||||||
|
|
Loading…
Reference in a new issue