add warning if ajqueue is running on spigot without a proxy

This commit is contained in:
ajgeiss0702
2021-10-07 19:19:26 -07:00
parent a5957bd7cb
commit 4d91663e20
3 changed files with 28 additions and 1 deletions
@@ -17,6 +17,10 @@ public class Commands implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(!pl.hasProxy()) {
sender.sendMessage(color("&cajQueue must also be installed on the proxy!&7 If it has been installed on the proxy, make sure it loaded correctly and try relogging."));
return true;
}
Player player = null;
if(sender instanceof Player) {
player = (Player) sender;
@@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
@@ -26,6 +27,8 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
Placeholders placeholders;
ConfigFile config;
boolean hasProxy = false;
@SuppressWarnings("ConstantConditions")
public void onEnable() {
@@ -74,7 +77,11 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
getLogger().info("Spigot side enabled! v"+getDescription().getVersion());
}
public boolean hasProxy() {
return hasProxy;
}
final HashMap<Player, String> queuebatch = new HashMap<>();
@Override
@@ -85,6 +92,10 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
String subchannel = in.readUTF();
if(subchannel.equals("ack")) {
hasProxy = true;
}
if(subchannel.equals("inqueueevent")) {
String playername = in.readUTF();
Player p = Bukkit.getPlayer(playername);
@@ -180,6 +191,14 @@ public class SpigotMain extends JavaPlugin implements PluginMessageListener,List
placeholders.cleanCache();
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
if(hasProxy) return;
Bukkit.getScheduler().runTask(this, () -> {
sendMessage(e.getPlayer(), "ack", "");
});
}
@EventHandler(priority = EventPriority.HIGH)
public void onServerPing(ServerListPingEvent e) {
if(!config.getBoolean("take-over-motd-for-whitelist")) return;