From a6cc28ee80072b57b4f6793cc22a6ad6bfd8c90c Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 7 Nov 2020 00:52:09 +0000 Subject: [PATCH] Add config option for enabling achievements (#1504) * Add config option for enabling achievements * Disabled achievements by default and added warning about commands being disabled * Update config.yml * Rename achievements-enabled to xbox-achievements-enabled for clarity Co-authored-by: Camotoy <20743703+DoctorMacc@users.noreply.github.com> --- .../connector/configuration/GeyserConfiguration.java | 2 ++ .../connector/configuration/GeyserJacksonConfiguration.java | 3 +++ .../geysermc/connector/network/session/GeyserSession.java | 4 ++-- connector/src/main/resources/config.yml | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java index c1cc4d03..153a9174 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java @@ -81,6 +81,8 @@ public interface GeyserConfiguration { boolean isForceResourcePacks(); + boolean isXboxAchievementsEnabled(); + int getCacheImages(); IMetricsInfo getMetrics(); diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java index 45676fbd..d19cfe49 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java @@ -107,6 +107,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration @JsonProperty("force-resource-packs") private boolean forceResourcePacks = true; + @JsonProperty("xbox-achievements-enabled") + private boolean xboxAchievementsEnabled = false; + private MetricsInfo metrics = new MetricsInfo(); @Getter diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 6a2913c8..4429268a 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -634,7 +634,7 @@ public class GeyserSession implements CommandSender { startGamePacket.setLevelGameType(GameType.SURVIVAL); startGamePacket.setDifficulty(1); startGamePacket.setDefaultSpawn(Vector3i.ZERO); - startGamePacket.setAchievementsDisabled(true); + startGamePacket.setAchievementsDisabled(!connector.getConfig().isXboxAchievementsEnabled()); startGamePacket.setCurrentTick(-1); startGamePacket.setEduEditionOffers(0); startGamePacket.setEduFeaturesEnabled(false); @@ -645,7 +645,7 @@ public class GeyserSession implements CommandSender { startGamePacket.getGamerules().add(new GameRuleData<>("showcoordinates", true)); startGamePacket.setPlatformBroadcastMode(GamePublishSetting.PUBLIC); startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC); - startGamePacket.setCommandsEnabled(true); + startGamePacket.setCommandsEnabled(!connector.getConfig().isXboxAchievementsEnabled()); startGamePacket.setTexturePacksRequired(false); startGamePacket.setBonusChestEnabled(false); startGamePacket.setStartingWithMap(false); diff --git a/connector/src/main/resources/config.yml b/connector/src/main/resources/config.yml index 43e3e8ed..b53fcdd0 100644 --- a/connector/src/main/resources/config.yml +++ b/connector/src/main/resources/config.yml @@ -117,6 +117,11 @@ above-bedrock-nether-building: false # want to download the resource packs force-resource-packs: true +# Allows Xbox achievements to be unlocked. +# This disables certain commands so the Bedrock client can't to "cheat" to get them. +# Commands such as /gamemode and /give will not work from Bedrock with this enabled +xbox-achievements-enabled: false + # 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, # what OS is being used, etc. You can learn more about bStats here: https://bstats.org/.