Added /lockdown

This commit is contained in:
JeromSar 2013-08-12 20:47:36 +02:00
parent 56493adcae
commit bac25258b0
6 changed files with 62 additions and 25 deletions

View File

@ -1,5 +1,5 @@
#Mon, 12 Aug 2013 17:57:31 +0200 #Mon, 12 Aug 2013 20:45:53 +0200
program.VERSION=2.22 program.VERSION=2.22
program.BUILDNUM=406 program.BUILDNUM=409
program.BUILDDATE=08/12/2013 05\:57 PM program.BUILDDATE=08/12/2013 08\:45 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Mon Aug 12 17:57:31 CEST 2013 #Mon Aug 12 20:45:53 CEST 2013
build.number=407 build.number=410

View File

@ -0,0 +1,34 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Prevents new players from joining the server", usage = "/<command> <on | off>")
public class Command_lockdown extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_Util.adminAction(sender.getName(), "De-activating server lockdown", true);
TotalFreedomMod.lockdownEnabled = false;
}
else
{
TFM_Util.adminAction(sender.getName(), "Activating server lockdown", true);
TotalFreedomMod.lockdownEnabled = true;
}
return true;
}
}

View File

@ -16,12 +16,7 @@ public class Command_tag extends TFM_Command
{ {
public static final List<String> FORBIDDEN_WORDS = Arrays.asList(new String[] public static final List<String> FORBIDDEN_WORDS = Arrays.asList(new String[]
{ {
"admin", "owner", "moderator", "developer" "admin", "owner", "moderator", "developer", "&k"
});
public static final List<String> FORBIDDEN_CODE = Arrays.asList(new String[]
{
"&k"
}); });
@Override @Override
@ -38,6 +33,7 @@ public class Command_tag extends TFM_Command
return true; return true;
} }
TFM_Util.adminAction(sender.getName(), "Removing all tags", false);
int count = 0; int count = 0;
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
@ -78,25 +74,20 @@ public class Command_tag extends TFM_Command
for (String word : FORBIDDEN_WORDS) for (String word : FORBIDDEN_WORDS)
{ {
if (args[0].toLowerCase().contains(word)) if (args[0].toLowerCase().contains(word))
{
if (word.contains("&"))
{
playerMsg("That tag contains a forbidden color-code.");
}
else
{ {
playerMsg("That tag contains a forbidden word."); playerMsg("That tag contains a forbidden word.");
}
return true; return true;
} }
} }
}
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
for (String word : FORBIDDEN_CODE)
{
if (args[0].toLowerCase().contains(word))
{
playerMsg("You may not include the colour code you have attempted to use in your tag")
return true;
} }
}
}
TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]); TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]);
playerMsg("Tag set."); playerMsg("Tag set.");

View File

@ -253,6 +253,12 @@ public class TFM_ServerInterface
return; return;
} }
if (TotalFreedomMod.lockdownEnabled)
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode.");
return;
}
if (player_list.hasWhitelist) if (player_list.hasWhitelist)
{ {
if (!player_list.getWhitelisted().contains(player_name.toLowerCase())) if (!player_list.getWhitelisted().contains(player_name.toLowerCase()))
@ -295,6 +301,11 @@ public class TFM_ServerInterface
} }
} }
} }
if (TotalFreedomMod.lockdownEnabled)
{
TFM_Util.playerMsg(p, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
}
} }
} }

View File

@ -49,6 +49,7 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean allPlayersFrozen = false; public static boolean allPlayersFrozen = false;
public static BukkitTask freezePurgeTask = null; public static BukkitTask freezePurgeTask = null;
public static BukkitTask mutePurgeTask = null; public static BukkitTask mutePurgeTask = null;
public static boolean lockdownEnabled = false;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>(); public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
// //
public static String pluginVersion = ""; public static String pluginVersion = "";