Permalink
Browse files

Trying to fix what broke up until Minecraft 1.7. Game->IRC colors add…

…ed, IRC->Game commands fixed maybe.
  • Loading branch information...
1 parent 86a301a commit 3c4b1e05d2904e87f5556280a9b843c344b1eb62 unknown committed Jul 4, 2011
Binary file not shown.
@@ -212,8 +212,8 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa
} else if (commandName.equals("ircraw")) {
if (this.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " CraftIRCListener onCommand(): commandName=ircraw"));
- if ( ((sender instanceof Player) && this.checkPerms((Player) sender, "craftirc.ircraw")) || (sender instanceof IRCConsoleCommandSender ))
- return this.cmdRawIrcCommand(sender, args);
+ if ( ((sender instanceof Player) && !this.checkPerms((Player) sender, "craftirc.ircraw"))) return false;
+ return this.cmdRawIrcCommand(sender, args);
} else
return false;
@@ -702,7 +702,11 @@ protected boolean cChanAdmin(int bot, String channel) {
protected boolean cChanChatColors(int bot, String channel) {
return getChanNode(bot, channel).getBoolean("chat-colors", true);
}
-
+
+ protected boolean cGameChatColors(int bot, String channel) {
+ return getChanNode(bot, channel).getBoolean("game-colors", true);
+ }
+
protected boolean cChanNameColors(int bot, String channel) {
return getChanNode(bot, channel).getBoolean("name-colors", true);
}
@@ -801,7 +805,7 @@ protected String getPermSuffix(String world, String pl) {
protected void enqueueConsoleCommand(String cmd) {
try {
- console.a(cmd, console);
+ console.issueCommand(cmd, console);
} catch (Exception e) {
e.printStackTrace();
@@ -350,7 +350,7 @@ public void onMessage(String channel, String sender, String login, String hostna
msg.sender = sender;
msg.srcBot = botId;
msg.srcChannel = channel;
- msg.message = message.replaceFirst(cmdPrefix, "");
+ msg.message = message.substring(cmdPrefix.length());
msg.updateTag();
// PLUGIN INTEROP
msg.setTarget(EndPoint.PLUGIN);
@@ -418,7 +418,7 @@ else if (message.startsWith(cmdPrefix + "say ") || message.startsWith(cmdPrefix
msg.sender = sender;
msg.srcBot = botId;
msg.srcChannel = channel;
- msg.message = message.replaceFirst(cmdPrefix, "");
+ msg.message = message.substring(cmdPrefix.length());
msg.updateTag();
// PLUGIN INTEROP
msg.setTarget(EndPoint.PLUGIN);
@@ -520,7 +520,7 @@ private boolean routeCommand(String fullCommand, RelayedMessage ircConCmd) {
//if (!this.plugin.defaultConsoleCommands.contains(rootCommand))
// return false;
- if (!this.plugin.cConsoleCommands().contains(rootCommand)){
+ if (!this.plugin.cConsoleCommands().contains(rootCommand) && !this.plugin.cConsoleCommands().contains("all")){
if (this.plugin.isDebug()) { CraftIRC.log.info(String.format(CraftIRC.NAME + " Console command: %s not found in config.yml",rootCommand)); }
return false;
}
@@ -533,7 +533,8 @@ private boolean routeCommand(String fullCommand, RelayedMessage ircConCmd) {
}
this.plugin.enqueueConsoleCommand(fullCommand);
-
+ return true;
+
} else {
if (this.plugin.isDebug()) {
CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot routeCommand() fullCommand=" + fullCommand
@@ -71,6 +71,7 @@ public String asString() throws RelayedMessageException {
if (target != EndPoint.BOTH) return asString(target);
else return asString(EndPoint.UNKNOWN);
}
+
public String asString(EndPoint realTarget) throws RelayedMessageException {
String result = "";
String msgout = message;
@@ -80,7 +81,21 @@ public String asString(EndPoint realTarget) throws RelayedMessageException {
if (source == EndPoint.PLUGIN || target == EndPoint.PLUGIN || target == EndPoint.UNKNOWN)
result = this.message;
if (source == EndPoint.GAME && target == EndPoint.IRC)
+ if (source == EndPoint.GAME && target == EndPoint.IRC) {
+ if(this.plugin.cGameChatColors(trgBot, trgChannel)) {
+ Pattern color_codes = Pattern.compile("\u00A7([A-Za-z0-9])?");
+ Matcher find_colors = color_codes.matcher(msgout);
+ while (find_colors.find()) {
+ msgout = find_colors.replaceFirst("\u0003" + Integer.toString(this.plugin.cColorIrcFromGame("\u00C2\u00A7" + find_colors.group(1))));
+ find_colors = color_codes.matcher(msgout);
+ }
+ }
+ else
+ msgout = msgout.replaceAll("(\u00A7([A-Za-z0-9])?)", "");
+
result = this.plugin.cFormatting("game-to-irc." + formatting, trgBot, trgChannel);
+ }
+
if (source == EndPoint.IRC && (target == EndPoint.IRC || target == EndPoint.BOTH && realTarget == EndPoint.IRC))
result = this.plugin.cFormatting("irc-to-irc." + formatting, trgBot, trgChannel);
if (source == EndPoint.IRC && (target == EndPoint.GAME || target == EndPoint.BOTH && realTarget == EndPoint.GAME)) {
@@ -153,5 +168,4 @@ else if (target == EndPoint.GAME || target == EndPoint.BOTH && realTarget == End
}
return result;
}
-
}
Oops, something went wrong.

0 comments on commit 3c4b1e0

Please sign in to comment.