Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Stop chat stream for picking up faction/party "private" chat messages #170

Merged
merged 2 commits into from

2 participants

@lucasec

Not sure if this is an issue or intentional.

JSONAPI's chat stream picks up messages sent over Faction chat (Factions) and Party chat (mcMMO).

I adjusted the event priority so JSONAPI will not receive events for those messages.

Depending on use cases, picking up those messages may not be a bad thing. In Adminium's case, seeing party/faction chat would be valuable, except that the messages would not appear differently than normal chat messages. In my case, I would not want such messages appearing as I am using the chat stream on a public website.

@lucasec lucasec Raise chat event handler priority
JSONAPI was picking up faction chat and party chat messages, which may
be intentional.  For my use, I only wanted to pick up global chat msgs.
3be0e17
@lucasec

It seems my commit also included a new build. My apologies.

@alecgorge
Owner

Thanks for the PR, but before I merge it, why does heightening the priority make it not receive messages by Factions?

BTW, Including the new build is good here because my CI server doesn't actually do the compiling (not enough memory on the VPS ;( ), but it does extract those artifacts and puts them up for download.

@lucasec

I dug up the event priority stuff here: http://jd.bukkit.org/apidocs/org/bukkit/event/Event.Priority.html
Admittedly, it says the methods are depreciated, but this still works.

Basically, a high priority means JSONAPI will get the event after plugins with a lower priority. Seems kinda backwards to me-- but that's what the docs say. I've tested it and it works.

When Faction chat or Party chat is on, Factions or mcMMO, respectively, catches the chat event, cancels it, and then sends messages out to the members of the faction/party. So if JSONAPI gets the event after those two plugins, the event will already have been canceled if it was not a public chat, so JSONAPI's handler will not receive the event because ignoreCanceled=true is set. Without the priority set, JSONAPI was getting the chat events before Factions/mcMMO had a chance to cancel it.

@lucasec

Hey I'm not sure if that build is actually up to date. If you could, hold off a sec on merging it.

@lucasec lucasec Build #2
Apparently the first build didn't go through.
2c95e60
@lucasec

Apparently my local source just reset for some reason. I re-cloned my repo and built again just to be safe. Noob mistake I guess.

@alecgorge alecgorge merged commit 5bf9d4d into alecgorge:master
@alecgorge
Owner

Okay, it the priority thing seems backwards to me too.

Merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 27, 2012
  1. @lucasec

    Raise chat event handler priority

    lucasec authored
    JSONAPI was picking up faction chat and party chat messages, which may
    be intentional.  For my use, I only wanted to pick up global chat msgs.
  2. @lucasec

    Build #2

    lucasec authored
    Apparently the first build didn't go through.
This page is out of date. Refresh to see the latest.
View
3  src/com/alecgorge/minecraft/jsonapi/JSONAPI.java
@@ -62,6 +62,7 @@
import com.alecgorge.minecraft.jsonapi.streams.ConsoleLogFormatter;
import com.alecgorge.minecraft.jsonapi.streams.StreamManager;
import com.alecgorge.minecraft.jsonapi.util.PropertiesFile;
+import org.bukkit.event.EventPriority;
/**
*
@@ -688,7 +689,7 @@ public JSONAPIPlayerListener(JSONAPI plugin) {
p = plugin;
}
- @EventHandler
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onPlayerChat(PlayerChatEvent event) {
p.jsonServer.logChat(event.getPlayer().getName(), event.getMessage());
}
View
BIN  target/JSONAPI-bleeding.zip
Binary file not shown
View
BIN  target/JSONAPI.jar
Binary file not shown
View
5 target/maven-archiver/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Fri Jul 27 13:02:10 CDT 2012
+version=bleeding
+groupId=com.ramblingwood.minecraft.jsonapi
+artifactId=JSONAPI
Something went wrong with that request. Please try again.