From 50b621b9506f3fa4bd1fd4a35b2e5253e1be5f19 Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Thu, 3 Aug 2023 02:14:13 +0900 Subject: [PATCH] feat: game mode change logger listener --- build.gradle.kts | 2 +- .../com/github/mori01231/lifecore/LifeCore.kt | 1 + .../GameModeChangeLoggerListener.java | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/mori01231/lifecore/listener/GameModeChangeLoggerListener.java diff --git a/build.gradle.kts b/build.gradle.kts index 0fc2b3a..817d85a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.azisaba" -version = "6.6.9" +version = "6.6.10" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) diff --git a/src/main/java/com/github/mori01231/lifecore/LifeCore.kt b/src/main/java/com/github/mori01231/lifecore/LifeCore.kt index ca6e3b1..617c2f0 100644 --- a/src/main/java/com/github/mori01231/lifecore/LifeCore.kt +++ b/src/main/java/com/github/mori01231/lifecore/LifeCore.kt @@ -247,6 +247,7 @@ class LifeCore : JavaPlugin() { pm.registerEvents(EscapeLobbyListener(this), this) pm.registerEvents(PreventOpenMerchantMenuListener(), this) pm.registerEvents(CancelMythicItemPlaceListener(), this) + pm.registerEvents(GameModeChangeLoggerListener(this), this) // Items pm.registerEvents(OreOnlyItemListener(), this) diff --git a/src/main/java/com/github/mori01231/lifecore/listener/GameModeChangeLoggerListener.java b/src/main/java/com/github/mori01231/lifecore/listener/GameModeChangeLoggerListener.java new file mode 100644 index 0000000..0d9a62d --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/listener/GameModeChangeLoggerListener.java @@ -0,0 +1,20 @@ +package com.github.mori01231.lifecore.listener; + +import com.github.mori01231.lifecore.LifeCore; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerGameModeChangeEvent; + +public class GameModeChangeLoggerListener implements Listener { + private final LifeCore plugin; + + public GameModeChangeLoggerListener(LifeCore plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onGameModeChange(PlayerGameModeChangeEvent e) { + plugin.getLogger().info("Game mode of " + e.getPlayer().getName() + " changed from " + e.getPlayer().getGameMode().name() + " to " + e.getNewGameMode().name()); + } +}