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

Commit

Permalink
Alises for smsg
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed Jun 27, 2015
1 parent 80f0a77 commit da27e54
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,28 @@ public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
}
}
if (plugin.overrideMsgCmd) {
if (cmd.equalsIgnoreCase("/msg")) {
if (cmd.equalsIgnoreCase(plugin.smsgAlias)) {
event.setCancelled(true); //prevent other plugins from using /msg
if (player.hasPermission("irc.smsg")) {
String newCmd[] = message.replaceFirst(cmd, "smsg").split(" ");
plugin.commandHandlers.commands.get("smsg").dispatch(player, newCmd);
String args[] = message.replaceFirst(cmd, "smsg").split(" ");
if (args.length >= 3) {
plugin.commandHandlers.commands.get("smsg").dispatch(player, args);
} else {
player.sendMessage(ChatColor.WHITE + "Usage: " + ChatColor.GOLD + plugin.smsgAlias + " [player] [message]");
}
} else {
player.sendMessage(plugin.noPermission);
}
} else if (cmd.equalsIgnoreCase("/r")) {
} else if (cmd.equalsIgnoreCase(plugin.smsgReplyAlias)) {
event.setCancelled(true); //prevent other plugins from using /msg
if (player.hasPermission("irc.smsg")) {
String pName = player.getName();
if (plugin.privateMsgReply.containsKey(pName)) {
String args[] = message.replaceFirst(cmd, "smsg " + plugin.privateMsgReply.get(pName)).split(" ");
if (args.length >= 1) {
if (args.length >= 3) {
plugin.commandHandlers.commands.get("smsg").dispatch(player, args);
} else {
player.sendMessage(ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/r [message]");
player.sendMessage(ChatColor.WHITE + "Usage: " + ChatColor.GOLD + plugin.smsgReplyAlias + " [message]");
}
} else {
player.sendMessage(ChatColor.RED + "No messages received.");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/cnaude/purpleirc/PurpleIRC.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ public class PurpleIRC extends JavaPlugin {
public static final String TOWNYTAG = "VG93bnlDaGF0Cg==";
public static final String LINK_CMD = "PurpleIRC-Link:";
public boolean overrideMsgCmd = false;
public String smsgAlias = "/m";
public String smsgReplyAlias = "/r";
public CaseInsensitiveMap<String> privateMsgReply;

public PurpleIRC() {
Expand Down Expand Up @@ -575,6 +577,8 @@ private void loadConfig() {
logError(ex.getMessage());
}
overrideMsgCmd = getConfig().getBoolean("override-msg-cmd", false);
smsgAlias = getConfig().getString("smsg-alias", "/m");
smsgReplyAlias = getConfig().getString("smsg-reply-alias", "/r");
updateCheckerEnabled = getConfig().getBoolean("update-checker", true);
updateCheckerMode = getConfig().getString("update-checker-mode", "stable");
debugEnabled = getConfig().getBoolean("Debug");
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ enable-ident-server: false
channel-check-interval: 100
# Alias /irc smsg to /msg
override-msg-cmd: false
# Alias for /irc smsg
smsg-alias: '/m'
# Alias for /irc smsg <prev player>
smsg-reply-alias: '/r'
# Chat messages support standard Bukkit color codes using '&#'. See http://minecraft.gamepedia.com/Formatting_codes
# The following macro tokens are also supported.
# %WORLD%
Expand Down

0 comments on commit da27e54

Please sign in to comment.