Added opall, deopall, and fixed listreal.

This commit is contained in:
Steven Lawson 2011-09-20 10:03:03 -04:00
parent 7757ac2097
commit 036b3322e0
2 changed files with 50 additions and 10 deletions

View File

@ -26,11 +26,11 @@ public class TotalFreedomMod extends JavaPlugin
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
Player player = null;
if (sender instanceof Player)
Player player = null;
if (sender instanceof Player)
{
player = (Player)sender;
}
}
if(cmd.getName().equalsIgnoreCase("opme"))
{
@ -40,7 +40,7 @@ public class TotalFreedomMod extends JavaPlugin
}
else
{
if (isUserSuperadmin(sender))
if (isUserSuperadmin(sender.getName()))
{
sender.setOp(true);
sender.sendMessage(ChatColor.YELLOW + "You are now op!");
@ -67,10 +67,13 @@ public class TotalFreedomMod extends JavaPlugin
boolean first = true;
for (Player p : Bukkit.getOnlinePlayers())
{
if (!first)
if (first)
{
first = false;
}
else
{
onlineUsers.append(", ");
first = false;
}
if (p.isOp())
{
@ -88,23 +91,54 @@ public class TotalFreedomMod extends JavaPlugin
}
else if(cmd.getName().equalsIgnoreCase("deopall"))
{
log.info("[Total Freedom Mod] - Got deopall command.");
if (isUserSuperadmin(sender.getName()) || player == null)
{
for (Player p : Bukkit.getOnlinePlayers())
{
if (!isUserSuperadmin(p.getName()) && !p.getName().equals(sender.getName()))
{
p.setOp(false);
}
}
log.log(Level.INFO, "[Total Freedom Mod]: {0} used deopall.", sender.getName());
Bukkit.broadcastMessage(ChatColor.YELLOW + sender.getName() + " de-op'd everyone on the server.");
}
else
{
sender.sendMessage(ChatColor.YELLOW + "You do not have permission to use this command.");
}
return true;
}
else if(cmd.getName().equalsIgnoreCase("opall"))
{
log.info("[Total Freedom Mod] - Got opall command.");
if (isUserSuperadmin(sender.getName()) || player == null)
{
for (Player p : Bukkit.getOnlinePlayers())
{
p.setOp(true);
}
log.log(Level.INFO, "[Total Freedom Mod]: {0} used opall.", sender.getName());
Bukkit.broadcastMessage(ChatColor.YELLOW + sender.getName() + " op'd everyone on the server.");
}
else
{
sender.sendMessage(ChatColor.YELLOW + "You do not have permission to use this command.");
}
return true;
}
return false;
}
private boolean isUserSuperadmin(CommandSender sender)
private boolean isUserSuperadmin(String userName)
{
return Arrays.asList(
"miwojedk",
"markbyron",
"madgeek1450"
).contains(sender.getName().toLowerCase());
).contains(userName.toLowerCase());
}
}

View File

@ -4,9 +4,15 @@ version: 1.0.0
description: Plugin for the Total Freedom server
author: StevenLawson / Madgeek1450
commands:
deopall:
description: Superadmin command - Deop everyone on the server.
usage: /<command>
listreal:
description: Lists the real names of all online players.
usage: /<command>
opall:
description: Superadmin command - Op everyone on the server.
usage: /<command>
opme:
description: Superadmin command - Automatically ops user.
usage: /<command>