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
+27 -21

No files matched your search

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