actionbar
This commit is contained in:
@@ -64,6 +64,11 @@ public interface QueueManager {
|
||||
*/
|
||||
void sendActionBars();
|
||||
|
||||
/**
|
||||
* Sends queue status titles to players in queues
|
||||
*/
|
||||
void sendTitles();
|
||||
|
||||
/**
|
||||
* Tell the spigot sides to call the queue scoreboard event
|
||||
*/
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ repositories {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
version = "2.0.3"
|
||||
version = "2.0.4"
|
||||
group = "us.ajg0702"
|
||||
|
||||
plugins.apply("java")
|
||||
|
||||
@@ -175,6 +175,9 @@ public class QueueMain {
|
||||
d.put("placeholders.queued.none", "None");
|
||||
d.put("placeholders.position.none", "None");
|
||||
|
||||
d.put("title.title", "");
|
||||
d.put("title.subtitle", "<gold>You are <green>#{POS} <gold>in the queue!");
|
||||
|
||||
d.put("commands.leave.more-args", "&cPlease specify which queue you want to leave! &7You are in these queues: {QUEUES}");
|
||||
d.put("commands.leave.queues-list-format", "&f{NAME}&7, ");
|
||||
d.put("commands.leave.not-queued", "&cYou are not queued for that server! &7You are in these queues: {QUEUES}");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package us.ajg0702.queue.common;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import us.ajg0702.queue.api.QueueManager;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
@@ -11,6 +13,7 @@ import us.ajg0702.queue.common.queues.QueueServerImpl;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
import us.ajg0702.utils.common.TimeUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -313,6 +316,44 @@ public class QueueManagerImpl implements QueueManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitles() {
|
||||
if(!main.getConfig().getBoolean("send-title")) return;
|
||||
|
||||
for(QueueServer server : servers) {
|
||||
String status = server.getStatusString();
|
||||
for(QueuePlayer queuePlayer : server.getQueue()) {
|
||||
|
||||
int pos = queuePlayer.getPosition();
|
||||
if(pos == 0) {
|
||||
server.removePlayer(queuePlayer);
|
||||
continue;
|
||||
}
|
||||
|
||||
AdaptedPlayer player = queuePlayer.getPlayer();
|
||||
if(player == null) continue;
|
||||
|
||||
if(!getSingleServer(player).equals(server)) continue;
|
||||
|
||||
Component titleMessage = msgs.getComponent("title.title",
|
||||
"POS:"+pos,
|
||||
"LEN:"+server.getQueue().size(),
|
||||
"SERVER:"+server.getAlias(),
|
||||
"STATUS:"+status
|
||||
);
|
||||
Component subTitleMessage = msgs.getComponent("title.title",
|
||||
"POS:"+pos,
|
||||
"LEN:"+server.getQueue().size(),
|
||||
"SERVER:"+server.getAlias(),
|
||||
"STATUS:"+status
|
||||
);
|
||||
|
||||
Title title = Title.title(titleMessage, subTitleMessage, Title.Times.of(Duration.ZERO, Duration.ofSeconds(2L), Duration.ZERO));
|
||||
player.showTitle(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendQueueEvents() {
|
||||
List<String> svs = main.getConfig().getStringList("queue-servers");
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TaskManager {
|
||||
}
|
||||
|
||||
public String taskStatus() {
|
||||
List<ScheduledFuture<?>> tasks = Arrays.asList(sendTask, updateTask, messageTask, actionBarTask, queueEventTask, reloadServerTask);
|
||||
List<ScheduledFuture<?>> tasks = Arrays.asList(sendTask, updateTask, messageTask, actionBarTask, titleTask, queueEventTask, reloadServerTask);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(ScheduledFuture<?> task : tasks) {
|
||||
sb.append(task == null ? "null" : task.isDone() ? "canceled/done" : "running");
|
||||
@@ -37,6 +37,7 @@ public class TaskManager {
|
||||
ScheduledFuture<?> updateTask;
|
||||
ScheduledFuture<?> messageTask;
|
||||
ScheduledFuture<?> actionBarTask;
|
||||
ScheduledFuture<?> titleTask;
|
||||
ScheduledFuture<?> queueEventTask;
|
||||
ScheduledFuture<?> reloadServerTask;
|
||||
public void rescheduleTasks() {
|
||||
@@ -67,6 +68,12 @@ public class TaskManager {
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
|
||||
titleTask = scheduleAtFixedRate(
|
||||
main.getQueueManager()::sendTitles,
|
||||
1500L,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
|
||||
queueEventTask = scheduleAtFixedRate(
|
||||
main.getQueueManager()::sendQueueEvents,
|
||||
1500L,
|
||||
@@ -96,6 +103,9 @@ public class TaskManager {
|
||||
if(actionBarTask != null && !actionBarTask.isCancelled()) {
|
||||
actionBarTask.cancel(true);
|
||||
}
|
||||
if(titleTask != null && !titleTask.isCancelled()) {
|
||||
titleTask.cancel(true);
|
||||
}
|
||||
if(queueEventTask != null && !queueEventTask.isCancelled()) {
|
||||
queueEventTask.cancel(true);
|
||||
}
|
||||
|
||||
+5
@@ -2,11 +2,16 @@ package us.ajg0702.queue.platforms.bungeecord;
|
||||
|
||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.kyori.adventure.title.Title;
|
||||
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.*;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.chat.BaseComponentSerializer;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
|
||||
+67
-3
@@ -1,8 +1,13 @@
|
||||
package us.ajg0702.queue.platforms.bungeecord.players;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.sound.SoundStop;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
@@ -15,6 +20,61 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeePlayer implements AdaptedPlayer, Audience {
|
||||
@Override
|
||||
public void sendActionBar(@NotNull ComponentLike message) {
|
||||
getAudience().sendActionBar(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTitle(@NotNull Title title) {
|
||||
System.out.println("title!");
|
||||
getAudience().showTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTitle() {
|
||||
getAudience().clearTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() {
|
||||
getAudience().resetTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBossBar(@NotNull BossBar bar) {
|
||||
getAudience().showBossBar(bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideBossBar(@NotNull BossBar bar) {
|
||||
getAudience().hideBossBar(bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Sound sound) {
|
||||
getAudience().playSound(sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Sound sound, double x, double y, double z) {
|
||||
getAudience().playSound(sound, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(@NotNull Sound sound) {
|
||||
getAudience().stopSound(sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(@NotNull Sound sound, Sound.@NotNull Emitter emitter) {
|
||||
getAudience().playSound(sound, emitter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(@NotNull SoundStop stop) {
|
||||
getAudience().stopSound(stop);
|
||||
}
|
||||
|
||||
final ProxiedPlayer handle;
|
||||
|
||||
@@ -30,19 +90,19 @@ public class BungeePlayer implements AdaptedPlayer, Audience {
|
||||
@Override
|
||||
public void sendMessage(@NotNull Component message) {
|
||||
if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
|
||||
BungeeQueue.adventure().player(handle).sendMessage(message);
|
||||
getAudience().sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(@NotNull Component message) {
|
||||
if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
|
||||
BungeeQueue.adventure().player(handle).sendActionBar(message);
|
||||
getAudience().sendActionBar(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if(message.isEmpty()) return;
|
||||
BungeeQueue.adventure().player(handle).sendMessage(Component.text(message));
|
||||
getAudience().sendMessage(Component.text(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,4 +139,8 @@ public class BungeePlayer implements AdaptedPlayer, Audience {
|
||||
public ProxiedPlayer getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
private Audience getAudience() {
|
||||
return BungeeQueue.adventure().player(handle);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user