Added Freeze and Mute purger

This commit is contained in:
Jerom van der Sar 2013-01-16 15:48:56 +01:00
parent 3399207fd7
commit bd0d437eae
5 changed files with 57 additions and 3 deletions

View File

@ -30,8 +30,8 @@ public class Command_blockcmd extends TFM_Command
counter += 1; counter += 1;
playerdata.setCommandsBlocked(false); playerdata.setCommandsBlocked(false);
} }
playerMsg("Unblocked commands for " + counter + " players.");
} }
playerMsg("Unblocked commands for " + counter + " players.");
return true; return true;
} }

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
@ -20,14 +21,36 @@ public class Command_fr extends TFM_Command
if (TotalFreedomMod.allPlayersFrozen) if (TotalFreedomMod.allPlayersFrozen)
{ {
TotalFreedomMod.allPlayersFrozen = true;
TFM_Util.adminAction(sender.getName(), "Freezing all players", false); TFM_Util.adminAction(sender.getName(), "Freezing all players", false);
TotalFreedomMod.allPlayersFrozen = true;
TotalFreedomMod.freezePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
@Override
public void run()
{
if (TotalFreedomMod.freezePurgeEventId == 0)
{
TFM_Log.warning("Freeze autopurge task was improperly cancelled!");
return;
}
TFM_Util.adminAction("FreezeTimer", "Unfreezing all players", false);
TotalFreedomMod.allPlayersFrozen = false;
TotalFreedomMod.freezePurgeEventId = 0;
}
}, 6000L); // five minutes in ticks: 20*60*5
playerMsg("Players are now frozen."); playerMsg("Players are now frozen.");
} }
else else
{ {
TotalFreedomMod.allPlayersFrozen = false;
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false); TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
TotalFreedomMod.allPlayersFrozen = false;
if (TotalFreedomMod.freezePurgeEventId != 0)
{
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
TotalFreedomMod.freezePurgeEventId = 0;
}
playerMsg("Players are now free to move."); playerMsg("Players are now free to move.");
} }
} }

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -39,6 +40,7 @@ public class Command_potion extends TFM_Command
playerMsg(TotalFreedomMod.MSG_NO_PERMS); playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true; return true;
} }
TFM_Util.adminAction(sender.getName(), "Cleared all potion effects from all players", true);
for (Player target : server.getOnlinePlayers()) for (Player target : server.getOnlinePlayers())
{ {
for (PotionEffect potion_effect : target.getActivePotionEffects()) for (PotionEffect potion_effect : target.getActivePotionEffects())

View File

@ -1,8 +1,10 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -51,6 +53,11 @@ public class Command_stfu extends TFM_Command
count++; count++;
} }
} }
if (TotalFreedomMod.mutePurgeEventId != 0)
{
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
TotalFreedomMod.mutePurgeEventId = 0;
}
playerMsg("Unmuted " + count + " players."); playerMsg("Unmuted " + count + " players.");
} }
else if (args[0].equalsIgnoreCase("all")) else if (args[0].equalsIgnoreCase("all"))
@ -69,6 +76,26 @@ public class Command_stfu extends TFM_Command
} }
} }
TotalFreedomMod.mutePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
@Override
public void run()
{
if (TotalFreedomMod.mutePurgeEventId == 0)
{
TFM_Log.warning("Mute autopurge task was improperly cancelled!");
return;
}
TFM_Util.adminAction("MuteTimer", "Unfreezing all players", false);
for (Player p : server.getOnlinePlayers())
{
TFM_UserInfo.getPlayerData(p).setMuted(false);
}
TotalFreedomMod.mutePurgeEventId = 0;
}
}, 6000L); // five minutes in ticks: 20*60*5
playerMsg("Muted " + counter + " players."); playerMsg("Muted " + counter + " players.");
} }
else else

View File

@ -46,6 +46,8 @@ public class TotalFreedomMod extends JavaPlugin
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console."; public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static boolean allPlayersFrozen = false; public static boolean allPlayersFrozen = false;
public static int freezePurgeEventId = 0;
public static int mutePurgeEventId = 0;
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 = "";