Skip to content

Commit

Permalink
Make GuardGameModeJoinListener log game mode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Apr 2, 2022
1 parent d3c1fba commit 8509525
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package ch.vorburger.minecraft.storeys.guard;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
Expand All @@ -32,8 +34,9 @@
*/
public class GuardGameModeJoinListener implements EventListener<Join> {

@Override
public void handle(Join joinEvent) throws Exception {
private static final Logger LOG = LoggerFactory.getLogger(GuardGameModeJoinListener.class);

@Override public void handle(Join joinEvent) throws Exception {
GameMode newGameMode = null;
Player player = joinEvent.getTargetEntity();
// NB: Order and use of if and not else if - because higher permission overrides lower...
Expand All @@ -48,6 +51,7 @@ public void handle(Join joinEvent) throws Exception {
}
if (newGameMode != null) {
player.offer(Keys.GAME_MODE, newGameMode);
LOG.info("Player {} game mode {}", player, newGameMode);
}
}

Expand Down

0 comments on commit 8509525

Please sign in to comment.