Skip to content

Commit

Permalink
Trying to fix what broke up until Minecraft 1.7. Game->IRC colors add…
Browse files Browse the repository at this point in the history
…ed, IRC->Game commands fixed maybe.
  • Loading branch information
unknown authored and unknown committed Jul 4, 2011
1 parent 86a301a commit 3c4b1e0
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 187 deletions.
Binary file modified beta/preview/CraftIRC.jar
Binary file not shown.
12 changes: 8 additions & 4 deletions com/ensifera/animosity/craftirc/CraftIRC.java
Expand Up @@ -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;

Expand Down Expand Up @@ -702,7 +702,11 @@ protected ArrayList<String> cChanOnJoin(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);
}
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions com/ensifera/animosity/craftirc/Minebot.java
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion com/ensifera/animosity/craftirc/RelayedMessage.java
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down Expand Up @@ -153,5 +168,4 @@ else if (target == EndPoint.GAME || target == EndPoint.BOTH && realTarget == End
}
return result;
}

}

0 comments on commit 3c4b1e0

Please sign in to comment.