This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
516 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
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 = 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).voiceFriends(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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
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; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/cnaude/purpleirc/Commands/ListVoices.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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 = 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; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/cnaude/purpleirc/Commands/RemoveVoice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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 = 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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 = 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; | ||
} | ||
} |
Oops, something went wrong.