mirror of
https://github.com/darksaid98/EntityBingo.git
synced 2026-12-03 00:18:52 +00:00
listen changes and event starting
This commit is contained in:
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.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,7 +33,11 @@ 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) {
|
||||||
return options;
|
if(args.length >= 2) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
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");
|
||||||
|
|
||||||
|
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
|
//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]", "");
|
||||||
|
|||||||
Reference in new issue
Block a user