Skip to content

Commit 33c1fe4

Browse files
committed
Fix critical bug where /locraw isn't cancelled. Made improvements to the chat buffer to avoid command spam warnings.
1 parent af3ee14 commit 33c1fe4

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jar {
2828

2929
targetCompatibility = sourceCompatibility = 1.8
3030

31-
version = "2.0.6"
31+
version = "2.0.7"
3232
group= "co.bugg.quickplay" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
3333
archivesBaseName = "Quickplay-1.8.9"
3434

src/main/java/co/bugg/quickplay/Quickplay.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,15 @@ public void enable() {
306306
registerEventHandler(new GlyphRenderer());
307307
registerEventHandler(new QuickplayEventHandler());
308308

309-
chatBuffer = (ChatBuffer) new ChatBuffer(100).start();
310-
instanceWatcher = new InstanceWatcher(30).start();
311-
instanceDisplay = new InstanceDisplay();
309+
if (this.chatBuffer != null) {
310+
this.chatBuffer.stop();
311+
}
312+
this.chatBuffer = (ChatBuffer) new ChatBuffer(750).start();
313+
if (this.instanceWatcher != null) {
314+
this.instanceWatcher.stop();
315+
}
316+
this.instanceWatcher = new InstanceWatcher(30).start();
317+
this.instanceDisplay = new InstanceDisplay();
312318

313319
commands.add(new CommandQuickplay());
314320

src/main/java/co/bugg/quickplay/util/InstanceWatcher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public InstanceWatcher stop() {
7878
* @return this
7979
*/
8080
public InstanceWatcher runLocraw() {
81-
if(Quickplay.INSTANCE.onHypixel && Quickplay.INSTANCE.enabled) {
81+
// Only need to run /locraw again if there isn't already a /locraw in the command queue.
82+
if(Quickplay.INSTANCE.onHypixel && Quickplay.INSTANCE.enabled && !Quickplay.INSTANCE.chatBuffer.contains("/locraw")) {
8283
new LocrawWrapper((server) -> {
8384

8485
// Automatic lobby 1 swapper

src/main/java/co/bugg/quickplay/util/LocrawWrapper.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.google.gson.JsonObject;
66
import com.google.gson.JsonSyntaxException;
77
import net.minecraftforge.client.event.ClientChatReceivedEvent;
8+
import net.minecraftforge.fml.common.eventhandler.EventPriority;
89
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
910

1011
import java.util.Date;
@@ -40,9 +41,7 @@ public LocrawWrapper(LocrawListenerCallback callback) {
4041
this.listening = true;
4142
this.cancel = true;
4243

43-
// Send the /locraw command
4444
Quickplay.INSTANCE.chatBuffer.push("/locraw");
45-
System.out.println("QUICKPLAY DEBUG > Locraw sent! " + new Date().getTime() + " " + this.hashCode());
4645
// If a /locraw isn't received within 120 ticks (30 seconds), don't cancel the message
4746
new TickDelay(this::stopCancelling, 600);
4847
// If a /locraw isn't received within 1200 ticks (60 seconds), stop listening
@@ -54,7 +53,6 @@ public LocrawWrapper(LocrawListenerCallback callback) {
5453
* in, but still listen & call the callback
5554
*/
5655
public void stopCancelling() {
57-
System.out.println("QUICKPLAY DEBUG > Cancelling stopped! " + new Date().getTime() + " " + this.hashCode());
5856
this.cancel = false;
5957
}
6058

@@ -72,7 +70,8 @@ public void stopListening(String instance) {
7270
}
7371
}
7472

75-
@SubscribeEvent(receiveCanceled = true)
73+
// Hytilities forces high priority - receiveCancelled seems to cause the message to be uncancelable...
74+
@SubscribeEvent(priority = EventPriority.HIGH)
7675
public void onChat(ClientChatReceivedEvent event) {
7776
final String message = event.message.getUnformattedText();
7877
// Regex for the /locraw response
@@ -85,7 +84,6 @@ public void onChat(ClientChatReceivedEvent event) {
8584
matcher.find() &&
8685
listening
8786
) {
88-
System.out.println("QUICKPLAY DEBUG > Locraw received! " + new Date().getTime() + " " + this.hashCode());
8987

9088
if(this.cancel) {
9189
event.setCanceled(true);

src/main/java/co/bugg/quickplay/util/buffer/ABuffer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public ABuffer start() {
109109
return this;
110110
}
111111

112+
public boolean contains(Object obj) {
113+
return this.buffer.contains(obj);
114+
}
115+
112116
/**
113117
* Stop looping {@link #run()}
114118
* @return this

0 commit comments

Comments
 (0)