auto queue
This commit is contained in:
@@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -216,6 +217,32 @@ public class Main extends Plugin implements Listener {
|
||||
public void onFailedMove(ServerKickEvent e) {
|
||||
ProxiedPlayer p = e.getPlayer();
|
||||
List<QueueServer> queuedServers = man.findPlayerInQueue(p);
|
||||
|
||||
|
||||
if(!queuedServers.contains(man.getServer(e.getKickedFrom().getName())) && config.getBoolean("auto-add-to-queue-on-kick")) {
|
||||
|
||||
String plainReason = "";
|
||||
for(BaseComponent b : e.getKickReasonComponent()) {
|
||||
plainReason += b.toPlainText();
|
||||
}
|
||||
|
||||
List<String> reasons = config.getStringList("auto-add-kick-reasons");
|
||||
boolean shouldqueue = false;
|
||||
for(String reason : reasons) {
|
||||
if(plainReason.toLowerCase().contains(reason.toLowerCase())) {
|
||||
shouldqueue = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(shouldqueue || reasons.isEmpty()) {
|
||||
plugin.getProxy().getScheduler().schedule(this, () -> {
|
||||
man.addToQueue(p, e.getKickedFrom().getName());
|
||||
}, (long) (config.getDouble("auto-add-to-queue-on-kick-delay")*1000), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for(QueueServer server : queuedServers) {
|
||||
if(!(server.getInfos().contains(e.getKickedFrom()))) continue;
|
||||
if(server.getQueue().indexOf(p) != 0) continue;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Dont touch this number please
|
||||
config-version: 20
|
||||
config-version: 21
|
||||
|
||||
# The time the server will wait between sending people in the queue
|
||||
# Default: 5
|
||||
@@ -147,7 +147,6 @@ max-tries: 10
|
||||
# Default: false
|
||||
enable-bypasspaused-permission: false
|
||||
|
||||
|
||||
# Should we check to make sure that people dont get sent quicker than wait-time?
|
||||
# Default: true
|
||||
check-last-player-sent-time: true
|
||||
@@ -158,4 +157,18 @@ check-last-player-sent-time: true
|
||||
# Default: false
|
||||
priority-queue-debug: false
|
||||
|
||||
# When a player is kicked from a server, should we automatically add that player to the queue?
|
||||
# You will still need to use another plugin to make sure the player doesnt get kicked from bungee completly.
|
||||
# Default: false
|
||||
auto-add-to-queue-on-kick: false
|
||||
# The delay for the above option.
|
||||
# In seconds, decimals supported.
|
||||
auto-add-to-queue-on-kick-delay: 1
|
||||
|
||||
# With what kick reasons should we auto-add the player to the queue
|
||||
# This wont work if auto-add-to-queue-on-kick is disabled.
|
||||
# If you set it to [], then all kick messages will cause the player to be added to the queue
|
||||
# This works on contains, so you dont have to include the whole kick message, just a few words.
|
||||
auto-add-kick-reasons:
|
||||
- "restarting"
|
||||
- "closed"
|
||||
Reference in New Issue
Block a user