first commit

This commit is contained in:
BuildTools 2015-01-01 12:38:43 -07:00
commit b3f330c3d7
124 changed files with 16182 additions and 0 deletions

14
README.md Normal file
View File

@ -0,0 +1,14 @@
PurpleIRC
=========
PurpleIRC is a Minecraft Bukkit plugin that connects to IRC as a bot. It will relay messages between the game and IRC.
It uses the PircBotX API. https://code.google.com/p/pircbotx/
Latest dev build:
* http://cnaude.org/jenkins/job/PurpleIRC/lastSuccessfulBuild/
Live demo and chat:
* irc.esper.net - #PurpleIRC
BukkitDev:
* http://dev.bukkit.org/bukkit-plugins/purpleirc

424
pom.xml Executable file
View File

@ -0,0 +1,424 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Bukkit API Version, change if out dated -->
<bukkit.version>1.8</bukkit.version>
<build.number>SNAPSHOT</build.number>
</properties>
<groupId>com.cnaude</groupId>
<artifactId>PurpleIRC</artifactId>
<version>1.0-${build.number}</version>
<name>PurpleIRC-spigot</name>
<description>A CraftBukkit plugin for bridging game chat with IRC. Connect to any number of IRC servers and channels simultaneously.</description>
<url>http://dev.bukkit.org/server-mods/purpleirc/</url>
<repositories>
<!-- For anything else without its own repo -->
<repository>
<id>cnaude-repo</id>
<url>http://cnaude.org/repo/</url>
</repository>
<repository>
<id>sonatype-nexus-public</id>
<name>SonaType public snapshots and releases repository</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<releases>
<!-- set to true if you wish to fetch releases from this repo too. -->
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Bukkit -->
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- ReportRTS -->
<repository>
<id>regularbox-repo</id>
<url>http://ci.regularbox.com/plugin/repository/everything/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!-- Vault -->
<!--
<repository>
<id>vault-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository>
-->
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>spigot-api</artifactId>
<version>${bukkit.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>spigot</artifactId>
<version>${bukkit.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- Following dependency is provided by CraftBukkit -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- Essentials -->
<dependency>
<groupId>com.cnaude.essentials</groupId>
<artifactId>essentials</artifactId>
<version>2.14</version>
<type>jar</type>
</dependency>
<!-- ReportRTS -->
<dependency>
<groupId>com.nyancraft.reportrts</groupId>
<artifactId>ReportRTS</artifactId>
<version>1.2.3</version>
<exclusions>
<exclusion>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
</exclusion>
<exclusion>
<groupId>net.milkbowl.net</groupId>
<artifactId>Vault</artifactId>
</exclusion>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Vault -->
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.5.1</version>
</dependency>
<!-- Herochat -->
<dependency>
<groupId>com.cnaude.herochat</groupId>
<artifactId>Herochat</artifactId>
<version>5.6.7</version>
</dependency>
<!-- Jobs -->
<dependency>
<groupId>com.cnaude.jobs</groupId>
<artifactId>Jobs</artifactId>
<version>2.13.1</version>
</dependency>
<!-- Jobs -->
<dependency>
<groupId>com.cnaude.jobs</groupId>
<artifactId>JobsOld</artifactId>
<version>2.12.0</version>
</dependency>
<!-- Factions -->
<dependency>
<groupId>com.cnaude.factions</groupId>
<artifactId>Factions</artifactId>
<version>2.7.3</version>
</dependency>
<!-- OreBroadcast -->
<dependency>
<groupId>com.cnaude.orebroadcast</groupId>
<artifactId>OreBroadcast</artifactId>
<version>1.2.3</version>
</dependency>
<!-- RedditStream -->
<dependency>
<groupId>com.cnaude.RedditStream</groupId>
<artifactId>RedditStream</artifactId>
<version>0.2</version>
</dependency>
<!-- VanishNoPacket -->
<dependency>
<groupId>com.cnaude.vanishnopacket</groupId>
<artifactId>VanishNoPacket</artifactId>
<version>3.19.1</version>
</dependency>
<!-- mcore -->
<dependency>
<groupId>com.cnaude.mcore</groupId>
<artifactId>MassiveCore</artifactId>
<version>2.7.3</version>
</dependency>
<!-- FactionChat -->
<dependency>
<groupId>com.cnaude.factionchat</groupId>
<artifactId>FactionChat</artifactId>
<version>1.8.6</version>
</dependency>
<!-- TitanChat -->
<dependency>
<groupId>com.cnaude.titanchat</groupId>
<artifactId>TitanChat</artifactId>
<version>4.1</version>
</dependency>
<!-- mcMMO -->
<dependency>
<groupId>com.gmail.nossr50</groupId>
<artifactId>mcMMO</artifactId>
<version>1.5.01-SNAPSHOT-b3682</version>
</dependency>
<!-- Mulitverse-Core -->
<dependency>
<groupId>com.cnaude.multiverse</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>2.5</version>
</dependency>
<!-- Towny -->
<dependency>
<groupId>com.cnaude.townychat</groupId>
<artifactId>TownyChat</artifactId>
<version>0.40</version>
</dependency>
<!-- Towny -->
<dependency>
<groupId>com.cnaude.towny</groupId>
<artifactId>Towny</artifactId>
<version>0.84.0.0</version>
</dependency>
<!-- ProtocolLib -->
<dependency>
<groupId>com.cnaude.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>3.6.3</version>
</dependency>
<!-- PircBotX -->
<dependency>
<groupId>org.pircbotx</groupId>
<artifactId>pircbotx</artifactId>
<version>2.0.1</version>
</dependency>
<!-- CleverNotch -->
<dependency>
<groupId>com.cnaude.clevernotch</groupId>
<artifactId>CleverNotch</artifactId>
<version>1.1-RELEASE</version>
</dependency>
<!-- slf4j (used by PircBotX) -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.5</version>
</dependency>
<!-- DeathMessages -->
<dependency>
<groupId>com.cnaude.deathmessages</groupId>
<artifactId>DeathMessages</artifactId>
<version>2.9.1-SNAPSHOT</version>
</dependency>
<!-- Shortify -->
<dependency>
<groupId>com.cnaude.shortify</groupId>
<artifactId>Shortify</artifactId>
<version>1.8-SNAPSHOT</version>
</dependency>
<!-- DynmapAPI -->
<dependency>
<groupId>com.cnaude.dynmap</groupId>
<artifactId>DynmapAPI</artifactId>
<version>1.9.4</version>
</dependency>
<!-- Prism -->
<dependency>
<groupId>com.cnaude.prism</groupId>
<artifactId>Prism</artifactId>
<version>2.0.1</version>
</dependency>
<!-- AdminPrivateChat -->
<dependency>
<groupId>com.cnaude.adminprivatechat</groupId>
<artifactId>AdminPrivateChat</artifactId>
<version>2.1</version>
</dependency>
<!-- SuperVanish -->
<dependency>
<groupId>com.cnaude.supervanish</groupId>
<artifactId>SuperVanish</artifactId>
<version>5.0.1</version>
</dependency>
<!-- Testing only -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>junit-benchmarks</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Filter only plugin.yml -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<!-- Minimum Minecraft requirement -->
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>org.pircbotx</include>
<include>org.slf4j</include>
<include>org.apache.commons</include>
</includes>
</artifactSet>
<filters>
</filters>
<relocations>
<relocation>
<pattern>org.pircbotx</pattern>
<shadedPattern>org.pircbotx</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>org.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j.impl</pattern>
<shadedPattern>org.slf4j.impl</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.lang3</pattern>
<shadedPattern>org.apache.commons.lang3</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy file="../${project.name}/target/PurpleIRC-${project.version}.jar" tofile="../${project.name}/target/PurpleIRC.jar"/>
<exec dir="../${project.name}/target" executable="scp">
<arg line="PurpleIRC.jar cnaude@h.cnaude.org:spigottest/plugins/PurpleIRC.jar"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>stage-repo</id>
<url>file://${basedir}/../repo/releases</url>
</repository>
<snapshotRepository>
<id>stage-repo-stapshots</id>
<url>file://${basedir}/../repo/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc;
import org.bukkit.scheduler.BukkitTask;
/** This thread checks each bot for connectivity and reconnects when appropriate.
*
* @author Chris Naude
*
*/
public class BotWatcher {
private final PurpleIRC plugin;
private final BukkitTask bt;
/**
*
* @param plugin
*/
public BotWatcher(final PurpleIRC plugin) {
this.plugin = plugin;
bt = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
@Override
public void run() {
//plugin.logDebug("Checking connection status of IRC bots.");
for (PurpleBot ircBot : plugin.ircBots.values()) {
if (ircBot.isConnectedBlocking()) {
//plugin.logDebug("[" + ircBot.botNick + "] CONNECTED");
ircBot.setConnected(true);
} else {
ircBot.setConnected(false);
if (ircBot.autoConnect) {
plugin.logInfo("[" + ircBot.botNick + "] NOT CONNECTED");
ircBot.reload();
}
}
}
}
}, plugin.ircConnCheckInterval, plugin.ircConnCheckInterval);
}
/**
*
*/
public void cancel() {
bt.cancel();
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc;
import org.bukkit.scheduler.BukkitTask;
/**
*
* @author Chris Naude This thread checks each for users and updates the
* internal lists.
*/
public class ChannelWatcher {
private final PurpleIRC plugin;
private final BukkitTask bt;
/**
*
* @param plugin
*/
public ChannelWatcher(final PurpleIRC plugin) {
this.plugin = plugin;
bt = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
@Override
public void run() {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.updateNickList();
}
}
}, plugin.ircChannelCheckInterval, plugin.ircChannelCheckInterval);
}
/**
*
*/
public void cancel() {
bt.cancel();
}
}

View File

@ -0,0 +1,126 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc;
import com.cnaude.purpleirc.Commands.*;
import com.google.common.base.Joiner;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class CommandHandlers implements CommandExecutor {
public HashMap<String, IRCCommandInterface> commands = new HashMap<>();
public ArrayList<String> sortedCommands = new ArrayList<>();
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public CommandHandlers(PurpleIRC plugin) {
this.plugin = plugin;
commands.put("addop", new AddOp(plugin));
commands.put("addvoice", new AddVoice(plugin));
commands.put("connect", new Connect(plugin));
commands.put("ctcp", new CTCP(plugin));
commands.put("deop", new DeOp(plugin));
commands.put("devoice", new DeVoice(plugin));
commands.put("debug", new Debug(plugin));
commands.put("disconnect", new Disconnect(plugin));
commands.put("join", new Join(plugin));
commands.put("kick", new Kick(plugin));
commands.put("leave", new Leave(plugin));
commands.put("list", new List(plugin));
commands.put("listbots", new ListBots(plugin));
commands.put("listops", new ListOps(plugin));
commands.put("listvoices", new ListVoices(plugin));
commands.put("login", new Login(plugin));
commands.put("load", new Load(plugin));
commands.put("messagedelay", new MessageDelay(plugin));
commands.put("msg", new Msg(plugin));
commands.put("motd", new Motd(plugin));
commands.put("mute", new Mute(plugin));
commands.put("mutelist", new MuteList(plugin));
commands.put("nick", new Nick(plugin));
commands.put("notice", new Notice(plugin));
commands.put("op", new Op(plugin));
commands.put("reload", new Reload(plugin));
commands.put("reloadbot", new ReloadBot(plugin));
commands.put("reloadbotconfig", new ReloadBotConfig(plugin));
commands.put("reloadbotconfigs", new ReloadBotConfigs(plugin));
commands.put("reloadbots", new ReloadBots(plugin));
commands.put("reloadconfig", new ReloadConfig(plugin));
commands.put("removeop", new RemoveOp(plugin));
commands.put("removevoice", new RemoveVoice(plugin));
commands.put("save", new Save(plugin));
commands.put("say", new Say(plugin));
commands.put("send", new Send(plugin));
commands.put("sendraw", new SendRaw(plugin));
commands.put("server", new Server(plugin));
commands.put("topic", new Topic(plugin));
commands.put("unmute", new UnMute(plugin));
commands.put("updatecheck", new UpdateCheck(plugin));
commands.put("unload", new Unload(plugin));
commands.put("voice", new Voice(plugin));
commands.put("whois", new Whois(plugin));
commands.put("help", new Help(plugin));
commands.put("test", new Test(plugin));
for (String s : commands.keySet()) {
sortedCommands.add(s);
}
Collections.sort(sortedCommands, Collator.getInstance());
plugin.logDebug("Commands enabled: " + Joiner.on(", ").join(sortedCommands));
}
/**
*
* @param sender
* @param cmd
* @param commandLabel
* @param args
* @return
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length >= 1) {
String subCmd = args[0].toLowerCase();
if (commands.containsKey(subCmd)) {
if (!sender.hasPermission("irc." + subCmd)) {
sender.sendMessage(plugin.noPermission);
return true;
}
commands.get(subCmd).dispatch(sender, args);
return true;
}
}
commands.get("help").dispatch(sender, args);
return true;
}
}

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc;
import com.cnaude.purpleirc.Events.IRCCommandEvent;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.bukkit.command.CommandException;
/**
*
* @author Chris Naude Poll the command queue and dispatch to Bukkit
*/
public class CommandQueueWatcher {
private final PurpleIRC plugin;
private int bt;
private final Queue<IRCCommand> queue = new ConcurrentLinkedQueue<>();
/**
*
* @param plugin
*/
public CommandQueueWatcher(final PurpleIRC plugin) {
this.plugin = plugin;
startWatcher();
}
private void startWatcher() {
plugin.logDebug("Starting command queue");
bt = this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, new Runnable() {
@Override
public void run() {
queueAndSend();
}
}, 0, 5);
}
private void queueAndSend() {
IRCCommand ircCommand = queue.poll();
if (ircCommand != null) {
try {
if (plugin.getServer().getVersion().contains("MC: 1.8")
&& plugin.getServer().getPluginCommand(ircCommand.getGameCommand()) == null) {
plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand());
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), ircCommand.getGameCommand());
} else {
plugin.logDebug("Dispatching command as IRCCommandSender: " + ircCommand.getGameCommand());
plugin.getServer().dispatchCommand(ircCommand.getIRCCommandSender(), ircCommand.getGameCommand());
}
} catch (CommandException ce) {
plugin.logError("Error running command: " + ce.getMessage());
}
plugin.getServer().getPluginManager().callEvent(new IRCCommandEvent(ircCommand));
}
}
public void cancel() {
this.plugin.getServer().getScheduler().cancelTask(bt);
}
public String clearQueue() {
int size = queue.size();
if (!queue.isEmpty()) {
queue.clear();
}
return "Elements removed from command queue: " + size;
}
/**
*
* @param command
*/
public void add(IRCCommand command) {
plugin.logDebug("Adding command to queue: " + command.getGameCommand());
queue.offer(command);
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.pircbotx.Channel;
import org.pircbotx.User;
/**
*
* @author cnaude
*/
public class AddOp implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user|mask]";
private final String desc = "Add IRC users to IRC auto op list.";
private final String name = "addop";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public AddOp(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 4) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
// #channel, user
String nick = args[3];
String mask = nick;
Channel channel = plugin.ircBots.get(bot).getChannel(channelName);
if (channel != null) {
for (User user : channel.getUsers()) {
if (user.getNick().equalsIgnoreCase(nick)) {
mask = "*!*" + user.getLogin() + "@" + user.getHostmask();
}
}
}
if (mask.split("[\\!\\@]", 3).length == 3) {
plugin.ircBots.get(bot).addOp(channelName, mask, sender);
plugin.ircBots.get(bot).opIrcUsers(channelName);
} else {
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
+ ChatColor.WHITE + mask);
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.pircbotx.Channel;
import org.pircbotx.User;
/**
*
* @author cnaude
*/
public class AddVoice implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user|mask]";
private final String desc = "Add IRC users to IRC auto voice list.";
private final String name = "addvoice";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public AddVoice(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 4) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
// #channel, user
String nick = args[3];
String mask = nick;
Channel channel = plugin.ircBots.get(bot).getChannel(channelName);
if (channel != null) {
for (User user : channel.getUsers()) {
if (user.getNick().equalsIgnoreCase(nick)) {
mask = "*!*" + user.getLogin() + "@" + user.getHostmask();
}
}
}
if (mask.split("[\\!\\@]", 3).length == 3) {
plugin.ircBots.get(bot).addVoice(channelName, mask, sender);
plugin.ircBots.get(bot).voiceIrcUsers(channelName);
} else {
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
+ ChatColor.WHITE + mask);
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,97 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class CTCP implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) [target] [command]";
private final String desc = "Send CTCP command to the user or channel.";
private final String name = "ctcp";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public CTCP(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 3) {
plugin.logDebug("Dispatching ctcp command...");
int msgIdx = 2;
String target;
java.util.List<PurpleBot> myBots = new ArrayList<PurpleBot>();
if (plugin.ircBots.containsKey(args[1])) {
myBots.add(plugin.ircBots.get(args[1]));
msgIdx = 3;
target = args[2];
} else {
myBots.addAll(plugin.ircBots.values());
target = args[1];
}
if (msgIdx == 3 && args.length <= 3) {
sender.sendMessage(fullUsage);
return;
}
for (PurpleBot ircBot : myBots) {
String msg = "";
for (int i = msgIdx; i < args.length; i++) {
msg = msg + " " + args[i];
}
ircBot.asyncCTCPCommand(target, msg.substring(1));
sender.sendMessage("Sent CTCP command \"" + msg.substring(1) + "\" to \"" + target + "\"");
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Connect implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot])";
private final String desc = "Connect to configured IRC server.";
private final String name = "connect";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Connect(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 1) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.asyncConnect(sender);
}
} else if (args.length == 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).asyncConnect(sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,93 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class DeOp implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel]) [user(s)]";
private final String desc = "De-op IRC user(s).";
private final String name = "deop";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public DeOp(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
BotsAndChannels bac;
int idx;
if (args.length >= 4) {
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
idx = 3;
} else if (args.length == 2) {
bac = new BotsAndChannels(plugin, sender);
idx = 1;
} else {
sender.sendMessage(fullUsage);
return;
}
if (bac.bot.size() > 0 && bac.channel.size() > 0) {
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
for (int i = idx; i < args.length; i++) {
plugin.ircBots.get(botName).deOp(channelName, args[i]);
sender.sendMessage("Removing operator status from "
+ ChatColor.WHITE + args[i]
+ ChatColor.RESET + " in "
+ ChatColor.WHITE + channelName);
}
}
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,93 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class DeVoice implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel]) [user(s)]";
private final String desc = "De-voice IRC user(s).";
private final String name = "devoice";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public DeVoice(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
BotsAndChannels bac;
int idx;
if (args.length >= 4) {
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
idx = 3;
} else if (args.length == 2) {
bac = new BotsAndChannels(plugin, sender);
idx = 1;
} else {
sender.sendMessage(fullUsage);
return;
}
if (bac.bot.size() > 0 && bac.channel.size() > 0) {
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
for (int i = idx; i < args.length; i++) {
plugin.ircBots.get(botName).deVoice(channelName, args[i]);
sender.sendMessage("Removing voice status from "
+ ChatColor.WHITE + args[i]
+ ChatColor.RESET + " in "
+ ChatColor.WHITE + channelName);
}
}
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Debug implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([t|f])";
private final String desc = "Enable or disable debug mode.";
private final String name = "debug";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Debug(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 1) {
sender.sendMessage(ChatColor.DARK_PURPLE + "Debug mode is currently "
+ ChatColor.WHITE + plugin.debugMode());
} else if (args.length == 2) {
if (args[1].startsWith("t")) {
plugin.debugMode(true);
} else if (args[1].startsWith("f")) {
plugin.debugMode(false);
} else {
sender.sendMessage(usage);
}
sender.sendMessage(ChatColor.DARK_PURPLE + "Debug mode is now "
+ ChatColor.WHITE + plugin.debugMode());
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Disconnect implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot])";
private final String desc = "Disconnect from IRC server.";
private final String name = "disconnect";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Disconnect(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 1) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.asyncQuit(sender);
}
} else if (args.length == 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).asyncQuit(sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Help implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([command])";
private final String desc = "Display help on a specific command or list all commands.";
private final String name = "help";
/**
*
* @param plugin
*/
public Help(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 2) {
String s = args[1];
if (plugin.commandHandlers.commands.containsKey(s)) {
sender.sendMessage(helpStringBuilder(
plugin.commandHandlers.commands.get(s).name(),
plugin.commandHandlers.commands.get(s).desc(),
plugin.commandHandlers.commands.get(s).usage()));
return;
} else {
sender.sendMessage(ChatColor.RED + "Invalid sub command: "
+ ChatColor.WHITE + s);
return;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&5-----[ &fPurpleIRC&5 - &f" + plugin.getServer().getPluginManager()
.getPlugin("PurpleIRC").getDescription().getVersion() + "&5 ]-----"));
for (String s : plugin.commandHandlers.sortedCommands) {
if (plugin.commandHandlers.commands.containsKey(s)) {
sender.sendMessage(helpStringBuilder(
plugin.commandHandlers.commands.get(s).name(),
plugin.commandHandlers.commands.get(s).desc(),
plugin.commandHandlers.commands.get(s).usage()));
}
}
}
private String helpStringBuilder(String n, String d, String u) {
return ChatColor.translateAlternateColorCodes('&', "&5/irc "
+ n + " &6" + u + " &f- " + d);
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public interface IRCCommandInterface {
void dispatch(CommandSender sender, String[] args);
String name();
String desc();
String usage();
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Join implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] ([password])";
private final String desc = "Join IRC channel.";
private final String name = "join";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Join(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 3) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
String password = "";
if (args.length >= 4) {
for (int i = 3; i < args.length; i++) {
password = password + " " + args[i];
}
}
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).asyncJoinChannel(channelName, password);
sender.sendMessage(ChatColor.WHITE + "Joining " + channelName + "...");
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Kick implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user(s)]";
private final String desc = "Kick user(s) from IRC channel.";
private final String name = "kick";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Kick(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 4) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
for (int i = 3; i < args.length; i++) {
// #channel, user
plugin.ircBots.get(bot).kick(channelName, args[3]);
sender.sendMessage(ChatColor.WHITE + "Kicking " + args[i] + " from " + channelName + "...");
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,95 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.pircbotx.Channel;
/**
*
* @author cnaude
*/
public class Leave implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel]";
private final String desc = "Leave IRC channel.";
private final String name = "leave";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Leave(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 3) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
String reason = "";
if (args.length >= 4) {
for (int i = 3; i < args.length; i++) {
reason = reason + " " + args[i];
}
}
if (plugin.ircBots.containsKey(bot)) {
if (plugin.ircBots.get(bot).isConnected()) {
for (Channel channel : plugin.ircBots.get(bot).getChannels()) {
if (channel.getName().equalsIgnoreCase(channelName)) {
channel.send().part(reason);
sender.sendMessage(ChatColor.WHITE + "Leaving " + channelName + "...");
return;
}
}
sender.sendMessage(ChatColor.WHITE + "Channel " + channelName + " is not valid.");
} else {
sender.sendMessage(ChatColor.RED + "Not connected.");
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class List implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel])";
private final String desc = "List users in IRC channel.";
private final String name = "list";
//private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public List(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 1) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.sendUserList(sender);
}
} else if (args.length > 1) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
PurpleBot ircBot = plugin.ircBots.get(bot);
if (args.length > 2) {
ircBot.sendUserList(sender, args[2]);
} else {
ircBot.sendUserList(sender);
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.pircbotx.Channel;
/**
*
* @author cnaude
*/
public class ListBots implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "";
private final String desc = "List IRC bots.";
private final String name = "listbots";
/**
*
* @param plugin
*/
public ListBots(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
sender.sendMessage(ChatColor.DARK_PURPLE + "-----[ " + ChatColor.WHITE + "IRC Bots"
+ ChatColor.DARK_PURPLE + " ]-----");
for (PurpleBot ircBot : plugin.ircBots.values()) {
sender.sendMessage(ChatColor.DARK_PURPLE + "* " + ChatColor.WHITE + ircBot.getFileName()
+ ChatColor.DARK_PURPLE + " [" + ChatColor.WHITE + ircBot.botNick + ChatColor.DARK_PURPLE + "]");
if (ircBot.isConnected()) {
for (Channel channel : ircBot.getChannels()) {
sender.sendMessage(ChatColor.DARK_PURPLE + " - " + ChatColor.WHITE + channel.getName());
}
} else {
sender.sendMessage(ChatColor.RED + "Not connected.");
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ListOps implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel]";
private final String desc = "List IRC user mask in auto-op list.";
private final String name = "listops";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public ListOps(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 3) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
if (plugin.ircBots.get(bot).opsList.containsKey(channelName)) {
sender.sendMessage(ChatColor.DARK_PURPLE + "-----[ " + ChatColor.WHITE + channelName
+ ChatColor.DARK_PURPLE + " - " + ChatColor.WHITE + "Auto Op Masks" + ChatColor.DARK_PURPLE + " ]-----");
for (String userMask : plugin.ircBots.get(bot).opsList.get(channelName)) {
sender.sendMessage(" - " + userMask);
}
} else {
sender.sendMessage(plugin.invalidChannel.replace("%CHANNEL%", channelName));
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ListVoices implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel]";
private final String desc = "List IRC user mask in auto-voice list.";
private final String name = "listvoices";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public ListVoices(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 3) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
if (plugin.ircBots.get(bot).voicesList.containsKey(channelName)) {
sender.sendMessage(ChatColor.DARK_PURPLE + "-----[ " + ChatColor.WHITE + channelName
+ ChatColor.DARK_PURPLE + " - " + ChatColor.WHITE + "Auto Voice Masks" + ChatColor.DARK_PURPLE + " ]-----");
for (String userMask : plugin.ircBots.get(bot).voicesList.get(channelName)) {
sender.sendMessage(" - " + userMask);
}
} else {
sender.sendMessage(plugin.invalidChannel.replace("%CHANNEL%", channelName));
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Load implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot]";
private final String desc = "Load a bot file.";
private final String name = "load";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Load(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
sender.sendMessage(ChatColor.RED + "Sorry that bot is already loaded. Try to unload it first.");
return;
}
File file = new File(plugin.botsFolder, bot);
if (file.exists()) {
sender.sendMessage(ChatColor.WHITE + "Loading " + bot + "...");
plugin.ircBots.put(file.getName(), new PurpleBot(file, plugin));
sender.sendMessage("Loaded bot: " + file.getName() + "[" + plugin.ircBots.get(file.getName()).botNick + "]");
} else {
sender.sendMessage(ChatColor.RED + "No such bot file: " + ChatColor.WHITE + bot);
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Login implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [login]";
private final String desc = "Change bot's IRC login name.";
private final String name = "login";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Login(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 3) {
String bot = plugin.botify(args[1]);
String login = args[2];
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).changeLogin(sender, login);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class MessageDelay implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [milliseconds]";
private final String desc = "Change IRC message delay.";
private final String name = "messagedelay";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public MessageDelay(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 3) {
if (args[2].matches("\\d+")) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
long delay = Long.parseLong(args[2]);
plugin.ircBots.get(bot).setIRCDelay(sender, delay);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
} else if (args.length == 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
sender.sendMessage(ChatColor.WHITE + "IRC message delay is currently "
+ plugin.ircBots.get(bot).getMessageDelay() + " ms.");
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.ArrayList;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Motd implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot])";
private final String desc = "Get server motd.";
private final String name = "motd";
/**
*
* @param plugin
*/
public Motd(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
java.util.List<PurpleBot> myBots = new ArrayList<PurpleBot>();
if (args.length >= 2) {
if (plugin.ircBots.containsKey(args[1])) {
myBots.add(plugin.ircBots.get(args[1]));
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", args[1]));
}
} else {
myBots.addAll(plugin.ircBots.values());
}
for (PurpleBot ircBot : myBots) {
String motd = ircBot.getMotd();
if (motd != null) {
sender.sendMessage(motd);
} else {
sender.sendMessage("No MOTD found.");
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,107 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class Msg implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) [user] [message]";
private final String desc = "Send a private message to an IRC user.";
private final String name = "msg";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Msg(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 3) {
plugin.logDebug("Dispatching msg command...");
int msgIdx = 2;
String nick;
java.util.List<PurpleBot> myBots = new ArrayList<>();
if (plugin.ircBots.containsKey(args[1])) {
myBots.add(plugin.ircBots.get(args[1]));
msgIdx = 3;
nick = args[2];
} else {
myBots.addAll(plugin.ircBots.values());
nick = args[1];
}
if (msgIdx == 3 && args.length <= 3) {
sender.sendMessage(fullUsage);
return;
}
for (PurpleBot ircBot : myBots) {
String msg = "";
final String template = plugin.getMsgTemplate(ircBot.botNick, "game-pchat-response");
for (int i = msgIdx; i < args.length; i++) {
msg = msg + " " + args[i];
}
if (sender instanceof Player) {
ircBot.msgPlayer((Player) sender, nick, msg.substring(1));
} else {
ircBot.consoleMsgPlayer(nick, msg.substring(1));
}
if (!template.isEmpty()) {
sender.sendMessage(plugin.tokenizer.msgChatResponseTokenizer(nick, msg.substring(1), template));
}
}
}
else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Mute implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel]) [user(s)]";
private final String desc = "Mute IRC user(s) in a channel.";
private final String name = "mute";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Mute(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
BotsAndChannels bac;
int idx;
if (args.length >= 4) {
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
idx = 3;
} else if (args.length == 2) {
bac = new BotsAndChannels(plugin, sender);
idx = 1;
} else {
sender.sendMessage(fullUsage);
return;
}
if (bac.bot.size() > 0 && bac.channel.size() > 0) {
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
for (int i = idx; i < args.length; i++) {
plugin.ircBots.get(botName).mute(channelName, sender, args[i]);
}
}
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class MuteList implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel])";
private final String desc = "List muted IRC user(s) for a channel.";
private final String name = "mutelist";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public MuteList(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
BotsAndChannels bac;
if (args.length >= 3) {
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
} else if (args.length == 1) {
bac = new BotsAndChannels(plugin, sender);
} else {
sender.sendMessage(fullUsage);
return;
}
if (bac.bot.size() > 0 && bac.channel.size() > 0) {
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
plugin.ircBots.get(botName).muteList(channelName, sender);
}
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Nick implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [nick]";
private final String desc = "Change bot's IRC nick.";
private final String name = "nick";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Nick(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 3) {
String bot = plugin.botify(args[1]);
String nick = args[2];
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).asyncChangeNick(sender, nick);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Notice implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) [target] [message]";
private final String desc = "Send notice message to the user or channel.";
private final String name = "notice";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Notice(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 3) {
plugin.logDebug("Dispatching notice command...");
int msgIdx = 2;
String target;
java.util.List<PurpleBot> myBots = new ArrayList<PurpleBot>();
if (plugin.ircBots.containsKey(args[1])) {
myBots.add(plugin.ircBots.get(args[1]));
msgIdx = 3;
target = args[2];
} else {
myBots.addAll(plugin.ircBots.values());
target = args[1];
}
if (msgIdx == 3 && args.length <= 3) {
sender.sendMessage(fullUsage);
return;
}
for (PurpleBot ircBot : myBots) {
String msg = "";
for (int i = msgIdx; i < args.length; i++) {
msg = msg + " " + args[i];
}
ircBot.asyncNotice(target, msg.substring(1));
sender.sendMessage("Sent notice message \"" + msg.substring(1) + "\" to \"" + target + "\"");
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Op implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user(s)]";
private final String desc = "Op an IRC user in a channel.";
private final String name = "op";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Op(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 4) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
for (int i = 3; i < args.length; i++) {
// #channel, user
plugin.ircBots.get(bot).op(channelName, args[i]);
sender.sendMessage("Giving operator status to "
+ ChatColor.WHITE + args[i]
+ ChatColor.RESET + " on "
+ ChatColor.WHITE + channelName);
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Reload implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "";
private final String desc = "Reload the plugin.";
private final String name = "reload";
/**
*
* @param plugin
*/
public Reload(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
sender.sendMessage("Disabling PurpleIRC...");
plugin.getServer().getPluginManager().disablePlugin(plugin);
sender.sendMessage("Enabling PurpleIRC...");
plugin.getServer().getPluginManager().enablePlugin(plugin);
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ReloadBot implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot]";
private final String desc = "Reload a bot.";
private final String name = "reloadbot";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public ReloadBot(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).reload(sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ReloadBotConfig implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot]";
private final String desc = "Reload a bot's configuration.";
private final String name = "reloadbotconfig";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public ReloadBotConfig(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).reloadConfig(sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ReloadBotConfigs implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "";
private final String desc = "Reload all bot configurations.";
private final String name = "reloadbotconfigs";
/**
*
* @param plugin
*/
public ReloadBotConfigs(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reloadConfig(sender);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ReloadBots implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "";
private final String desc = "Reload all bots.";
private final String name = "reloadbots";
/**
*
* @param plugin
*/
public ReloadBots(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reload(sender);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class ReloadConfig implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "";
private final String desc = "Reload PurpleIRC/config.yml.";
private final String name = "reloadconfig";
/**
*
* @param plugin
*/
public ReloadConfig(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
plugin.reloadMainConfig(sender);
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class RemoveOp implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user mask]";
private final String desc = "Remove a user mask from the auto-op list.";
private final String name = "removeop";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public RemoveOp(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 4) {
String bot = plugin.botify(args[1]);
String channel = args[2];
if (plugin.ircBots.containsKey(bot)) {
// #channel, user
plugin.ircBots.get(bot).removeOp(channel, args[3], sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class RemoveVoice implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user mask]";
private final String desc = "Remove a user mask from the auto-voice list.";
private final String name = "removevoice";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public RemoveVoice(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 4) {
String bot = plugin.botify(args[1]);
String channel = args[2];
if (plugin.ircBots.containsKey(bot)) {
// #channel, user
plugin.ircBots.get(bot).removeVoice(channel, args[3], sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Save implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot])";
private final String desc = "Save bot configuration.";
private final String name = "save";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Save(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 1) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.saveConfig(sender);
}
} else if (args.length >= 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
plugin.ircBots.get(bot).saveConfig(sender);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Say implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [message]";
private final String desc = "Make the bot speak.";
private final String name = "say";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Say(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 4) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
String msg = "";
for (int i = 3; i < args.length; i++) {
msg = msg + " " + args[i];
}
plugin.ircBots.get(bot).asyncIRCMessage(channelName, msg.substring(1));
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,110 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class Send implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel]) [message]";
private final String desc = "Send a message to an IRC channel.";
private final String name = "send";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Send(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 2) {
int msgIdx = 1;
String channelName = null;
List<PurpleBot> myBots = new ArrayList<PurpleBot>();
if (plugin.ircBots.containsKey(args[1])) {
myBots.add(plugin.ircBots.get(args[1]));
msgIdx = 2;
if (args.length >= 3) {
if (plugin.ircBots.get(args[1]).isValidChannel(args[2])) {
channelName = args[2];
}
}
} else {
myBots.addAll(plugin.ircBots.values());
}
for (PurpleBot ircBot : myBots) {
String msg = "";
for (int i = msgIdx; i < args.length; i++) {
msg = msg + " " + args[i];
}
if (channelName == null) {
for (String c : ircBot.botChannels) {
if (sender instanceof Player) {
ircBot.gameChat((Player) sender, c, msg.substring(1));
} else {
ircBot.consoleChat(c, msg.substring(1));
}
}
} else {
if (sender instanceof Player) {
ircBot.gameChat((Player) sender, channelName, msg.substring(1));
} else {
ircBot.consoleChat(channelName, msg.substring(1));
}
}
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class SendRaw implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) [message]";
private final String desc = "Send raw message to the IRC server.";
private final String name = "sendraw";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public SendRaw(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 2) {
int msgIdx = 1;
List<PurpleBot> myBots = new ArrayList<PurpleBot>();
if (plugin.ircBots.containsKey(args[1])) {
myBots.add(plugin.ircBots.get(args[1]));
msgIdx = 2;
} else {
myBots.addAll(plugin.ircBots.values());
}
for (PurpleBot ircBot : myBots) {
String msg = "";
for (int i = msgIdx; i < args.length; i++) {
msg = msg + " " + args[i];
}
plugin.logDebug("Sending raw message to the server: " + msg.substring(1));
ircBot.asyncRawlineNow(msg.substring(1));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Server implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [server] ([true|false])";
private final String desc = "Set IRC server hostname. Optionally set autoconnect.";
private final String name = "server";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Server(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 3) {
String bot = plugin.botify(args[1]);
String server = args[2];
if (plugin.ircBots.containsKey(bot)) {
if (args.length == 3) {
plugin.ircBots.get(bot).setServer(sender, server);
} else if (args.length == 4) {
plugin.ircBots.get(bot).setServer(sender, server, Boolean.parseBoolean(args[3]));
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Test implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[player name]";
private final String desc = "Testing various Vault methods.";
private final String name = "test";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Test(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
//irc test <username>
if (plugin.vaultHelpers == null) {
sender.sendMessage(ChatColor.RED + "Vault is no enabled!");
return;
}
if (plugin.debugMode()) {
if (args.length >= 2) {
String playername = args[1];
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Testing " + playername);
sender.sendMessage("getGroupPrefix : " + plugin.getGroupPrefix(plugin.defaultPlayerWorld, playername));
sender.sendMessage("getGroupSuffix : " + plugin.getGroupSuffix(plugin.defaultPlayerWorld, playername));
sender.sendMessage("getPlayerPrefix : " + plugin.getPlayerPrefix(plugin.defaultPlayerWorld, playername));
sender.sendMessage("getPlayerSuffix : " + plugin.getPlayerSuffix(plugin.defaultPlayerWorld, playername));
sender.sendMessage("getPlayerGroup : " + plugin.getPlayerGroup(plugin.defaultPlayerWorld, playername));
} else {
sender.sendMessage(fullUsage);
}
} else {
sender.sendMessage(ChatColor.RED + "Debug mode must enabled to use this feature.");
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Topic implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel]) ([topic])";
private final String desc = "Set, or get, IRC channel top";
private final String name = "topic";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Topic(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
BotsAndChannels bac;
int idx;
if (args.length >= 4) {
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
idx = 3;
} else if (args.length == 2) {
bac = new BotsAndChannels(plugin, sender);
idx = 1;
} else {
bac = new BotsAndChannels(plugin, sender);
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
sender.sendMessage(ChatColor.WHITE + "[" + ChatColor.DARK_PURPLE
+ botName + ChatColor.WHITE
+ "/" + ChatColor.DARK_PURPLE + channelName
+ ChatColor.WHITE + "]"
+ " Topic: " + plugin.ircBots.get(botName)
.channelTopic.get(channelName));
}
}
sender.sendMessage(fullUsage);
return;
}
if (bac.bot.size() > 0 && bac.channel.size() > 0) {
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
String topic = "";
for (int i = idx; i < args.length; i++) {
topic = topic + " " + args[i];
}
plugin.ircBots.get(botName).changeTopic(channelName,
topic.substring(1), sender);
}
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class UnMute implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) ([channel]) [user(s)]";
private final String desc = "Unmute IRC user(s) in a channel.";
private final String name = "unmute";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public UnMute(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
BotsAndChannels bac;
int idx;
if (args.length >= 4) {
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
idx = 3;
} else if (args.length == 2) {
bac = new BotsAndChannels(plugin, sender);
idx = 1;
} else {
sender.sendMessage(fullUsage);
return;
}
if (bac.bot.size() > 0 && bac.channel.size() > 0) {
for (String botName : bac.bot) {
for (String channelName : bac.channel) {
for (int i = idx; i < args.length; i++) {
plugin.ircBots.get(botName).unMute(channelName, sender, args[i]);
}
}
}
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Unload implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] (disable)";
private final String desc = "Unload the bot and optionally disable it.";
private final String name = "unload";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Unload(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 2) {
String bot = plugin.botify(args[1]);
if (plugin.ircBots.containsKey(bot)) {
sender.sendMessage(ChatColor.WHITE + "Unloading " + bot + "...");
plugin.ircBots.get(bot).quit();
plugin.ircBots.get(bot).saveConfig(plugin.getServer().getConsoleSender());
plugin.ircBots.remove(bot);
if (args.length >= 3) {
if (args[2].equalsIgnoreCase("disable")) {
sender.sendMessage(ChatColor.WHITE + "Renaming " + bot + " to " + bot + ".disabled");
File file = new File(plugin.botsFolder, bot);
file.renameTo(new File(plugin.botsFolder, bot + ".disabled"));
}
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class UpdateCheck implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[stable|dev]";
private final String desc = "Ceck for latest updates.";
private final String name = "updatecheck";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public UpdateCheck(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 2) {
String mode = args[1];
plugin.updateChecker.asyncUpdateCheck(sender, mode);
} else {
plugin.updateChecker.asyncUpdateCheck(sender, plugin.updateCheckerMode());
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Voice implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "[bot] [channel] [user(s)]";
private final String desc = "Voice an IRC user in a channel.";
private final String name = "voice";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Voice(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length >= 4) {
String bot = plugin.botify(args[1]);
String channelName = args[2];
if (plugin.ircBots.containsKey(bot)) {
for (int i = 3; i < args.length; i++) {
// #channel, user
plugin.ircBots.get(bot).voice(channelName, args[i]);
sender.sendMessage("Giving voice status to "
+ ChatColor.WHITE + args[i]
+ ChatColor.RESET + " on "
+ ChatColor.WHITE + channelName);
}
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Commands;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
/**
*
* @author cnaude
*/
public class Whois implements IRCCommandInterface {
private final PurpleIRC plugin;
private final String usage = "([bot]) [nick]";
private final String desc = "Get whois info for IRC user.";
private final String name = "whois";
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
/**
*
* @param plugin
*/
public Whois(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param sender
* @param args
*/
@Override
public void dispatch(CommandSender sender, String[] args) {
if (args.length == 2) {
String nick = args[1];
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.sendUserWhois(sender, nick);
}
} else if (args.length == 3) {
String bot = plugin.botify(args[1]);
String nick = args[2];
if (plugin.ircBots.containsKey(bot)) {
PurpleBot ircBot = plugin.ircBots.get(bot);
ircBot.sendUserWhois(sender, nick);
} else {
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", bot));
}
} else {
sender.sendMessage(fullUsage);
}
}
@Override
public String name() {
return name;
}
@Override
public String desc() {
return desc;
}
@Override
public String usage() {
return usage;
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Events;
import com.cnaude.purpleirc.IRCCommand;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
*
* @author cnaude
* Event listener for plugins that want to catch command events from PurpleIRC
*/
public class IRCCommandEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final IRCCommand ircCommand;
/**
*
* @param ircCommand
*/
public IRCCommandEvent(IRCCommand ircCommand) {
this.ircCommand = ircCommand;
}
/**
*
* @return
*/
public IRCCommand getIRCCommand() {
return this.ircCommand;
}
/**
*
* @return
*/
@Override
public HandlerList getHandlers() {
return handlers;
}
/**
*
* @return
*/
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.ammaraskar.adminonly.AdminChatEvent;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class AdminChatListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public AdminChatListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onAdminChatEvent(AdminChatEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.adminChat(event.getName(), event.getMessage(), event.getWorld());
}
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.dotGaming.Endain.CleverNotch.CleverEvent;
/**
*
* @author cnaude
*/
public class CleverNotchListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public CleverNotchListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onCleverEvent(CleverEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.cleverChat(event.getName(), event.getMessage());
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.TemplateName;
import com.gmail.josemanuelgassin.DeathMessages.DeathMessageEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class DeathMessagesListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public DeathMessagesListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onDeathMessageEvent(DeathMessageEvent event) {
plugin.logDebug("onDeathMessageEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameDeath(event.getPlayer(), event.getDeathMessage(), TemplateName.DEATH_MESSAGES);
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.dynmap.DynmapWebChatEvent;
/**
*
* @author cnaude
*/
public class DynmapListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public DynmapListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onDynmapWebChatEvent(DynmapWebChatEvent event) {
String message = event.getMessage();
String name = event.getName();
String source = event.getSource();
plugin.logDebug("DynmapWebChat: " + source + " : " + name + ":" + message);
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.dynmapWebChat(source, name, message);
}
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import net.ess3.api.IUser;
import net.ess3.api.events.AfkStatusChangeEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class EssentialsListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public EssentialsListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onAfkStatusChangeEvent(AfkStatusChangeEvent event) {
IUser user = event.getAffected();
plugin.logDebug("AFK: " + user.getName() + ":" + user.isAfk());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.essentialsAFK(user.getBase(), !user.isAfk());
}
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
/**
*
* @author cnaude
*/
public class GamePlayerChatListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerChatListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
String message = event.getMessage();
plugin.logDebug("ChatFormat [" + event.isCancelled() + "]: " + event.getFormat());
if (message.startsWith("[[townytag]]")) {
event.setMessage(message.replace("[[townytag]]", ""));
plugin.logDebug("Ignoring due to townytag");
return;
}
event.setMessage(message.replace("[[townytag]]", ""));
if (event.isCancelled() && !plugin.isPluginEnabled("FactionChat") && !plugin.ignoreChatCancel) {
plugin.logDebug("Ignore chat message due to event cancellation: " + event.getMessage());
return;
}
if (event.getPlayer().hasPermission("irc.message.gamechat")) {
plugin.logDebug("Player " + event.getPlayer().getName() + " has permission irc.message.gamechat");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameChat(event.getPlayer(), event.getMessage());
}
} else {
plugin.logDebug("Player " + event.getPlayer().getName() + " does not have irc.message.gamechat permission.");
}
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
/**
*
* @author cnaude
*/
public class GamePlayerCommandPreprocessingListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerCommandPreprocessingListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
return;
}
String msg = event.getMessage();
if (event.getPlayer().hasPermission("irc.message.gamechat")) {
if (msg.startsWith("/me ")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameAction(event.getPlayer(), msg.replace("/me", ""));
}
} else if (msg.startsWith("/broadcast ")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameBroadcast(event.getPlayer(), msg.replace("/broadcast", ""));
}
}
}
if (plugin.isPluginEnabled("Essentials")) {
if (msg.startsWith("/helpop ") || msg.startsWith("/amsg ") || msg.startsWith("/ac ")) {
if (msg.contains(" ")) {
String message = msg.split(" ", 2)[1];
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.essHelpOp(event.getPlayer(), message);
}
}
}
}
for (PurpleBot ircBot : plugin.ircBots.values()) {
if (msg.startsWith("/")) {
String cmd;
String params = "";
if (msg.contains(" ")) {
cmd = msg.split(" ", 2)[0];
params = msg.split(" ", 2)[1];
} else {
cmd = msg;
}
cmd = cmd.substring(0);
if (ircBot.channelCmdNotifyEnabled && !ircBot.channelCmdNotifyIgnore.contains(cmd)) {
ircBot.commandNotify(event.getPlayer(), cmd, params);
}
}
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.TemplateName;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
/**
*
* @author cnaude
*/
public class GamePlayerDeathListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerDeathListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeathEvent(PlayerDeathEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameDeath((Player) event.getEntity(),
event.getDeathMessage(), TemplateName.GAME_DEATH);
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
/**
*
* @author cnaude
*/
public class GamePlayerGameModeChangeListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerGameModeChangeListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerGameModeChangeEvent(PlayerGameModeChangeEvent event) {
plugin.logDebug("GAMEMODE: " + event.getPlayer().getName() + " => " + event.getNewGameMode());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameModeChange(event.getPlayer(), event.getNewGameMode());
}
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
/**
*
* @author cnaude
*/
public class GamePlayerJoinListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerJoinListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoinEvent(final PlayerJoinEvent event) {
plugin.logDebug("PlayerJoinEvent: " + event.getPlayer().getDisplayName()
+ ": " + event.getPlayer().getCustomName());
if (plugin.kickedPlayers.contains(event.getPlayer().getName())) {
plugin.kickedPlayers.remove(event.getPlayer().getName());
plugin.logDebug("Removing player " + event.getPlayer().getName() + " from the recently kicked list.");
}
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.clearHostCache(event.getPlayer());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameJoin(event.getPlayer(), event.getJoinMessage());
if (plugin.netPackets != null) {
plugin.netPackets.updateTabList(event.getPlayer());
}
}
plugin.updateDisplayNameCache(event.getPlayer());
plugin.updateUuidCache(event.getPlayer());
}
}, 20);
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerKickEvent;
/**
*
* @author cnaude
*/
public class GamePlayerKickListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerKickListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerKickEvent(PlayerKickEvent event) {
plugin.logDebug("KICK: " + event.getPlayer().getName());
if (!plugin.kickedPlayers.contains(event.getPlayer().getName())) {
plugin.kickedPlayers.add(event.getPlayer().getName());
}
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameKick(event.getPlayer(), event.getLeaveMessage(), event.getReason());
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerAchievementAwardedEvent;
/**
*
* @author cnaude
*/
public class GamePlayerPlayerAchievementAwardedListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerPlayerAchievementAwardedListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerAchievementAwardedEvent(PlayerAchievementAwardedEvent event) {
plugin.logDebug("ACHIEVEMENT: " + event.getPlayer().getName() + " => " + event.getAchievement());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameAchievement(event.getPlayer(), event.getAchievement());
}
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
/**
*
* @author cnaude
*/
public class GamePlayerQuitListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GamePlayerQuitListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerQuitEvent(PlayerQuitEvent event) {
plugin.logDebug("QUIT: " + event.getPlayer().getName());
if (plugin.kickedPlayers.contains(event.getPlayer().getName())) {
plugin.kickedPlayers.remove(event.getPlayer().getName());
plugin.logDebug("Player "
+ event.getPlayer().getName()
+ " was in the recently kicked list. Not sending quit message.");
return;
}
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameQuit(event.getPlayer(), event.getQuitMessage());
if (plugin.netPackets != null) {
plugin.netPackets.updateTabList(event.getPlayer());
}
}
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent;
/**
*
* @author cnaude
*/
public class GameServerCommandListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public GameServerCommandListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.NORMAL)
public void onServerCommandEvent(ServerCommandEvent event) {
String cmd = event.getCommand();
if (cmd.startsWith("say ")) {
String msg = cmd.split(" ", 2)[1];
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.consoleChat(msg);
}
} else if (cmd.startsWith("broadcast ")) {
String msg = cmd.split(" ", 2)[1];
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.consoleBroadcast(msg);
}
} else {
//plugin.logDebug("Invalid CE: " + cmd);
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.Chatter;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class HeroChatListener implements Listener {
final PurpleIRC plugin;
/**
*
* @param plugin
*/
public HeroChatListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onChannelChatEvent(ChannelChatEvent event) {
Chatter chatter = event.getSender();
plugin.logDebug("HC Format: " + event.getFormat());
ChatColor chatColor = event.getChannel().getColor();
Player player = chatter.getPlayer();
if (player.hasPermission("irc.message.gamechat")
&& chatter.getChannels().contains(event.getChannel())) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
if (plugin.heroChatEmoteFormat.equals(event.getFormat())) {
plugin.logDebug("HC Emote: TRUE");
ircBot.heroAction(chatter, chatColor, event.getMessage());
} else {
plugin.logDebug("HC Emote: FALSE");
ircBot.heroChat(chatter, chatColor, event.getMessage());
}
}
}
}
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class McMMOChatListener implements Listener {
final PurpleIRC plugin;
public McMMOChatListener(PurpleIRC plugin) {
this.plugin = plugin;
}
@EventHandler
public void onMcMMOChatEvent(McMMOChatEvent event) {
event.setMessage(event.getMessage().replace("[[townytag]]", ""));
String sender = event.getSender();
Player player = plugin.getServer().getPlayer(sender);
plugin.logDebug("McMMOChatEvent caught: " + sender);
if (player != null && !sender.isEmpty()) {
if (player.hasPermission("irc.message.gamechat")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.mcMMOChat(player, event.getMessage());
}
}
}
}
@EventHandler
public void onMcMMOAdminChatEvent(McMMOAdminChatEvent event) {
event.setMessage(event.getMessage().replace("[[townytag]]", ""));
String sender = event.getSender();
Player player = plugin.getServer().getPlayer(sender);
plugin.logDebug("McMMOAdminChatEvent caught: " + sender);
if (player != null && !sender.isEmpty()) {
if (player.hasPermission("irc.message.gamechat")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.mcMMOAdminChat(player, event.getMessage());
}
}
}
}
@EventHandler
public void onMcMMOPartyChatEvent(McMMOPartyChatEvent event) {
event.setMessage(event.getMessage().replace("[[townytag]]", ""));
String sender = event.getSender();
Player player = plugin.getServer().getPlayer(sender);
String party = event.getParty();
plugin.logDebug("onMcMMOPartyChatEvent caught: " + sender);
if (player != null && !sender.isEmpty()) {
if (player.hasPermission("irc.message.gamechat")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.mcMMOPartyChat(player, party, event.getMessage());
}
}
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import be.bendem.orebroadcast.OreBroadcastEvent;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class OreBroadcastListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public OreBroadcastListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onOreBroadcastEvent(OreBroadcastEvent event) {
plugin.logDebug("onOreBroadcastEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameOreBroadcast(event.getPlayer(), event.getMessage());
}
}
}

View File

@ -0,0 +1,93 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.TemplateName;
import me.botsko.prism.events.PrismBlocksDrainEvent;
import me.botsko.prism.events.PrismBlocksExtinguishEvent;
import me.botsko.prism.events.PrismBlocksRollbackEvent;
import me.botsko.prism.events.PrismCustomPlayerActionEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class PrismListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public PrismListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onPrismBlocksRollbackEvent(PrismBlocksRollbackEvent event) {
plugin.logDebug("onPrismBlocksRollbackEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gamePrismRollback(event.onBehalfOf(), event.getQueryParameters(), event.getResult().getBlockStateChanges());
}
}
/**
*
* @param event
*/
@EventHandler
public void onPrismBlocksDrainEvent(PrismBlocksDrainEvent event) {
plugin.logDebug("onPrismBlocksDrainEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gamePrismDrainOrExtinguish(TemplateName.PRISM_DRAIN, event.onBehalfOf(), event.getRadius(), event.getBlockStateChanges());
}
}
/**
*
* @param event
*/
@EventHandler
public void onPrismBlocksExtinguishEvent(PrismBlocksExtinguishEvent event) {
plugin.logDebug("onPrismBlocksExtinguishEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gamePrismDrainOrExtinguish(TemplateName.PRISM_EXTINGUISH, event.onBehalfOf(), event.getRadius(), event.getBlockStateChanges());
}
}
/**
*
* @param event
*/
@EventHandler
public void onPrismCustomPlayerActionEvent(PrismCustomPlayerActionEvent event) {
plugin.logDebug("onPrismCustomPlayerActionEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gamePrismCustom(event.getPlayer(), event.getActionTypeName(),
event.getMessage(), event.getPluginName());
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import io.github.wolf_359.RedditBroadcastEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class RedditStreamListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public RedditStreamListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onRedditBroadcastEvent(RedditBroadcastEvent event) {
plugin.logDebug("onRedditBroadcastEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.redditStreamBroadcast(event.getMessage());
}
}
}

View File

@ -0,0 +1,115 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.nyancraft.reportrts.event.TicketAssignEvent;
import com.nyancraft.reportrts.event.TicketClaimEvent;
import com.nyancraft.reportrts.event.TicketCompleteEvent;
import com.nyancraft.reportrts.event.TicketCreateEvent;
import com.nyancraft.reportrts.event.TicketHoldEvent;
import com.nyancraft.reportrts.event.TicketBroadcastEvent;
import com.nyancraft.reportrts.event.TicketReopenEvent;
import com.nyancraft.reportrts.event.TicketUnclaimEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class ReportRTSListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public ReportRTSListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onTicketCreateEvent(TicketCreateEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-notify");
}
}
@EventHandler
public void onTicketCompleteEvent(TicketCompleteEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-complete");
}
}
@EventHandler
public void onTicketClaimEvent(TicketClaimEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-claim");
}
}
@EventHandler
public void onTicketUnclaimEvent(TicketUnclaimEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-unclaim");
}
}
@EventHandler
public void onTicketHoldEvent(TicketHoldEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-held");
}
}
@EventHandler
public void onTicketAssignEvent(TicketAssignEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-assign");
}
}
@EventHandler
public void onTicketReopenEvent(TicketReopenEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getTicket().getName(),
event.getTicket(), ircBot.botNick, "rts-reopen");
}
}
@EventHandler
public void onTicketBroadcastEvent(TicketBroadcastEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.reportRTSNotify(event.getSender(),
event.getMessage(), ircBot.botNick, "rts-modbroadcast");
}
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.titankingdoms.dev.titanchat.core.participant.Participant;
import com.titankingdoms.dev.titanchat.event.ChannelChatEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class TitanChatListener implements Listener {
final PurpleIRC plugin;
/**
*
* @param plugin
*/
public TitanChatListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onChannelChatEvent(ChannelChatEvent event) {
Participant participant = event.getSender();
Player player = plugin.getServer().getPlayer(participant.getName());
String tChannel = event.getChannel().getName();
String tColor = event.getChannel().getDisplayColour();
if (player.hasPermission("irc.message.gamechat")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.titanChat(participant, tChannel, tColor, event.getMessage());
}
}
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.palmergames.bukkit.TownyChat.channels.Channel;
import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author cnaude
*/
public class TownyChatListener implements Listener {
final PurpleIRC plugin;
public TownyChatListener(PurpleIRC plugin) {
this.plugin = plugin;
}
@EventHandler
public void onAsyncChatHookEvent(AsyncChatHookEvent event) {
if (event.getAsyncPlayerChatEvent().isCancelled()) {
plugin.logDebug("Ignore TC chat due to event is cancelled.");
return;
}
Channel townyChannel = event.getChannel();
plugin.logDebug("TC Format[1]: " + event.getFormat());
Player player = event.getPlayer();
if (player.hasPermission("irc.message.gamechat")) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.townyChat(player, townyChannel, event.getMessage());
}
}
event.getAsyncPlayerChatEvent().setMessage("[[townytag]]" + event.getMessage());
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.ammaraskar.adminonly.AdminChat;
import com.cnaude.purpleirc.PurpleIRC;
/**
*
* @author cnaude
*/
public class AdminPrivateChatHook {
private final PurpleIRC plugin;
private final AdminChat ac;
/**
*
* @param plugin
*/
public AdminPrivateChatHook(PurpleIRC plugin) {
this.plugin = plugin;
this.ac = (AdminChat) plugin.getServer().getPluginManager().getPlugin("AdminPrivateChat");
}
public void sendMessage(String message, String playername) {
plugin.logDebug("AdminPrivateChatHook: " + message);
ac.methods.MessageBuild(message, playername, "");
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import org.dynmap.DynmapCommonAPI;
/**
*
* @author cnaude
*/
public class DynmapHook {
private final PurpleIRC plugin;
private final DynmapCommonAPI dynmapAPI;
/**
*
* @param plugin
*/
public DynmapHook(PurpleIRC plugin) {
this.plugin = plugin;
this.dynmapAPI = (DynmapCommonAPI)plugin.getServer().getPluginManager().getPlugin("dynmap");
}
/**
*
* @param nick
* @param message
*/
public void sendMessage(String nick, String message) {
dynmapAPI.sendBroadcastToWeb(nick, message);
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import nz.co.lolnet.james137137.FactionChat.FactionChatAPI;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class FactionChatHook {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public FactionChatHook(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param player
* @return
*/
public String getChatMode(Player player) {
String playerChatMode = null;
try {
playerChatMode = FactionChatAPI.getChatMode(player);
plugin.logDebug("fcHook => [CM: " + playerChatMode + "] [" + player.getName() + "]");
} catch (Exception ex) {
plugin.logError("fcHook ERROR: " + ex.getMessage());
}
if (playerChatMode == null) {
playerChatMode = "unknown";
}
return playerChatMode.toLowerCase();
}
/**
*
* @param player
* @return
*/
public String getFactionName(Player player) {
String factionName = null;
try {
factionName = FactionChatAPI.getFactionName(player);
plugin.logDebug("fcHook => [FN: " + factionName + "] [" + player.getName() + "]");
} catch (Exception ex) {
plugin.logError("fcHook ERROR: " + ex.getMessage());
}
if (factionName == null) {
factionName = "unknown";
}
return factionName;
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.TemplateName;
import com.cnaude.purpleirc.PurpleIRC;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.PlayerManager;
import com.gamingmesh.jobs.container.Job;
import com.google.common.base.Joiner;
import java.util.ArrayList;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class JobsHook {
private final PurpleIRC plugin;
private PlayerManager playerManager = null;
/**
*
* @param plugin
*/
public JobsHook(PurpleIRC plugin) {
this.plugin = plugin;
try {
this.playerManager = Jobs.getPlayerManager();
} catch (Exception ex) {
plugin.logError("Jobs: " + ex.getMessage());
}
}
public String getPlayerJob(Player player, boolean shortName) {
if (playerManager == null) {
return "";
}
if (player != null) {
ArrayList<String> j = new ArrayList<>();
if (plugin.isPluginEnabled("Jobs")) {
for (Job job : Jobs.getJobs()) {
if (playerManager.getJobsPlayer(player).isInJob(job)) {
if (shortName) {
j.add(job.getShortName());
} else {
j.add(job.getName());
}
}
}
if (!j.isEmpty()) {
return Joiner.on(plugin.getMsgTemplate(TemplateName.JOBS_SEPARATOR)).join(j);
}
}
}
return "";
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.TemplateName;
import com.cnaude.purpleirc.PurpleIRC;
import com.google.common.base.Joiner;
import java.util.ArrayList;
import me.zford.jobs.Jobs;
import me.zford.jobs.PlayerManager;
import me.zford.jobs.container.Job;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class JobsHookOld {
private final PurpleIRC plugin;
private PlayerManager playerManager = null;
/**
*
* @param plugin
*/
public JobsHookOld(PurpleIRC plugin) {
this.plugin = plugin;
try {
this.playerManager = Jobs.getPlayerManager();
} catch (Exception ex) {
plugin.logError("Jobs: " + ex.getMessage());
}
}
public String getPlayerJob(Player player, boolean shortName) {
if (playerManager == null) {
return "";
}
if (player != null) {
ArrayList<String> j = new ArrayList<>();
if (plugin.isPluginEnabled("Jobs")) {
for (Job job : Jobs.getJobs()) {
if (playerManager.getJobsPlayer(player).isInJob(job)) {
if (shortName) {
j.add(job.getShortName());
} else {
j.add(job.getName());
}
}
}
if (!j.isEmpty()) {
return Joiner.on(plugin.getMsgTemplate(TemplateName.JOBS_SEPARATOR)).join(j);
}
}
}
return "";
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import com.nyancraft.reportrts.RTSFunctions;
import com.nyancraft.reportrts.util.Message;
/**
*
* @author cnaude
*/
public class ReportRTSHook {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public ReportRTSHook(PurpleIRC plugin) {
this.plugin = plugin;
}
public void modBroadcast(String name, String message) {
RTSFunctions.messageMods(Message.parse("broadcastMessage", name, message), false);
plugin.logDebug("RTSMB: " + message);
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import com.nullblock.vemacs.Shortify.common.CommonConfiguration;
import com.nullblock.vemacs.Shortify.common.Shortener;
import com.nullblock.vemacs.Shortify.common.ShortifyException;
import com.nullblock.vemacs.Shortify.util.ShortifyUtility;
import java.io.File;
/**
*
* @author cnaude
*/
public class ShortifyHook {
private final PurpleIRC plugin;
private final CommonConfiguration configuration;
private final Shortener shortener;
/**
*
* @param plugin
*/
public ShortifyHook(PurpleIRC plugin) {
this.plugin = plugin;
this.configuration = ShortifyUtility.loadCfg(new File("plugins/Shortify/config.yml"));
this.shortener = ShortifyUtility.getShortener(configuration);
}
public String shorten(String message) {
String m = message;
int minLength = 20;
plugin.logDebug("ShortifyBefore: " + m);
if (configuration != null) {
try {
minLength = Integer.valueOf(configuration.getString("minlength", "20"));
} catch (Exception ex) {
plugin.logError(ex.getMessage());
return message;
}
}
if (shortener != null) {
try {
m = ShortifyUtility.shortenAll(message, minLength, shortener, "");
} catch (ShortifyException ex) {
plugin.logError(ex.getMessage());
return message;
}
}
plugin.logDebug("ShortifyAfter: " + m);
return m;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import java.util.List;
import me.MyzelYam.SuperVanish.api.SVAPI;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class SuperVanishHook {
final PurpleIRC plugin;
/**
*
* @param plugin
*/
public SuperVanishHook(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param player
* @return
*/
public boolean isVanished(Player player) {
List<String> invisiblePlayers = SVAPI.getInvisiblePlayers();
for (String uuid : invisiblePlayers) {
if (uuid.equalsIgnoreCase(player.getUniqueId().toString())) {
plugin.logDebug("Player " + player.getName() + " is vanished.");
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import com.palmergames.bukkit.TownyChat.Chat;
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import java.util.ArrayList;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class TownyChatHook {
private final PurpleIRC plugin;
private final Chat chat;
private final ArrayList<channelTypes> townyChannelTypes;
/**
*
* @param plugin
*/
public TownyChatHook(PurpleIRC plugin) {
this.plugin = plugin;
chat = (Chat) plugin.getServer().getPluginManager().getPlugin("TownyChat");
townyChannelTypes = new ArrayList<channelTypes>();
townyChannelTypes.add(channelTypes.TOWN);
townyChannelTypes.add(channelTypes.GLOBAL);
townyChannelTypes.add(channelTypes.NATION);
townyChannelTypes.add(channelTypes.DEFAULT);
}
public String getTown(Player player) {
String town = "";
Resident resident;
try {
resident = TownyUniverse.getDataSource().getResident(player.getName());
} catch (NotRegisteredException ex) {
resident = null;
}
if (resident != null) {
try {
town = resident.getTown().getName();
} catch (NotRegisteredException ex) {
town = "";
}
}
return town;
}
public String getNation(Player player) {
String nation = "";
Resident resident;
try {
resident = TownyUniverse.getDataSource().getResident(player.getName());
} catch (NotRegisteredException ex) {
resident = null;
}
if (resident != null) {
try {
nation = resident.getTown().getNation().getName();
} catch (NotRegisteredException ex) {
nation = "";
}
}
return nation;
}
public String getTitle(Player player) {
Resident resident;
try {
resident = TownyUniverse.getDataSource().getResident(player.getName());
} catch (NotRegisteredException ex) {
resident = null;
}
String title = "";
if (resident != null) {
title = resident.getTitle();
}
return title;
}
public void sendMessage(String townyChannel, String message) {
plugin.logDebug("TownyChatHook called...");
for (Player player : plugin.getServer().getOnlinePlayers()) {
plugin.logDebug("P: " + player.getName());
for (channelTypes ct : townyChannelTypes) {
plugin.logDebug("CT: " + ct.name());
String townyChannelName = chat.getChannelsHandler().getActiveChannel(player, ct).getName();
if (townyChannel.equalsIgnoreCase(townyChannelName)) {
plugin.logDebug("TC ["+townyChannelName+"]: Sending message to " + player + ": " + message);
player.sendMessage(message);
break;
} else {
plugin.logDebug("TC "+townyChannelName+"]: invalid TC channel name for " + player);
}
}
}
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;
/**
*
* @author cnaude
*/
public class VanishHook {
final PurpleIRC plugin;
/**
*
* @param plugin
*/
public VanishHook(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param player
* @return
*/
public boolean isVanished(Player player) {
// Try SuperVanish first
if (plugin.superVanishHook != null) {
return plugin.superVanishHook.isVanished(player);
} else {
// Fallback to other Vanish
if (player.hasMetadata("vanished")) {
plugin.logDebug("Player " + player.getName() + " has vanished metadata.");
MetadataValue md = player.getMetadata("vanished").get(0);
if (md.asBoolean()) {
plugin.logDebug("Player " + player.getName() + " is vanished.");
return true;
} else {
plugin.logDebug("Player " + player.getName() + " is NOT vanished.");
}
} else {
plugin.logDebug("Player " + player.getName() + " has NO vanished metadata.");
}
}
return false;
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.plugin.RegisteredServiceProvider;
/**
*
* @author cnaude
*/
public class VaultHook {
final PurpleIRC plugin;
/**
*
*/
public Permission permission;
/**
*
*/
public Chat chat;
/**
*
* @param plugin
*/
public VaultHook(PurpleIRC plugin) {
this.plugin = plugin;
setupPermissions();
setupChat();
}
private void setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
}
}
private void setupChat() {
RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc;
/**
*
* @author cnaude
*/
public class IRCCommand {
final private IRCCommandSender sender;
final private String command;
/**
*
* @param sender
* @param command
*/
public IRCCommand(IRCCommandSender sender, String command) {
this.sender = sender;
this.command = command;
}
/**
*
* @return
*/
public IRCCommandSender getIRCCommandSender() {
return sender;
}
/**
*
* @return
*/
public String getGameCommand() {
return command;
}
}

View File

@ -0,0 +1,228 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
/**
*
* @author Chris Naude We have to implement our own CommandSender so that we can
* receive output from the command dispatcher.
*/
public class IRCCommandSender implements CommandSender {
private final PurpleBot ircBot;
private final String target;
private final PurpleIRC plugin;
private final boolean ctcpResponse;
/**
*
* @param message
*/
@Override
public void sendMessage(String message) {
plugin.logDebug("sendMessage: " + message);
addMessageToQueue(message);
}
/**
*
* @param messages
*/
@Override
public void sendMessage(String[] messages) {
for (String message : messages) {
plugin.logDebug("sendMessage[]: " + message);
addMessageToQueue(message);
}
}
private void addMessageToQueue(String message) {
ircBot.messageQueue.add(new IRCMessage(target,
plugin.colorConverter.gameColorsToIrc(message), ctcpResponse));
}
/**
*
* @param ircBot
* @param target
* @param plugin
* @param ctcpResponse
*/
public IRCCommandSender(PurpleBot ircBot, String target, PurpleIRC plugin, boolean ctcpResponse) {
super();
this.target = target;
this.ircBot = ircBot;
this.plugin = plugin;
this.ctcpResponse = ctcpResponse;
}
/**
*
* @return
*/
@Override
public Server getServer() {
return Bukkit.getServer();
}
/**
*
* @return
*/
@Override
public String getName() {
return "CONSOLE";
}
/**
*
* @return
*/
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
return null;
}
/**
*
* @param perm
* @return
*/
@Override
public boolean hasPermission(final String perm) {
return true;
}
/**
*
* @param arg0
* @return
*/
@Override
public boolean hasPermission(final Permission arg0) {
return true;
}
/**
*
* @param arg0
* @return
*/
@Override
public boolean isPermissionSet(final String arg0) {
return true;
}
/**
*
* @param arg0
* @return
*/
@Override
public boolean isPermissionSet(final Permission arg0) {
return true;
}
/**
*
*/
@Override
public void recalculatePermissions() {
}
/**
*
* @param arg0
*/
@Override
public void removeAttachment(final PermissionAttachment arg0) {
}
/**
*
* @return
*/
@Override
public boolean isOp() {
return true;
}
/**
*
* @param op
*/
@Override
public void setOp(final boolean op) {
}
/**
*
* @param arg0
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0) {
return null;
}
/**
*
* @param arg0
* @param arg1
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0, final int arg1) {
return null;
}
/**
*
* @param arg0
* @param arg1
* @param arg2
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0, final String arg1, final boolean arg2) {
return null;
}
/**
*
* @param arg0
* @param arg1
* @param arg2
* @param arg3
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0, final String arg1, final boolean arg2, final int arg3) {
return null;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ActionEvent;
/**
*
* @author cnaude
*/
public class ActionListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public ActionListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onAction(ActionEvent event) {
Channel channel = event.getChannel();
if (ircBot.isValidChannel(channel.getName())) {
ircBot.broadcastAction(event.getUser(), channel, event.getAction());
}
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.PircBotX;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ConnectEvent;
/**
*
* @author cnaude
*/
public class ConnectListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public ConnectListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onConnect(ConnectEvent event) {
PircBotX bot = event.getBot();
if (bot.getUserBot().getNick().isEmpty()) {
plugin.logError("Connected but bot nick is blank!");
} else {
ircBot.broadcastIRCConnect(ircBot.botNick);
if (ircBot.sendRawMessageOnConnect) {
plugin.logInfo("Sending raw message to server");
ircBot.asyncRawlineNow(ircBot.rawMessage);
}
}
ircBot.setConnected(true);
ircBot.autoJoinChannels();
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.DisconnectEvent;
/**
*
* @author cnaude
*/
public class DisconnectListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public DisconnectListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onDisconnect(DisconnectEvent event) {
ircBot.asyncQuit(false);
ircBot.broadcastIRCDisconnect(ircBot.botNick);
ircBot.setConnected(false);
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.JoinEvent;
/**
*
* @author cnaude
*/
public class JoinListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public JoinListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onJoin(JoinEvent event) {
Channel channel = event.getChannel();
String channelName = channel.getName();
User user = event.getUser();
if (!ircBot.isValidChannel(channel.getName())) {
plugin.logDebug("Invalid channel: " + channelName);
plugin.logDebug("Part if invalid: " + ircBot.partInvalidChannels);
plugin.logDebug("Nick: " + user.getNick());
if (user.getNick().equals(ircBot.botNick) && ircBot.partInvalidChannels) {
plugin.logInfo("Leaving invalid channel: " + channel.getName());
channel.send().part(ircBot.partInvalidChannelsMsg);
}
return;
}
ircBot.broadcastIRCJoin(user, channel);
ircBot.opIrcUser(channel, user);
ircBot.voiceIrcUser(channel, user);
ircBot.joinNotice(channel, user);
if (user.getNick().equals(ircBot.botNick)) {
plugin.logInfo("Joining channel: " + channelName);
plugin.logDebug("Setting channel modes: " + channelName + " => " + ircBot.channelModes.get(channel.getName()));
channel.send().setMode(ircBot.channelModes.get(channelName));
ircBot.fixTopic(channel, channel.getTopic(), channel.getTopicSetter());
ircBot.updateNickList(channel);
if (ircBot.msgOnJoin.containsKey(channelName) && ircBot.joinMsg.containsKey(channelName)) {
if (ircBot.msgOnJoin.get(channelName) && !ircBot.joinMsg.get(channelName).isEmpty()) {
plugin.logDebug("Sending on join message to IRC server: " + ircBot.joinMsg.get(channelName));
ircBot.asyncRawlineNow(ircBot.joinMsg.get(channelName));
}
}
}
if (plugin.netPackets != null) {
plugin.netPackets.addToTabList(user.getNick(), ircBot, channel);
}
}
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.KickEvent;
/**
*
* @author cnaude
*/
public class KickListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public KickListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onKick(KickEvent event) {
Channel channel = event.getChannel();
User recipient = event.getRecipient();
User user = event.getUser();
if (ircBot.isValidChannel(channel.getName())) {
ircBot.broadcastIRCKick(recipient, user, event.getReason(), channel);
if (plugin.netPackets != null) {
plugin.netPackets.remFromTabList(recipient.getNick());
}
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.MessageEvent;
/**
*
* @author cnaude
*/
public class MessageListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public MessageListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onMessage(MessageEvent event) {
String message = event.getMessage();
Channel channel = event.getChannel();
User user = event.getUser();
plugin.logDebug("Message caught <" + user.getNick() + ">: " + message);
if (plugin.shortifyHook != null && ircBot.isShortifyEnabled(channel.getName())) {
plugin.logDebug("Shortifying message (before): " + message);
message = plugin.shortifyHook.shorten(message);
plugin.logDebug("Shortifying message (after): " + message);
} else {
plugin.logDebug("Shortify: false");
}
if (ircBot.isValidChannel(channel.getName())) {
plugin.ircMessageHandler.processMessage(ircBot, user, channel, message, false);
}
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ModeEvent;
/**
*
* @author cnaude
*/
public class ModeListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public ModeListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onMode(ModeEvent event) {
Channel channel = event.getChannel();
String mode = event.getMode();
User user = event.getUser();
if (!ircBot.isValidChannel(channel.getName())) {
ircBot.broadcastIRCMode(user, mode, channel);
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.MotdEvent;
/**
*
* @author cnaude
*/
public class MotdListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public MotdListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onMotd(MotdEvent event) {
if (ircBot.showMOTD) {
plugin.logInfo(event.getMotd());
}
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.TemplateName;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.NickChangeEvent;
/**
*
* @author cnaude
*/
public class NickChangeListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public NickChangeListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onNickChange(NickChangeEvent event) {
String newNick = event.getNewNick();
String oldNick = event.getOldNick();
plugin.logDebug("OLD: " + oldNick);
plugin.logDebug("NEW: " + newNick);
for (String channelName : ircBot.channelNicks.keySet()) {
Channel channel = ircBot.getChannel(channelName);
if (channel != null) {
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.IRC_NICK_CHANGE)) {
plugin.getServer().broadcast(plugin.colorConverter.ircColorsToGame(
plugin.getMsgTemplate(ircBot.botNick, TemplateName.IRC_NICK_CHANGE)
.replace("%NEWNICK%", newNick)
.replace("%OLDNICK%", oldNick)
.replace("%CHANNEL%", channelName)), "irc.message.nickchange");
}
if (plugin.netPackets != null) {
plugin.netPackets.remFromTabList(oldNick);
plugin.netPackets.addToTabList(newNick, ircBot, channel);
}
if (ircBot.channelNicks.get(channelName).contains(oldNick)) {
ircBot.channelNicks.get(channelName).remove(oldNick);
plugin.logDebug("Removing " + oldNick);
}
ircBot.channelNicks.get(channelName).add(newNick);
plugin.logDebug("Adding " + newNick);
}
}
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.NoticeEvent;
/**
*
* @author cnaude
*/
public class NoticeListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public NoticeListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onNotice(NoticeEvent event) {
Channel channel = event.getChannel();
String message = event.getMessage();
String notice = event.getNotice();
User user = event.getUser();
plugin.logInfo("-" + user.getNick() + "-" + message);
if (channel != null) {
if (ircBot.isValidChannel(channel.getName())) {
ircBot.broadcastIRCNotice(user, message, notice, channel);
}
}
}
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2014 cnaude
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.IRCListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.PartEvent;
/**
*
* @author cnaude
*/
public class PartListener extends ListenerAdapter {
PurpleIRC plugin;
PurpleBot ircBot;
/**
*
* @param plugin
* @param ircBot
*/
public PartListener(PurpleIRC plugin, PurpleBot ircBot) {
this.plugin = plugin;
this.ircBot = ircBot;
}
/**
*
* @param event
*/
@Override
public void onPart(PartEvent event) {
Channel channel = event.getChannel();
User user = event.getUser();
if (ircBot.isValidChannel(channel.getName())) {
ircBot.broadcastIRCPart(user, channel);
if (plugin.netPackets != null) {
plugin.netPackets.remFromTabList(user.getNick());
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More