Permalink
Browse files

Added (better?) support for CraftIRC3

  • Loading branch information...
1 parent 37c109f commit 0a9127f739dca9c95d1682ca97dcedfbc66324d2 @GuntherDW committed Sep 25, 2011
View
@@ -9,6 +9,7 @@ authors:
website: https://github.com/GuntherDW/TweakcraftUtils
description: A general usage plugin primarily aimed at Tweakcraft, but can be used by any server
database: true
+softdepend: ['CraftIRC']
commands:
tweakcraft:
description: General tweakcraftutils command
@@ -18,6 +18,8 @@
package com.guntherdw.bukkit.tweakcraft.Chat.Modes;
+import com.ensifera.animosity.craftirc.CraftIRC;
+import com.ensifera.animosity.craftirc.RelayedMessage;
import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
import com.guntherdw.bukkit.tweakcraft.Chat.ChatMode;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
@@ -33,14 +35,21 @@
*/
public class AdminChat implements ChatMode {
+ /* TweakcraftUtils stuff */
+
private List<String> subscribers;
private TweakcraftUtils plugin;
private ChatHandler chathandler;
+ private CraftIRC circ;
public AdminChat(ChatHandler instance) {
subscribers = new ArrayList<String>();
this.chathandler = instance;
this.plugin = chathandler.getTCUtilsInstance();
+ if(plugin.getConfigHandler().enableIRC) {
+ this.circ = plugin.getCraftIRC();
+ circ.registerEndPoint("tcutilsadmin", plugin.getAdminEndPoint());
+ }
}
public boolean sendMessage(CommandSender sender, String message) {
@@ -66,7 +75,22 @@ public boolean sendMessage(CommandSender sender, String message) {
targetmsg = targetmsg.replace("%message%", message);
targetmsg = targetmsg.replace("%dispname%", ChatColor.stripColor(sendername));
- plugin.getCraftIRC().sendMessageToTag(targetmsg, plugin.getConfigHandler().AIRCtag);
+ // plugin.getCraftIRC().sendMessageToTag(targetmsg, plugin.getConfigHandler().AIRCtag);
+ /// plugin.getCraftIRC().newMsgToTag(this, plugin.getConfigHandler().AIRCtag, targetmsg);
+
+ RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().AIRCtag, "generic");
+ rmsg.setField("sender", pcolor+sendername);
+ rmsg.setField("realSender", cleanname);
+ rmsg.setField("message", targetmsg);
+ if(sender instanceof Player) {
+ Player p = (Player) sender;
+ // World w = p.getWorld();
+ rmsg.setField("world", p.getWorld().getName());
+ rmsg.setField("prefix", plugin.getPermissionHandler().getUserPrefix(p.getWorld().getName(), p.getName()));
+ rmsg.setField("suffix", plugin.getPermissionHandler().getUserSuffix(p.getWorld().getName(), p.getName()));
+ }
+ rmsg.post();
+
}
}
@@ -18,6 +18,7 @@
package com.guntherdw.bukkit.tweakcraft.Commands.General;
+import com.ensifera.animosity.craftirc.RelayedMessage;
import com.guntherdw.bukkit.tweakcraft.Commands.iCommand;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
@@ -28,7 +29,6 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -81,9 +81,12 @@ public boolean executeCommand(CommandSender sender, String command, String[] rea
if(plugin.getConfigHandler().enableIRC && plugin.getCraftIRC()!=null && groups==null ) {
if(plugin.getConfigHandler().GIRCenabled) {
- String tag = plugin.getConfigHandler().GIRCtag;
+ // String tag = ;
- plugin.getCraftIRC().sendMessageToTag("[Broadcast] "+message, tag);
+ // plugin.getCraftIRC(). ("[Broadcast] "+message, tag);
+ RelayedMessage rm = plugin.getCraftIRC().newMsgToTag(plugin.getEndPoint(), plugin.getConfigHandler().GIRCtag, "generic");
+ rm.setField("message", "[Broadcast] "+message);
+ rm.post();
}
}
// plugin.getLogger().info
@@ -18,23 +18,20 @@
package com.guntherdw.bukkit.tweakcraft.Listeners;
-import com.guntherdw.bukkit.tweakcraft.DataSources.Ban.BanHandler;
import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
import com.guntherdw.bukkit.tweakcraft.Chat.ChatMode;
+import com.guntherdw.bukkit.tweakcraft.DataSources.Ban.BanHandler;
import com.guntherdw.bukkit.tweakcraft.DataSources.PersistenceClass.PlayerHistoryInfo;
import com.guntherdw.bukkit.tweakcraft.DataSources.PersistenceClass.PlayerInfo;
import com.guntherdw.bukkit.tweakcraft.DataSources.PersistenceClass.PlayerOptions;
import com.guntherdw.bukkit.tweakcraft.Exceptions.ChatModeException;
import com.guntherdw.bukkit.tweakcraft.Packages.Ban;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
-import com.guntherdw.bukkit.tweakcraft.Util.TimeTool;
import com.guntherdw.bukkit.tweakcraft.Worlds.IWorld;
-import com.guntherdw.bukkit.tweakcraft.Worlds.TweakWorld;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
-import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
@@ -307,19 +304,6 @@ public void onPlayerChat(PlayerChatEvent event) {
event.setCancelled(true);
}
}
-
- if(!event.isCancelled() && cm==null) {
- // Log nicks!
- if(getNick(name)!=null) {
- // plugin.getLogger().info("[TweakcraftUtils] "+getNick(name)+" is "+name);
- event.setCancelled(true);
- plugin.getLogger().info("("+player.getName()+") <"+player.getDisplayName()+"> "+message);
- /* if(plugin.getConfigHandler().enableIRC && plugin.getCraftIRC()!=null) {
- plugin.getCraftIRC().sendMessageToTag();
- } */
- plugin.getServer().broadcastMessage(ChatColor.WHITE+"<"+player.getDisplayName()+ChatColor.WHITE+"> "+message);
- }
- }
}
public void onPlayerRespawn(PlayerRespawnEvent event) {
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011 GuntherDW
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package com.guntherdw.bukkit.tweakcraft.Packages;
+
+import com.ensifera.animosity.craftirc.CraftIRC;
+import com.ensifera.animosity.craftirc.EndPoint;
+import com.ensifera.animosity.craftirc.RelayedMessage;
+import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
+import com.guntherdw.bukkit.tweakcraft.Chat.ChatMode;
+import com.guntherdw.bukkit.tweakcraft.Chat.Modes.AdminChat;
+import com.guntherdw.bukkit.tweakcraft.Exceptions.ChatModeException;
+import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+
+/**
+ * @author GuntherDW
+ */
+public class CraftIRCAdminEndPoint implements EndPoint {
+
+ private TweakcraftUtils plugin = null;
+ private ChatHandler ch = null;
+ private ChatMode cm = null;
+ private AdminChat ac = null;
+ private CraftIRC circ = null;
+
+ public CraftIRCAdminEndPoint(TweakcraftUtils instance) {
+ this.plugin = instance;
+ this.ch = instance.getChathandler();
+ circ = instance.getCraftIRC();
+ circ.registerEndPoint("tcutilsadmin", this);
+ // this.cm = ch.getChatMode("A")
+ try { this.ac = (AdminChat) ch.getChatMode("admin"); }
+ catch(ChatModeException ex) { }
+ }
+
+ @Override
+ public void messageIn(RelayedMessage relayedMessage) {
+ /* chat: '%grey%[IRC]%foreground% <%ircPrefix%%sender%> %message%'
+ private: '%grey%[IRC]%foreground% %sender% whispers> %message%'
+ action: '%grey%[IRC]%purple% * %ircPrefix%%sender% %message%'
+ join: '%grey%[IRC]%darkgreen% * Joins: %sender%'
+ part: '%grey%[IRC]%darkgreen% * Parts: %sender%'
+ quit: '%grey%[IRC]%blue% * Quits: %sender%'
+ kick: '%grey%[IRC]%darkgreen% * %sender% was kicked by %ircModPrefix%%moderator%'
+ nick: '%grey%[IRC]%darkgreen% * %sender% is now known as %message%'
+ generic: '%grey%%message%' */
+
+ String event = relayedMessage.getEvent();
+ if(event.equals("chat") || event.equals("action")) {
+ String pname = relayedMessage.getField("sender");
+ if(pname!=null) {
+ Player p = plugin.getServer().getPlayer(pname);
+ OfflinePlayer op = null;
+ boolean offline = p==null;
+ if(offline) {
+ op = plugin.getServer().getOfflinePlayer(pname);
+ }
+
+ boolean found = p!=null || op!=null;
+ if(found) {
+ World w = offline?plugin.getServer().getWorlds().get(0):p.getWorld();
+ String name = offline?op.getName():p.getName();
+ relayedMessage.setField("prefix", plugin.getPermissionHandler().getUserPrefix(w.getName(), name).replace('&', '§'));
+ relayedMessage.setField("suffix", plugin.getPermissionHandler().getUserSuffix(w.getName(), name).replace('&', '§'));
+ }
+ }
+ ac.broadcastMessage(relayedMessage.getMessage(this));
+ }
+
+ }
+
+ @Override
+ public Type getType() {
+ return EndPoint.Type.MINECRAFT;
+ }
+
+ @Override
+ public boolean userMessageIn(String s, RelayedMessage relayedMessage) {
+ return false;
+ }
+
+ @Override
+ public boolean adminMessageIn(RelayedMessage relayedMessage) {
+ return false;
+ }
+
+ @Override
+ public List<String> listUsers() {
+ return null;
+ }
+
+ @Override
+ public List<String> listDisplayUsers() {
+ return null;
+ }
+}
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011 GuntherDW
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package com.guntherdw.bukkit.tweakcraft.Packages;
+
+import com.ensifera.animosity.craftirc.CraftIRC;
+import com.ensifera.animosity.craftirc.EndPoint;
+import com.ensifera.animosity.craftirc.RelayedMessage;
+import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
+import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
+
+import java.util.List;
+
+/**
+ * @author GuntherDW
+ */
+public class CraftIRCEndPoint implements EndPoint {
+
+ private ChatHandler ch = null;
+ private CraftIRC circ = null;
+
+ public CraftIRCEndPoint(TweakcraftUtils instance) {
+ this.ch = instance.getChathandler();
+ this.circ = instance.getCraftIRC();
+ circ.registerEndPoint("tcutils", this);
+ }
+
+ @Override
+ public Type getType() {
+ return EndPoint.Type.MINECRAFT;
+ }
+
+ @Override
+ public void messageIn(RelayedMessage relayedMessage) {
+ /* chat: '%grey%[IRC]%foreground% <%ircPrefix%%sender%> %message%'
+ private: '%grey%[IRC]%foreground% %sender% whispers> %message%'
+ action: '%grey%[IRC]%purple% * %ircPrefix%%sender% %message%'
+ join: '%grey%[IRC]%darkgreen% * Joins: %sender%'
+ part: '%grey%[IRC]%darkgreen% * Parts: %sender%'
+ quit: '%grey%[IRC]%blue% * Quits: %sender%'
+ kick: '%grey%[IRC]%darkgreen% * %sender% was kicked by %ircModPrefix%%moderator%'
+ nick: '%grey%[IRC]%darkgreen% * %sender% is now known as %message%'
+ generic: '%grey%%message%' */
+
+ /* String event = relayedMessage.getEvent();
+ if(event.equals("chat") || event.equals("action")) {
+
+ } */
+ }
+
+ @Override
+ public boolean userMessageIn(String s, RelayedMessage relayedMessage) {
+ return false;
+ }
+
+ @Override
+ public boolean adminMessageIn(RelayedMessage relayedMessage) {
+ return false;
+ }
+
+ @Override
+ public List<String> listUsers() {
+ return null;
+ }
+
+ @Override
+ public List<String> listDisplayUsers() {
+ return null;
+ }
+}
Oops, something went wrong.

0 comments on commit 0a9127f

Please sign in to comment.