Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Fix unwanted behaviour with show-coordinates (#2151)
Co-authored-by: rtm516 <ryantmilner@hotmail.co.uk>
Dieser Commit ist enthalten in:
Ursprung
f0a002f0e3
Commit
0a79eb92ac
@ -1022,7 +1022,6 @@ public class GeyserSession implements CommandSender {
|
|||||||
startGamePacket.setLightningLevel(0);
|
startGamePacket.setLightningLevel(0);
|
||||||
startGamePacket.setMultiplayerGame(true);
|
startGamePacket.setMultiplayerGame(true);
|
||||||
startGamePacket.setBroadcastingToLan(true);
|
startGamePacket.setBroadcastingToLan(true);
|
||||||
startGamePacket.getGamerules().add(new GameRuleData<>("showcoordinates", connector.getConfig().isShowCoordinates()));
|
|
||||||
startGamePacket.setPlatformBroadcastMode(GamePublishSetting.PUBLIC);
|
startGamePacket.setPlatformBroadcastMode(GamePublishSetting.PUBLIC);
|
||||||
startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC);
|
startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC);
|
||||||
startGamePacket.setCommandsEnabled(!connector.getConfig().isXboxAchievementsEnabled());
|
startGamePacket.setCommandsEnabled(!connector.getConfig().isXboxAchievementsEnabled());
|
||||||
@ -1214,13 +1213,14 @@ public class GeyserSession implements CommandSender {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the cached value for the reduced debug info gamerule.
|
* Update the cached value for the reduced debug info gamerule.
|
||||||
* This also toggles the coordinates display
|
* If enabled, also hides the player's coordinates.
|
||||||
*
|
*
|
||||||
* @param value The new value for reducedDebugInfo
|
* @param value The new value for reducedDebugInfo
|
||||||
*/
|
*/
|
||||||
public void setReducedDebugInfo(boolean value) {
|
public void setReducedDebugInfo(boolean value) {
|
||||||
worldCache.setShowCoordinates(!value);
|
|
||||||
reducedDebugInfo = value;
|
reducedDebugInfo = value;
|
||||||
|
// Set the showCoordinates data. This is done because updateShowCoordinates() uses this gamerule as a variable.
|
||||||
|
getWorldCache().updateShowCoordinates();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@ package org.geysermc.connector.network.session.cache;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.scoreboard.Objective;
|
import org.geysermc.connector.scoreboard.Objective;
|
||||||
import org.geysermc.connector.scoreboard.Scoreboard;
|
import org.geysermc.connector.scoreboard.Scoreboard;
|
||||||
@ -38,7 +39,13 @@ public class WorldCache {
|
|||||||
private final GeyserSession session;
|
private final GeyserSession session;
|
||||||
@Setter
|
@Setter
|
||||||
private Difficulty difficulty = Difficulty.EASY;
|
private Difficulty difficulty = Difficulty.EASY;
|
||||||
private boolean showCoordinates = true;
|
|
||||||
|
/**
|
||||||
|
* True if the client prefers being shown their coordinates, regardless if they're being shown or not.
|
||||||
|
* This will be true everytime the client joins the server because neither the client nor server store the preference permanently.
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private boolean prefersShowCoordinates = true;
|
||||||
|
|
||||||
private Scoreboard scoreboard;
|
private Scoreboard scoreboard;
|
||||||
private final ScoreboardUpdater scoreboardUpdater;
|
private final ScoreboardUpdater scoreboardUpdater;
|
||||||
@ -66,12 +73,16 @@ public class WorldCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell the client to hide or show the coordinates
|
* Tell the client to hide or show the coordinates.
|
||||||
|
*
|
||||||
|
* If {@link #isPrefersShowCoordinates()} is true, coordinates will be shown, unless either of the following conditions apply:
|
||||||
|
*
|
||||||
|
* <li> {@link GeyserSession#isReducedDebugInfo()} is enabled
|
||||||
|
* <li> {@link GeyserConfiguration#isShowCoordinates()} is disabled
|
||||||
*
|
*
|
||||||
* @param value True to show, false to hide
|
|
||||||
*/
|
*/
|
||||||
public void setShowCoordinates(boolean value) {
|
public void updateShowCoordinates() {
|
||||||
showCoordinates = value;
|
boolean allowShowCoordinates = !session.isReducedDebugInfo() && session.getConnector().getConfig().isShowCoordinates();
|
||||||
session.sendGameRule("showcoordinates", value);
|
session.sendGameRule("showcoordinates", allowShowCoordinates && prefersShowCoordinates);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -86,6 +86,8 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
|||||||
gamerulePacket.getGameRules().add(new GameRuleData<>("doimmediaterespawn", !packet.isEnableRespawnScreen()));
|
gamerulePacket.getGameRules().add(new GameRuleData<>("doimmediaterespawn", !packet.isEnableRespawnScreen()));
|
||||||
session.sendUpstreamPacket(gamerulePacket);
|
session.sendUpstreamPacket(gamerulePacket);
|
||||||
|
|
||||||
|
session.setReducedDebugInfo(packet.isReducedDebugInfo());
|
||||||
|
|
||||||
session.setRenderDistance(packet.getViewDistance());
|
session.setRenderDistance(packet.getViewDistance());
|
||||||
|
|
||||||
// We need to send our skin parts to the server otherwise java sees us with no hat, jacket etc
|
// We need to send our skin parts to the server otherwise java sees us with no hat, jacket etc
|
||||||
|
@ -57,8 +57,12 @@ public class SettingsUtils {
|
|||||||
CustomFormBuilder builder = new CustomFormBuilder(LanguageUtils.getPlayerLocaleString("geyser.settings.title.main", language));
|
CustomFormBuilder builder = new CustomFormBuilder(LanguageUtils.getPlayerLocaleString("geyser.settings.title.main", language));
|
||||||
builder.setIcon(new FormImage(FormImage.FormImageType.PATH, "textures/ui/settings_glyph_color_2x.png"));
|
builder.setIcon(new FormImage(FormImage.FormImageType.PATH, "textures/ui/settings_glyph_color_2x.png"));
|
||||||
|
|
||||||
builder.addComponent(new LabelComponent(LanguageUtils.getPlayerLocaleString("geyser.settings.title.client", language)));
|
// Client can only see its coordinates if reducedDebugInfo is disabled and coordinates are enabled in geyser config.
|
||||||
builder.addComponent(new ToggleComponent(LanguageUtils.getPlayerLocaleString("geyser.settings.option.coordinates", language), session.getWorldCache().isShowCoordinates()));
|
if (!session.isReducedDebugInfo() && session.getConnector().getConfig().isShowCoordinates()) {
|
||||||
|
builder.addComponent(new LabelComponent(LanguageUtils.getPlayerLocaleString("geyser.settings.title.client", language)));
|
||||||
|
|
||||||
|
builder.addComponent(new ToggleComponent(LanguageUtils.getPlayerLocaleString("geyser.settings.option.coordinates", language), session.getWorldCache().isPrefersShowCoordinates()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (session.getOpPermissionLevel() >= 2 || session.hasPermission("geyser.settings.server")) {
|
if (session.getOpPermissionLevel() >= 2 || session.hasPermission("geyser.settings.server")) {
|
||||||
@ -117,10 +121,14 @@ public class SettingsUtils {
|
|||||||
}
|
}
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
offset++; // Client settings title
|
// Client can only see its coordinates if reducedDebugInfo is disabled and coordinates are enabled in geyser config.
|
||||||
|
if (!session.isReducedDebugInfo() && session.getConnector().getConfig().isShowCoordinates()) {
|
||||||
|
offset++; // Client settings title
|
||||||
|
|
||||||
session.getWorldCache().setShowCoordinates(settingsResponse.getToggleResponses().get(offset));
|
session.getWorldCache().setPrefersShowCoordinates(settingsResponse.getToggleResponses().get(offset));
|
||||||
offset++;
|
session.getWorldCache().updateShowCoordinates();
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
if (session.getOpPermissionLevel() >= 2 || session.hasPermission("geyser.settings.server")) {
|
if (session.getOpPermissionLevel() >= 2 || session.hasPermission("geyser.settings.server")) {
|
||||||
offset++; // Server settings title
|
offset++; // Server settings title
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren