Made isUserSuperadmin simpler.

This commit is contained in:
Steven Lawson 2012-07-28 19:08:44 -04:00
parent f0679c4f61
commit 5838eb23ff
38 changed files with 75 additions and 43 deletions

View file

@ -1,5 +1,5 @@
#Sun, 22 Jul 2012 15:29:37 -0400
#Sat, 28 Jul 2012 15:17:23 -0400
program.VERSION=2.5
program.BUILDNUM=68
program.BUILDDATE=07/22/2012 03\:29 PM
program.BUILDNUM=77
program.BUILDDATE=07/28/2012 03\:17 PM

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sun Jul 22 15:29:37 EDT 2012
build.number=69
#Sat Jul 28 15:17:23 EDT 2012
build.number=78

View file

@ -16,7 +16,7 @@ public class Command_cage extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length == 0)
{

View file

@ -14,7 +14,7 @@ public class Command_cake extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
StringBuilder output = new StringBuilder();
Random randomGenerator = new Random();

View file

@ -34,7 +34,7 @@ public class Command_creative extends TFM_Command
}
else
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
try
{

View file

@ -13,7 +13,7 @@ public class Command_deopall extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (TFM_Util.isUserSuperadmin(sender, plugin) || senderIsConsole)
if (TFM_Util.isUserSuperadmin(sender) || senderIsConsole)
{
TFM_Util.bcastMsg(String.format("(%s: De-opping all players on server)", sender.getName()), ChatColor.YELLOW);

View file

@ -10,7 +10,7 @@ public class Command_ender extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.gotoWorld(sender, "the_end");
TFM_Util.gotoWorld(sender, server.getWorlds().get(0).getName() + "_the_end");
return true;
}
}

View file

@ -17,7 +17,7 @@ public class Command_expel extends TFM_Command
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
}
else if (TFM_Util.isUserSuperadmin(sender, plugin))
else if (TFM_Util.isUserSuperadmin(sender))
{
double radius = 50.0;
double strength = 100.0;

View file

@ -11,7 +11,7 @@ public class Command_explosives extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length == 0)
{

View file

@ -11,7 +11,7 @@ public class Command_fireplace extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -11,7 +11,7 @@ public class Command_firespread extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -11,7 +11,7 @@ public class Command_fluidspread extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -13,7 +13,7 @@ public class Command_fr extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length == 0)
{

View file

@ -18,7 +18,7 @@ public class Command_fuckoff extends TFM_Command
return true;
}
if (!TFM_Util.isUserSuperadmin(sender, plugin))
if (!TFM_Util.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;

View file

@ -20,7 +20,7 @@ public class Command_gadmin extends TFM_Command
String mode = args[0].toLowerCase();
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (mode.equals("list"))
{

View file

@ -12,7 +12,7 @@ public class Command_gcmd extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length < 2)
{

View file

@ -21,7 +21,7 @@ public class Command_glist extends TFM_Command
return false;
}
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length == 1)
{

View file

@ -19,7 +19,7 @@ public class Command_gtfo extends TFM_Command
return false;
}
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
Player p;
try

View file

@ -21,7 +21,7 @@ public class Command_kicknoob extends TFM_Command
for (Player p : server.getOnlinePlayers())
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
if (!TFM_Util.isUserSuperadmin(p))
{
p.kickPlayer("Disconnected by admin.");
}

View file

@ -11,7 +11,7 @@ public class Command_lavadmg extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -11,7 +11,7 @@ public class Command_lavaplace extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -10,7 +10,7 @@ public class Command_nether extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.gotoWorld(sender, "nether");
TFM_Util.gotoWorld(sender, server.getWorlds().get(0).getName() + "_nether");
return true;
}
}

View file

@ -13,7 +13,7 @@ public class Command_opall extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (TFM_Util.isUserSuperadmin(sender, plugin) || senderIsConsole)
if (TFM_Util.isUserSuperadmin(sender) || senderIsConsole)
{
TFM_Util.bcastMsg(String.format("(%s: Opping all players on server)", sender.getName()), ChatColor.YELLOW);

View file

@ -16,7 +16,7 @@ public class Command_opme extends TFM_Command
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
}
else if (TFM_Util.isUserSuperadmin(sender, plugin))
else if (TFM_Util.isUserSuperadmin(sender))
{
TFM_Util.bcastMsg(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY);
sender.setOp(true);

View file

@ -15,7 +15,7 @@ public class Command_orbit extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length == 0)
{

View file

@ -11,7 +11,7 @@ public class Command_prelog extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -17,7 +17,7 @@ public class Command_qdeop extends TFM_Command
return false;
}
if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
boolean matched_player = false;
for (Player p : server.matchPlayer(args[0]))

View file

@ -17,7 +17,7 @@ public class Command_qop extends TFM_Command
return false;
}
if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
boolean matched_player = false;
for (Player p : server.matchPlayer(args[0]))

View file

@ -19,7 +19,7 @@ public class Command_setspawnworld extends TFM_Command
return true;
}
if (!TFM_Util.isUserSuperadmin(sender, plugin))
if (!TFM_Util.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;

View file

@ -12,7 +12,7 @@ public class Command_stop extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
TFM_Util.bcastMsg("Server is going offline.", ChatColor.GRAY);

View file

@ -34,7 +34,7 @@ public class Command_survival extends TFM_Command
}
else
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
try
{

View file

@ -16,7 +16,7 @@ public class Command_tfbanlist extends TFM_Command
{
if (args[0].equalsIgnoreCase("purge"))
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
for (OfflinePlayer p : server.getBannedPlayers())
{

View file

@ -18,7 +18,7 @@ public class Command_tfipbanlist extends TFM_Command
{
if (args[0].equalsIgnoreCase("purge"))
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
for (String ip : server.getIPBans())
{

View file

@ -11,7 +11,7 @@ public class Command_waterplace extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args.length != 1)
{

View file

@ -12,7 +12,7 @@ public class Command_wildcard extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
{
if (args[0].equals("wildcard"))
{

View file

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@ -24,6 +25,7 @@ public class TFM_PlayerListener implements Listener
private final TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
private final Server server;
private static final Random randomGenerator = new Random();
public TFM_PlayerListener(TotalFreedomMod instance)
{
@ -178,7 +180,7 @@ public class TFM_PlayerListener implements Listener
boolean do_freeze = false;
if (TotalFreedomMod.allPlayersFrozen)
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
if (!TFM_Util.isUserSuperadmin(p))
{
do_freeze = true;
}
@ -236,6 +238,24 @@ public class TFM_PlayerListener implements Listener
}
}
// if (p.getItemInHand().getType() == Material.SPECKLED_MELON)
// {
// if (TFM_Util.isUserSuperadmin(p))
// {
// Location from_pos = event.getFrom().clone();
// Location to_pos = event.getTo().clone();
//
// /*
// Block block_pos = user_pos.clone().add(user_pos.getDirection().multiply(-2.0)).getBlock();
//
// if ((block_pos.isEmpty() || block_pos.isLiquid()))
// {
// block_pos.setTypeIdAndData(Material.WOOL.getId(), DyeColor.values()[randomGenerator.nextInt(DyeColor.values().length)].getData(), false);
// }
// */
// }
// }
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
{
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
@ -353,21 +373,21 @@ public class TFM_PlayerListener implements Listener
//Commands that will auto-kick the user:
if (Pattern.compile("^/stop").matcher(command).find())
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
if (!TFM_Util.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/reload").matcher(command).find())
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
if (!TFM_Util.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/save-").matcher(command).find())
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
if (!TFM_Util.isUserSuperadmin(p))
{
block_command = true;
}
@ -386,6 +406,11 @@ public class TFM_PlayerListener implements Listener
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
block_command = true;
}
else if (Pattern.compile("^/md").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.");
block_command = true;
}
}
if (block_command)

View file

@ -5,7 +5,8 @@ import org.bukkit.Server;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.weather.*;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
public class TFM_WeatherListener implements Listener
{

View file

@ -246,7 +246,13 @@ public class TFM_Util
}
}
@Deprecated
public static boolean isUserSuperadmin(CommandSender user, TotalFreedomMod tfm)
{
return isUserSuperadmin(user);
}
public static boolean isUserSuperadmin(CommandSender user)
{
try
{