QueueScoreboardActivator event
This commit is contained in:
@@ -80,6 +80,7 @@ public class Manager {
|
||||
int messagerId = -1;
|
||||
int actionbarId = -1;
|
||||
int srvRefId = -1;
|
||||
int queueEventId = -1;
|
||||
/**
|
||||
* Clears all intervals and re-makes them
|
||||
*/
|
||||
@@ -114,6 +115,18 @@ public class Manager {
|
||||
} catch(IllegalArgumentException e) {}
|
||||
srvRefId = -1;
|
||||
}
|
||||
if(queueEventId != -1) {
|
||||
try {
|
||||
pl.getProxy().getScheduler().cancel(queueEventId);
|
||||
} catch(IllegalArgumentException e) {}
|
||||
queueEventId = -1;
|
||||
}
|
||||
|
||||
queueEventId = pl.getProxy().getScheduler().schedule(pl, new Runnable() {
|
||||
public void run() {
|
||||
sendQueueEvents();
|
||||
}
|
||||
}, 2, 2, TimeUnit.SECONDS).getId();
|
||||
|
||||
sendId = pl.getProxy().getScheduler().schedule(pl, new Runnable() {
|
||||
public void run() {
|
||||
@@ -317,6 +330,15 @@ public class Manager {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void sendQueueEvents() {
|
||||
for(QueueServer s : servers) {
|
||||
for(ProxiedPlayer p : s.getQueue()) {
|
||||
BungeeUtils.sendCustomData(p, "inqueueevent", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the message to the player updating them on their position in the queue
|
||||
* along with their time remaining
|
||||
@@ -684,6 +706,7 @@ public class Manager {
|
||||
BungeeUtils.sendCustomData(p, "positionof", len+"");
|
||||
BungeeUtils.sendCustomData(p, "queuename", pl.aliases.getAlias(s));
|
||||
BungeeUtils.sendCustomData(p, "inqueue", "true");
|
||||
BungeeUtils.sendCustomData(p, "inqueueevent", "true");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
@@ -80,10 +79,17 @@ public class Main extends JavaPlugin implements PluginMessageListener,Listener {
|
||||
//getLogger().info("recieved actionbar for "+player.getName()+": "+text);
|
||||
VersionSupport.sendActionBar(p, text);
|
||||
|
||||
QueueActionbarUpdateEvent e = new QueueActionbarUpdateEvent(p);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
/*QueueActionbarUpdateEvent e = new QueueActionbarUpdateEvent(p);
|
||||
Bukkit.getPluginManager().callEvent(e);*/
|
||||
return;
|
||||
}
|
||||
if(subchannel.equals("inqueueevent")) {
|
||||
String playername = in.readUTF();
|
||||
Player p = Bukkit.getPlayer(playername);
|
||||
if(p == null) return;
|
||||
QueueScoreboardActivator e = new QueueScoreboardActivator(p);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
}
|
||||
if(subchannel.equals("queuename") && papi) {
|
||||
String playername = in.readUTF();
|
||||
Player p = Bukkit.getPlayer(playername);
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class QueueActionbarUpdateEvent extends Event {
|
||||
public class QueueScoreboardActivator extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
@@ -17,7 +17,7 @@ public class QueueActionbarUpdateEvent extends Event {
|
||||
|
||||
Player ply;
|
||||
|
||||
public QueueActionbarUpdateEvent(Player p) {
|
||||
public QueueScoreboardActivator(Player p) {
|
||||
this.ply = p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user