Permalink
Browse files

Reverted coloring changes, added IRCEVENT.MSG properly, added IRCEVEN…

…T.NICKCHANGE for when nick event works, build Preview 10
  • Loading branch information...
1 parent 7e4277c commit fc721875cfbed5055edcf3a534760ca323d2c74c @Animosity committed Mar 7, 2011
View
Binary file not shown.
@@ -470,6 +470,9 @@ private Minebot getBotFromId(int id) {
return result;
}
+ public ArrayList<String> getIrcUserListFromTag(String tag) {
+ return ircUserLists(tag);
+ }
protected void noticeAdmins(String message) {
for (int i = 0; i < bots.size(); i++) {
ArrayList<String> chans = cBotChannels(i);
@@ -594,10 +597,10 @@ protected String cColorGameFromName(String name) {
while (it.hasNext()) {
color = it.next();
if (color.getString("name").equalsIgnoreCase(name) && color.getProperty("game") != null)
- return color.getString("game", "§f");
+ return color.getString("game", "§f");
}
if (name.equalsIgnoreCase("foreground"))
- return "§f";
+ return "§f";
else
return cColorGameFromName("foreground");
}
@@ -756,12 +759,11 @@ protected boolean checkPerms(String pl, String path) {
return false;
}
- // TODO: This needs repair
protected String colorizeName(String name) {
- Pattern color_codes = Pattern.compile(Character.toString((char) 3)+"[0-9a-f]");
+ Pattern color_codes = Pattern.compile("§[0-9a-f]");
Matcher find_colors = color_codes.matcher(name);
while (find_colors.find()) {
- name = find_colors.replaceAll(Character.toString((char) 3)
+ name = find_colors.replaceFirst(Character.toString((char) 3)
+ String.format("%02d", cColorIrcFromGame(find_colors.group())));
find_colors = color_codes.matcher(name);
}
@@ -777,7 +779,7 @@ protected String getPermPrefix(String pl) {
String result = perms.getGroupPrefix(group);
if (result == null)
return "";
- return colorizeName(result.replaceAll("&([0-9a-f])", Character.toString((char) 3)+"$1"));
+ return colorizeName(result.replaceAll("&([0-9a-f])", "§$1"));
}
protected String getPermSuffix(String pl) {
@@ -789,7 +791,7 @@ protected String getPermSuffix(String pl) {
String result = perms.getGroupSuffix(group);
if (result == null)
return "";
- return colorizeName(result.replaceAll("&([0-9a-f])", Character.toString((char) 3)+"$1"));
+ return colorizeName(result.replaceAll("&([0-9a-f])", "§$1"));
}
protected void enqueueConsoleCommand(String cmd) {
@@ -50,7 +50,7 @@ protected IRCEvent(Mode mode, RelayedMessage message) {
}
public enum Mode {
- JOIN, PART, QUIT, KICK, BAN, MSG, PRIVMSG, ACTION, COMMAND, AUTHED_COMMAND, HANDLED
+ JOIN, PART, QUIT, KICK, BAN, MSG, PRIVMSG, ACTION, COMMAND, AUTHED_COMMAND, NICKCHANGE, HANDLED
}
/*public String getServer() {
@@ -134,14 +134,12 @@ public void start() {
} catch (Exception e) {
e.printStackTrace();
}
-
}
public CraftIRC getPlugin() {
return this.plugin;
}
-
void authenticateBot() {
if (this.authMethod.equalsIgnoreCase("nickserv") && !authPass.isEmpty()) {
CraftIRC.log.info(CraftIRC.NAME + " - Using Nickserv authentication.");
@@ -169,7 +167,7 @@ void authenticateBot() {
}
}
-
+ // TODO: DOCUMENTATION
public void onJoin(String channel, String sender, String login, String hostname) {
if (this.plugin.isDebug()) {
CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.JOIN"));
@@ -198,7 +196,8 @@ public void onJoin(String channel, String sender, String login, String hostname)
}
}
}
-
+
+ // TODO: DOCUMENTATION
public void onPart(String channel, String sender, String login, String hostname, String reason) {
if (this.plugin.isDebug()) {
CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.PART"));
@@ -219,7 +218,8 @@ public void onPart(String channel, String sender, String login, String hostname,
this.plugin.getServer().getPluginManager().callEvent(ie);
}
}
-
+
+ // TODO: DOCUMENTATION
public void onChannelQuit(String channel, String sender, String login, String hostname, String reason) {
if (this.plugin.isDebug()) {
CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.QUIT"));
@@ -240,12 +240,10 @@ public void onChannelQuit(String channel, String sender, String login, String ho
this.plugin.getServer().getPluginManager().callEvent(ie);
}
}
-
+
+ // TODO: DOCUMENTATION
public void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname,
String recipientNick, String reason) {
- if (this.plugin.isDebug()) {
- CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.KICK"));
- }
if (recipientNick.equalsIgnoreCase(this.getNick())) {
if (this.channels.contains(channel)) {
this.joinChannel(channel, this.plugin.cChanPassword(botId, channel));
@@ -261,24 +259,30 @@ public void onKick(String channel, String kickerNick, String kickerLogin, String
msg.updateTag();
this.plugin.sendMessage(msg, null, "kicks");
// PLUGIN INTEROP
+ if (this.plugin.isDebug())
+ CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.KICK"));
msg.setTarget(EndPoint.PLUGIN);
- Event ie = new IRCEvent(Mode.QUIT, msg);
+ Event ie = new IRCEvent(Mode.KICK, msg);
this.plugin.getServer().getPluginManager().callEvent(ie);
}
+ // TODO: DOCUMENTATION
public void onChannelNickChange(String channel, String oldNick, String login, String hostname, String newNick) {
- if (this.channels.contains(channel)) {
- RelayedMessage msg = this.plugin.newMsg(EndPoint.IRC, EndPoint.BOTH);
- msg.formatting = "nicks";
- msg.sender = oldNick;
- msg.srcBot = botId;
- msg.srcChannel = channel;
- msg.message = newNick;
- msg.updateTag();
- this.plugin.sendMessage(msg, null, "nicks");
- msg.setTarget(EndPoint.PLUGIN);
-
- }
+ RelayedMessage msg = this.plugin.newMsg(EndPoint.IRC, EndPoint.BOTH);
+ msg.formatting = "nicks";
+ msg.sender = oldNick;
+ msg.srcBot = botId;
+ msg.srcChannel = channel;
+ msg.message = newNick;
+ msg.updateTag();
+ this.plugin.sendMessage(msg, null, "nicks");
+ // PLUGIN INTEROP
+ if (this.plugin.isDebug())
+ CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.NICKCHANGE"));
+
+ msg.setTarget(EndPoint.PLUGIN);
+ Event ie = new IRCEvent(Mode.NICKCHANGE, msg);
+ this.plugin.getServer().getPluginManager().callEvent(ie);
}
/* (non-Javadoc)
@@ -371,11 +375,18 @@ public void onMessage(String channel, String sender, String login, String hostna
msg.message = message;
msg.updateTag();
this.plugin.sendMessage(msg, null, "all-chat");
+ // PLUGIN INTEROP
+ if (this.plugin.isDebug())
+ CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.MSG"));
+
+ msg.setTarget(EndPoint.PLUGIN);
+ Event ie = new IRCEvent(Mode.MSG, msg);
+ this.plugin.getServer().getPluginManager().callEvent(ie);
return;
}
// .say - Send single message to the game
- if (message.startsWith(cmdPrefix + "say ") || message.startsWith(cmdPrefix + "mc ")) {
+ else if (message.startsWith(cmdPrefix + "say ") || message.startsWith(cmdPrefix + "mc ")) {
if (splitMessage.length > 1) {
RelayedMessage msg = this.plugin.newMsg(EndPoint.IRC, EndPoint.GAME);
msg.formatting = "chat";
@@ -481,7 +492,6 @@ public void onAction(String sender, String login, String hostname, String target
// IRC user authorization check against prefixes
// Currently just for admin channel as first-order level of security
public boolean userAuthorized(String channel, String user) {
-
if (this.plugin.cChanAdmin(botId, channel))
try {
User check = this.getUser(user, channel);
@@ -28,7 +28,7 @@
/* (non-Javadoc)
* @see org.bukkit.plugin.Plugin#onEnable()
*/
- @Override
+
public void onEnable() {
Plugin checkplugin = this.getServer().getPluginManager().getPlugin("CraftIRC");
if (checkplugin == null || !checkplugin.isEnabled()) {
View
@@ -1,6 +1,6 @@
name: CraftIRC
main: com.ensifera.animosity.craftirc.CraftIRC
-version: 2.0 Preview 9d
+version: 2.0 Preview 10
commands:
irc:
description: Sends a message to all IRC channels

0 comments on commit fc72187

Please sign in to comment.