Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Add client option to hide custom skulls (#2603)
Dieser Commit ist enthalten in:
Ursprung
f883dfdf2c
Commit
eb211884de
@ -231,7 +231,6 @@ public class GeyserConnector {
|
|||||||
|
|
||||||
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
||||||
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
||||||
SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS = config.isAllowCustomSkulls();
|
|
||||||
|
|
||||||
// https://github.com/GeyserMC/Geyser/issues/957
|
// https://github.com/GeyserMC/Geyser/issues/957
|
||||||
RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();
|
RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();
|
||||||
|
@ -41,11 +41,18 @@ public class PreferencesCache {
|
|||||||
*/
|
*/
|
||||||
@Setter
|
@Setter
|
||||||
private boolean prefersShowCoordinates = true;
|
private boolean prefersShowCoordinates = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the client's preference will be ignored, this will return false.
|
* If the client's preference will be ignored, this will return false.
|
||||||
*/
|
*/
|
||||||
private boolean allowShowCoordinates;
|
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()}.
|
* Which CooldownType the client prefers. Initially set to {@link CooldownUtils#getDefaultShowCooldown()}.
|
||||||
*/
|
*/
|
||||||
@ -54,6 +61,8 @@ public class PreferencesCache {
|
|||||||
|
|
||||||
public PreferencesCache(GeyserSession session) {
|
public PreferencesCache(GeyserSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
|
||||||
|
prefersCustomSkulls = session.getConnector().getConfig().isAllowCustomSkulls();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,4 +77,11 @@ public class PreferencesCache {
|
|||||||
allowShowCoordinates = !session.isReducedDebugInfo() && session.getConnector().getConfig().isShowCoordinates();
|
allowShowCoordinates = !session.isReducedDebugInfo() && session.getConnector().getConfig().isShowCoordinates();
|
||||||
session.sendGameRule("showcoordinates", allowShowCoordinates && prefersShowCoordinates);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
|
|||||||
}
|
}
|
||||||
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), blockState), packet.getPosition());
|
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), blockState), packet.getPosition());
|
||||||
// Check for custom skulls.
|
// 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);
|
SkullBlockEntityTranslator.spawnPlayer(session, packet.getNbt(), blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ public class ChunkUtils {
|
|||||||
bedrockBlockEntities[i] = blockEntityTranslator.getBlockEntityTag(tagName, tag, blockState);
|
bedrockBlockEntities[i] = blockEntityTranslator.getBlockEntityTag(tagName, tag, blockState);
|
||||||
|
|
||||||
// Check for custom skulls
|
// Check for custom skulls
|
||||||
if (SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS && tag.contains("SkullOwner")) {
|
if (session.getPreferencesCache().showCustomSkulls() && tag.contains("SkullOwner")) {
|
||||||
SkullBlockEntityTranslator.spawnPlayer(session, tag, blockState);
|
SkullBlockEntityTranslator.spawnPlayer(session, tag, blockState);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -50,7 +50,10 @@ public class SettingsUtils {
|
|||||||
.iconPath("textures/ui/settings_glyph_color_2x.png");
|
.iconPath("textures/ui/settings_glyph_color_2x.png");
|
||||||
|
|
||||||
// Only show the client title if any of the client settings are available
|
// 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) {
|
if (showClientSettings) {
|
||||||
builder.label("geyser.settings.title.client");
|
builder.label("geyser.settings.title.client");
|
||||||
|
|
||||||
@ -66,6 +69,10 @@ public class SettingsUtils {
|
|||||||
cooldownDropdown.option("options.off", session.getPreferencesCache().getCooldownPreference() == CooldownUtils.CooldownType.DISABLED);
|
cooldownDropdown.option("options.off", session.getPreferencesCache().getCooldownPreference() == CooldownUtils.CooldownType.DISABLED);
|
||||||
builder.dropdown(cooldownDropdown);
|
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");
|
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()];
|
CooldownUtils.CooldownType cooldownType = CooldownUtils.CooldownType.VALUES[(int) response.next()];
|
||||||
session.getPreferencesCache().setCooldownPreference(cooldownType);
|
session.getPreferencesCache().setCooldownPreference(cooldownType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (session.getConnector().getConfig().isAllowCustomSkulls()) {
|
||||||
|
session.getPreferencesCache().setPrefersCustomSkulls(response.next());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canModifyServer) {
|
if (canModifyServer) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren