Skip to content

Instantly share code, notes, and snippets.

@Spyboticsguy
Created April 1, 2012 11:29
Show Gist options
  • Save Spyboticsguy/2274803 to your computer and use it in GitHub Desktop.
Save Spyboticsguy/2274803 to your computer and use it in GitHub Desktop.
some code
@EventHandler(priority=EventPriority.MONITOR)
public void onPlayerChat(PlayerChatEvent event) {
if (this.plugin.isHeld(CraftIRC.HoldType.CHAT)) {
return;
}
// String[] split = message.split(" ");
try {
if (this.plugin.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " onPlayerChat(): <%s> %s", event.getMessage(), event.getPlayer()));
if (event.isCancelled() && !this.plugin.cEvents("game-to-irc.cancelled-chat", -1, null)) {
if (this.plugin.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " onPlayerChat(CHAT CANCELLED!): <%s> %s", event.getMessage(), event.getPlayer()));
return;
}
RelayedMessage msg = this.plugin.newMsg(EndPoint.GAME, EndPoint.IRC);
msg.formatting = "chat";
msg.sender = event.getPlayer().getName().replaceAll("[§&Â][0-9a-fklmnor]", "");
msg.message = event.getMessage();
msg.world = event.getPlayer().getWorld().getName();
this.plugin.sendMessage(msg, null, "all-chat");
} catch (Exception e) {
e.printStackTrace();
}
}
@EventHandler(priority=EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
if (this.plugin.isHeld(CraftIRC.HoldType.JOINS))
return;
try {
RelayedMessage msg = this.plugin.newMsg(EndPoint.GAME, EndPoint.IRC);
msg.formatting = "joins";
msg.sender = event.getPlayer().getName();
this.plugin.sendMessage(msg, null, "joins");
} catch (Exception e) {
e.printStackTrace();
}
}
@EventHandler(priority=EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if (this.plugin.isHeld(CraftIRC.HoldType.QUITS))
return;
try {
RelayedMessage msg = this.plugin.newMsg(EndPoint.GAME, EndPoint.IRC);
msg.formatting = "quits";
msg.sender = event.getPlayer().getName();
this.plugin.sendMessage(msg, null, "quits");
} catch (Exception e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment