a bunch of stuff im too lazy to go through (1.3.4)
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<groupId>us.ajg0702</groupId>
|
<groupId>us.ajg0702</groupId>
|
||||||
<artifactId>ajQueue</artifactId>
|
<artifactId>ajQueue</artifactId>
|
||||||
<name>ajQueue</name>
|
<name>ajQueue</name>
|
||||||
<version>1.3.0</version>
|
<version>1.3.4</version>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>us.ajg0702</groupId>
|
<groupId>us.ajg0702</groupId>
|
||||||
<artifactId>ajQueue</artifactId>
|
<artifactId>ajQueue</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>1.3.4</version>
|
||||||
<name>ajQueue</name>
|
<name>ajQueue</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package us.ajg0702.queue;
|
package us.ajg0702.queue;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
@@ -48,6 +52,7 @@ public class Main extends Plugin implements Listener {
|
|||||||
this.getProxy().getPluginManager().registerListener(this, this);
|
this.getProxy().getPluginManager().registerListener(this, this);
|
||||||
|
|
||||||
getProxy().registerChannel("ajqueue:tospigot");
|
getProxy().registerChannel("ajqueue:tospigot");
|
||||||
|
getProxy().registerChannel("ajqueue:tobungee");
|
||||||
|
|
||||||
timeBetweenPlayers = config.getInt("wait-time");
|
timeBetweenPlayers = config.getInt("wait-time");
|
||||||
|
|
||||||
@@ -121,4 +126,26 @@ public class Main extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMessage(PluginMessageEvent e) {
|
||||||
|
//getLogger().info("Recieved message of "+e.getTag());
|
||||||
|
if(!e.getTag().equals("ajqueue:tobungee")) return;
|
||||||
|
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
|
||||||
|
try {
|
||||||
|
String subchannel = in.readUTF();
|
||||||
|
|
||||||
|
|
||||||
|
if(subchannel.equals("queue")) {
|
||||||
|
String data = in.readUTF();
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) e.getReceiver();
|
||||||
|
man.addToQueue(player, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e1) {
|
||||||
|
getLogger().warning("An error occured while reading data from spigot side:");
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class Manager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int len = plys.size();
|
int len = plys.size();
|
||||||
if(!s.isOnline()) {
|
if(!s.isOnline() || s.isFull()) {
|
||||||
String or = msgs.get("status.offline.restarting");
|
String or = msgs.get("status.offline.restarting");
|
||||||
if(ot > pl.config.getInt("offline-time")) {
|
if(ot > pl.config.getInt("offline-time")) {
|
||||||
or = msgs.get("status.offline.offline");
|
or = msgs.get("status.offline.offline");
|
||||||
@@ -169,11 +169,14 @@ public class Manager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int len = plys.size();
|
int len = plys.size();
|
||||||
if(!s.isOnline()) {
|
if(!s.isOnline() || s.isFull()) {
|
||||||
String or = msgs.get("status.offline.restarting");
|
String or = msgs.get("status.offline.restarting");
|
||||||
if(ot > pl.config.getInt("offline-time")) {
|
if(ot > pl.config.getInt("offline-time")) {
|
||||||
or = msgs.get("status.offline.offline");
|
or = msgs.get("status.offline.offline");
|
||||||
}
|
}
|
||||||
|
if(s.isFull() && s.isOnline()) {
|
||||||
|
or = msgs.get("status.offline.full");
|
||||||
|
}
|
||||||
ply.sendMessage(Main.formatMessage(
|
ply.sendMessage(Main.formatMessage(
|
||||||
msgs.get("status.offline.base")
|
msgs.get("status.offline.base")
|
||||||
.replaceAll("\\{STATUS\\}", or)
|
.replaceAll("\\{STATUS\\}", or)
|
||||||
@@ -246,7 +249,17 @@ public class Manager {
|
|||||||
if(!s.isOnline()) continue;
|
if(!s.isOnline()) continue;
|
||||||
if(s.getQueue().size() <= 0) continue;
|
if(s.getQueue().size() <= 0) continue;
|
||||||
|
|
||||||
s.getQueue().get(0).connect(s.getInfo());
|
ProxiedPlayer nextplayer = s.getQueue().get(0);
|
||||||
|
|
||||||
|
while(nextplayer.getServer().getInfo().getName().equals(s.getName())) {
|
||||||
|
s.getQueue().remove(nextplayer);
|
||||||
|
if(s.getQueue().size() <= 0) break;
|
||||||
|
nextplayer = s.getQueue().get(0);
|
||||||
|
}
|
||||||
|
if(s.getQueue().size() <= 0) continue;
|
||||||
|
if(s.isFull() && !nextplayer.hasPermission("ajqueue.joinfull")) continue;
|
||||||
|
|
||||||
|
nextplayer.connect(s.getInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +275,11 @@ public class Manager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(p.getServer().getInfo().getName().equals(s)) {
|
||||||
|
p.sendMessage(msgs.getBC("errors.already-connected"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Server beforeQueue = findPlayerInQueue(p);
|
Server beforeQueue = findPlayerInQueue(p);
|
||||||
if(beforeQueue != null) {
|
if(beforeQueue != null) {
|
||||||
if(beforeQueue.equals(server)) {
|
if(beforeQueue.equals(server)) {
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package us.ajg0702.queue.spigot;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Commands implements CommandExecutor {
|
||||||
|
|
||||||
|
Main pl;
|
||||||
|
public Commands(Main pl) {
|
||||||
|
this.pl = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)) return true;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(args.length < 1) return false;
|
||||||
|
this.pl.sendMessage(player, "queue", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
import us.ajg0702.queue.spigot.utils.VersionSupport;
|
import us.ajg0702.queue.spigot.utils.VersionSupport;
|
||||||
@@ -13,6 +14,10 @@ import us.ajg0702.queue.spigot.utils.VersionSupport;
|
|||||||
public class Main extends JavaPlugin implements PluginMessageListener {
|
public class Main extends JavaPlugin implements PluginMessageListener {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getServer().getMessenger().registerIncomingPluginChannel(this, "ajqueue:tospigot", this);
|
getServer().getMessenger().registerIncomingPluginChannel(this, "ajqueue:tospigot", this);
|
||||||
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "ajqueue:tobungee");
|
||||||
|
|
||||||
|
this.getCommand("move").setExecutor(new Commands(this));
|
||||||
|
|
||||||
getLogger().info("Spigot side enabled! v"+getDescription().getVersion());
|
getLogger().info("Spigot side enabled! v"+getDescription().getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +38,17 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||||||
final String text = data.split(";time=")[0];
|
final String text = data.split(";time=")[0];
|
||||||
//getLogger().info("recieved actionbar for "+player.getName()+": "+text);
|
//getLogger().info("recieved actionbar for "+player.getName()+": "+text);
|
||||||
VersionSupport.sendActionBar(p, text);
|
VersionSupport.sendActionBar(p, text);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void sendMessage(Player player, String subchannel, String data) {
|
||||||
|
//getLogger().info("Sending message. "+subchannel+" "+data);
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
out.writeUTF(subchannel);
|
||||||
|
out.writeUTF(data);
|
||||||
|
|
||||||
|
player.sendPluginMessage(this, "ajqueue:tobungee", out.toByteArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class BungeeMessages {
|
|||||||
d.put("status.offline.base", "&cThe server you are queued for is {STATUS}. &7You are in position &f{POS}&7 of &f{LEN}&7.");
|
d.put("status.offline.base", "&cThe server you are queued for is {STATUS}. &7You are in position &f{POS}&7 of &f{LEN}&7.");
|
||||||
d.put("status.offline.offline", "offline");
|
d.put("status.offline.offline", "offline");
|
||||||
d.put("status.offline.restarting", "restarting");
|
d.put("status.offline.restarting", "restarting");
|
||||||
|
d.put("status.offline.full", "full");
|
||||||
d.put("status.online.base", "&7You are in position &f{POS}&7 of &f{LEN}&7. Estimated time: {TIME}");
|
d.put("status.online.base", "&7You are in position &f{POS}&7 of &f{LEN}&7. Estimated time: {TIME}");
|
||||||
d.put("status.left-last-queue", "&aYou left the last queue you were in.");
|
d.put("status.left-last-queue", "&aYou left the last queue you were in.");
|
||||||
d.put("status.now-in-queue", "&aYou are now queued! &7You are in position &f{POS}&7 of &f{LEN}&7.\n&7Type &f/leavequeue&7 to leave the queue!");
|
d.put("status.now-in-queue", "&aYou are now queued! &7You are in position &f{POS}&7 of &f{LEN}&7.\n&7Type &f/leavequeue&7 to leave the queue!");
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ offline-time: 120
|
|||||||
message-time: 10
|
message-time: 10
|
||||||
|
|
||||||
# If a player is in a server, you can have the plugin make them automatically join a queue for another server
|
# If a player is in a server, you can have the plugin make them automatically join a queue for another server
|
||||||
# Example with the default values: Player joins survivalfallback server, they will auto-join the queue for survival
|
# Example with the default values: Player joins survivalqueue server, they will auto-join the queue for survival
|
||||||
queue-servers:
|
queue-servers:
|
||||||
- 'survivalfallback:survival'
|
- 'survivalqueue:survival'
|
||||||
|
|
||||||
# Should the plugin send an actionbar to the player?
|
# Should the plugin send an actionbar to the player?
|
||||||
# Requires this plugin to be installed on the server the player is on for it to work
|
# Requires this plugin to be installed on the server the player is on for it to work
|
||||||
|
|||||||
@@ -2,3 +2,7 @@ main: us.ajg0702.queue.spigot.Main
|
|||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
author: ajgeiss0702
|
author: ajgeiss0702
|
||||||
name: ajQueue
|
name: ajQueue
|
||||||
|
commands:
|
||||||
|
move:
|
||||||
|
aliases: [server, queue]
|
||||||
|
description: Queue for a server
|
||||||
Reference in New Issue
Block a user