Merge branch 'dev' into 'master'
2.2.2 See merge request ajg0702/ajqueue!35
This commit is contained in:
@@ -78,6 +78,12 @@ public interface AdaptedPlayer extends Handle, Audience {
|
|||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kick a player from the proxy
|
||||||
|
* @param reason The reason to kick them with
|
||||||
|
*/
|
||||||
|
void kick(Component reason);
|
||||||
|
|
||||||
List<String> getPermissions();
|
List<String> getPermissions();
|
||||||
|
|
||||||
default boolean equals(AdaptedPlayer other) {
|
default boolean equals(AdaptedPlayer other) {
|
||||||
|
|||||||
@@ -256,6 +256,14 @@ public interface QueueServer {
|
|||||||
*/
|
*/
|
||||||
void addPlayer(AdaptedServer server);
|
void addPlayer(AdaptedServer server);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if this server is online.
|
||||||
|
* Note that this is overrided by the pinger, so if you set
|
||||||
|
* this, it will most likely be temporary
|
||||||
|
* @param online whether the server is online or not
|
||||||
|
*/
|
||||||
|
void setOnline(boolean online);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* elliot is bad
|
* elliot is bad
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
version = "2.2.1"
|
version = "2.2.2"
|
||||||
group = "us.ajg0702"
|
group = "us.ajg0702"
|
||||||
|
|
||||||
plugins.apply("java")
|
plugins.apply("java")
|
||||||
|
|||||||
+4
@@ -45,6 +45,10 @@ public class SlashServerCommand extends BaseCommand {
|
|||||||
sender.sendMessage(getMessages().getComponent("errors.player-only"));
|
sender.sendMessage(getMessages().getComponent("errors.player-only"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(main.getConfig().getBoolean("require-permission") && !sender.hasPermission("ajqueue.queue."+args[0])) {
|
||||||
|
sender.sendMessage(getMessages().getComponent("noperm"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
main.getQueueManager().addToQueue(main.getPlatformMethods().senderToPlayer(sender), server);
|
main.getQueueManager().addToQueue(main.getPlatformMethods().senderToPlayer(sender), server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,10 +217,29 @@ public class EventHandlerImpl implements EventHandler {
|
|||||||
QueuePlayer queuePlayer = server.findPlayer(player);
|
QueuePlayer queuePlayer = server.findPlayer(player);
|
||||||
if(queuePlayer.getPosition() != 1) continue;
|
if(queuePlayer.getPosition() != 1) continue;
|
||||||
List<String> kickReasons = main.getConfig().getStringList("kick-reasons");
|
List<String> kickReasons = main.getConfig().getStringList("kick-reasons");
|
||||||
|
boolean kickPlayer = main.getConfig().getBoolean("kick-kicked-players");
|
||||||
|
if(kickPlayer) {
|
||||||
|
List<String> svs = main.getConfig().getStringList("queue-servers");
|
||||||
|
boolean found = false;
|
||||||
|
for(String s : svs) {
|
||||||
|
if(!s.contains(":")) continue;
|
||||||
|
String[] parts = s.split(":");
|
||||||
|
String fromName = parts[0];
|
||||||
|
QueueServer toServer = main.getQueueManager().findServer(parts[1]);
|
||||||
|
if(fromName.equalsIgnoreCase(server.getName()) && toServer != null && toServer.equals(server)) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kickPlayer = found;
|
||||||
|
}
|
||||||
|
|
||||||
for(String kickReason : kickReasons) {
|
for(String kickReason : kickReasons) {
|
||||||
if(plainReason.toLowerCase().contains(kickReason.toLowerCase())) {
|
if(plainReason.toLowerCase().contains(kickReason.toLowerCase())) {
|
||||||
server.removePlayer(queuePlayer);
|
server.removePlayer(queuePlayer);
|
||||||
|
if(kickPlayer) {
|
||||||
|
player.kick(reason);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ public class QueueManagerImpl implements QueueManager {
|
|||||||
if(previousServer != null) {
|
if(previousServer != null) {
|
||||||
queueServer.setPaused(previousServer.isPaused());
|
queueServer.setPaused(previousServer.isPaused());
|
||||||
queueServer.setLastSentTime(previousServer.getLastSentTime());
|
queueServer.setLastSentTime(previousServer.getLastSentTime());
|
||||||
|
queueServer.setOnline(previousServer.isOnline());
|
||||||
|
queueServer.setWhitelisted(previousServer.isWhitelisted());
|
||||||
|
queueServer.setWhitelistedPlayers(previousServer.getWhitelistedPlayers());
|
||||||
}
|
}
|
||||||
result.add(queueServer);
|
result.add(queueServer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
AdaptedServerPing ping = null;
|
AdaptedServerPing ping = null;
|
||||||
try {
|
try {
|
||||||
ping = futurePing.get(5, TimeUnit.SECONDS);
|
ping = futurePing.get(5, TimeUnit.SECONDS);
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
} catch (Exception e) {
|
||||||
if(pingerDebug) {
|
if(pingerDebug) {
|
||||||
main.getLogger().info("[pinger] ["+server.getServerInfo().getName()+"] offline:");
|
main.getLogger().info("[pinger] ["+server.getServerInfo().getName()+"] offline:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -243,7 +243,7 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(pingerDebug) {
|
if(pingerDebug) {
|
||||||
main.getLogger().info("[pinger] ["+server.getServerInfo().getName()+"] Success");
|
main.getLogger().info("[pinger] ["+server.getServerInfo().getName()+"] Finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,4 +468,9 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
if(!pings.containsKey(server)) throw new IllegalArgumentException("Server is not in this group!");
|
if(!pings.containsKey(server)) throw new IllegalArgumentException("Server is not in this group!");
|
||||||
pings.get(server).addPlayer();
|
pings.get(server).addPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnline(boolean online) {
|
||||||
|
this.online = online;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Dont touch this number please
|
# Dont touch this number please
|
||||||
config-version: 31
|
config-version: 32
|
||||||
|
|
||||||
|
|
||||||
# This is the main config for ajQueue.
|
# This is the main config for ajQueue.
|
||||||
@@ -38,6 +38,12 @@ kick-reasons:
|
|||||||
- 'banned'
|
- 'banned'
|
||||||
- 'blacklisted'
|
- 'blacklisted'
|
||||||
|
|
||||||
|
# Should we completly kick the user from the server if they are in a queue-server
|
||||||
|
# and are kicked from the server with one of the above reasons?
|
||||||
|
# Note this will do nothing on servers that arent queue-servers
|
||||||
|
# (as in the config option queue-servers)
|
||||||
|
# Default: true
|
||||||
|
kick-kicked-players: true
|
||||||
|
|
||||||
# Should we remove a player from the queue if they move servers?
|
# Should we remove a player from the queue if they move servers?
|
||||||
# This will remove the player from if they switch to any other server
|
# This will remove the player from if they switch to any other server
|
||||||
@@ -224,6 +230,7 @@ supported-protocols:
|
|||||||
# api will be used to find the name of the protocol.
|
# api will be used to find the name of the protocol.
|
||||||
# If you are on bungee, only this list can be used.
|
# If you are on bungee, only this list can be used.
|
||||||
protocol-names:
|
protocol-names:
|
||||||
|
- "757:1.18.1"
|
||||||
- "756:1.17.1"
|
- "756:1.17.1"
|
||||||
- "755:1.17"
|
- "755:1.17"
|
||||||
- "754:1.16.5"
|
- "754:1.16.5"
|
||||||
|
|||||||
+9
-1
@@ -3,6 +3,7 @@ package us.ajg0702.queue.platforms.bungeecord;
|
|||||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.*;
|
import net.md_5.bungee.api.event.*;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
@@ -30,6 +31,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class BungeeQueue extends Plugin implements Listener, Implementation {
|
public class BungeeQueue extends Plugin implements Listener, Implementation {
|
||||||
|
|
||||||
private QueueMain main;
|
private QueueMain main;
|
||||||
@@ -106,7 +108,13 @@ public class BungeeQueue extends Plugin implements Listener, Implementation {
|
|||||||
|
|
||||||
if(!(e.getReceiver() instanceof ProxiedPlayer)) return;
|
if(!(e.getReceiver() instanceof ProxiedPlayer)) return;
|
||||||
|
|
||||||
main.getEventHandler().handleMessage(new BungeePlayer((ProxiedPlayer) e.getReceiver()), e.getData());
|
ProxyServer.getInstance().getScheduler().runAsync(this, () ->
|
||||||
|
main.getEventHandler()
|
||||||
|
.handleMessage(
|
||||||
|
new BungeePlayer((ProxiedPlayer) e.getReceiver()),
|
||||||
|
e.getData()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
+3
@@ -15,6 +15,9 @@ public class BungeeCommand extends Command implements TabExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(args.length == 1 && args[0].isEmpty()) {
|
||||||
|
args = new String[]{};
|
||||||
|
}
|
||||||
command.execute(new BungeeSender(sender), args);
|
command.execute(new BungeeSender(sender), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
@@ -6,6 +6,7 @@ import net.kyori.adventure.sound.Sound;
|
|||||||
import net.kyori.adventure.sound.SoundStop;
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@@ -136,6 +137,11 @@ public class BungeePlayer implements AdaptedPlayer, Audience {
|
|||||||
return handle.getName();
|
return handle.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void kick(Component reason) {
|
||||||
|
handle.disconnect(BungeeComponentSerializer.get().serialize(reason));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPermissions() {
|
public List<String> getPermissions() {
|
||||||
return new ArrayList<>(handle.getPermissions());
|
return new ArrayList<>(handle.getPermissions());
|
||||||
|
|||||||
+5
-1
@@ -20,7 +20,11 @@ public class VelocityCommand implements RawCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Invocation invocation) {
|
public void execute(Invocation invocation) {
|
||||||
command.execute(new VelocitySender(invocation.source()), invocation.arguments().split(" "));
|
String[] args = new String[]{};
|
||||||
|
if(!invocation.arguments().isEmpty()) {
|
||||||
|
args = invocation.arguments().split(" ");
|
||||||
|
}
|
||||||
|
command.execute(new VelocitySender(invocation.source()), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
@@ -174,6 +174,11 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
|
|||||||
return handle.getUsername();
|
return handle.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void kick(Component reason) {
|
||||||
|
handle.disconnect(reason);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPermissions() {
|
public List<String> getPermissions() {
|
||||||
throw new IllegalStateException("AdaptedPlayer#getPermissions cannot be used on velocity");
|
throw new IllegalStateException("AdaptedPlayer#getPermissions cannot be used on velocity");
|
||||||
|
|||||||
Reference in New Issue
Block a user