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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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) { public static void setDefaultGameMode(@NotNull GameMode mode) {
server.setDefaultGameMode(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 * 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 * @return the default game mode
*/ */
@NotNull @NotNull
public GameMode getDefaultGameMode(); GameMode getDefaultGameMode();
/** /**
* Sets the default {@link GameMode} for new players. * Sets the default {@link GameMode} for new players.
* *
* @param mode the new game mode * @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 * Gets a {@link ConsoleCommandSender} that may be used as an input source
* for this server. * 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 @Override
public ConsoleCommandSender getConsoleSender() { public ConsoleCommandSender getConsoleSender() {
return this.console.console; return this.console.console;