-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kwantux
committed
Nov 10, 2024
1 parent
f64d79d
commit 4d4056e
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/de/kwantux/networks/event/NoticeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package de.kwantux.networks.event; | ||
|
||
import de.kwantux.networks.Main; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.InventoryCloseEvent; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import static de.kwantux.networks.Main.mgr; | ||
import static de.kwantux.networks.Main.lang; | ||
|
||
public class NoticeListener implements Listener { | ||
|
||
private List<UUID> notices = new ArrayList<>(); | ||
|
||
public NoticeListener(Main plugin) { | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@EventHandler | ||
public void onInventoryOpen(InventoryCloseEvent event) { | ||
if (event.getInventory().firstEmpty() != -1) return; | ||
if (notices.contains(event.getPlayer().getUniqueId())) return; | ||
if (mgr.withUser(event.getPlayer().getUniqueId()).isEmpty()) { | ||
notices.add(event.getPlayer().getUniqueId()); | ||
lang.message(event.getPlayer(), "notice"); | ||
} | ||
} | ||
} |