no longer requires spigot added for actionbar

This commit is contained in:
ajgeiss0702
2020-09-05 11:30:49 -07:00
parent 0ec25476e5
commit 0b47fde43f
2 changed files with 81 additions and 60 deletions
+80 -59
View File
@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.ServerPing; import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
@@ -276,11 +277,16 @@ public class Manager {
} }
BungeeUtils.sendCustomData(p, "actionbar", msgs.get("spigot.actionbar.offline") /*BungeeUtils.sendCustomData(p, "actionbar", msgs.get("spigot.actionbar.offline")
.replaceAll("\\{POS\\}", pos+"") .replaceAll("\\{POS\\}", pos+"")
.replaceAll("\\{LEN\\}", len+"") .replaceAll("\\{LEN\\}", len+"")
.replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName())) .replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName()))
.replaceAll("\\{STATUS\\}", status)+";time="+pl.timeBetweenPlayers); .replaceAll("\\{STATUS\\}", status)+";time="+pl.timeBetweenPlayers);*/
p.sendMessage(ChatMessageType.ACTION_BAR, msgs.getBC("spigot.actionbar.offline",
"POS:"+pos,
"LEN:"+len,
"SERVER:"+pl.aliases.getAlias(s.getName()),
"STATUS:"+status));
} else { } else {
int time = (int) Math.round(pos*pl.timeBetweenPlayers); int time = (int) Math.round(pos*pl.timeBetweenPlayers);
int min = (int) Math.floor((time) / (60)); int min = (int) Math.floor((time) / (60));
@@ -295,11 +301,16 @@ public class Manager {
.replaceAll("\\{m\\}", min+"") .replaceAll("\\{m\\}", min+"")
.replaceAll("\\{s\\}", sec+""); .replaceAll("\\{s\\}", sec+"");
} }
BungeeUtils.sendCustomData(p, "actionbar", msgs.get("spigot.actionbar.online") /*BungeeUtils.sendCustomData(p, "actionbar", msgs.get("spigot.actionbar.online")
.replaceAll("\\{POS\\}", pos+"") .replaceAll("\\{POS\\}", pos+"")
.replaceAll("\\{LEN\\}", len+"") .replaceAll("\\{LEN\\}", len+"")
.replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName())) .replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName()))
.replaceAll("\\{TIME\\}", timeStr)+";time="+pl.timeBetweenPlayers); .replaceAll("\\{TIME\\}", timeStr)+";time="+pl.timeBetweenPlayers);*/
p.sendMessage(ChatMessageType.ACTION_BAR, msgs.getBC("spigot.actionbar.online",
"POS:"+pos,
"LEN:"+len,
"SERVER:"+pl.aliases.getAlias(s.getName()),
"TIME:"+timeStr));
} }
} }
@@ -364,7 +375,6 @@ public class Manager {
*/ */
public void sendMessages() { public void sendMessages() {
for(QueueServer s : servers) { for(QueueServer s : servers) {
int ot = s.getOfflineTime();
List<ProxiedPlayer> plys = s.getQueue(); List<ProxiedPlayer> plys = s.getQueue();
Iterator<ProxiedPlayer> it = plys.iterator(); Iterator<ProxiedPlayer> it = plys.iterator();
while(it.hasNext()) { while(it.hasNext()) {
@@ -374,63 +384,74 @@ public class Manager {
it.remove(); it.remove();
continue; continue;
} }
int len = plys.size(); sendMessage(ply, s);
if(!s.isJoinable(ply)) {
String status = msgs.get("status.offline.restarting");
if(ot > pl.config.getInt("offline-time")) {
status = msgs.get("status.offline.offline");
}
if(s.isFull() && s.isOnline()) {
status = msgs.get("status.offline.full");
}
if(!s.canAccess(ply)) {
status = msgs.get("status.offline.restricted");
}
if(s.isPaused()) {
status = msgs.get("status.offline.paused");
}
if(status.isEmpty()) return;
ply.sendMessage(Main.formatMessage(
msgs.get("status.offline.base")
.replaceAll("\\{STATUS\\}", status)
.replaceAll("\\{POS\\}", pos+"")
.replaceAll("\\{LEN\\}", len+"")
.replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName()))
));
} else {
if(msgs.get("spigot.actionbar.offline").isEmpty()) return;
int time = (int) Math.round(pos*pl.timeBetweenPlayers);
int min = (int) Math.floor((time) / (60));
int sec = (int) Math.floor((time % (60)));
String timeStr;
if(min <= 0) {
timeStr = msgs.get("format.time.secs")
.replaceAll("\\{m\\}", "0")
.replaceAll("\\{s\\}", sec+"");
} else {
timeStr = msgs.get("format.time.mins")
.replaceAll("\\{m\\}", min+"")
.replaceAll("\\{s\\}", sec+"");
}
ply.sendMessage(Main.formatMessage(
msgs.get("status.online.base")
.replaceAll("\\{POS\\}", pos+"")
.replaceAll("\\{LEN\\}", len+"")
.replaceAll("\\{TIME\\}", timeStr)
.replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName()))
));
}
} }
} }
} }
/**
* Sends a status message to a player
* @param ply The player to send the message to
* @param s The QueueServer the message should be about
*/
public void sendMessage(ProxiedPlayer ply, QueueServer s) {
List<ProxiedPlayer> plys = s.getQueue();
int pos = plys.indexOf(ply)+1;
if(pos == 0) return;
int len = plys.size();
int ot = s.getOfflineTime();
if(!s.isJoinable(ply)) {
String status = msgs.get("status.offline.restarting");
if(ot > pl.config.getInt("offline-time")) {
status = msgs.get("status.offline.offline");
}
if(s.isFull() && s.isOnline()) {
status = msgs.get("status.offline.full");
}
if(!s.canAccess(ply)) {
status = msgs.get("status.offline.restricted");
}
if(s.isPaused()) {
status = msgs.get("status.offline.paused");
}
if(status.isEmpty()) return;
ply.sendMessage(Main.formatMessage(
msgs.get("status.offline.base")
.replaceAll("\\{STATUS\\}", status)
.replaceAll("\\{POS\\}", pos+"")
.replaceAll("\\{LEN\\}", len+"")
.replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName()))
));
} else {
if(msgs.get("spigot.actionbar.offline").isEmpty()) return;
int time = (int) Math.round(pos*pl.timeBetweenPlayers);
int min = (int) Math.floor((time) / (60));
int sec = (int) Math.floor((time % (60)));
String timeStr;
if(min <= 0) {
timeStr = msgs.get("format.time.secs")
.replaceAll("\\{m\\}", "0")
.replaceAll("\\{s\\}", sec+"");
} else {
timeStr = msgs.get("format.time.mins")
.replaceAll("\\{m\\}", min+"")
.replaceAll("\\{s\\}", sec+"");
}
ply.sendMessage(Main.formatMessage(
msgs.get("status.online.base")
.replaceAll("\\{POS\\}", pos+"")
.replaceAll("\\{LEN\\}", len+"")
.replaceAll("\\{TIME\\}", timeStr)
.replaceAll("\\{SERVER\\}", pl.aliases.getAlias(s.getName()))
));
}
}
/** /**
* Find a server by name * Find a server by name
+1 -1
View File
@@ -19,7 +19,7 @@ queue-servers:
- 'survivalqueue:survival' - 'survivalqueue:survival'
# Should the plugin send an actionbar to the player? # Should the plugin send an actionbar to the player?
# Requires this plugin to be installed on the server the player is on for it to work # The actionbar contains some info such as which server they are queued for, what position they are in, estimated time remaining, etc.
send-actionbar: true send-actionbar: true
# What kick reasons should cause the player to be removed from the queue? # What kick reasons should cause the player to be removed from the queue?