mirror of
https://github.com/darksaid98/EntityBingo.git
synced 2026-12-02 08:08:46 +00:00
polish
This commit is contained in:
1 parent
55008b41ba
commit
3171cfe8de
3 files changed
+34
-12
No files matched your search
@@ -31,6 +31,20 @@ public final class EntityBingo extends JavaPlugin {
|
||||
|
||||
DataManager.init();
|
||||
|
||||
//Reload scoreboard
|
||||
HashMap<String, Object> raw = DataManager.getData("scoreboard.yml");
|
||||
HashMap<String, Object> data = (HashMap<String, Object>) raw.get("scores");
|
||||
//grab only entries with integer values, should be all, but we need to check anyway
|
||||
Map<String, Integer> filtered = data.entrySet()
|
||||
.stream()
|
||||
.filter(v -> v.getValue() instanceof Integer)
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
v -> (int) v.getValue()));
|
||||
|
||||
//Save to static scoreboard reference
|
||||
ChatListener.scoreboard = Helper.sortData(filtered);
|
||||
|
||||
this.getLogger().info("EntityBingo loaded.");
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +59,13 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
|
||||
int page = 1;
|
||||
try {
|
||||
page = args.length >= 2 ? Integer.parseInt(args[1]) : 1;
|
||||
page = Math.min(1, page);
|
||||
page = Math.max((int) pages, page);
|
||||
page = Math.max(1, page);
|
||||
page = Math.min((int) pages, page);
|
||||
} catch (NumberFormatException ex) {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cPage number not a value."));
|
||||
}
|
||||
|
||||
int startIndex = (page - 1) * 10;
|
||||
int startIndex = (page - 1) * 8;
|
||||
|
||||
//print
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("Entity Bingo Scoreboard:"));
|
||||
@@ -73,18 +73,28 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
int i = 0;
|
||||
for (String s : ChatListener.scoreboard.keySet()) {
|
||||
if (i < startIndex) continue;
|
||||
//if were past page 1 this will kick into effect
|
||||
if (i < startIndex) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
//format and push to player
|
||||
String name = Bukkit.getOfflinePlayer(UUID.fromString(s)).getName();
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&7 " + (i + 1) + ". " + name + ", " + ChatListener.scoreboard.get(s)));
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&7" + (i + 1) + ". " + name + ", " + ChatListener.scoreboard.get(s)));
|
||||
i++;
|
||||
//page limit
|
||||
if(i > 9 + startIndex) break;
|
||||
if(i > 7 + startIndex) break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
} else if(args[0].equalsIgnoreCase("guesses")) {
|
||||
//print off all guesses
|
||||
|
||||
if (EntityBingo.getCurrrentEvent() == null) {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("No games have occurred recently."));
|
||||
}
|
||||
|
||||
//print off all guesses
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("List of all guesses in the " + (EntityBingo.getCurrrentEvent().isDone() ? "previous" : "current") + " event:"));
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("----------------------------------"));
|
||||
|
||||
@@ -101,7 +111,7 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
//clear entry pool
|
||||
EntityBingo.getCurrrentEvent().getEntries().clear();
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cCleared all entries in the current event."));
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cCleared all entries in the " + (EntityBingo.getCurrrentEvent().isDone() ? "previous" : "current") + " event. This won't effect the scoreboard."));
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + Helper.color("&cEntries cleared by an admin!"));
|
||||
EntityBingo.getInstance().getLogger().info(Helper.color("&cEntries cleared by an admin!"));
|
||||
return true;
|
||||
@@ -140,6 +150,8 @@ public class EntityBingoCommand implements CommandExecutor, TabCompleter {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cReloaded scoreboard."));
|
||||
EntityBingo.getInstance().getLogger().info(Helper.color("&cAdmin reloaded scoreboard!"));
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cError. Subcommand not found"));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,6 @@ public class ChatListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBroadcast(BroadcastMessageEvent e) {
|
||||
Bukkit.getLogger().info(Helper.chatLabel() + "comparing: " + e.getMessage());
|
||||
boolean matchFound = e.getMessage().equals("§4[ClearLag] §cWarning Ground items will be removed in §760 §cseconds!");
|
||||
boolean matchFound2 = false;
|
||||
if(matchFound) {
|
||||
@@ -46,15 +45,12 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
Bukkit.getLogger().info("Match not found, checking endpoint");
|
||||
|
||||
//check for end broadcast
|
||||
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 for endpoint");
|
||||
//check if we have an bingo event happening
|
||||
if(EntityBingo.getCurrrentEvent() != null) {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "Entity Bingo has ended!");
|
||||
|
||||
Reference in new issue
Block a user