Added /ops list

This commit is contained in:
Jerome van der Sar 2012-09-16 14:11:33 +02:00
parent 0de47783b9
commit 89cfbbcef8
9 changed files with 61 additions and 40 deletions

15
.gitignore vendored
View file

@ -1,5 +1,20 @@
# netbeans excludes (StevenLawson)
/nbproject/private/
/dist/
/build/
appinfo.properties
buildnumber.properties
# eclipse excludes (JeromSar)
.project
.classpath
/bin/
/.settings/
# OS generated files
.DS_Store
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

View file

@ -4,7 +4,10 @@ import org.bukkit.ChatColor;
public class CantFindPlayerException extends Exception
{
public CantFindPlayerException()
// apparently, java needs this
private static final long serialVersionUID = 1L;
public CantFindPlayerException()
{
super(ChatColor.GRAY + "Can't find player.");
}

View file

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -15,12 +14,34 @@ public class Command_ops extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 1)
if (!(senderIsConsole || sender.isOp()))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if (args.length < 1 || args.length > 1)
{
return false;
}
if (args[0].equalsIgnoreCase("list"))
{
String ops = "";
String delim = "";
for (OfflinePlayer p : server.getOperators()) {
ops += delim;
ops += p.getName();
delim = ",";
}
TFM_Util.playerMsg(sender, "Operators: " + ops);
if (args.length == 0 || args[0].equalsIgnoreCase("list"))
return true;
}
if (args[0].equalsIgnoreCase("count"))
{
int onlineOPs = 0;
int offlineOPs = 0;
@ -42,8 +63,11 @@ public class Command_ops extends TFM_Command
sender.sendMessage(ChatColor.GRAY + "Online OPs: " + onlineOPs);
sender.sendMessage(ChatColor.GRAY + "Offline OPs: " + offlineOPs);
sender.sendMessage(ChatColor.GRAY + "Total OPs: " + totalOPs);
return true;
}
else if (args[0].equalsIgnoreCase("purge"))
if (args[0].equalsIgnoreCase("purge"))
{
if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole))
{
@ -62,6 +86,8 @@ public class Command_ops extends TFM_Command
p.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
}
}
return true;
}
return true;

View file

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

View file

@ -16,12 +16,6 @@ import org.bukkit.inventory.ItemStack;
public class TFM_BlockListener implements Listener
{
private final TotalFreedomMod plugin;
public TFM_BlockListener(TotalFreedomMod instance)
{
this.plugin = instance;
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBurn(BlockBurnEvent event)

View file

@ -9,12 +9,6 @@ import org.bukkit.event.entity.*;
public class TFM_EntityListener implements Listener
{
private final TotalFreedomMod plugin;
public TFM_EntityListener(TotalFreedomMod instance)
{
this.plugin = instance;
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event)

View file

@ -25,13 +25,8 @@ import org.bukkit.util.Vector;
public class TFM_PlayerListener implements Listener
{
private final TotalFreedomMod plugin;
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
public TFM_PlayerListener(TotalFreedomMod instance)
{
this.plugin = instance;
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
@ -91,7 +86,7 @@ public class TFM_PlayerListener implements Listener
{
if (playerdata.toggleMP44Firing())
{
playerdata.startArrowShooter(plugin);
playerdata.startArrowShooter(TotalFreedomMod.plugin);
}
else
{
@ -494,7 +489,7 @@ public class TFM_PlayerListener implements Listener
{
final Player p = event.getPlayer();
TFM_UserList.getInstance(plugin).addUser(p);
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(p);
boolean superadmin_impostor = TFM_Util.isSuperadminImpostor(p);
@ -516,7 +511,7 @@ public class TFM_PlayerListener implements Listener
if (TotalFreedomMod.adminOnlyMode)
{
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
TotalFreedomMod.plugin.getServer().getScheduler().scheduleAsyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
{
@Override
public void run()
@ -534,10 +529,10 @@ public class TFM_PlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event)
{
//This should supercede all other onPlayerLogin authentication on the TFM server.
//This should supersede all other onPlayerLogin authentication on the TFM server.
//When using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication.
final Server server = plugin.getServer();
final Server server = TotalFreedomMod.plugin.getServer();
final ServerConfigurationManagerAbstract scm = MinecraftServer.getServer().getServerConfigurationManager();
final BanList banByIP = scm.getIPBans();
@ -595,7 +590,8 @@ public class TFM_PlayerListener implements Listener
boolean is_ip_banned = false;
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
@SuppressWarnings("rawtypes")
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
while (ip_bans.hasNext())
{
String test_ip = (String) ip_bans.next();

View file

@ -9,13 +9,7 @@ import org.bukkit.event.weather.WeatherChangeEvent;
public class TFM_WeatherListener implements Listener
{
private final TotalFreedomMod plugin;
public TFM_WeatherListener(TotalFreedomMod instance)
{
this.plugin = instance;
}
@EventHandler(priority = EventPriority.HIGH)
public void onThunderChange(ThunderChangeEvent event)
{

View file

@ -236,10 +236,10 @@ public class TotalFreedomMod extends JavaPlugin
{
PluginManager pm = server.getPluginManager();
pm.registerEvents(new TFM_EntityListener(this), this);
pm.registerEvents(new TFM_BlockListener(this), this);
pm.registerEvents(new TFM_PlayerListener(this), this);
pm.registerEvents(new TFM_WeatherListener(this), this);
pm.registerEvents(new TFM_EntityListener(), plugin);
pm.registerEvents(new TFM_BlockListener(), plugin);
pm.registerEvents(new TFM_PlayerListener(), plugin);
pm.registerEvents(new TFM_WeatherListener(), plugin);
}
private void setAppProperties()