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 ed72d1801..884134948 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 @@ -51,6 +51,7 @@ import org.geysermc.api.session.AuthData; import org.geysermc.api.window.FormWindow; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.cache.InventoryCache; +import org.geysermc.connector.network.session.cache.ScoreboardCache; import org.geysermc.connector.network.session.cache.WindowCache; import org.geysermc.connector.network.translators.Registry; import org.geysermc.connector.utils.Toolbox; @@ -77,6 +78,9 @@ public class GeyserSession implements PlayerSession, Player { @Getter private WindowCache windowCache; + @Getter + private ScoreboardCache scoreboardCache; + @Getter private boolean loggedIn; @@ -89,6 +93,8 @@ public class GeyserSession implements PlayerSession, Player { this.inventoryCache = new InventoryCache(this); this.windowCache = new WindowCache(this); + this.scoreboardCache = new ScoreboardCache(this); + this.loggedIn = false; } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/ScoreboardCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/ScoreboardCache.java new file mode 100644 index 000000000..01efa9693 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/ScoreboardCache.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.connector.network.session.cache; + +import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket; +import lombok.Getter; +import lombok.Setter; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.scoreboard.Scoreboard; + +public class ScoreboardCache { + + private GeyserSession session; + + public ScoreboardCache(GeyserSession session) { + this.session = session; + } + + @Getter + @Setter + private Scoreboard scoreboard; + + public void removeScoreboard() { + RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket(); + removeObjectivePacket.setObjectiveId(scoreboard.getObjective().getObjectiveName()); + session.getUpstream().sendPacket(removeObjectivePacket); + } +} \ No newline at end of file