-Make /saconfig clean a "Telnet Senior" command only.

-Move some TwitterBot stuff around.
This commit is contained in:
StevenLawson
2013-09-27 08:46:42 -04:00
parent 1e79b90249
commit 9f889efa76
5 changed files with 44 additions and 40 deletions

View File

@ -27,7 +27,7 @@ public class Command_saconfig extends TFM_Command
}
else
{
if (sender instanceof Player && !TFM_SuperadminList.isSeniorAdmin(sender))
if (!TFM_SuperadminList.isSeniorAdmin(sender, true))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -151,43 +151,11 @@ public class Command_saconfig extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
TFM_SuperadminList.removeSuperadmin(targetName);
if (!TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
{
return true;
}
// Twitterbot
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance();
String reply = twitterbot.delTwitter(targetName);
if ("ok".equals(reply))
if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
{
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from TwitterBot", true);
TFM_TwitterHandler.getInstance().delTwitterVerbose(targetName, sender);
}
else if ("disabled".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "TwitterBot has been temporarily disabled, please wait until it gets re-enabled", ChatColor.RED);
}
else if ("failed".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "There was a problem querying the database, please let a developer know.", ChatColor.RED);
}
else if ("false".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "There was a problem with the database, please let a developer know.", ChatColor.RED);
}
else if ("cannotauth".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "The database password is incorrect, please let a developer know.", ChatColor.RED);
}
else if ("notfound".equals(reply))
{
TFM_Util.playerMsg(sender, targetName + " did not have a twitter handle registered to their name.", ChatColor.GREEN);
}
}
else
{

View File

@ -428,6 +428,7 @@ public class TFM_SuperadminList
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
TFM_TwitterHandler.getInstance().delTwitter(superadmin.getName());
}
}
}

View File

@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class TFM_TwitterHandler
{
@ -30,6 +32,39 @@ public class TFM_TwitterHandler
return request("action=deltwitter&player=" + player);
}
public void delTwitterVerbose(String targetName, CommandSender sender)
{
final String reply = delTwitter(targetName);
if ("ok".equals(reply))
{
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from TwitterBot", true);
}
else if ("disabled".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "TwitterBot has been temporarily disabled, please wait until it gets re-enabled", ChatColor.RED);
}
else if ("failed".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "There was a problem querying the database, please let a developer know.", ChatColor.RED);
}
else if ("false".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "There was a problem with the database, please let a developer know.", ChatColor.RED);
}
else if ("cannotauth".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "The database password is incorrect, please let a developer know.", ChatColor.RED);
}
else if ("notfound".equals(reply))
{
TFM_Util.playerMsg(sender, targetName + " did not have a twitter handle registered to their name.", ChatColor.GREEN);
}
}
public String isEnabled()
{
return request("action=getstatus");