Made it so console can use /potion when a target is specified.

This commit is contained in:
Steven Lawson 2012-09-23 19:00:45 -04:00
parent 054ce678f4
commit d0569c0243
4 changed files with 25 additions and 19 deletions

View File

@ -1,4 +1,4 @@
# Total Freedom Mod v2.4 Configuration # Total Freedom Mod v2.7 Configuration
# by Madgeek1450 # by Madgeek1450
# Block placement prevention: # Block placement prevention:

View File

@ -17,12 +17,6 @@ public class Command_potion extends TFM_Command
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if (senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
if (!sender.isOp()) if (!sender.isOp())
{ {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
@ -60,11 +54,19 @@ public class Command_potion extends TFM_Command
} }
} }
if (!target.equals(sender_p) && !TFM_Util.isUserSuperadmin(sender)) if (!target.equals(sender_p))
{
if (!TFM_Util.isUserSuperadmin(sender))
{ {
sender.sendMessage("Only superadmins can clear potion effects from other players."); sender.sendMessage("Only superadmins can clear potion effects from other players.");
return true; return true;
} }
}
else if (senderIsConsole)
{
sender.sendMessage("You must specify a target player when using this command from the console.");
return true;
}
for (PotionEffect potion_effect : target.getActivePotionEffects()) for (PotionEffect potion_effect : target.getActivePotionEffects())
{ {
@ -97,11 +99,19 @@ public class Command_potion extends TFM_Command
} }
} }
if (!target.equals(sender_p) && !TFM_Util.isUserSuperadmin(sender)) if (!target.equals(sender_p))
{
if (!TFM_Util.isUserSuperadmin(sender))
{ {
sender.sendMessage("Only superadmins can apply potion effects to other players."); sender.sendMessage("Only superadmins can apply potion effects to other players.");
return true; return true;
} }
}
else if (senderIsConsole)
{
sender.sendMessage("You must specify a target player when using this command from the console.");
return true;
}
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]); PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
if (potion_effect_type == null) if (potion_effect_type == null)

View File

@ -69,22 +69,17 @@ public class TFM_Util
public static void bcastMsg(String message, ChatColor color) public static void bcastMsg(String message, ChatColor color)
{ {
TFM_Log.info(message); TFM_Log.info(message, true);
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : Bukkit.getOnlinePlayers())
{ {
p.sendMessage(color + message); p.sendMessage((color == null ? "" : color) + message);
} }
} }
public static void bcastMsg(String message) public static void bcastMsg(String message)
{ {
TFM_Log.info(message); TFM_Util.bcastMsg(message, null);
for (Player p : Bukkit.getOnlinePlayers())
{
p.sendMessage(message);
}
} }
//JeromSar //JeromSar

View File

@ -262,6 +262,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage()); TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
} }
} }
public static List<String> permbanned_players = new ArrayList<String>(); public static List<String> permbanned_players = new ArrayList<String>();
public static List<String> permbanned_ips = new ArrayList<String>(); public static List<String> permbanned_ips = new ArrayList<String>();