mirror of
https://github.com/darksaid98/EntityBingo.git
synced 2026-12-04 08:58:50 +00:00
command tweaks and event finalization rework
This commit is contained in:
1 parent
e0ac7b4eff
commit
d644d1e25b
4 files changed
+21
-14
No files matched your search
@@ -8,6 +8,7 @@ public class BingoEvent {
|
|||||||
|
|
||||||
private final HashMap<String, Integer> entries;
|
private final HashMap<String, Integer> entries;
|
||||||
|
|
||||||
|
private boolean done = false;
|
||||||
|
|
||||||
private final long age;
|
private final long age;
|
||||||
|
|
||||||
@@ -62,4 +63,12 @@ public class BingoEvent {
|
|||||||
public long getAge() {
|
public long getAge() {
|
||||||
return age;
|
return age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDone() {
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDone() {
|
||||||
|
this.done = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@ public final class EntityBingo extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if(currrentEvent != null) {
|
if(currrentEvent != null) {
|
||||||
Bukkit.broadcastMessage(ChatListener.chatLabel() + "Server Shutting down, clearing Bingo Event without results!");
|
Bukkit.broadcastMessage(ChatListener.chatLabel() + "Server Shutting down, clearing Bingo Event without results!");
|
||||||
|
currrentEvent.setDone();
|
||||||
currrentEvent = null;
|
currrentEvent = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
|
|||||||
return true;
|
return true;
|
||||||
} else if(args[0].equalsIgnoreCase("guesses")) {
|
} else if(args[0].equalsIgnoreCase("guesses")) {
|
||||||
//print off all guesses
|
//print off all guesses
|
||||||
p.sendMessage(ChatListener.chatLabel() + ChatListener.color("List of all guesses in this event:"));
|
p.sendMessage(ChatListener.chatLabel() + ChatListener.color("List of all guesses in the " + (EntityBingo.getCurrrentEvent().isDone() ? "previous" : "current") + " event:"));
|
||||||
p.sendMessage(ChatListener.chatLabel() + ChatListener.color("----------------------------------"));
|
p.sendMessage(ChatListener.chatLabel() + ChatListener.color("----------------------------------"));
|
||||||
|
|
||||||
for (String s : EntityBingo.getCurrrentEvent().getEntries().keySet()) {
|
for (String s : EntityBingo.getCurrrentEvent().getEntries().keySet()) {
|
||||||
@@ -83,7 +83,7 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
|
|||||||
if(args.length >= 2) {
|
if(args.length >= 2) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (!p.hasPermission("EntityBingo.admin")) {
|
if (p.hasPermission("EntityBingo.admin")) {
|
||||||
return adminOptions;
|
return adminOptions;
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
|
|||||||
@@ -1,23 +1,19 @@
|
|||||||
package org.aubrithehuman.entitybingo.listeners;
|
package org.aubrithehuman.entitybingo.listeners;
|
||||||
|
|
||||||
import org.aubrithehuman.entitybingo.BingoEvent;
|
import org.aubrithehuman.entitybingo.BingoEvent;
|
||||||
|
import org.aubrithehuman.entitybingo.DataManager;
|
||||||
import org.aubrithehuman.entitybingo.EntityBingo;
|
import org.aubrithehuman.entitybingo.EntityBingo;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.server.BroadcastMessageEvent;
|
import org.bukkit.event.server.BroadcastMessageEvent;
|
||||||
import org.bukkit.event.server.ServerEvent;
|
|
||||||
|
|
||||||
import javax.sound.midi.SysexMessage;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ChatListener implements Listener {
|
public class ChatListener implements Listener {
|
||||||
|
|
||||||
@@ -27,8 +23,8 @@ public class ChatListener implements Listener {
|
|||||||
boolean matchFound = e.getMessage().equals("§4[ClearLag] §cWarning Ground items will be removed in §760 §cseconds!");
|
boolean matchFound = e.getMessage().equals("§4[ClearLag] §cWarning Ground items will be removed in §760 §cseconds!");
|
||||||
boolean matchFound2 = false;
|
boolean matchFound2 = false;
|
||||||
if(matchFound) {
|
if(matchFound) {
|
||||||
//start the event
|
//start the event, only if previous one is marked as done
|
||||||
if(EntityBingo.getCurrrentEvent() == null) {
|
if(EntityBingo.getCurrrentEvent().isDone()) {
|
||||||
EntityBingo.setCurrrentEvent(new BingoEvent());
|
EntityBingo.setCurrrentEvent(new BingoEvent());
|
||||||
Bukkit.broadcastMessage(chatLabel() + "Entity Bingo has begun! Type a number to enter!");
|
Bukkit.broadcastMessage(chatLabel() + "Entity Bingo has begun! Type a number to enter!");
|
||||||
EntityBingo.getInstance().getLogger().info(chatLabel() + "Entity Bingo has begun! Type a number to enter!");
|
EntityBingo.getInstance().getLogger().info(chatLabel() + "Entity Bingo has begun! Type a number to enter!");
|
||||||
@@ -62,7 +58,7 @@ public class ChatListener implements Listener {
|
|||||||
i = Integer.parseInt(numberOnly);
|
i = Integer.parseInt(numberOnly);
|
||||||
} catch (NumberFormatException exception) {
|
} catch (NumberFormatException exception) {
|
||||||
EntityBingo.getInstance().getLogger().info(chatLabel() + color("&cFailed to find the result number, cancelling bingo."));
|
EntityBingo.getInstance().getLogger().info(chatLabel() + color("&cFailed to find the result number, cancelling bingo."));
|
||||||
EntityBingo.setCurrrentEvent(null);
|
EntityBingo.getCurrrentEvent().setDone();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,11 +81,12 @@ public class ChatListener implements Listener {
|
|||||||
for (String s : winners) {
|
for (String s : winners) {
|
||||||
Bukkit.broadcastMessage(chatLabel() + s + " guessed correctly!");
|
Bukkit.broadcastMessage(chatLabel() + s + " guessed correctly!");
|
||||||
EntityBingo.getInstance().getLogger().info(chatLabel() + s + " guessed correctly!");
|
EntityBingo.getInstance().getLogger().info(chatLabel() + s + " guessed correctly!");
|
||||||
//TODO save result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityBingo.setCurrrentEvent(null);
|
}
|
||||||
|
|
||||||
|
EntityBingo.getCurrrentEvent().setDone();
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user