listen changes and event starting

This commit is contained in:
Aubri Seebauer committed 2023-04-21 12:16:47 -04:00
1 parent 6a17bbaa8d
commit f8c14bf0b9
3 files changed
+22 -16

No files matched your search

@@ -2,12 +2,8 @@ package org.aubrithehuman.entitybingo;
import org.aubrithehuman.entitybingo.command.EntityBingoCommand; import org.aubrithehuman.entitybingo.command.EntityBingoCommand;
import org.aubrithehuman.entitybingo.listeners.ChatListener; import org.aubrithehuman.entitybingo.listeners.ChatListener;
import org.aubrithehuman.entitybingo.listeners.EntityClearEventListener;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import javax.swing.text.html.parser.Entity;
public final class EntityBingo extends JavaPlugin { public final class EntityBingo extends JavaPlugin {
static EntityBingo instance; static EntityBingo instance;
@@ -26,7 +22,6 @@ public final class EntityBingo extends JavaPlugin {
this.saveDefaultConfig(); this.saveDefaultConfig();
this.getServer().getPluginManager().registerEvents(new ChatListener(), this); this.getServer().getPluginManager().registerEvents(new ChatListener(), this);
this.getServer().getPluginManager().registerEvents(new EntityClearEventListener(), this);
DataManager.init(); DataManager.init();
@@ -33,8 +33,12 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(args.length >= 1) { if(args.length >= 1) {
if(args.length >= 2) {
return null;
} else {
return options; return options;
} }
}
return null; return null;
} }
} }
@@ -22,25 +22,31 @@ import java.util.regex.Pattern;
public class ChatListener implements Listener { public class ChatListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onChat(BroadcastMessageEvent e) { public void onBroadcast(BroadcastMessageEvent e) {
Bukkit.getLogger().info(e.getMessage()); Bukkit.getLogger().info(chatLabel() + "comparing: " + e.getMessage());
Pattern pattern = Pattern.compile("[ClearLag] Warning Ground items will be removed in 60 seconds", Pattern.CASE_INSENSITIVE); // Pattern pattern = Pattern.compile("", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(e.getMessage()); // Matcher matcher = pattern.matcher(e.getMessage());
boolean matchFound = matcher.find(); boolean matchFound = e.getMessage().equals("§4[ClearLag] §cWarning Ground items will be removed in §760 §cseconds!");
boolean matchFound2 = false;
if(matchFound) { if(matchFound) {
Bukkit.getLogger().info("Match found"); Bukkit.getLogger().info("Match found");
} else { } else {
Bukkit.getLogger().info("Match not found"); Bukkit.getLogger().info("Match not found, checking endpoint");
}
Pattern pattern2 = Pattern.compile("[ClearLag] Removed Entities!", Pattern.CASE_INSENSITIVE); String check = "§6[ClearLag] §aRemoved ";
Matcher matcher2 = pattern2.matcher(e.getMessage()); if(e.getMessage().length() >= 23) {
boolean matchFound2 = matcher2.find(); String p1 = e.getMessage().substring(0, 23);
matchFound2 = p1.equals(check);
if(matchFound2) { if(matchFound2) {
Bukkit.getLogger().info("Match found"); Bukkit.getLogger().info("Match found");
} else { } else {
Bukkit.getLogger().info("Match not found"); Bukkit.getLogger().info("Match not found");
} }
}
}
//TODO start event //TODO start event
if(matchFound) { if(matchFound) {
@@ -78,6 +84,7 @@ public class ChatListener implements Listener {
} }
} }
EntityBingo.setCurrrentEvent(null);
} }
} }
} }
@@ -87,7 +94,7 @@ public class ChatListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onChat(AsyncPlayerChatEvent e) { public void onChat(AsyncPlayerChatEvent e) {
//Entry detection //Entry detection
Bukkit.getLogger().info(e.getMessage()); Bukkit.getLogger().info(chatLabel() + "comparing: " + e.getMessage());
if (EntityBingo.getCurrrentEvent() != null) { if (EntityBingo.getCurrrentEvent() != null) {
String str = e.getMessage(); String str = e.getMessage();
String numberOnly = str.replaceAll("[^0-9]", ""); String numberOnly = str.replaceAll("[^0-9]", "");