Moved all player messages to playerMsg()

Changes to /blockcmd
This commit is contained in:
Jerom van der Sar 2013-01-07 15:56:53 +01:00
parent f0ca909069
commit ac0dc43cd7
65 changed files with 271 additions and 208 deletions

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
@ -7,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = false)
public class Command_blockcommand extends TFM_Command
public class Command_blockcmd extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
@ -17,6 +18,23 @@ public class Command_blockcommand extends TFM_Command
return false;
}
if (args[0].equalsIgnoreCase("purge"))
{
TFM_Util.adminAction(sender.getName(), "Unblocking commands for all players", true);
int counter = 0;
for (Player p : server.getOnlinePlayers())
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
if (playerdata.allCommandsBlocked())
{
counter += 1;
playerdata.setCommandsBlocked(false);
}
playerMsg("Unblocked commands for " + counter + " players.");
}
return true;
}
Player p;
try
{
@ -24,7 +42,13 @@ public class Command_blockcommand extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage());
return true;
}
if (TFM_SuperadminList.isUserSuperadmin(p))
{
playerMsg(p.getName() + " is a Superadmin, and cannot have their commands blocked.");
return true;
}
@ -33,7 +57,7 @@ public class Command_blockcommand extends TFM_Command
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
TFM_Util.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + p.getName(), true);
TFM_Util.playerMsg(sender, (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
playerMsg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
return true;
}

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;

View File

@ -42,13 +42,13 @@ public class Command_creative extends TFM_Command
}
else
{
sender.sendMessage("Only superadmins can change other user's gamemode.");
playerMsg("Only superadmins can change other user's gamemode.");
return true;
}
}
sender.sendMessage("Setting " + p.getName() + " to game mode 'Creative'.");
p.sendMessage(sender.getName() + " set your game mode to 'Creative'.");
playerMsg("Setting " + p.getName() + " to game mode 'Creative'.");
playerMsg(p, sender.getName() + " set your game mode to 'Creative'.");
p.setGameMode(GameMode.CREATIVE);
return true;

View File

@ -21,7 +21,7 @@ public class Command_enchant extends TFM_Command
if (itemInHand == null)
{
sender.sendMessage("You are holding an invalid item.");
playerMsg("You are holding an invalid item.");
return true;
}
@ -41,11 +41,11 @@ public class Command_enchant extends TFM_Command
if (has_enchantments)
{
sender.sendMessage(possible_ench.toString());
playerMsg(possible_ench.toString());
}
else
{
sender.sendMessage("The held item has no enchantments.");
playerMsg("The held item has no enchantments.");
}
}
else if (args[0].equalsIgnoreCase("addall"))
@ -58,7 +58,7 @@ public class Command_enchant extends TFM_Command
}
}
sender.sendMessage("Added all possible enchantments for this item.");
playerMsg("Added all possible enchantments for this item.");
}
else if (args[0].equalsIgnoreCase("reset"))
{
@ -67,7 +67,7 @@ public class Command_enchant extends TFM_Command
itemInHand.removeEnchantment(ench);
}
sender.sendMessage("Removed all enchantments.");
playerMsg("Removed all enchantments.");
}
else
{
@ -88,7 +88,7 @@ public class Command_enchant extends TFM_Command
if (ench == null)
{
sender.sendMessage(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
playerMsg(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
return true;
}
@ -98,18 +98,18 @@ public class Command_enchant extends TFM_Command
{
itemInHand.addEnchantment(ench, ench.getMaxLevel());
sender.sendMessage("Added enchantment: " + ench.getName());
playerMsg("Added enchantment: " + ench.getName());
}
else
{
sender.sendMessage("Can't use this enchantment on held item.");
playerMsg("Can't use this enchantment on held item.");
}
}
else if (args[0].equalsIgnoreCase("remove"))
{
itemInHand.removeEnchantment(ench);
sender.sendMessage("Removed enchantment: " + ench.getName());
playerMsg("Removed enchantment: " + ench.getName());
}
}

View File

@ -55,7 +55,7 @@ public class Command_expel extends TFM_Command
if (in_range)
{
p.setVelocity(target_pos.clone().subtract(sender_pos).toVector().normalize().multiply(strength));
sender.sendMessage("Pushing " + p.getName() + ".");
playerMsg("Pushing " + p.getName() + ".");
}
}
}

View File

@ -33,12 +33,12 @@ public class Command_explosives extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowExplosions = true;
sender.sendMessage("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks.");
playerMsg("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks.");
}
else
{
TotalFreedomMod.allowExplosions = false;
sender.sendMessage("Explosives are now disabled.");
playerMsg("Explosives are now disabled.");
}
return true;

View File

@ -19,12 +19,12 @@ public class Command_fireplace extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowFirePlace = true;
sender.sendMessage("Fire placement is now enabled.");
playerMsg("Fire placement is now enabled.");
}
else
{
TotalFreedomMod.allowFirePlace = false;
sender.sendMessage("Fire placement is now disabled.");
playerMsg("Fire placement is now disabled.");
}
return true;

View File

@ -19,12 +19,12 @@ public class Command_firespread extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowFireSpread = true;
sender.sendMessage("Fire spread is now enabled.");
playerMsg("Fire spread is now enabled.");
}
else
{
TotalFreedomMod.allowFireSpread = false;
sender.sendMessage("Fire spread is now disabled.");
playerMsg("Fire spread is now disabled.");
}
return true;

View File

@ -19,7 +19,7 @@ public class Command_flatlands extends TFM_Command
}
else
{
sender.sendMessage(ChatColor.GRAY + "Flatlands is currently disabled.");
playerMsg("Flatlands is currently disabled.");
}
return true;
}

View File

@ -19,12 +19,12 @@ public class Command_fluidspread extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowFliudSpread = true;
sender.sendMessage("Lava and water spread is now enabled.");
playerMsg("Lava and water spread is now enabled.");
}
else
{
TotalFreedomMod.allowFliudSpread = false;
sender.sendMessage("Lava and water spread is now disabled.");
playerMsg("Lava and water spread is now disabled.");
}
return true;

View File

@ -21,14 +21,14 @@ public class Command_fr extends TFM_Command
if (TotalFreedomMod.allPlayersFrozen)
{
TotalFreedomMod.allPlayersFrozen = true;
sender.sendMessage("Players are now frozen.");
TFM_Util.adminAction(sender.getName(), "Freezing all players", false);
playerMsg("Players are now frozen.");
}
else
{
TotalFreedomMod.allPlayersFrozen = false;
sender.sendMessage("Players are now free to move.");
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
playerMsg("Players are now free to move.");
}
}
else
@ -54,15 +54,15 @@ public class Command_fr extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen());
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(p, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
}
}

View File

@ -45,7 +45,7 @@ public class Command_fuckoff extends TFM_Command
TotalFreedomMod.fuckoffEnabledFor.put(sender_p, new Double(fuckoff_range));
}
sender.sendMessage("Fuckoff " + (fuckoff_enabled ? ("enabled. Range: " + fuckoff_range + ".") : "disabled."));
playerMsg("Fuckoff " + (fuckoff_enabled ? ("enabled. Range: " + fuckoff_range + ".") : "disabled."));
return true;
}

View File

@ -24,7 +24,7 @@ public class Command_gadmin extends TFM_Command
if (mode.equals("list"))
{
sender.sendMessage(ChatColor.GRAY + "[ Real Name ] : [ Display Name ] - Hash:");
playerMsg("[ Real Name ] : [ Display Name ] - Hash:");
}
for (Player p : server.getOnlinePlayers())
@ -96,7 +96,7 @@ public class Command_gadmin extends TFM_Command
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen());
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
}
@ -106,7 +106,7 @@ public class Command_gadmin extends TFM_Command
if (!mode.equals("list"))
{
sender.sendMessage(ChatColor.RED + "Invalid hash.");
playerMsg("Invalid hash.", ChatColor.RED);
}
return true;

View File

@ -45,19 +45,19 @@ public class Command_gcmd extends TFM_Command
try
{
sender.sendMessage(ChatColor.GRAY + "Sending command as " + p.getName() + ": " + outcommand);
playerMsg("Sending command as " + p.getName() + ": " + outcommand);
if (server.dispatchCommand(p, outcommand))
{
sender.sendMessage(ChatColor.GRAY + "Command sent.");
playerMsg("Command sent.");
}
else
{
sender.sendMessage(ChatColor.GRAY + "Unknown error sending command.");
playerMsg("Unknown error sending command.");
}
}
catch (Throwable ex)
{
sender.sendMessage(ChatColor.GRAY + "Error sending command: " + ex.getMessage());
playerMsg("Error sending command: " + ex.getMessage());
}
return true;

View File

@ -34,7 +34,7 @@ public class Command_glist extends TFM_Command
}
else
{
TFM_Util.playerMsg(sender, "Only Senior Admins may purge the userlist.");
playerMsg("Only Senior Admins may purge the userlist.");
}
return true;
}

View File

@ -27,7 +27,7 @@ public class Command_gtfo extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -31,7 +32,7 @@ public class Command_halt extends TFM_Command
counter++;
}
}
TFM_Util.playerMsg(sender, "Halted " + counter + " players.");
playerMsg("Halted " + counter + " players.");
return true;
}
@ -47,7 +48,7 @@ public class Command_halt extends TFM_Command
counter++;
}
}
TFM_Util.playerMsg(sender, "Unhalted " + counter + " players.");
playerMsg("Unhalted " + counter + " players.");
return true;
}
@ -62,15 +63,15 @@ public class Command_halt extends TFM_Command
{
if (count == 0)
{
TFM_Util.playerMsg(sender, "Halted players:");
playerMsg(sender, "Halted players:");
}
TFM_Util.playerMsg(sender, "- " + hp.getName());
playerMsg("- " + hp.getName());
count++;
}
}
if (count == 0)
{
TFM_Util.playerMsg(sender, "There are currently no halted players.");
playerMsg("There are currently no halted players.");
}
return true;
}
@ -119,7 +120,7 @@ public class Command_halt extends TFM_Command
playerdata.setMuted(true);
playerdata.setHalted(true);
TFM_Util.playerMsg(p, "You have been halted, don't move!");
p.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
}
else
{
@ -128,7 +129,7 @@ public class Command_halt extends TFM_Command
playerdata.setFrozen(false);
playerdata.setMuted(false);
playerdata.setHalted(false);
TFM_Util.playerMsg(p, "You are no longer halted.");
p.sendMessage(ChatColor.GRAY + "You are no longer halted.");
}
}
}

View File

@ -30,7 +30,7 @@ public class Command_health extends TFM_Command
{
TFM_TickMeter meter = new TFM_TickMeter(plugin);
meter.startTicking();
Thread.sleep(1000); // ticks per second
Thread.sleep(1000); // per second
meter.stopTicking();
Runtime runtime = Runtime.getRuntime();
@ -38,15 +38,15 @@ public class Command_health extends TFM_Command
float usedMem = runtime.totalMemory() - runtime.freeMemory();
TFM_Util.playerMsg(sender, "Reserved Memory: " + runtime.totalMemory() / mb + "mb");
TFM_Util.playerMsg(sender, "Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format(usedMem/runtime.totalMemory()*100) + "%)");
TFM_Util.playerMsg(sender, "Max Memory: " + runtime.maxMemory() / mb + "mb");
TFM_Util.playerMsg(sender, "Ticks per second: " + (meter.getTicks() == 20 ? ChatColor.GREEN : ChatColor.RED) + meter.getTicks());
playerMsg("Reserved Memory: " + runtime.totalMemory() / mb + "mb");
playerMsg("Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format(usedMem/runtime.totalMemory()*100) + "%)");
playerMsg("Max Memory: " + runtime.maxMemory() / mb + "mb");
playerMsg("Ticks per second: " + (meter.getTicks() == 20 ? ChatColor.GREEN : ChatColor.RED) + meter.getTicks());
}
catch (Exception iex)
{
TFM_Log.warning("Exception in TFM_TickMeter: Thread was interupted in sleeping process.");
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
TFM_Log.warning("Exception in TFM_TickMeter: Thread was interupted in sleeping process.");
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
}
}
};

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -18,7 +19,7 @@ public class Command_kicknoob extends TFM_Command
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
p.kickPlayer("Disconnected by admin.");
p.kickPlayer(ChatColor.RED + "Disconnected by admin.");
}
}

View File

@ -18,11 +18,11 @@ public class Command_landmine extends TFM_Command
{
if (!TotalFreedomMod.landminesEnabled)
{
sender.sendMessage(ChatColor.GREEN + "The landmine is currently disabled.");
playerMsg("The landmine is currently disabled.", ChatColor.GREEN);
}
else if (!TotalFreedomMod.allowExplosions)
{
sender.sendMessage(ChatColor.GREEN + "Explosions are currently disabled.");
playerMsg("Explosions are currently disabled.", ChatColor.GREEN);
}
else if (sender.isOp())
{
@ -42,7 +42,7 @@ public class Command_landmine extends TFM_Command
landmine.setType(Material.TNT);
TFM_LandmineData.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p, radius));
sender.sendMessage(ChatColor.GREEN + "Landmine planted. Radius: " + radius + " blocks.");
playerMsg("Landmine planted. Radius: " + radius + " blocks.", ChatColor.GREEN);
}
return true;

View File

@ -25,7 +25,7 @@ public class Command_lastcmd extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
@ -38,7 +38,7 @@ public class Command_lastcmd extends TFM_Command
{
last_command = "(none)";
}
TFM_Util.playerMsg(sender, p.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
playerMsg(p.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
}
return true;

View File

@ -19,12 +19,12 @@ public class Command_lavadmg extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowLavaDamage = true;
sender.sendMessage("Lava damage is now enabled.");
playerMsg("Lava damage is now enabled.");
}
else
{
TotalFreedomMod.allowLavaDamage = false;
sender.sendMessage("Lava damage is now disabled.");
playerMsg("Lava damage is now disabled.");
}
return true;

View File

@ -19,12 +19,12 @@ public class Command_lavaplace extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowLavaPlace = true;
sender.sendMessage("Lava placement is now enabled.");
playerMsg("Lava placement is now enabled.");
}
else
{
TotalFreedomMod.allowLavaPlace = false;
sender.sendMessage("Lava placement is now disabled.");
playerMsg("Lava placement is now disabled.");
}
return true;

View File

@ -23,7 +23,7 @@ public class Command_list extends TFM_Command
{
player_names.add(p.getName());
}
sender.sendMessage("There are " + player_names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(player_names, ", "));
playerMsg("There are " + player_names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(player_names, ", "), ChatColor.WHITE);
return true;
}
@ -49,6 +49,11 @@ public class Command_list extends TFM_Command
{
prefix = (ChatColor.GOLD + "[SA]");
}
if (p.getName().equalsIgnoreCase("madgeek1450") || p.getName().equalsIgnoreCase("darthsalamon"))
{
prefix = (ChatColor.DARK_PURPLE+ "[Dev]");
}
}
else
{

View File

@ -25,7 +25,7 @@ public class Command_lockup extends TFM_Command
{
startLockup(p);
}
TFM_Util.playerMsg(sender, "Locked up all players.");
playerMsg("Locked up all players.");
}
else if (args[0].equalsIgnoreCase("purge"))
{
@ -34,7 +34,8 @@ public class Command_lockup extends TFM_Command
{
cancelLockup(p);
}
TFM_Util.playerMsg(sender, "Unlocked all players.");
playerMsg("Unlocked all players.");
}
else
{
@ -58,7 +59,7 @@ public class Command_lockup extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Locking up " + p.getName(), true);
startLockup(p);
TFM_Util.playerMsg(sender, "Locked up " + p.getName() + ".");
playerMsg("Locked up " + p.getName() + ".");
}
else if (TFM_Util.isStopCommand(args[1]))
{
@ -75,7 +76,7 @@ public class Command_lockup extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Unlocking " + p.getName(), true);
cancelLockup(p);
TFM_Util.playerMsg(sender, "Unlocked " + p.getName() + ".");
playerMsg("Unlocked " + p.getName() + ".");
}
else
{

View File

@ -63,14 +63,14 @@ public class Command_moblimiter extends TFM_Command
{
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TotalFreedomMod.mobLimiterMax + ".");
sender.sendMessage("Dragon: " + (TotalFreedomMod.mobLimiterDisableDragon ? "disabled" : "enabled") + ".");
sender.sendMessage("Giant: " + (TotalFreedomMod.mobLimiterDisableGiant ? "disabled" : "enabled") + ".");
sender.sendMessage("Slime: " + (TotalFreedomMod.mobLimiterDisableSlime ? "disabled" : "enabled") + ".");
sender.sendMessage("Ghast: " + (TotalFreedomMod.mobLimiterDisableGhast ? "disabled" : "enabled") + ".");
playerMsg("Dragon: " + (TotalFreedomMod.mobLimiterDisableDragon ? "disabled" : "enabled") + ".");
playerMsg("Giant: " + (TotalFreedomMod.mobLimiterDisableGiant ? "disabled" : "enabled") + ".");
playerMsg("Slime: " + (TotalFreedomMod.mobLimiterDisableSlime ? "disabled" : "enabled") + ".");
playerMsg("Ghast: " + (TotalFreedomMod.mobLimiterDisableGhast ? "disabled" : "enabled") + ".");
}
else
{
sender.sendMessage("Moblimiter is disabled. No mob restrictions are in effect.");
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
}
return true;

View File

@ -27,7 +27,7 @@ public class Command_mp extends TFM_Command
}
}
sender.sendMessage(ChatColor.GRAY + String.valueOf(removed) + " mobs removed.");
playerMsg(removed + " mobs removed.");
return true;
}

View File

@ -17,7 +17,7 @@ public class Command_mp44 extends TFM_Command
{
if (!TotalFreedomMod.mp44Enabled)
{
sender.sendMessage(ChatColor.GREEN + "The mp44 is currently disabled.");
playerMsg("The mp44 is currently disabled.", ChatColor.GREEN);
return true;
}
@ -32,8 +32,8 @@ public class Command_mp44 extends TFM_Command
{
playerdata.armMP44();
sender.sendMessage(ChatColor.GREEN + "mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.");
sender.sendMessage(ChatColor.GREEN + "Type /mp44 sling to disable. -by Madgeek1450");
playerMsg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
playerMsg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
sender_p.setItemInHand(new ItemStack(Material.SULPHUR, 1));
}

View File

@ -42,14 +42,14 @@ public class Command_nonuke extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.nukeMonitor = true;
sender.sendMessage(ChatColor.GRAY + "Nuke monitor is enabled.");
sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks.");
sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
playerMsg( "Nuke monitor is enabled.");
playerMsg("Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks.");
playerMsg("Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
}
else
{
TotalFreedomMod.nukeMonitor = false;
sender.sendMessage("Nuke monitor is disabled.");
playerMsg("Nuke monitor is disabled.");
}
return true;

View File

@ -17,13 +17,13 @@ public class Command_o extends TFM_Command
{
if (senderIsConsole)
{
TFM_Util.playerMsg(sender, "Only in-game players can toggle AdminChat.");
playerMsg("Only in-game players can toggle AdminChat.");
return true;
}
TFM_UserInfo userinfo = TFM_UserInfo.getPlayerData(sender_p);
userinfo.setAdminChat(!userinfo.inAdminChat());
TFM_Util.playerMsg(sender, "Toggled Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
playerMsg("Toggled Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
}
else
{

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -15,8 +16,8 @@ public class Command_onlinemode extends TFM_Command
{
if (args.length < 1)
{
sender.sendMessage("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.");
sender.sendMessage("Use \"/onlinemode on\" and \"/onlinemode off\" to change online mode.");
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.WHITE);
playerMsg("Use \"/onlinemode on\" and \"/onlinemode off\" to change online mode.", ChatColor.WHITE);
}
else
{

View File

@ -21,7 +21,7 @@ public class Command_op extends TFM_Command
if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("everyone"))
{
TFM_Util.playerMsg(sender, "Correct usage: /opall");
playerMsg("Correct usage: /opall");
return true;
}
@ -43,8 +43,8 @@ public class Command_op extends TFM_Command
}
else
{
TFM_Util.playerMsg(sender, "That player is not online.");
TFM_Util.playerMsg(sender, "You don't have permissions to OP offline players.", ChatColor.YELLOW);
playerMsg("That player is not online.");
playerMsg("You don't have permissions to OP offline players.", ChatColor.YELLOW);
return true;
}
}

View File

@ -44,9 +44,9 @@ public class Command_ops extends TFM_Command
totalOPs++;
}
sender.sendMessage(ChatColor.GRAY + "Online OPs: " + onlineOPs);
sender.sendMessage(ChatColor.GRAY + "Offline OPs: " + offlineOPs);
sender.sendMessage(ChatColor.GRAY + "Total OPs: " + totalOPs);
playerMsg("Online OPs: " + onlineOPs);
playerMsg("Offline OPs: " + offlineOPs);
playerMsg("Total OPs: " + totalOPs);
return true;
}
@ -55,7 +55,7 @@ public class Command_ops extends TFM_Command
{
if (!senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}

View File

@ -27,7 +27,7 @@ public class Command_orbit extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
@ -39,7 +39,7 @@ public class Command_orbit extends TFM_Command
{
if (TFM_Util.isStopCommand(args[1]))
{
sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName());
playerMsg("Stopped orbiting " + p.getName());
playerdata.stopOrbiting();
return true;
}
@ -50,7 +50,7 @@ public class Command_orbit extends TFM_Command
}
catch (NumberFormatException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}

View File

@ -30,7 +30,7 @@ public class Command_permban extends TFM_Command
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
TFM_Util.playerMsg(sender, "Reloading permban list...", ChatColor.RED);
playerMsg("Reloading permban list...", ChatColor.RED);
TotalFreedomMod.loadPermbanConfig();
dumplist(sender);
}
@ -46,22 +46,22 @@ public class Command_permban extends TFM_Command
{
if (TotalFreedomMod.permbanned_players.isEmpty())
{
TFM_Util.playerMsg(sender, "No permanently banned player names.");
playerMsg(sender, "No permanently banned player names.");
}
else
{
TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:");
TFM_Util.playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_players, ", "));
playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_players, ", "));
}
if (TotalFreedomMod.permbanned_ips.isEmpty())
{
TFM_Util.playerMsg(sender, "No permanently banned IPs.");
playerMsg(sender, "No permanently banned IPs.");
}
else
{
TFM_Util.playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:");
TFM_Util.playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_ips, ", "));
playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_ips, ", "));
}
}
}

View File

@ -29,7 +29,7 @@ public class Command_potion extends TFM_Command
potionEffectTypeNames.add(potion_effect_type.getName());
}
}
sender.sendMessage(ChatColor.AQUA + "Potion effect types: " + StringUtils.join(potionEffectTypeNames, ", "));
playerMsg("Potion effect types: " + StringUtils.join(potionEffectTypeNames, ", "), ChatColor.AQUA);
}
else if (args[0].equalsIgnoreCase("clear"))
{
@ -43,7 +43,7 @@ public class Command_potion extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}
@ -52,13 +52,13 @@ public class Command_potion extends TFM_Command
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
sender.sendMessage("Only superadmins can clear potion effects from other players.");
playerMsg("Only superadmins can clear potion effects from other players.");
return true;
}
}
else if (senderIsConsole)
{
sender.sendMessage("You must specify a target player when using this command from the console.");
playerMsg("You must specify a target player when using this command from the console.");
return true;
}
@ -67,7 +67,7 @@ public class Command_potion extends TFM_Command
target.removePotionEffect(potion_effect.getType());
}
sender.sendMessage(ChatColor.AQUA + "Cleared all active potion effects " + (!target.equals(sender_p) ? "from player " + target.getName() + "." : "from yourself."));
playerMsg("Cleared all active potion effects " + (!target.equals(sender_p) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA);
}
else
{
@ -88,7 +88,7 @@ public class Command_potion extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}
@ -121,7 +121,7 @@ public class Command_potion extends TFM_Command
}
catch (NumberFormatException ex)
{
sender.sendMessage(ChatColor.AQUA + "Invalid potion duration.");
playerMsg("Invalid potion duration.", ChatColor.RED);
return true;
}
@ -132,17 +132,17 @@ public class Command_potion extends TFM_Command
}
catch (NumberFormatException ex)
{
sender.sendMessage(ChatColor.AQUA + "Invalid potion amplifier.");
playerMsg("Invalid potion amplifier.", ChatColor.RED);
return true;
}
PotionEffect new_effect = potion_effect_type.createEffect(duration, amplifier);
target.addPotionEffect(new_effect, true);
sender.sendMessage(ChatColor.AQUA
+ "Added potion effect: " + new_effect.getType().getName()
playerMsg(
"Added potion effect: " + new_effect.getType().getName()
+ ", Duration: " + new_effect.getDuration()
+ ", Amplifier: " + new_effect.getAmplifier()
+ (!target.equals(sender_p) ? " to player " + target.getName() + "." : " to yourself."));
+ (!target.equals(sender_p) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
return true;
}

View File

@ -19,12 +19,12 @@ public class Command_prelog extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.preprocessLogEnabled = true;
sender.sendMessage("Command preprocess logging is now enabled. This will be spammy in the log.");
playerMsg("Command preprocess logging is now enabled. This will be spammy in the log.");
}
else
{
TotalFreedomMod.preprocessLogEnabled = false;
sender.sendMessage("Command preprocess logging is now disabled.");
playerMsg("Command preprocess logging is now disabled.");
}
return true;

View File

@ -15,7 +15,7 @@ public class Command_protectarea extends TFM_Command
{
if (!TotalFreedomMod.protectedAreasEnabled)
{
sender.sendMessage("Protected areas are currently disabled in the TotalFreedomMod configuration.");
playerMsg("Protected areas are currently disabled in the TotalFreedomMod configuration.");
return true;
}
@ -23,13 +23,13 @@ public class Command_protectarea extends TFM_Command
{
if (args[0].equalsIgnoreCase("list"))
{
sender.sendMessage("Protected Areas: " + StringUtils.join(TFM_ProtectedArea.getProtectedAreaLabels(), ", "));
playerMsg("Protected Areas: " + StringUtils.join(TFM_ProtectedArea.getProtectedAreaLabels(), ", "));
}
else if (args[0].equalsIgnoreCase("clear"))
{
TFM_ProtectedArea.clearProtectedAreas();
sender.sendMessage("Protected Areas Cleared.");
playerMsg("Protected Areas Cleared.");
}
else
{
@ -44,7 +44,7 @@ public class Command_protectarea extends TFM_Command
{
TFM_ProtectedArea.removeProtectedArea(args[1]);
sender.sendMessage("Area removed. Protected Areas: " + StringUtils.join(TFM_ProtectedArea.getProtectedAreaLabels(), ", "));
playerMsg("Area removed. Protected Areas: " + StringUtils.join(TFM_ProtectedArea.getProtectedAreaLabels(), ", "));
}
else
{
@ -59,7 +59,7 @@ public class Command_protectarea extends TFM_Command
{
if (senderIsConsole)
{
sender.sendMessage("You must be in-game to set a protected area.");
playerMsg("You must be in-game to set a protected area.");
return true;
}
@ -70,19 +70,19 @@ public class Command_protectarea extends TFM_Command
}
catch (NumberFormatException nfex)
{
sender.sendMessage("Invalid radius.");
playerMsg("Invalid radius.");
return true;
}
if (radius > TFM_ProtectedArea.MAX_RADIUS || radius < 0.0D)
{
sender.sendMessage("Invalid radius. Radius must be a positive value less than " + TFM_ProtectedArea.MAX_RADIUS + ".");
playerMsg("Invalid radius. Radius must be a positive value less than " + TFM_ProtectedArea.MAX_RADIUS + ".");
return true;
}
TFM_ProtectedArea.addProtectedArea(args[1], sender_p.getLocation(), radius);
sender.sendMessage("Area added. Protected Areas: " + StringUtils.join(TFM_ProtectedArea.getProtectedAreaLabels(), ", "));
playerMsg("Area added. Protected Areas: " + StringUtils.join(TFM_ProtectedArea.getProtectedAreaLabels(), ", "));
}
else
{

View File

@ -44,7 +44,7 @@ public class Command_qdeop extends TFM_Command
if (!matched_player)
{
TFM_Util.playerMsg(sender, "No targets matched.");
playerMsg("No targets matched.");
}
return true;

View File

@ -44,7 +44,7 @@ public class Command_qop extends TFM_Command
if (!matched_player)
{
TFM_Util.playerMsg(sender, "No targets matched.");
playerMsg("No targets matched.");
}
return true;

View File

@ -36,13 +36,13 @@ public class Command_radar extends TFM_Command
if (radar_data.isEmpty())
{
sender.sendMessage(ChatColor.YELLOW + "You are the only player in this world. (Forever alone...)");
playerMsg("You are the only player in this world. (" + ChatColor.GREEN + "Forever alone..." + ChatColor.YELLOW + ")", ChatColor.YELLOW); //lol
return true;
}
Collections.sort(radar_data, new TFM_RadarData());
sender.sendMessage(ChatColor.YELLOW + "People nearby in " + sender_pos.getWorld().getName() + ":");
playerMsg("People nearby in " + sender_pos.getWorld().getName() + ":", ChatColor.YELLOW);
int countmax = 5;
if (args.length == 1)
@ -58,10 +58,10 @@ public class Command_radar extends TFM_Command
for (TFM_RadarData i : radar_data)
{
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d",
playerMsg(String.format("%s - %d",
i.player.getName(),
Math.round(i.distance)
));
), ChatColor.YELLOW);
if (--countmax <= 0)
{

View File

@ -16,7 +16,7 @@ public class Command_rank extends TFM_Command
{
for (Player p : server.getOnlinePlayers())
{
sender.sendMessage(p.getName() + " is " + TFM_Util.getRank(p));
playerMsg(p.getName() + " is " + TFM_Util.getRank(p));
}
return true;
}
@ -28,7 +28,7 @@ public class Command_rank extends TFM_Command
if (args.length == 0)
{
TFM_Util.playerMsg(sender, sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA);
playerMsg(sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA);
return true;
}
@ -43,7 +43,7 @@ public class Command_rank extends TFM_Command
return true;
}
TFM_Util.playerMsg(sender, p.getName() + " is " + TFM_Util.getRank(p), ChatColor.AQUA);
playerMsg(p.getName() + " is " + TFM_Util.getRank(p), ChatColor.AQUA);
return true;
}

View File

@ -13,7 +13,7 @@ public class Command_rd extends TFM_Command
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.adminAction(sender.getName(), "Removing all server entities.", false);
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed.");
playerMsg((TFM_Util.wipeEntities(true, true)) + " enties removed.");
return true;
}

View File

@ -31,7 +31,7 @@ public class Command_ro extends TFM_Command
if (from_material == null)
{
TFM_Util.playerMsg(sender, "Invalid block: " + args[0], ChatColor.RED);
playerMsg("Invalid block: " + args[0], ChatColor.RED);
return true;
}
}
@ -45,7 +45,7 @@ public class Command_ro extends TFM_Command
}
catch (NumberFormatException ex)
{
TFM_Util.playerMsg(sender, "Invalid radius: " + args[1], ChatColor.RED);
playerMsg("Invalid radius: " + args[1], ChatColor.RED);
return true;
}
}
@ -59,7 +59,7 @@ public class Command_ro extends TFM_Command
}
catch (CantFindPlayerException ex)
{
TFM_Util.playerMsg(sender, ex.getMessage(), ChatColor.RED);
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}

View File

@ -20,13 +20,13 @@ public class Command_saconfig extends TFM_Command
{
if (args[0].equals("list"))
{
sender.sendMessage(ChatColor.GOLD + "Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "));
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "), ChatColor.GOLD);
}
else
{
if (!senderIsConsole)
{
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the console.");
playerMsg("This command may only be used from the console.");
return true;
}
@ -34,7 +34,7 @@ public class Command_saconfig extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list.", true);
TFM_SuperadminList.cleanSuperadminList(true);
sender.sendMessage(ChatColor.GOLD + "Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "));
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "), ChatColor.YELLOW);
}
else
{
@ -52,7 +52,7 @@ public class Command_saconfig extends TFM_Command
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
@ -71,11 +71,11 @@ public class Command_saconfig extends TFM_Command
if (superadmin == null)
{
sender.sendMessage("Superadmin not found: " + args[1]);
playerMsg("Superadmin not found: " + args[1]);
}
else
{
sender.sendMessage(ChatColor.GRAY + ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', superadmin.toString())));
playerMsg(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', superadmin.toString())));
}
return true;
@ -83,7 +83,7 @@ public class Command_saconfig extends TFM_Command
if (!senderIsConsole)
{
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the console.");
playerMsg("This command may only be used from the console.");
return true;
}
@ -105,7 +105,7 @@ public class Command_saconfig extends TFM_Command
}
else
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}
@ -125,7 +125,7 @@ public class Command_saconfig extends TFM_Command
{
if (!TFM_SuperadminList.isSeniorAdmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
@ -141,7 +141,7 @@ public class Command_saconfig extends TFM_Command
if (!TFM_SuperadminList.getSuperadminNames().contains(target_name.toLowerCase()))
{
sender.sendMessage("Superadmin not found: " + target_name);
playerMsg("Superadmin not found: " + target_name);
return true;
}

View File

@ -33,13 +33,13 @@ public class Command_setlevel extends TFM_Command
}
catch (NumberFormatException ex)
{
sender.sendMessage(ChatColor.AQUA + "Invalid level.");
playerMsg("Invalid level.", ChatColor.RED);
return true;
}
sender_p.setLevel(new_level);
sender.sendMessage(ChatColor.AQUA + "You have been set to level " + Integer.toString(new_level));
playerMsg("You have been set to level " + Integer.toString(new_level), ChatColor.AQUA);
return true;
}

View File

@ -18,7 +18,7 @@ public class Command_setspawnworld extends TFM_Command
Location pos = sender_p.getLocation();
sender_p.getWorld().setSpawnLocation(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
sender.sendMessage(ChatColor.GRAY + "Spawn location for this world set to: " + TFM_Util.formatLocation(sender_p.getWorld().getSpawnLocation()));
playerMsg("Spawn location for this world set to: " + TFM_Util.formatLocation(sender_p.getWorld().getSpawnLocation()));
if (TotalFreedomMod.protectedAreasEnabled && TotalFreedomMod.autoProtectSpawnpoints)
{

View File

@ -27,7 +27,7 @@ public class Command_smite extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}

View File

@ -40,16 +40,16 @@ public class Command_status extends TFM_Command
@Override
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.playerMsg(sender, String.format("Total Freedom Mod v%s.%s, built %s.", TotalFreedomMod.pluginVersion, TotalFreedomMod.buildNumber, TotalFreedomMod.buildDate), ChatColor.GOLD);
TFM_Util.playerMsg(sender, "TotalFreedomMod was created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
playerMsg(String.format("Total Freedom Mod v%s.%s, built %s.", TotalFreedomMod.pluginVersion, TotalFreedomMod.buildNumber, TotalFreedomMod.buildDate), ChatColor.GOLD);
playerMsg("TotalFreedomMod was created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
TFM_Util.playerMsg(sender, "Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
TFM_Util.playerMsg(sender, "Loaded worlds:", ChatColor.BLUE);
playerMsg("Loaded worlds:", ChatColor.BLUE);
int i = 0;
for (World world : server.getWorlds())
{
TFM_Util.playerMsg(sender, String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
}
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
@ -96,7 +96,7 @@ public class Command_status extends TFM_Command
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
}
TFM_Util.playerMsg(sender, String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
}
catch (Exception ex)
{

View File

@ -20,7 +20,7 @@ public class Command_stfu extends TFM_Command
if (args[0].equalsIgnoreCase("list"))
{
TFM_Util.playerMsg(sender, "Muted players:");
playerMsg("Muted players:");
TFM_UserInfo info;
int count = 0;
for (Player mp : server.getOnlinePlayers())
@ -28,13 +28,13 @@ public class Command_stfu extends TFM_Command
info = TFM_UserInfo.getPlayerData(mp);
if (info.isMuted())
{
TFM_Util.playerMsg(sender, "- " + mp.getName());
playerMsg("- " + mp.getName());
count++;
}
}
if (count == 0)
{
TFM_Util.playerMsg(sender, "- none");
playerMsg("- none");
}
}
else if (args[0].equalsIgnoreCase("purge"))
@ -51,7 +51,7 @@ public class Command_stfu extends TFM_Command
count++;
}
}
TFM_Util.playerMsg(sender, "Unmuted " + count + " players.");
playerMsg("Unmuted " + count + " players.");
}
else if (args[0].equalsIgnoreCase("all"))
{
@ -69,7 +69,7 @@ public class Command_stfu extends TFM_Command
}
}
TFM_Util.playerMsg(sender, "Muted " + counter + " players.");
playerMsg("Muted " + counter + " players.");
}
else
{
@ -89,7 +89,7 @@ public class Command_stfu extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Unmuting " + p.getName(), true);
playerdata.setMuted(false);
TFM_Util.playerMsg(sender, "Unmuted " + p.getName());
playerMsg("Unmuted " + p.getName());
}
else
{
@ -97,11 +97,11 @@ public class Command_stfu extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Muting " + p.getName(), true);
playerdata.setMuted(true);
TFM_Util.playerMsg(sender, "Muted " + p.getName());
playerMsg("Muted " + p.getName());
}
else
{
TFM_Util.playerMsg(sender, p.getName() + " is a superadmin, and can't be muted.");
playerMsg(p.getName() + " is a superadmin, and can't be muted.");
}
}
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -16,7 +17,7 @@ public class Command_survival extends TFM_Command
{
if (args.length == 0)
{
sender.sendMessage("When used from the console, you must define a target user to change gamemode on.");
playerMsg("When used from the console, you must define a target user to change gamemode on.");
return true;
}
}
@ -36,18 +37,18 @@ public class Command_survival extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}
else
{
sender.sendMessage("Only superadmins can change other user's gamemode.");
playerMsg("Only superadmins can change other user's gamemode.");
return true;
}
}
sender.sendMessage("Setting " + p.getName() + " to game mode 'Survival'.");
playerMsg("Setting " + p.getName() + " to game mode 'Survival'.");
p.sendMessage(sender.getName() + " set your game mode to 'Survival'.");
p.setGameMode(GameMode.SURVIVAL);

View File

@ -6,6 +6,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -30,7 +31,7 @@ public class Command_tempban extends TFM_Command
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}

View File

@ -1,7 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RunSystemCommand;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,11 +23,11 @@ public class Command_terminal extends TFM_Command
}
catch (Throwable ex)
{
sender.sendMessage(ChatColor.GRAY + "Error building command: " + ex.getMessage());
playerMsg("Error building command: " + ex.getMessage());
return true;
}
sender.sendMessage("Running system command: " + command);
playerMsg("Running system command: " + command);
server.getScheduler().runTaskAsynchronously(plugin, new TFM_RunSystemCommand(command, plugin));
return true;

View File

@ -35,7 +35,7 @@ public class Command_tfbanlist extends TFM_Command
}
else
{
sender.sendMessage(ChatColor.YELLOW + "You do not have permission to purge the ban list, you may only view it.");
playerMsg("You do not have permission to purge the ban list, you may only view it.");
}
}
}
@ -53,7 +53,7 @@ public class Command_tfbanlist extends TFM_Command
banned_players.append(p.getName().trim());
}
sender.sendMessage(ChatColor.GRAY + banned_players.toString());
playerMsg(banned_players.toString());
return true;
}

View File

@ -37,7 +37,7 @@ public class Command_tfipbanlist extends TFM_Command
}
else
{
sender.sendMessage(ChatColor.YELLOW + "You do not have permission to purge the IP ban list, you may only view it.");
playerMsg("You do not have permission to purge the IP ban list, you may only view it.");
}
}
}
@ -61,7 +61,7 @@ public class Command_tfipbanlist extends TFM_Command
}
}
sender.sendMessage(ChatColor.GRAY + banned_ips.toString());
playerMsg(banned_ips.toString());
return true;
}

View File

@ -27,7 +27,7 @@ public class Command_tfupdate extends TFM_Command
{
if (!sender.getName().equalsIgnoreCase("madgeek1450"))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}

View File

@ -20,7 +20,7 @@ public class Command_tossmob extends TFM_Command
{
if (!TotalFreedomMod.tossmobEnabled)
{
sender.sendMessage(ChatColor.RED + "Tossmob is currently disabled.");
playerMsg("Tossmob is currently disabled.");
return true;
}
@ -32,13 +32,13 @@ public class Command_tossmob extends TFM_Command
if (TFM_Util.isStopCommand(args[0]))
{
playerData.disableMobThrower();
sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled.");
playerMsg("MobThrower is disabled.", ChatColor.GREEN);
return true;
}
if (args[0].equalsIgnoreCase("list"))
{
sender.sendMessage(ChatColor.GREEN + "Supported mobs: " + StringUtils.join(TFM_Util.mobtypes.keySet(), ", "));
playerMsg("Supported mobs: " + StringUtils.join(TFM_Util.mobtypes.keySet(), ", "), ChatColor.GREEN);
return true;
}
@ -48,8 +48,8 @@ public class Command_tossmob extends TFM_Command
}
catch (Exception ex)
{
sender.sendMessage(ChatColor.RED + args[0] + " is not a supported mob type. Using a pig instead.");
sender.sendMessage(ChatColor.RED + "By the way, you can type /tossmob list to see all possible mobs.");
playerMsg(args[0] + " is not a supported mob type. Using a pig instead.", ChatColor.RED);
playerMsg("By the way, you can type /tossmob list to see all possible mobs.", ChatColor.RED);
creature = EntityType.PIG;
}
}
@ -76,9 +76,9 @@ public class Command_tossmob extends TFM_Command
}
playerData.enableMobThrower(creature, speed);
sender.sendMessage(ChatColor.GREEN + "MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + ".");
sender.sendMessage(ChatColor.GREEN + "Left click while holding a stick to throw mobs!");
sender.sendMessage(ChatColor.GREEN + "Type '/tossmob off' to disable. -By Madgeek1450");
playerMsg("MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + ".", ChatColor.GREEN);
playerMsg("Left click while holding a stick to throw mobs!", ChatColor.GREEN);
playerMsg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
sender_p.setItemInHand(new ItemStack(Material.STICK, 1));

View File

@ -21,12 +21,12 @@ public class Command_waterplace extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowWaterPlace = true;
sender.sendMessage("Water placement is now enabled.");
playerMsg("Water placement is now enabled.");
}
else
{
TotalFreedomMod.allowWaterPlace = false;
sender.sendMessage("Water placement is now disabled.");
playerMsg("Water placement is now disabled.");
}
return true;

View File

@ -24,7 +24,7 @@ public class Command_whitelist extends TFM_Command
// list
if (args[0].equalsIgnoreCase("list"))
{
TFM_Util.playerMsg(sender, "Whitelisted players: " + TFM_Util.playerListToNames(server.getWhitelistedPlayers()));
playerMsg("Whitelisted players: " + TFM_Util.playerListToNames(server.getWhitelistedPlayers()));
return true;
}
@ -48,9 +48,9 @@ public class Command_whitelist extends TFM_Command
totalWPs++;
}
sender.sendMessage(ChatColor.GRAY + "Online whitelisted players: " + onlineWPs);
sender.sendMessage(ChatColor.GRAY + "Offline whitelisted players: " + offlineWPs);
sender.sendMessage(ChatColor.GRAY + "Total whitelisted players: " + totalWPs);
playerMsg("Online whitelisted players: " + onlineWPs);
playerMsg("Offline whitelisted players: " + offlineWPs);
playerMsg("Total whitelisted players: " + totalWPs);
return true;
}
@ -131,7 +131,7 @@ public class Command_whitelist extends TFM_Command
}
else
{
TFM_Util.playerMsg(sender, "That player is not whitelisted");
playerMsg("That player is not whitelisted");
return true;
}
@ -151,7 +151,7 @@ public class Command_whitelist extends TFM_Command
}
}
TFM_Util.playerMsg(sender, "Whitelisted " + counter + " players.");
playerMsg("Whitelisted " + counter + " players.");
return true;
}
@ -166,7 +166,7 @@ public class Command_whitelist extends TFM_Command
if (args[0].equalsIgnoreCase("purge"))
{
TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist.", false);
TFM_Util.playerMsg(sender, "Removed " + TFM_ServerInterface.purgeWhitelist() + " players from the whitelist.");
playerMsg("Removed " + TFM_ServerInterface.purgeWhitelist() + " players from the whitelist.");
return true;
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -13,7 +14,7 @@ public class Command_wildcard extends TFM_Command
{
if (args[0].equals("wildcard"))
{
sender.sendMessage("What the hell are you trying to do, you stupid idiot...");
playerMsg("What the hell are you trying to do, you stupid idiot...", ChatColor.RED);
return true;
}
@ -22,7 +23,7 @@ public class Command_wildcard extends TFM_Command
for (Player p : server.getOnlinePlayers())
{
String out_command = base_command.replaceAll("\\x3f", p.getName());
sender.sendMessage("Running Command: " + out_command);
playerMsg("Running Command: " + out_command);
server.dispatchCommand(sender, out_command);
}

View File

@ -25,13 +25,13 @@ public class Command_ziptool extends TFM_Command
if (!directory.isDirectory())
{
sender.sendMessage(directory.getPath() + " is not a directory.");
playerMsg(directory.getPath() + " is not a directory.");
return true;
}
File output = new File(directory.getParent() + "/" + directory.getName() + ".zip");
sender.sendMessage("Zipping '" + directory.getPath() + "' to '" + output.getPath() + "'.");
playerMsg("Zipping '" + directory.getPath() + "' to '" + output.getPath() + "'.");
try
{
@ -42,7 +42,7 @@ public class Command_ziptool extends TFM_Command
TFM_Log.severe(ex);
}
sender.sendMessage("Zip finished.");
playerMsg("Zip finished.");
}
else if (args[0].equalsIgnoreCase("unzip"))
{
@ -50,11 +50,11 @@ public class Command_ziptool extends TFM_Command
if (!output.exists() || !output.isFile())
{
sender.sendMessage(output.getPath() + " is not a file.");
playerMsg(output.getPath() + " is not a file.");
return true;
}
sender.sendMessage("Unzipping '" + output.getPath() + "'.");
playerMsg("Unzipping '" + output.getPath() + "'.");
try
{
@ -65,7 +65,7 @@ public class Command_ziptool extends TFM_Command
TFM_Log.severe(ex);
}
sender.sendMessage("Unzip finished.");
playerMsg("Unzip finished.");
}
else
{

View File

@ -16,6 +16,7 @@ public class TFM_Command
{
protected TotalFreedomMod plugin;
protected Server server;
private CommandSender commandsender;
public TFM_Command()
{
@ -34,6 +35,31 @@ public class TFM_Command
this.server = plugin.getServer();
}
public void setCommandsender(CommandSender commandsender)
{
this.commandsender = commandsender;
}
public void playerMsg(CommandSender sender, String message, ChatColor color) // complete function
{
sender.sendMessage(color + message);
}
public void playerMsg(String message, ChatColor color)
{
playerMsg(commandsender, message, color);
}
public void playerMsg(CommandSender sender, String message)
{
playerMsg(sender, message, ChatColor.GRAY);
}
public void playerMsg(String message)
{
playerMsg(commandsender, message);
}
public boolean senderHasPermission(Class<?> cmd_class, CommandSender sender)
{
CommandPermissions permissions = cmd_class.getAnnotation(CommandPermissions.class);
@ -125,7 +151,7 @@ public class TFM_Command
{
for (Player p : server.getOnlinePlayers())
{
if (p.getDisplayName().toLowerCase().indexOf(partialname) != -1)
if (p.getDisplayName().toLowerCase().contains(partialname.toLowerCase()))
{
return p;
}

View File

@ -67,11 +67,13 @@ public class TFM_Util
TFM_Util.bcastMsg(message, null);
}
@Deprecated
public static void playerMsg(CommandSender sender, String message, ChatColor color)
{
sender.sendMessage(color + message);
}
@Deprecated
public static void playerMsg(CommandSender sender, String message)
{
TFM_Util.playerMsg(sender, message, ChatColor.GRAY);

View File

@ -153,6 +153,7 @@ public class TotalFreedomMod extends JavaPlugin
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
dispatcher.setPlugin(this);
dispatcher.setCommandsender(sender);
}
catch (Throwable ex)
{

View File

@ -7,10 +7,10 @@ commands:
adminmode:
description: Console-only command - Close server to non-superadmins.
usage: /<command> [on | off]
blockcommand:
blockcmd:
description: Superadmin command - Block all commands for a specific player
usage: /<command> <partialname>
aliases: [blockcommands]
usage: /<command> <purge | <partialname>>
aliases: [blockcommands, blockcommand]
cage:
description: Superadmin command - Place a cage around someone.
usage: /<command> <partialname> <off | [[outermaterial] [innermaterial]]>