Add isForceDefaultGameMode method (#12673)

This commit is contained in:
David
2025-06-21 13:10:11 +02:00
committed by GitHub
parent 5652882134
commit c0dda0ea14
3 changed files with 23 additions and 2 deletions

View File

@@ -1730,6 +1730,15 @@ public final class Bukkit {
public static void setDefaultGameMode(@NotNull GameMode mode) {
server.setDefaultGameMode(mode);
}
/**
* Gets whether the default gamemode is being enforced.
*
* @return {@code true} if the default gamemode is being forced, {@code false} otherwise
*/
public static boolean forcesDefaultGameMode() {
return server.forcesDefaultGameMode();
}
/**
* Gets a {@link ConsoleCommandSender} that may be used as an input source

View File

@@ -1514,15 +1514,22 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return the default game mode
*/
@NotNull
public GameMode getDefaultGameMode();
GameMode getDefaultGameMode();
/**
* Sets the default {@link GameMode} for new players.
*
* @param mode the new game mode
*/
public void setDefaultGameMode(@NotNull GameMode mode);
void setDefaultGameMode(@NotNull GameMode mode);
/**
* Gets whether the default gamemode is being enforced.
*
* @return {@code true} if the default gamemode is being forced, {@code false} otherwise
*/
boolean forcesDefaultGameMode();
/**
* Gets a {@link ConsoleCommandSender} that may be used as an input source
* for this server.

View File

@@ -2295,6 +2295,11 @@ public final class CraftServer implements Server {
}
}
@Override
public boolean forcesDefaultGameMode() {
return this.console.getProperties().forceGameMode;
}
@Override
public ConsoleCommandSender getConsoleSender() {
return this.console.console;