Skip to content

Commit

Permalink
Fix alwaysqueue with authfirst and fix pistonmotd support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Jan 24, 2021
1 parent 5761b06 commit 170d02d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>Xera.Bungee.Queue</groupId>
<groupId>ca.xera</groupId>
<artifactId>XeraBungeeQueue</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<description>Best queue plugin out there!</description>

<properties>
Expand All @@ -24,6 +24,7 @@
<target>${java.version}</target>
</configuration>
</plugin>

</plugins>
<resources>
<resource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ca.xera.bungee.queue.bungee.utils.*;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import me.alexprogrammerde.pistonmotd.api.PlaceholderUtil;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.ProxyServer;
Expand Down Expand Up @@ -54,7 +53,7 @@ public void onEnable() {
logger.info(ChatColor.BLUE + "Looking for hooks");
if (getProxy().getPluginManager().getPlugin("PistonMOTD") != null) {
logger.info(ChatColor.BLUE + "Hooking into PistonMOTD");
PlaceholderUtil.registerParser(new PistonMOTDPlaceholder());
new PistonMOTDPlaceholder();
}

logger.info(ChatColor.BLUE + "Registering plugin messaging channel");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import ca.xera.bungee.queue.bungee.QueueAPI;
import me.alexprogrammerde.pistonmotd.api.PlaceholderParser;
import me.alexprogrammerde.pistonmotd.api.PlaceholderUtil;

public class PistonMOTDPlaceholder implements PlaceholderParser {
public PistonMOTDPlaceholder() {
PlaceholderUtil.registerParser(this);
}

@Override
public String parseString(String s) {
return s.replace("%xerabungeequeue_regular%", String.valueOf(QueueAPI.getRegularSize()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void onPostLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer();

if (!Config.KICKWHENDOWN || (mainOnline && queueOnline && authOnline)) { // authOnline is always true if enableauth is false
if (!Config.AUTHFIRST && (Config.ALWAYSQUEUE || plugin.getProxy().getOnlineCount() > Config.MAINSERVERSLOTS)) {
if (!Config.AUTHFIRST && isMainFull()) {
if (player.hasPermission(Config.QUEUEVETERANPERMISSION)) {
veteran.add(player.getUniqueId());
} else if (player.hasPermission(Config.QUEUEPRIORITYPERMISSION)) {
Expand All @@ -65,7 +65,6 @@ public void onQueueSend(ServerSwitchEvent event) {
if (event.getFrom() != null &&
event.getFrom().equals(plugin.getProxy().getServerInfo(Config.AUTHSERVER)) &&
player.getServer().getInfo().equals(plugin.getProxy().getServerInfo(Config.QUEUESERVER))) {

if (player.hasPermission(Config.QUEUEVETERANPERMISSION)) {
putQueueAuthFirst(player, Config.HEADERVETERAN, Config.FOOTERVETERAN, XeraBungeeQueue.veteranQueue);
} else if (player.hasPermission(Config.QUEUEPRIORITYPERMISSION)) {
Expand All @@ -80,15 +79,20 @@ public void onQueueSend(ServerSwitchEvent event) {
public void onSend(ServerConnectEvent event) {
ProxiedPlayer player = event.getPlayer();

if (Config.AUTHFIRST || player.hasPermission(Config.QUEUEBYPASSPERMISSION))
return;

if (player.hasPermission(Config.QUEUEVETERANPERMISSION)) {
putQueue(player, Config.HEADERVETERAN, Config.FOOTERVETERAN, XeraBungeeQueue.veteranQueue, veteran, event);
} else if (player.hasPermission(Config.QUEUEPRIORITYPERMISSION)) {
putQueue(player, Config.HEADERPRIORITY, Config.FOOTERPRIORITY, XeraBungeeQueue.priorityQueue, priority, event);
if (Config.AUTHFIRST) {
if (event.getTarget().getName().equals(Config.QUEUESERVER) && !isMainFull())
event.setTarget(plugin.getProxy().getServerInfo(Config.MAINSERVER));
} else {
putQueue(player, Config.HEADER, Config.FOOTER, XeraBungeeQueue.regularQueue, regular, event);
if (player.hasPermission(Config.QUEUEBYPASSPERMISSION))
return;

if (player.hasPermission(Config.QUEUEVETERANPERMISSION)) {
putQueue(player, Config.HEADERVETERAN, Config.FOOTERVETERAN, XeraBungeeQueue.veteranQueue, veteran, event);
} else if (player.hasPermission(Config.QUEUEPRIORITYPERMISSION)) {
putQueue(player, Config.HEADERPRIORITY, Config.FOOTERPRIORITY, XeraBungeeQueue.priorityQueue, priority, event);
} else {
putQueue(player, Config.HEADER, Config.FOOTER, XeraBungeeQueue.regularQueue, regular, event);
}
}
}

Expand Down Expand Up @@ -222,4 +226,8 @@ private String getNoneString(List<String> tab) {

return builder.toString();
}

private boolean isMainFull() {
return Config.ALWAYSQUEUE || plugin.getProxy().getOnlineCount() > Config.MAINSERVERSLOTS;
}
}

0 comments on commit 170d02d

Please sign in to comment.