diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureBlah.java) | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureBlah.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java index 16c99db2..85bb3398 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureBlah.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java @@ -1,7 +1,9 @@ package kr.syeyoung.dungeonsguide.features.impl.etc; import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.StompConnectedListener; import kr.syeyoung.dungeonsguide.features.listener.TickListener; import kr.syeyoung.dungeonsguide.stomp.StompInterface; import kr.syeyoung.dungeonsguide.stomp.StompMessageHandler; @@ -13,26 +15,31 @@ import net.minecraft.util.ChatComponentText; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -public class FeatureBlah extends SimpleFeature implements StompMessageHandler, TickListener { - public FeatureBlah() { - super("ETC", "TEST","test.test"); - e.getDungeonsGuide().getStompConnection().subscribe(StompSubscription.builder() - .destination("/topic/updates") - .ackMode(StompSubscription.AckMode.AUTO) - .stompMessageHandler(this).build()); +public class FeatureUpdateAlarm extends SimpleFeature implements StompConnectedListener, StompMessageHandler, TickListener { + public FeatureUpdateAlarm() { + super("ETC", "Update Alarm","Show a warning on chat when new update has bnee released.", "etc.updatealarm", true); } - Queue<StompPayload> stompPayloadQueue = new ConcurrentLinkedQueue<StompPayload>(); + private StompPayload stompPayload; @Override public void handle(StompInterface stompInterface, StompPayload stompPayload) { - stompPayloadQueue.add(stompPayload); + this.stompPayload = stompPayload; } - @Override public void onTick() { - while (!stompPayloadQueue.isEmpty()) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(stompPayloadQueue.poll().payload())); + if (stompPayload != null) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(stompPayload.payload())); + stompPayload = null; + Minecraft.getMinecraft().thePlayer.playSound("random.successful_hit", 1f,1f); } } + + @Override + public void onStompConnected(StompConnectedEvent event) { + event.getStompInterface().subscribe(StompSubscription.builder() + .destination("/topic/updates") + .ackMode(StompSubscription.AckMode.AUTO) + .stompMessageHandler(this).build()); + } } |