Skip to content

Commit

Permalink
Fixup server brand fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
OreCruncher committed Feb 5, 2024
1 parent 24ca59d commit c48fb28
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/java/org/orecruncher/dsurround/lib/GameUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.core.RegistryAccess;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.entity.player.Player;

import java.util.Objects;
import java.util.Optional;
Expand All @@ -23,7 +23,7 @@ private GameUtils() {
}

// Client methods
public static Optional<Player> getPlayer() {
public static Optional<LocalPlayer> getPlayer() {
return Optional.ofNullable(getMC().player);
}

Expand Down Expand Up @@ -94,10 +94,7 @@ public static Minecraft getMC() {
}

public static Optional<String> getServerBrand() {
var connection = getMC().getConnection();
if (connection != null)
return Optional.ofNullable(connection.serverBrand());
return Optional.empty();
return getPlayer().map(LocalPlayer::getServerBrand);
}

public static MinecraftServerType getServerType() {
Expand Down

0 comments on commit c48fb28

Please sign in to comment.