Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change event priority #4

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.EventPriority;

import java.io.IOException;
import java.util.function.Consumer;
Expand Down Expand Up @@ -51,8 +52,9 @@ public void onEnable() {
}
};

@EventHandler
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (event.isCancelled() && !config.forceful) return;
BlueMapAPI api = BlueMapAPI.getInstance().orElse(null);
if (api == null) return; //BlueMap not loaded, ignore

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/technicjelle/bluemapchatmarkers/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Config {
public String markerSetName;
public boolean toggleable;
public boolean defaultHidden;
public boolean forceful;
public long markerDuration;

public Config(BlueMapChatMarkers plugin) {
Expand All @@ -28,10 +29,11 @@ public Config(BlueMapChatMarkers plugin) {
plugin.reloadConfig();

//Load config values into variables
markerSetName = configFile().getString("MarkerSetName");
toggleable = configFile().getBoolean("Toggleable");
defaultHidden = configFile().getBoolean("DefaultHidden");
markerDuration = configFile().getLong("MarkerDuration");
markerSetName = configFile().getString("MarkerSetName", "Chat Messages");
toggleable = configFile().getBoolean("Toggleable", true);
defaultHidden = configFile().getBoolean("DefaultHidden", false);
markerDuration = configFile().getLong("MarkerDuration", 60);
forceful = configFile().getBoolean("Forceful", false);
}

private FileConfiguration configFile() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ DefaultHidden: false

# Amount of time a chat marker stays on the map (in seconds)
MarkerDuration: 60

# Set this to `true` if you have other chat management plugins that are cancelling the chat event
# before it gets registered with this plugin
Forceful: false