Skip to content

Commit

Permalink
Add world event 'on player chats' with <context.message> and determin…
Browse files Browse the repository at this point in the history
…e cancelled or determine message:new_message
  • Loading branch information
aufdemrand committed Apr 1, 2013
1 parent ec33b06 commit cd823d7
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -18,6 +18,7 @@
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
Expand Down Expand Up @@ -272,7 +273,19 @@ else if (event.getAction() == Action.PHYSICAL) {

}

@EventHandler(priority = EventPriority.LOWEST)
public void playerChat(AsyncPlayerChatEvent event) {

Map<String, String> context = new HashMap<String, String>();
context.put("message", event.getMessage());

String determination = doEvent("player chats", null, event.getPlayer(), context);

if (determination.toUpperCase().startsWith("CANCELLED"))
event.setCancelled(true);
if (aH.matchesValueArg("MESSAGE", determination, aH.ArgumentType.Integer))
event.setMessage(aH.getStringFrom(determination));
}

@EventHandler
public void playerHit(EntityDamageEvent event) {
Expand Down

0 comments on commit cd823d7

Please sign in to comment.