mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 13:36:04 +01:00
New commands: ban, unban, addban, removeban, listbans
Improved addop and addvoice commands.
This commit is contained in:
parent
529ac427a1
commit
2c65df64bf
@ -44,8 +44,10 @@ public class CommandHandlers implements CommandExecutor {
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
commands.put("addban", new AddBan(plugin));
|
||||
commands.put("addop", new AddOp(plugin));
|
||||
commands.put("addvoice", new AddVoice(plugin));
|
||||
commands.put("ban", new Ban(plugin));
|
||||
commands.put("connect", new Connect(plugin));
|
||||
commands.put("ctcp", new CTCP(plugin));
|
||||
commands.put("deop", new DeOp(plugin));
|
||||
@ -61,6 +63,7 @@ public class CommandHandlers implements CommandExecutor {
|
||||
commands.put("list", new List(plugin));
|
||||
commands.put("listbots", new ListBots(plugin));
|
||||
commands.put("listops", new ListOps(plugin));
|
||||
commands.put("listbans", new ListBans(plugin));
|
||||
commands.put("listvoices", new ListVoices(plugin));
|
||||
commands.put("login", new Login(plugin));
|
||||
commands.put("load", new Load(plugin));
|
||||
@ -78,7 +81,8 @@ public class CommandHandlers implements CommandExecutor {
|
||||
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("removeban", new RemoveBan(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));
|
||||
@ -88,6 +92,7 @@ public class CommandHandlers implements CommandExecutor {
|
||||
commands.put("slist", new SList(plugin));
|
||||
commands.put("smsg", new SMsg(plugin));
|
||||
commands.put("topic", new Topic(plugin));
|
||||
commands.put("unban", new UnBan(plugin));
|
||||
commands.put("unmute", new UnMute(plugin));
|
||||
commands.put("updatecheck", new UpdateCheck(plugin));
|
||||
commands.put("unload", new Unload(plugin));
|
||||
|
109
src/main/java/com/cnaude/purpleirc/Commands/AddBan.java
Normal file
109
src/main/java/com/cnaude/purpleirc/Commands/AddBan.java
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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;
|
||||
import org.pircbotx.Channel;
|
||||
import org.pircbotx.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class AddBan implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "([bot]) ([channel]) [user|mask]";
|
||||
private final String desc = "Add IRC users to the ban list.";
|
||||
private final String name = "addban";
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public AddBan(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++) {
|
||||
|
||||
String nick = args[i];
|
||||
String mask = nick;
|
||||
Channel channel = plugin.ircBots.get(botName).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(botName).addBan(channelName, mask, sender);
|
||||
plugin.ircBots.get(botName).ban(channelName, mask);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
|
||||
+ ChatColor.WHITE + mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
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;
|
||||
import org.pircbotx.Channel;
|
||||
@ -29,7 +30,7 @@ import org.pircbotx.User;
|
||||
public class AddOp implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "[bot] [channel] [user|mask]";
|
||||
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;
|
||||
@ -49,34 +50,46 @@ public class AddOp implements IRCCommandInterface {
|
||||
*/
|
||||
@Override
|
||||
public void dispatch(CommandSender sender, String[] args) {
|
||||
if (args.length == 4) {
|
||||
String bot = 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();
|
||||
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++) {
|
||||
|
||||
String nick = args[i];
|
||||
String mask = nick;
|
||||
Channel channel = plugin.ircBots.get(botName).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(botName).addOp(channelName, mask, sender);
|
||||
plugin.ircBots.get(botName).opIrcUsers(channelName);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
|
||||
+ ChatColor.WHITE + mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
@ -93,4 +106,4 @@ public class AddOp implements IRCCommandInterface {
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
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;
|
||||
import org.pircbotx.Channel;
|
||||
@ -29,7 +30,7 @@ import org.pircbotx.User;
|
||||
public class AddVoice implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "[bot] [channel] [user|mask]";
|
||||
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;
|
||||
@ -49,33 +50,44 @@ public class AddVoice implements IRCCommandInterface {
|
||||
*/
|
||||
@Override
|
||||
public void dispatch(CommandSender sender, String[] args) {
|
||||
if (args.length == 4) {
|
||||
String bot = 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();
|
||||
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++) {
|
||||
|
||||
String nick = args[i];
|
||||
String mask = nick;
|
||||
Channel channel = plugin.ircBots.get(botName).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(botName).addVoice(channelName, mask, sender);
|
||||
plugin.ircBots.get(botName).voiceIrcUsers(channelName);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
|
||||
+ ChatColor.WHITE + mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,4 +105,4 @@ public class AddVoice implements IRCCommandInterface {
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
113
src/main/java/com/cnaude/purpleirc/Commands/Ban.java
Normal file
113
src/main/java/com/cnaude/purpleirc/Commands/Ban.java
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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;
|
||||
import org.pircbotx.Channel;
|
||||
import org.pircbotx.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class Ban implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "([bot]) ([channel]) [user(s)]";
|
||||
private final String desc = "Ban an IRC user from a channel.";
|
||||
private final String name = "ban";
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public Ban(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++) {
|
||||
|
||||
String nick = args[i];
|
||||
String mask = nick;
|
||||
Channel channel = plugin.ircBots.get(botName).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(botName).ban(channelName, mask);
|
||||
plugin.ircBots.get(botName).kick(channelName, nick, "Banned");
|
||||
sender.sendMessage("Setting +b for "
|
||||
+ ChatColor.WHITE + mask
|
||||
+ ChatColor.RESET + " on "
|
||||
+ ChatColor.WHITE + channelName);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
|
||||
+ ChatColor.WHITE + mask);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
94
src/main/java/com/cnaude/purpleirc/Commands/ListBans.java
Normal file
94
src/main/java/com/cnaude/purpleirc/Commands/ListBans.java
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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 ListBans implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "([bot]) ([channel])";
|
||||
private final String desc = "List IRC user mask in ban list.";
|
||||
private final String name = "listbans";
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public ListBans(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 >= 2) {
|
||||
bac = new BotsAndChannels(plugin, sender, args[1]);
|
||||
} 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) {
|
||||
if (plugin.ircBots.get(botName).banList.containsKey(channelName)) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "-----[ " + ChatColor.WHITE + channelName
|
||||
+ ChatColor.LIGHT_PURPLE + " - " + ChatColor.WHITE + "Ban Masks" + ChatColor.LIGHT_PURPLE + " ]-----");
|
||||
for (String userMask : plugin.ircBots.get(botName).banList.get(channelName)) {
|
||||
sender.sendMessage(" - " + userMask);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.invalidChannel.replace("%CHANNEL%", channelName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
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;
|
||||
|
||||
@ -27,10 +28,10 @@ import org.bukkit.command.CommandSender;
|
||||
public class ListOps implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "[bot] [channel]";
|
||||
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;
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -47,24 +48,32 @@ public class ListOps implements IRCCommandInterface {
|
||||
*/
|
||||
@Override
|
||||
public void dispatch(CommandSender sender, String[] args) {
|
||||
if (args.length == 3) {
|
||||
String bot = args[1];
|
||||
String channelName = args[2];
|
||||
if (plugin.ircBots.containsKey(bot)) {
|
||||
if (plugin.ircBots.get(bot).opsList.containsKey(channelName)) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "-----[ " + ChatColor.WHITE + channelName
|
||||
+ ChatColor.LIGHT_PURPLE + " - " + ChatColor.WHITE + "Auto Op Masks" + ChatColor.LIGHT_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));
|
||||
}
|
||||
BotsAndChannels bac;
|
||||
|
||||
if (args.length >= 3) {
|
||||
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
|
||||
} else if (args.length >= 2) {
|
||||
bac = new BotsAndChannels(plugin, sender, args[1]);
|
||||
} 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) {
|
||||
if (plugin.ircBots.get(botName).opsList.containsKey(channelName)) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "-----[ " + ChatColor.WHITE + channelName
|
||||
+ ChatColor.LIGHT_PURPLE + " - " + ChatColor.WHITE + "Auto Op Masks" + ChatColor.LIGHT_PURPLE + " ]-----");
|
||||
for (String userMask : plugin.ircBots.get(botName).opsList.get(channelName)) {
|
||||
sender.sendMessage(" - " + userMask);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.invalidChannel.replace("%CHANNEL%", channelName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
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;
|
||||
|
||||
@ -27,10 +28,10 @@ import org.bukkit.command.CommandSender;
|
||||
public class ListVoices implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "[bot] [channel]";
|
||||
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;
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -47,24 +48,30 @@ public class ListVoices implements IRCCommandInterface {
|
||||
*/
|
||||
@Override
|
||||
public void dispatch(CommandSender sender, String[] args) {
|
||||
if (args.length == 3) {
|
||||
String bot = args[1];
|
||||
String channelName = args[2];
|
||||
if (plugin.ircBots.containsKey(bot)) {
|
||||
if (plugin.ircBots.get(bot).voicesList.containsKey(channelName)) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "-----[ " + ChatColor.WHITE + channelName
|
||||
+ ChatColor.LIGHT_PURPLE + " - " + ChatColor.WHITE + "Auto Voice Masks" + ChatColor.LIGHT_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));
|
||||
}
|
||||
BotsAndChannels bac;
|
||||
|
||||
if (args.length >= 3) {
|
||||
bac = new BotsAndChannels(plugin, sender, args[1], args[2]);
|
||||
} else if (args.length >= 2) {
|
||||
bac = new BotsAndChannels(plugin, sender, args[1]);
|
||||
} 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) {
|
||||
if (plugin.ircBots.get(botName).voicesList.containsKey(channelName)) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "-----[ " + ChatColor.WHITE + channelName
|
||||
+ ChatColor.LIGHT_PURPLE + " - " + ChatColor.WHITE + "Auto Voice Masks" + ChatColor.LIGHT_PURPLE + " ]-----");
|
||||
for (String userMask : plugin.ircBots.get(botName).voicesList.get(channelName)) {
|
||||
sender.sendMessage(" - " + userMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
79
src/main/java/com/cnaude/purpleirc/Commands/RemoveBan.java
Normal file
79
src/main/java/com/cnaude/purpleirc/Commands/RemoveBan.java
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 RemoveBan implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "[bot] [channel] [user mask]";
|
||||
private final String desc = "Remove a user mask from the ban list.";
|
||||
private final String name = "removeban";
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public RemoveBan(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sender
|
||||
* @param args
|
||||
*/
|
||||
@Override
|
||||
public void dispatch(CommandSender sender, String[] args) {
|
||||
if (args.length == 4) {
|
||||
String bot = args[1];
|
||||
String channel = args[2];
|
||||
if (plugin.ircBots.containsKey(bot)) {
|
||||
// #channel, user
|
||||
plugin.ircBots.get(bot).removeBan(channel, args[3], sender);
|
||||
plugin.ircBots.get(bot).unBan(channel, 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;
|
||||
}
|
||||
}
|
93
src/main/java/com/cnaude/purpleirc/Commands/UnBan.java
Normal file
93
src/main/java/com/cnaude/purpleirc/Commands/UnBan.java
Normal 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 UnBan implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "([bot]) ([channel]) [user(s)]";
|
||||
private final String desc = "Unban IRC user(s).";
|
||||
private final String name = "unban";
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public UnBan(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).unBan(channelName, args[i]);
|
||||
sender.sendMessage("Setting -b for "
|
||||
+ ChatColor.WHITE + args[i]
|
||||
+ ChatColor.RESET + " on "
|
||||
+ ChatColor.WHITE + channelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
@ -147,6 +147,7 @@ public final class PurpleBot {
|
||||
public CaseInsensitiveMap<String> heroChannel;
|
||||
public CaseInsensitiveMap<String> townyChannel;
|
||||
public CaseInsensitiveMap<Collection<String>> opsList;
|
||||
public CaseInsensitiveMap<Collection<String>> banList;
|
||||
public CaseInsensitiveMap<Collection<String>> voicesList;
|
||||
public CaseInsensitiveMap<Collection<String>> worldList;
|
||||
public CaseInsensitiveMap<Collection<String>> muteList;
|
||||
@ -213,6 +214,7 @@ public final class PurpleBot {
|
||||
this.muteList = new CaseInsensitiveMap<>();
|
||||
this.worldList = new CaseInsensitiveMap<>();
|
||||
this.opsList = new CaseInsensitiveMap<>();
|
||||
this.banList = new CaseInsensitiveMap<>();
|
||||
this.voicesList = new CaseInsensitiveMap<>();
|
||||
this.heroChannel = new CaseInsensitiveMap<>();
|
||||
this.townyChannel = new CaseInsensitiveMap<>();
|
||||
@ -711,6 +713,7 @@ public final class PurpleBot {
|
||||
plugin.logDebug("Quit Message => " + quitMessage);
|
||||
botChannels.clear();
|
||||
opsList.clear();
|
||||
banList.clear();
|
||||
voicesList.clear();
|
||||
muteList.clear();
|
||||
enabledMessages.clear();
|
||||
@ -872,6 +875,19 @@ public final class PurpleBot {
|
||||
if (opsList.isEmpty()) {
|
||||
plugin.logInfo("No channel ops defined.");
|
||||
}
|
||||
|
||||
// build channel ban list
|
||||
Collection<String> cBans = new ArrayList<>();
|
||||
for (String channelBan : config.getStringList("channels." + enChannelName + ".banlist")) {
|
||||
if (!cBans.contains(channelBan)) {
|
||||
cBans.add(channelBan);
|
||||
}
|
||||
plugin.logDebug(" Channel Ban => " + channelBan);
|
||||
}
|
||||
banList.put(channelName, cBans);
|
||||
if (banList.isEmpty()) {
|
||||
plugin.logInfo("No channel bans defined.");
|
||||
}
|
||||
|
||||
// build channel voice list
|
||||
Collection<String> cVoices = new ArrayList<>();
|
||||
@ -1849,6 +1865,24 @@ public final class PurpleBot {
|
||||
}
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
* @param userMask
|
||||
* @param sender
|
||||
*/
|
||||
public void addBan(String channelName, String userMask, CommandSender sender) {
|
||||
if (banList.get(channelName).contains(userMask)) {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " is already in the ban list.");
|
||||
} else {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " has been added to the ban list.");
|
||||
banList.get(channelName).add(userMask);
|
||||
}
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1877,7 +1911,7 @@ public final class PurpleBot {
|
||||
public void removeOp(String channelName, String userMask, CommandSender sender) {
|
||||
if (opsList.get(channelName).contains(userMask)) {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " has been removed to the ops list.");
|
||||
+ ChatColor.RESET + " has been removed from the ops list.");
|
||||
opsList.get(channelName).remove(userMask);
|
||||
} else {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
@ -1885,6 +1919,24 @@ public final class PurpleBot {
|
||||
}
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
* @param userMask
|
||||
* @param sender
|
||||
*/
|
||||
public void removeBan(String channelName, String userMask, CommandSender sender) {
|
||||
if (banList.get(channelName).contains(userMask)) {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " has been removed from the ban list.");
|
||||
banList.get(channelName).remove(userMask);
|
||||
} else {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " is not in the ban list.");
|
||||
}
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".banlist", banList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1922,6 +1974,32 @@ public final class PurpleBot {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
* @param mask
|
||||
*/
|
||||
public void ban(String channelName, String mask) {
|
||||
Channel channel;
|
||||
channel = getChannel(channelName);
|
||||
if (channel != null) {
|
||||
channel.send().ban(mask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
* @param mask
|
||||
*/
|
||||
public void unBan(String channelName, String mask) {
|
||||
Channel channel;
|
||||
channel = getChannel(channelName);
|
||||
if (channel != null) {
|
||||
channel.send().unBan(mask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
@ -1993,6 +2071,25 @@ public final class PurpleBot {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
* @param nick
|
||||
* @param reason
|
||||
*/
|
||||
public void kick(String channelName, String nick, String reason) {
|
||||
Channel channel;
|
||||
channel = getChannel(channelName);
|
||||
if (channel != null) {
|
||||
for (User user : channel.getUsers()) {
|
||||
if (user.getNick().equals(nick)) {
|
||||
channel.send().kick(user, reason);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String encodeChannel(String s) {
|
||||
return s.replace(".", "%2E");
|
||||
@ -2366,6 +2463,26 @@ public final class PurpleBot {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channel
|
||||
* @param user
|
||||
*/
|
||||
public void banIrcUser(Channel channel, User user) {
|
||||
String channelName = channel.getName();
|
||||
if (user.getNick().equals(botNick)) {
|
||||
return;
|
||||
}
|
||||
for (String userMask : banList.get(channelName)) {
|
||||
if (checkUserMask(user, userMask)) {
|
||||
plugin.logInfo("Setting +b for " + userMask + " on " + channelName);
|
||||
ban(channelName, userMask);
|
||||
kick(channelName, user.getNick(), "Banned");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -832,10 +832,10 @@ public class PurpleIRC extends JavaPlugin {
|
||||
.replace("%COUNT%", Integer.toString(pl.count))
|
||||
.replace("%MAX%", Integer.toString(pl.max))
|
||||
.replace("%PLAYERS%", pl.list);
|
||||
|
||||
|
||||
return colorConverter.gameColorsToIrc(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ircBot
|
||||
@ -844,7 +844,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
*/
|
||||
public PlayerList getMCPlayerList(PurpleBot ircBot, String channelName) {
|
||||
PlayerList pl = new PlayerList();
|
||||
|
||||
|
||||
Map<String, String> playerList = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
if (ircBot.hideListWhenVanished.get(channelName)) {
|
||||
@ -868,15 +868,15 @@ public class PurpleIRC extends JavaPlugin {
|
||||
// sort without nick prefixes
|
||||
pList = Joiner.on(listSeparator).join(playerList.values());
|
||||
}
|
||||
|
||||
|
||||
pl.count = playerList.size();
|
||||
pl.max = getServer().getMaxPlayers();
|
||||
pl.list = pList;
|
||||
|
||||
|
||||
return pl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getRemotePlayers(String commandArgs) {
|
||||
if (commandArgs != null) {
|
||||
String host;
|
||||
|
@ -49,6 +49,23 @@ public class BotsAndChannels {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
* @param sender
|
||||
* @param botName
|
||||
*/
|
||||
public BotsAndChannels(PurpleIRC plugin, CommandSender sender, String botName) {
|
||||
if (plugin.ircBots.containsKey(botName)) {
|
||||
bot.add(botName);
|
||||
for (String channelName : plugin.ircBots.get(botName).botChannels) {
|
||||
channel.add(channelName);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.invalidBotName.replace("%BOT%", botName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
|
@ -122,4 +122,19 @@ permissions:
|
||||
default: true
|
||||
'irc.smsg':
|
||||
description: Gives player access to the /irc smsg command.
|
||||
default: true
|
||||
default: true
|
||||
'irc.addban':
|
||||
description: Gives player access to the /addban link command.
|
||||
default: op
|
||||
'irc.removeban':
|
||||
description: Gives player access to the /removeban link command.
|
||||
default: op
|
||||
'irc.ban':
|
||||
description: Gives player access to the /ban link command.
|
||||
default: op
|
||||
'irc.unban':
|
||||
description: Gives player access to the /unban link command.
|
||||
default: op
|
||||
'irc.listbans':
|
||||
description: Gives player access to the /listbans link command.
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user