fix actionbar
This commit is contained in:
@@ -19,22 +19,32 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||||
if (!channel.equals("ajqueue:tospigot")) return;
|
if (!channel.equals("ajqueue:tospigot")) return;
|
||||||
|
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||||
|
|
||||||
String subchannel = in.readUTF();
|
String subchannel = in.readUTF();
|
||||||
|
|
||||||
if(subchannel.equals("actionbar")) {
|
if(subchannel.equals("actionbar")) {
|
||||||
|
String playername = in.readUTF();
|
||||||
|
Player p = Bukkit.getPlayer(playername);
|
||||||
|
if(p == null) return;
|
||||||
|
|
||||||
String data = in.readUTF();
|
String data = in.readUTF();
|
||||||
VersionSupport.sendActionBar(player, data.split(";time=")[0]);
|
final String text = data.split(";time=")[0];
|
||||||
|
//getLogger().info("recieved actionbar for "+player.getName()+": "+text);
|
||||||
|
VersionSupport.sendActionBar(p, text);
|
||||||
|
|
||||||
int time = Integer.parseInt(data.split(";time=")[1]);
|
int time = Integer.parseInt(data.split(";time=")[1]);
|
||||||
if(time > 2) {
|
if(time > 2) {
|
||||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
VersionSupport.sendActionBar(player, data.split(";time=")[0]);
|
VersionSupport.sendActionBar(p, text);
|
||||||
}
|
}
|
||||||
}, 2*20);
|
}, 2*20);
|
||||||
if(time > 4) {
|
if(time > 4) {
|
||||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
VersionSupport.sendActionBar(player, data.split(";time=")[0]);
|
VersionSupport.sendActionBar(p, text);
|
||||||
}
|
}
|
||||||
}, 4*20);
|
}, 4*20);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ public class BungeeUtils {
|
|||||||
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF( channel );
|
out.writeUTF( channel );
|
||||||
|
out.writeUTF(player.getName());
|
||||||
out.writeUTF( data1 );
|
out.writeUTF( data1 );
|
||||||
|
|
||||||
// we send the data to the server
|
// we send the data to the server
|
||||||
// using ServerInfo the packet is being queued if there are no players in the server
|
// using ServerInfo the packet is being queued if there are no players in the server
|
||||||
// using only the server to send data the packet will be lost if no players are in it
|
// using only the server to send data the packet will be lost if no players are in it
|
||||||
player.getServer().getInfo().sendData( "ajqueue:tospigot", out.toByteArray() );
|
player.getServer().sendData( "ajqueue:tospigot", out.toByteArray() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user