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

Add client option to hide custom skulls (#2603)

Dieser Commit ist enthalten in:
Konicai 2021-10-30 23:22:04 -04:00 committet von GitHub
Ursprung f883dfdf2c
Commit eb211884de
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
5 geänderte Dateien mit 30 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -231,7 +231,6 @@ public class GeyserConnector {
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS = config.isAllowCustomSkulls();
// https://github.com/GeyserMC/Geyser/issues/957
RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();

Datei anzeigen

@ -41,11 +41,18 @@ public class PreferencesCache {
*/
@Setter
private boolean prefersShowCoordinates = true;
/**
* If the client's preference will be ignored, this will return false.
*/
private boolean allowShowCoordinates;
/**
* If the session wants custom skulls to be shown.
*/
@Setter
private boolean prefersCustomSkulls;
/**
* Which CooldownType the client prefers. Initially set to {@link CooldownUtils#getDefaultShowCooldown()}.
*/
@ -54,6 +61,8 @@ public class PreferencesCache {
public PreferencesCache(GeyserSession session) {
this.session = session;
prefersCustomSkulls = session.getConnector().getConfig().isAllowCustomSkulls();
}
/**
@ -68,4 +77,11 @@ public class PreferencesCache {
allowShowCoordinates = !session.isReducedDebugInfo() && session.getConnector().getConfig().isShowCoordinates();
session.sendGameRule("showcoordinates", allowShowCoordinates && prefersShowCoordinates);
}
/**
* @return true if the session prefers custom skulls, and the config allows them.
*/
public boolean showCustomSkulls() {
return prefersCustomSkulls && session.getConnector().getConfig().isAllowCustomSkulls();
}
}

Datei anzeigen

@ -63,7 +63,7 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
}
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), blockState), packet.getPosition());
// Check for custom skulls.
if (SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS && packet.getNbt().contains("SkullOwner")) {
if (session.getPreferencesCache().showCustomSkulls() && packet.getNbt().contains("SkullOwner")) {
SkullBlockEntityTranslator.spawnPlayer(session, packet.getNbt(), blockState);
}

Datei anzeigen

@ -294,7 +294,7 @@ public class ChunkUtils {
bedrockBlockEntities[i] = blockEntityTranslator.getBlockEntityTag(tagName, tag, blockState);
// Check for custom skulls
if (SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS && tag.contains("SkullOwner")) {
if (session.getPreferencesCache().showCustomSkulls() && tag.contains("SkullOwner")) {
SkullBlockEntityTranslator.spawnPlayer(session, tag, blockState);
}
i++;

Datei anzeigen

@ -50,7 +50,10 @@ public class SettingsUtils {
.iconPath("textures/ui/settings_glyph_color_2x.png");
// Only show the client title if any of the client settings are available
boolean showClientSettings = session.getPreferencesCache().isAllowShowCoordinates() || CooldownUtils.getDefaultShowCooldown() != CooldownUtils.CooldownType.DISABLED;
boolean showClientSettings = session.getPreferencesCache().isAllowShowCoordinates()
|| CooldownUtils.getDefaultShowCooldown() != CooldownUtils.CooldownType.DISABLED
|| session.getConnector().getConfig().isAllowCustomSkulls();
if (showClientSettings) {
builder.label("geyser.settings.title.client");
@ -66,6 +69,10 @@ public class SettingsUtils {
cooldownDropdown.option("options.off", session.getPreferencesCache().getCooldownPreference() == CooldownUtils.CooldownType.DISABLED);
builder.dropdown(cooldownDropdown);
}
if (session.getConnector().getConfig().isAllowCustomSkulls()) {
builder.toggle("geyser.settings.option.customSkulls", session.getPreferencesCache().isPrefersCustomSkulls());
}
}
boolean canModifyServer = session.getOpPermissionLevel() >= 2 || session.hasPermission("geyser.settings.server");
@ -122,6 +129,10 @@ public class SettingsUtils {
CooldownUtils.CooldownType cooldownType = CooldownUtils.CooldownType.VALUES[(int) response.next()];
session.getPreferencesCache().setCooldownPreference(cooldownType);
}
if (session.getConnector().getConfig().isAllowCustomSkulls()) {
session.getPreferencesCache().setPrefersCustomSkulls(response.next());
}
}
if (canModifyServer) {