This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
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
7 changed files
with
172 additions
and
14 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
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.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; | ||
} | ||
} |
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,71 @@ | ||
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; | ||
} | ||
} |
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
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