Merge pull request #9 from ajgeiss0702/dev

2.2.8
This commit is contained in:
ajgeiss0702
2022-07-19 12:56:09 -07:00
committed by GitHub
23 changed files with 137 additions and 40 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ dependencies {
implementation("net.kyori:adventure-text-serializer-plain:4.9.3")
compileOnly("com.google.guava:guava:30.1.1-jre")
compileOnly("us.ajg0702:ajUtils:1.1.22")
compileOnly("us.ajg0702:ajUtils:1.2.10")
}
publishing {
@@ -36,6 +36,20 @@ public interface QueueServer {
*/
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
*/
+3 -3
View File
@@ -12,7 +12,7 @@ repositories {
}
allprojects {
version = "2.2.7"
version = "2.2.8"
group = "us.ajg0702"
plugins.apply("java")
@@ -27,8 +27,8 @@ allprojects {
failFast = true
maxParallelForks = (Runtime.getRuntime().availableProcessors() - 1).takeIf { it > 0 } ?: 1
reports.html.isEnabled = false
reports.junitXml.isEnabled = false
reports.html.required.set(false)
reports.junitXml.required.set(false)
}
+1 -1
View File
@@ -18,7 +18,7 @@ dependencies {
compileOnly("net.kyori:adventure-text-serializer-plain:4.9.3")
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")
@@ -8,7 +8,6 @@ import us.ajg0702.utils.common.Messages;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class SlashServerCommand extends BaseCommand {
@@ -1,9 +1,6 @@
package us.ajg0702.queue.commands.commands.manage;
import com.google.common.collect.ImmutableList;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.spongepowered.configurate.ConfigurateException;
import us.ajg0702.queue.api.commands.ICommandSender;
import us.ajg0702.queue.api.players.QueuePlayer;
import us.ajg0702.queue.api.queues.QueueServer;
@@ -9,7 +9,6 @@ import us.ajg0702.queue.common.QueueMain;
import us.ajg0702.utils.common.Messages;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class KickAll extends SubCommand {
@@ -116,6 +116,17 @@ public class EventHandlerImpl implements EventHandler {
if(server == null) return;
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")) {
String[] args = new String[1];
try {
@@ -180,7 +180,7 @@ public class QueueMain extends AjQueueAPI {
}
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.");
@@ -237,8 +237,18 @@ public class QueueMain extends AjQueueAPI {
d.put("placeholders.position.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.subtitle", "<gold>You are <green>#{POS} <gold>in the queue!");
d.put("title.sending-now.title", "");
d.put("title.sending-now.subtitle", "<green>Sending you to <white>{SERVER} <green>now..");
d.put("commands.leave.more-args", "&cPlease specify which queue you want to leave! &7You are in these queues: {QUEUES}");
d.put("commands.leave.queues-list-format", "&f{NAME}&7, ");
@@ -394,17 +394,21 @@ public class QueueManagerImpl implements QueueManager {
if(!getSingleServer(player).equals(server)) continue;
int time = (int) Math.round(pos * main.getTimeBetweenPlayers());
Component titleMessage = msgs.getComponent("title.title",
"POS:"+pos,
"LEN:"+server.getQueue().size(),
"SERVER:"+server.getAlias(),
"STATUS:"+status
"STATUS:"+status,
"TIME:"+ TimeUtils.timeString(time, msgs.getString("format.time.mins"), msgs.getString("format.time.secs"))
);
Component subTitleMessage = msgs.getComponent("title.subtitle",
"POS:"+pos,
"LEN:"+server.getQueue().size(),
"SERVER:"+server.getAlias(),
"STATUS:"+status
"STATUS:"+status,
"TIME:"+ TimeUtils.timeString(time, msgs.getString("format.time.mins"), msgs.getString("format.time.secs"))
);
Title title = Title.title(titleMessage, subTitleMessage, Title.Times.of(Duration.ZERO, Duration.ofSeconds(2L), Duration.ZERO));
@@ -616,6 +620,19 @@ public class QueueManagerImpl implements QueueManager {
}
if(System.currentTimeMillis() - sendingNowAntiSpam.get(nextPlayer) >= 5000) {
nextPlayer.sendMessage(msgs.getComponent("status.sending-now", "SERVER:"+server.getAlias()));
if(main.getConfig().getBoolean("send-title")) {
nextPlayer.showTitle(Title.title(
main.getMessages().getComponent(
"title.sending-now.title",
"SERVER:"+server.getAlias()
),
main.getMessages().getComponent(
"title.sending-now.subtitle",
"SERVER:"+server.getAlias()
),
Title.Times.of(Duration.ZERO, Duration.ofSeconds(2L), Duration.ZERO)
));
}
sendingNowAntiSpam.put(nextPlayer, System.currentTimeMillis());
}
@@ -157,6 +157,40 @@ public class QueueServerImpl implements QueueServer {
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
public void updatePing() {
boolean pingerDebug = main.getConfig().getBoolean("pinger-debug");
@@ -19,7 +19,7 @@ public class FreeLogic implements Logic {
@Override
public boolean playerDisconnectedTooLong(QueuePlayer player) {
return player.getMaxOfflineTime() < player.getTimeSinceOnline()*1000;
return player.getTimeSinceOnline() > player.getMaxOfflineTime()*1000L;
}
@Override
+1 -1
View File
@@ -18,7 +18,7 @@ dependencies {
compileOnly("com.google.guava:guava:30.1.1-jre")
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:bungeecord"))
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+2 -2
View File
@@ -16,7 +16,7 @@ repositories {
dependencies {
compileOnly("net.kyori:adventure-api:4.9.3")
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")
@@ -25,7 +25,7 @@ dependencies {
implementation("net.kyori:adventure-platform-bungeecord:4.0.0")
compileOnly("net.kyori:adventure-text-serializer-plain:4.9.3")
compileOnly("com.viaversion:viaversion-api:4.2.1")
compileOnly("com.viaversion:viaversion-api:4.3.1")
implementation("org.bstats:bstats-bungeecord:3.0.0")
+5 -5
View File
@@ -8,7 +8,7 @@ group = "us.ajg0702.queue.platforms.velocity"
repositories {
//mavenLocal()
maven { url = uri("https://repo.ajg0702.us") }
maven { url = uri("https://nexus.velocitypowered.com/repository/maven-public/") }
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
maven { url = uri("https://repo.viaversion.com/") }
mavenCentral()
}
@@ -16,13 +16,13 @@ repositories {
dependencies {
compileOnly("net.kyori:adventure-api:4.9.3")
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.1.0")
annotationProcessor("com.velocitypowered:velocity-api:3.1.0")
compileOnly("com.velocitypowered:velocity-api:3.1.1")
annotationProcessor("com.velocitypowered:velocity-api:3.1.1")
implementation("net.kyori:adventure-text-minimessage:4.10.0")
compileOnly("com.viaversion:viaversion-api:4.2.1")
compileOnly("com.viaversion:viaversion-api:4.3.1")
implementation("org.bstats:bstats-velocity:3.0.0")
@@ -12,7 +12,6 @@ import us.ajg0702.queue.platforms.velocity.players.VelocityPlayer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class VelocityServer implements AdaptedServer {
+2 -2
View File
@@ -23,14 +23,14 @@ dependencies {
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(fileTree(mapOf("dir" to "../libs/private", "include" to listOf("*.jar"))))
compileOnly(fileTree(mapOf("dir" to "../libs/public", "include" to listOf("*.jar"))))
compileOnly("net.luckperms:api:5.0")
compileOnly("net.luckperms:api:5.4")
}
tasks.shadowJar {
@@ -6,11 +6,10 @@ import net.luckperms.api.context.Context;
import net.luckperms.api.model.user.User;
import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.query.QueryMode;
import net.luckperms.api.query.QueryOptions;
import us.ajg0702.queue.api.players.AdaptedPlayer;
import us.ajg0702.queue.common.QueueMain;
import us.ajg0702.queue.api.premium.PermissionHook;
import us.ajg0702.queue.common.QueueMain;
import java.util.*;
+2 -2
View File
@@ -22,9 +22,9 @@ dependencies {
implementation("net.kyori:adventure-api:4.9.3")
compileOnly("com.google.guava:guava:30.1.1-jre")
compileOnly("org.spongepowered:configurate-yaml:4.0.0")
compileOnly("org.spongepowered:configurate-yaml:4.1.2")
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("me.clip:placeholderapi:2.10.4")
@@ -175,6 +175,9 @@ public class Placeholders extends PlaceholderExpansion {
if(identifier.matches("queuedfor_*.*")) {
return "0";
}
if(identifier.matches("status_*.*")) {
return "Loading";
}
}
@@ -185,21 +188,24 @@ public class Placeholders extends PlaceholderExpansion {
private String parsePlaceholder(Player player, String identifier) {
if(identifier.equalsIgnoreCase("queued")) {
plugin.sendMessage(player, "queuename", "");
}
} else
if(identifier.equalsIgnoreCase("position")) {
plugin.sendMessage(player, "position", "");
}
} else
if(identifier.equalsIgnoreCase("of")) {
plugin.sendMessage(player, "positionof", "");
}
} else
if(identifier.equalsIgnoreCase("inqueue")) {
plugin.sendMessage(player, "inqueue", "");
}
} else
if(identifier.equalsIgnoreCase("estimated_time")) {
plugin.sendMessage(player, "estimated_time", "");
}
} else
if(identifier.matches("queuedfor_*.*")) {
plugin.sendMessage(player, "queuedfor", identifier.split("_")[1]);
} else
if(identifier.matches("status_*.*")) {
plugin.sendMessage(player, "status", identifier.split("_")[1]);
}
@@ -178,6 +178,20 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
phs.put("estimated_time", time);
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
public void onJoin(PlayerJoinEvent e) {
if(hasProxy) return;
Bukkit.getScheduler().runTask(this, () -> {
sendMessage(e.getPlayer(), "ack", "");
});
Bukkit.getScheduler().runTask(this, () -> sendMessage(e.getPlayer(), "ack", ""));
}
@EventHandler(priority = EventPriority.HIGH)
@@ -8,7 +8,7 @@ import java.lang.reflect.Method;
/**
* A cross-version actionbar class
* @author Based on ActionBarAPI from https://github.com/ConnorLinfoot
* @author Based on ActionBarAPI from <a href="https://github.com/ConnorLinfoot">ConnorLinfoot</a>
*
*/
public class ActionBar {