Skip to content

Commit

Permalink
fixing some color character issues, add stub for getBotFromId, colori…
Browse files Browse the repository at this point in the history
…zeName() needs fixing, build Preview 9d
  • Loading branch information
Animosity committed Mar 7, 2011
1 parent 8012610 commit 7e4277c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
Binary file modified beta/preview/CraftIRC.jar
Binary file not shown.
24 changes: 17 additions & 7 deletions com/ensifera/animosity/craftirc/CraftIRC.java
Expand Up @@ -441,10 +441,19 @@ public void sendMessageToTag(String message, String tag) {
* @param tag
* @return
*/
private int getBotFromTag(String tag) {
private int getBotIdFromTag(String tag) {
return 0;
}

/** TODO: MAKE THIS
* CraftIRC API call - getBotFromId(id) Gets the bot id# from a source tag
* @param id
* @return
private Minebot getBotFromId(int id) {
return Minebot;
}
*/
protected ArrayList<String> ircUserLists(String tag) {
ArrayList<String> result = new ArrayList<String>();
if (tag == null)
Expand Down Expand Up @@ -747,11 +756,12 @@ protected boolean checkPerms(String pl, String path) {
return false;
}

// TODO: This needs repair
protected String colorizeName(String name) {
Pattern color_codes = Pattern.compile([0-9a-f]");
Pattern color_codes = Pattern.compile(Character.toString((char) 3)+"[0-9a-f]");
Matcher find_colors = color_codes.matcher(name);
while (find_colors.find()) {
name = find_colors.replaceFirst(Character.toString((char) 3)
name = find_colors.replaceAll(Character.toString((char) 3)
+ String.format("%02d", cColorIrcFromGame(find_colors.group())));
find_colors = color_codes.matcher(name);
}
Expand All @@ -767,7 +777,7 @@ protected String getPermPrefix(String pl) {
String result = perms.getGroupPrefix(group);
if (result == null)
return "";
return colorizeName(result.replaceAll("&([0-9a-f])", $1"));
return colorizeName(result.replaceAll("&([0-9a-f])", Character.toString((char) 3)+"$1"));
}

protected String getPermSuffix(String pl) {
Expand All @@ -779,15 +789,15 @@ protected String getPermSuffix(String pl) {
String result = perms.getGroupSuffix(group);
if (result == null)
return "";
return colorizeName(result.replaceAll("&([0-9a-f])", $1"));
return colorizeName(result.replaceAll("&([0-9a-f])", Character.toString((char) 3)+"$1"));
}

public void enqueueConsoleCommand(String cmd) {
protected void enqueueConsoleCommand(String cmd) {
try {
console.a(cmd, console);

} catch (Exception e) {

e.printStackTrace();
}


Expand Down
4 changes: 2 additions & 2 deletions com/ensifera/animosity/craftirc/RelayedMessage.java
Expand Up @@ -121,7 +121,7 @@ public String asString(EndPoint realTarget) throws RelayedMessageException {
result = result.replace("%trgChannel%", trgChannel);
result = result.replace("%world%", world);
if (source == EndPoint.GAME && this.plugin.hasPerms() && this.plugin.cChanNameColors(trgBot, trgChannel)) {
if (this.plugin.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " RelayedMessage: hasPerms="+String.valueOf(this.plugin.hasPerms())+" cChanNameColors()="+String.valueOf(this.plugin.cChanNameColors(trgBot, trgChannel)))+", apply pre/suffixes ");
//if (this.plugin.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " RelayedMessage: hasPerms="+String.valueOf(this.plugin.hasPerms())+" cChanNameColors()="+String.valueOf(this.plugin.cChanNameColors(trgBot, trgChannel)))+", apply pre/suffixes ");
result = result.replace("%prefix%", this.plugin.getPermPrefix(sender));
result = result.replace("%suffix%", this.plugin.getPermSuffix(sender));
if (!moderator.equals("")) {
Expand All @@ -132,7 +132,7 @@ public String asString(EndPoint realTarget) throws RelayedMessageException {
result = result.replace("%modSuffix%", "");
}
} else {
if (this.plugin.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " RelayedMessage: hasPerms="+String.valueOf(this.plugin.hasPerms())+" cChanNameColors()="+String.valueOf(this.plugin.cChanNameColors(trgBot, trgChannel)))+", apply EMPTY pre/suffixes ");
//if (this.plugin.isDebug()) CraftIRC.log.info(String.format(CraftIRC.NAME + " RelayedMessage: hasPerms="+String.valueOf(this.plugin.hasPerms())+" cChanNameColors()="+String.valueOf(this.plugin.cChanNameColors(trgBot, trgChannel)))+", apply EMPTY pre/suffixes ");
result = result.replace("%prefix%", "");
result = result.replace("%suffix%", "");
result = result.replace("%modPrefix%", "");
Expand Down
3 changes: 2 additions & 1 deletion config.yml
Expand Up @@ -25,7 +25,7 @@ settings:
formatting:
#### Formatting for the messages relayed by the plugin. You can override all formatting strings in the bot or channel
#### scope (within a formatting: block). In irc-to-irc, the target channel controls the format strings.
#### VARIABLES (may be blank depending on the context): %sender% %message% %moderator% %srcChannel% %trgChannel%
#### VARIABLES (may be blank depending on the context): %sender% %message% %moderator% %srcChannel% %trgChannel% %world%
#### IF YOU'RE RUNNING Permissions: %prefix% %suffix% %modPredix% %modSuffix% (game-to-irc only)
#### IRC FORMATTING: %b% %u% %r% %o% %k% %kNUM% (NUM is 0 to 15); Do the same as CTRL+key in mIRC
#### GAME COLORS: §NUM (NUM is 1 to f); Do not use in the end of a line
Expand Down Expand Up @@ -66,6 +66,7 @@ settings:
#### events can be redefined in the bot or channel scopes (within an events: block). In irc-to-irc, the source
#### channel controls the events.
game-to-irc:
# If you use other chat plugins, you probably want to set cancelled-chat: true
cancelled-chat: false
all-chat: true
joins: false
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
@@ -1,6 +1,6 @@
name: CraftIRC
main: com.ensifera.animosity.craftirc.CraftIRC
version: 2.0 Preview 9c
version: 2.0 Preview 9d
commands:
irc:
description: Sends a message to all IRC channels
Expand Down

0 comments on commit 7e4277c

Please sign in to comment.