a bunch of stuff im too lazy to go through (1.3.4)
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package us.ajg0702.queue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
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.plugin.Listener;
|
||||
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);
|
||||
|
||||
getProxy().registerChannel("ajqueue:tospigot");
|
||||
getProxy().registerChannel("ajqueue:tobungee");
|
||||
|
||||
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;
|
||||
}
|
||||
int len = plys.size();
|
||||
if(!s.isOnline()) {
|
||||
if(!s.isOnline() || s.isFull()) {
|
||||
String or = msgs.get("status.offline.restarting");
|
||||
if(ot > pl.config.getInt("offline-time")) {
|
||||
or = msgs.get("status.offline.offline");
|
||||
@@ -169,11 +169,14 @@ public class Manager {
|
||||
continue;
|
||||
}
|
||||
int len = plys.size();
|
||||
if(!s.isOnline()) {
|
||||
if(!s.isOnline() || s.isFull()) {
|
||||
String or = msgs.get("status.offline.restarting");
|
||||
if(ot > pl.config.getInt("offline-time")) {
|
||||
or = msgs.get("status.offline.offline");
|
||||
}
|
||||
if(s.isFull() && s.isOnline()) {
|
||||
or = msgs.get("status.offline.full");
|
||||
}
|
||||
ply.sendMessage(Main.formatMessage(
|
||||
msgs.get("status.offline.base")
|
||||
.replaceAll("\\{STATUS\\}", or)
|
||||
@@ -246,7 +249,17 @@ public class Manager {
|
||||
if(!s.isOnline()) 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;
|
||||
}
|
||||
|
||||
if(p.getServer().getInfo().getName().equals(s)) {
|
||||
p.sendMessage(msgs.getBC("errors.already-connected"));
|
||||
return;
|
||||
}
|
||||
|
||||
Server beforeQueue = findPlayerInQueue(p);
|
||||
if(beforeQueue != null) {
|
||||
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 com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
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 void onEnable() {
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -33,6 +38,17 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
||||
final String text = data.split(";time=")[0];
|
||||
//getLogger().info("recieved actionbar for "+player.getName()+": "+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.offline", "offline");
|
||||
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.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!");
|
||||
|
||||
Reference in New Issue
Block a user