Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Add support for Essentials /helpop /amsg and /ac.
Browse files Browse the repository at this point in the history
Resolves issue #70
  • Loading branch information
cnaude committed Jun 14, 2014
1 parent 0f8a992 commit 8921d28
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@

import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerCommandEvent;

/**
*
Expand All @@ -40,9 +33,9 @@ public GamePlayerCommandPreprocessingListener(PurpleIRC plugin) {
*/
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
if (event.isCancelled()) {
return;
}
}
String msg = event.getMessage();
if (event.getPlayer().hasPermission("irc.message.gamechat")) {
if (msg.startsWith("/me ")) {
Expand All @@ -55,6 +48,16 @@ public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
}
}
}
if (plugin.isPluginEnabled("Essentials")) {
if (msg.startsWith("/helpop ") || msg.startsWith("/amsg ") || msg.startsWith("/ac ")) {
if (msg.contains(" ")) {
String message = msg.split(" ", 2)[1];
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.essHelpOp(event.getPlayer(), message);
}
}
}
}
for (PurpleBot ircBot : plugin.ircBots.values()) {
if (msg.startsWith("/")) {
String cmd;
Expand Down
23 changes: 21 additions & 2 deletions src/main/java/com/cnaude/purpleirc/PurpleBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -1151,14 +1151,33 @@ public void gameBroadcast(Player player, String message) {
return;
}
for (String channelName : botChannels) {
if (isMessageEnabled(channelName,"broadcast-message")) {
if (isMessageEnabled(channelName,TemplateName.BROADCAST_MESSAGE)) {
asyncIRCMessage(channelName, plugin.tokenizer
.gameChatToIRCTokenizer(player, plugin
.getMsgTemplate(botNick, "broadcast-message"),
.getMsgTemplate(botNick, TemplateName.BROADCAST_MESSAGE),
ChatColor.translateAlternateColorCodes('&', message)));
}
}
}

/**
*
* @param player
* @param message
*/
public void essHelpOp(Player player, String message) {
if (!this.isConnected()) {
return;
}
for (String channelName : botChannels) {
if (isMessageEnabled(channelName,TemplateName.ESS_HELPOP)) {
asyncIRCMessage(channelName, plugin.tokenizer
.gameChatToIRCTokenizer(player, plugin
.getMsgTemplate(botNick, TemplateName.ESS_HELPOP),
ChatColor.translateAlternateColorCodes('&', message)));
}
}
}

/**
*
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/cnaude/purpleirc/TemplateName.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class TemplateName {

public final static String ESS_PLAYER_AFK = "ess-player-afk";
public final static String ESS_PLAYER_NOT_AFK = "ess-player-not-afk";
public final static String ESS_HELPOP = "ess-helpop";

public final static String INVALID_IRC_COMMAND = "invalid-irc-command";
public final static String NO_PERM_FOR_IRC_COMMAND = "no-perm-for-irc-command";
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/SampleBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ channels:
- game-join
- game-quit
- game-mode
# Essentials helpop messages (/helpop /amsg /ac)
- ess-helpop
# The game-afk message type is not functional yet.
#- game-afk
# These messages are sent from IRC to game (see permissions)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ message-format:
# Essentials messages
ess-player-afk: '[&2%WORLD%&r] %NAME% is now AFK'
ess-player-not-afk: '[&2%WORLD%&r] %NAME% is no longer AFK'
ess-helpop: '&4[HelpOp] %DISPLAYNAME%&r: %MESSAGE%'
# Message templates for IRC to game messages
irc-action: '[&4IRC&r] ***%NAME% %MESSAGE%'
irc-chat: '[&4IRC]<%NAME%> %MESSAGE%'
Expand Down

0 comments on commit 8921d28

Please sign in to comment.