Add %ajqueue_status_<server>% placeholder
This commit is contained in:
@@ -18,7 +18,7 @@ dependencies {
|
|||||||
implementation("net.kyori:adventure-text-serializer-plain:4.9.3")
|
implementation("net.kyori:adventure-text-serializer-plain:4.9.3")
|
||||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||||
|
|
||||||
compileOnly("us.ajg0702:ajUtils:1.1.22")
|
compileOnly("us.ajg0702:ajUtils:1.2.10")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
@@ -36,6 +36,20 @@ public interface QueueServer {
|
|||||||
*/
|
*/
|
||||||
String getStatusString();
|
String getStatusString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the status of the server as a string (not from the messages file)
|
||||||
|
* @param p The player that you are checking for. Used for checking restricted servers
|
||||||
|
* @return The status of the server as a string
|
||||||
|
*/
|
||||||
|
String getStatus(AdaptedPlayer p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the status of the server as a string (not from the messages file)
|
||||||
|
* Does not check if the player has access using restricted mode. May show online if it is restricted
|
||||||
|
* @return The status of the server as a string
|
||||||
|
*/
|
||||||
|
String getStatus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a server ping and uses the response to update online status, player count status, and whitelist status
|
* Sends a server ping and uses the response to update online status, player count status, and whitelist status
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ dependencies {
|
|||||||
compileOnly("net.kyori:adventure-text-serializer-plain:4.9.3")
|
compileOnly("net.kyori:adventure-text-serializer-plain:4.9.3")
|
||||||
|
|
||||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||||
compileOnly("us.ajg0702:ajUtils:1.1.22")
|
compileOnly("us.ajg0702:ajUtils:1.2.10")
|
||||||
|
|
||||||
compileOnly("org.slf4j:slf4j-log4j12:1.7.29")
|
compileOnly("org.slf4j:slf4j-log4j12:1.7.29")
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,17 @@ public class EventHandlerImpl implements EventHandler {
|
|||||||
if(server == null) return;
|
if(server == null) return;
|
||||||
main.getPlatformMethods().sendPluginMessage(recievingPlayer, "queuedfor", srv, server.getQueue().size()+"");
|
main.getPlatformMethods().sendPluginMessage(recievingPlayer, "queuedfor", srv, server.getQueue().size()+"");
|
||||||
}
|
}
|
||||||
|
if(subchannel.equals("status")) {
|
||||||
|
String srv = in.readUTF();
|
||||||
|
QueueServer server = main.getQueueManager().findServer(srv);
|
||||||
|
if(server == null) return;
|
||||||
|
main.getPlatformMethods().sendPluginMessage(
|
||||||
|
recievingPlayer,
|
||||||
|
"status",
|
||||||
|
srv,
|
||||||
|
main.getMessages().getRawString("placeholders.status."+server.getStatus(recievingPlayer))
|
||||||
|
);
|
||||||
|
}
|
||||||
if(subchannel.equals("leavequeue")) {
|
if(subchannel.equals("leavequeue")) {
|
||||||
String[] args = new String[1];
|
String[] args = new String[1];
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class QueueMain extends AjQueueAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void constructMessages() {
|
private void constructMessages() {
|
||||||
LinkedHashMap<String, String> d = new LinkedHashMap<>();
|
LinkedHashMap<String, Object> d = new LinkedHashMap<>();
|
||||||
|
|
||||||
d.put("status.offline.base", "&c{SERVER} is {STATUS}. &7You are in position &f{POS}&7 of &f{LEN}&7.");
|
d.put("status.offline.base", "&c{SERVER} is {STATUS}. &7You are in position &f{POS}&7 of &f{LEN}&7.");
|
||||||
|
|
||||||
@@ -237,6 +237,14 @@ public class QueueMain extends AjQueueAPI {
|
|||||||
d.put("placeholders.position.none", "None");
|
d.put("placeholders.position.none", "None");
|
||||||
d.put("placeholders.estimated_time.none", "None");
|
d.put("placeholders.estimated_time.none", "None");
|
||||||
|
|
||||||
|
d.put("placeholders.status.online", "&aOnline");
|
||||||
|
d.put("placeholders.status.offline", "&cOffline");
|
||||||
|
d.put("placeholders.status.restarting", "&cRestarting");
|
||||||
|
d.put("placeholders.status.full", "&eFull");
|
||||||
|
d.put("placeholders.status.restricted", "&eRestricted");
|
||||||
|
d.put("placeholders.status.paused", "&ePaused");
|
||||||
|
d.put("placeholders.status.whitelisted", "&eWhitelisted");
|
||||||
|
|
||||||
d.put("title.title", "");
|
d.put("title.title", "");
|
||||||
d.put("title.subtitle", "<gold>You are <green>#{POS} <gold>in the queue!");
|
d.put("title.subtitle", "<gold>You are <green>#{POS} <gold>in the queue!");
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,40 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
return getStatusString(null);
|
return getStatusString(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStatus(AdaptedPlayer p) {
|
||||||
|
if(getOfflineTime() > main.getConfig().getInt("offline-time")) {
|
||||||
|
return "offline";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isOnline()) {
|
||||||
|
return "restarting";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isPaused()) {
|
||||||
|
return "paused";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p != null && isWhitelisted() && !getWhitelistedPlayers().contains(p.getUniqueId())) {
|
||||||
|
return "whitelisted";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isFull() && !canJoinFull(p)) {
|
||||||
|
return "full";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p != null && !canAccess(p)) {
|
||||||
|
return "restricted";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "online";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStatus() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePing() {
|
public void updatePing() {
|
||||||
boolean pingerDebug = main.getConfig().getBoolean("pinger-debug");
|
boolean pingerDebug = main.getConfig().getBoolean("pinger-debug");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ dependencies {
|
|||||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||||
compileOnly("org.spongepowered:configurate-yaml:4.0.0")
|
compileOnly("org.spongepowered:configurate-yaml:4.0.0")
|
||||||
|
|
||||||
implementation("us.ajg0702:ajUtils:1.1.22")
|
implementation("us.ajg0702:ajUtils:1.2.10")
|
||||||
|
|
||||||
implementation(project(":platforms:velocity"))
|
implementation(project(":platforms:velocity"))
|
||||||
implementation(project(":platforms:bungeecord"))
|
implementation(project(":platforms:bungeecord"))
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("net.kyori:adventure-api:4.9.3")
|
compileOnly("net.kyori:adventure-api:4.9.3")
|
||||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||||
compileOnly("us.ajg0702:ajUtils:1.1.22")
|
compileOnly("us.ajg0702:ajUtils:1.2.10")
|
||||||
|
|
||||||
compileOnly("net.md-5:bungeecord-api:1.16-R0.4")
|
compileOnly("net.md-5:bungeecord-api:1.16-R0.4")
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("net.kyori:adventure-api:4.9.3")
|
compileOnly("net.kyori:adventure-api:4.9.3")
|
||||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||||
compileOnly("us.ajg0702:ajUtils:1.1.22")
|
compileOnly("us.ajg0702:ajUtils:1.2.10")
|
||||||
|
|
||||||
compileOnly("com.velocitypowered:velocity-api:3.0.0")
|
compileOnly("com.velocitypowered:velocity-api:3.0.0")
|
||||||
annotationProcessor("com.velocitypowered:velocity-api:3.0.0")
|
annotationProcessor("com.velocitypowered:velocity-api:3.0.0")
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly("me.TechsCode:FakeUltraPerms:1.0.2")
|
compileOnly("me.TechsCode:FakeUltraPerms:1.0.2")
|
||||||
|
|
||||||
compileOnly("us.ajg0702:ajUtils:1.1.22")
|
compileOnly("us.ajg0702:ajUtils:1.2.10")
|
||||||
|
|
||||||
compileOnly("net.kyori:adventure-api:4.9.3")
|
compileOnly("net.kyori:adventure-api:4.9.3")
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly("org.spongepowered:configurate-yaml:4.0.0")
|
compileOnly("org.spongepowered:configurate-yaml:4.0.0")
|
||||||
|
|
||||||
compileOnly("us.ajg0702:ajUtils:1.1.22")
|
compileOnly("us.ajg0702:ajUtils:1.2.10")
|
||||||
|
|
||||||
compileOnly(group = "org.spigotmc", name = "spigot", version = "1.16.5-R0.1-SNAPSHOT")
|
compileOnly(group = "org.spigotmc", name = "spigot", version = "1.16.5-R0.1-SNAPSHOT")
|
||||||
compileOnly("me.clip:placeholderapi:2.10.4")
|
compileOnly("me.clip:placeholderapi:2.10.4")
|
||||||
|
|||||||
@@ -175,6 +175,9 @@ public class Placeholders extends PlaceholderExpansion {
|
|||||||
if(identifier.matches("queuedfor_*.*")) {
|
if(identifier.matches("queuedfor_*.*")) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
if(identifier.matches("status_*.*")) {
|
||||||
|
return "Loading";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,22 +188,25 @@ public class Placeholders extends PlaceholderExpansion {
|
|||||||
private String parsePlaceholder(Player player, String identifier) {
|
private String parsePlaceholder(Player player, String identifier) {
|
||||||
if(identifier.equalsIgnoreCase("queued")) {
|
if(identifier.equalsIgnoreCase("queued")) {
|
||||||
plugin.sendMessage(player, "queuename", "");
|
plugin.sendMessage(player, "queuename", "");
|
||||||
}
|
} else
|
||||||
if(identifier.equalsIgnoreCase("position")) {
|
if(identifier.equalsIgnoreCase("position")) {
|
||||||
plugin.sendMessage(player, "position", "");
|
plugin.sendMessage(player, "position", "");
|
||||||
}
|
} else
|
||||||
if(identifier.equalsIgnoreCase("of")) {
|
if(identifier.equalsIgnoreCase("of")) {
|
||||||
plugin.sendMessage(player, "positionof", "");
|
plugin.sendMessage(player, "positionof", "");
|
||||||
}
|
} else
|
||||||
if(identifier.equalsIgnoreCase("inqueue")) {
|
if(identifier.equalsIgnoreCase("inqueue")) {
|
||||||
plugin.sendMessage(player, "inqueue", "");
|
plugin.sendMessage(player, "inqueue", "");
|
||||||
}
|
} else
|
||||||
if(identifier.equalsIgnoreCase("estimated_time")) {
|
if(identifier.equalsIgnoreCase("estimated_time")) {
|
||||||
plugin.sendMessage(player, "estimated_time", "");
|
plugin.sendMessage(player, "estimated_time", "");
|
||||||
}
|
} else
|
||||||
if(identifier.matches("queuedfor_*.*")) {
|
if(identifier.matches("queuedfor_*.*")) {
|
||||||
plugin.sendMessage(player, "queuedfor", identifier.split("_")[1]);
|
plugin.sendMessage(player, "queuedfor", identifier.split("_")[1]);
|
||||||
}
|
} else
|
||||||
|
if(identifier.matches("status_*.*")) {
|
||||||
|
plugin.sendMessage(player, "status", identifier.split("_")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -178,6 +178,20 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
|
|||||||
phs.put("estimated_time", time);
|
phs.put("estimated_time", time);
|
||||||
placeholders.responseCache.put(p, phs);
|
placeholders.responseCache.put(p, phs);
|
||||||
}
|
}
|
||||||
|
if(subchannel.equals("status")) {
|
||||||
|
String playername = in.readUTF();
|
||||||
|
String server = in.readUTF();
|
||||||
|
|
||||||
|
Player p = Bukkit.getPlayer(playername);
|
||||||
|
if(p == null) return;
|
||||||
|
if(!p.isOnline()) return;
|
||||||
|
|
||||||
|
String status = in.readUTF();
|
||||||
|
HashMap<String, String> phs = placeholders.responseCache.get(p);
|
||||||
|
if(phs == null) phs = new HashMap<>();
|
||||||
|
phs.put("status_"+server, status+"");
|
||||||
|
placeholders.responseCache.put(p, phs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -207,9 +221,7 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
if(hasProxy) return;
|
if(hasProxy) return;
|
||||||
Bukkit.getScheduler().runTask(this, () -> {
|
Bukkit.getScheduler().runTask(this, () -> sendMessage(e.getPlayer(), "ack", ""));
|
||||||
sendMessage(e.getPlayer(), "ack", "");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
|||||||
Reference in New Issue
Block a user