aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java2
-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
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java7
3 files changed, 27 insertions, 13 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
index fa1b3c92..c758bc25 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
@@ -66,7 +66,7 @@ public class FeatureRegistry {
public static final FeatureRepartyCommand ETC_REPARTY = register(new FeatureRepartyCommand());
public static final FeatureDecreaseExplosionSound ETC_EXPLOSION_SOUND = register(new FeatureDecreaseExplosionSound());
public static final FeatureAutoAcceptReparty ETC_AUTO_ACCEPT_REPARTY = register(new FeatureAutoAcceptReparty());
- public static final FeatureBlah ETC_TEST = register(new FeatureBlah());
+ public static final FeatureUpdateAlarm ETC_TEST = register(new FeatureUpdateAlarm());
public static final SimpleFeature FIX_SPIRIT_BOOTS = register(new SimpleFeature("Fixes", "Spirit Boots Fixer", "Fix Spirit boots messing up with inventory", "fixes.spirit", true));
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());
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java
new file mode 100644
index 00000000..696336d3
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java
@@ -0,0 +1,7 @@
+package kr.syeyoung.dungeonsguide.features.listener;
+
+import kr.syeyoung.dungeonsguide.events.StompConnectedEvent;
+
+public interface StompConnectedListener {
+ void onStompConnected(StompConnectedEvent event);
+}