mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Cleaned up /purgeall and /halt
This commit is contained in:
parent
5c2e67ae1d
commit
8751e0454c
@ -1,5 +1,5 @@
|
|||||||
#Tue, 02 Jul 2013 14:04:59 +0200
|
#Tue, 02 Jul 2013 22:29:05 +0200
|
||||||
|
|
||||||
program.VERSION=2.20
|
program.VERSION=2.20
|
||||||
program.BUILDNUM=238
|
program.BUILDNUM=239
|
||||||
program.BUILDDATE=07/02/2013 02\:04 PM
|
program.BUILDDATE=07/02/2013 10\:29 PM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Tue Jul 02 14:04:59 CEST 2013
|
#Tue Jul 02 22:29:05 CEST 2013
|
||||||
build.number=239
|
build.number=240
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
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;
|
||||||
@ -29,7 +27,7 @@ public class Command_halt extends TFM_Command
|
|||||||
{
|
{
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
{
|
{
|
||||||
setHalted(p, true);
|
TFM_PlayerData.getPlayerData(p).setHalted(true);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,9 +41,10 @@ public class Command_halt extends TFM_Command
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||||
if (TFM_PlayerData.getPlayerData(p).isHalted())
|
if (TFM_PlayerData.getPlayerData(p).isHalted())
|
||||||
{
|
{
|
||||||
setHalted(p, false);
|
playerdata.setHalted(false);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,48 +88,20 @@ public class Command_halt extends TFM_Command
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TFM_PlayerData.getPlayerData(p).isHalted())
|
|
||||||
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||||
|
if (!playerdata.isHalted())
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
|
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
|
||||||
setHalted(p, true);
|
playerdata.setHalted(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
|
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
|
||||||
setHalted(p, false);
|
playerdata.setHalted(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setHalted(Player p, boolean is_halted)
|
|
||||||
{
|
|
||||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
|
||||||
|
|
||||||
if (is_halted)
|
|
||||||
{
|
|
||||||
p.setOp(false);
|
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
|
||||||
p.setFlying(false);
|
|
||||||
p.setDisplayName(p.getName());
|
|
||||||
p.closeInventory();
|
|
||||||
p.setTotalExperience(0);
|
|
||||||
|
|
||||||
playerdata.stopOrbiting();
|
|
||||||
playerdata.setFrozen(true);
|
|
||||||
playerdata.setMuted(true);
|
|
||||||
playerdata.setHalted(true);
|
|
||||||
|
|
||||||
p.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.setOp(true);
|
|
||||||
p.setGameMode(GameMode.CREATIVE);
|
|
||||||
playerdata.setFrozen(false);
|
|
||||||
playerdata.setMuted(false);
|
|
||||||
playerdata.setHalted(false);
|
|
||||||
p.sendMessage(ChatColor.GRAY + "You are no longer halted.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Ambient;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
|
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
|
||||||
@ -11,16 +22,81 @@ public class Command_purgeall 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)
|
||||||
{
|
{
|
||||||
server.dispatchCommand(sender, "rd");
|
|
||||||
server.dispatchCommand(sender, "potion clearall");
|
|
||||||
server.dispatchCommand(sender, "uall");
|
|
||||||
server.dispatchCommand(sender, "mute purge");
|
|
||||||
server.dispatchCommand(sender, "fr purge");
|
|
||||||
server.dispatchCommand(sender, "mp");
|
|
||||||
server.dispatchCommand(sender, "blockcmd purge");
|
|
||||||
server.dispatchCommand(sender, "halt purge");
|
|
||||||
|
|
||||||
//If I'm missing any, lemme know. Or just add it yourself.
|
TFM_Util.adminAction(sender.getName(), "Purging all player data", true);
|
||||||
|
|
||||||
|
// Purge entities
|
||||||
|
TFM_Util.wipeEntities(true, true);
|
||||||
|
|
||||||
|
// Undisguise all players
|
||||||
|
server.dispatchCommand(sender, "u *");
|
||||||
|
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||||
|
|
||||||
|
// Unmute all players
|
||||||
|
if (playerdata.isMuted())
|
||||||
|
{
|
||||||
|
playerdata.setMuted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unblock all commands
|
||||||
|
if (playerdata.allCommandsBlocked())
|
||||||
|
{
|
||||||
|
playerdata.setCommandsBlocked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unhalt all players
|
||||||
|
if (playerdata.isHalted())
|
||||||
|
{
|
||||||
|
playerdata.setHalted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop orbiting
|
||||||
|
if (playerdata.isOrbiting())
|
||||||
|
{
|
||||||
|
playerdata.stopOrbiting();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unfreeze
|
||||||
|
if (playerdata.isFrozen())
|
||||||
|
{
|
||||||
|
playerdata.setFrozen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purge potion effects
|
||||||
|
for (PotionEffect potion_effect : p.getActivePotionEffects())
|
||||||
|
{
|
||||||
|
p.removePotionEffect(potion_effect.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear auto-unmute and auto-unfreeze tasks
|
||||||
|
if (TotalFreedomMod.mutePurgeEventId != 0)
|
||||||
|
{
|
||||||
|
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
|
||||||
|
TotalFreedomMod.mutePurgeEventId = 0;
|
||||||
|
}
|
||||||
|
if (TotalFreedomMod.freezePurgeEventId != 0)
|
||||||
|
{
|
||||||
|
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
|
||||||
|
TotalFreedomMod.freezePurgeEventId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Remove all mobs
|
||||||
|
for (World world : server.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity ent : world.getLivingEntities())
|
||||||
|
{
|
||||||
|
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient)
|
||||||
|
{
|
||||||
|
ent.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
@ -400,6 +402,34 @@ public class TFM_PlayerData
|
|||||||
public void setHalted(boolean is_halted)
|
public void setHalted(boolean is_halted)
|
||||||
{
|
{
|
||||||
this.is_halted = is_halted;
|
this.is_halted = is_halted;
|
||||||
|
|
||||||
|
if (is_halted)
|
||||||
|
{
|
||||||
|
player.setOp(false);
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
player.setFlying(false);
|
||||||
|
player.setDisplayName(player_name);
|
||||||
|
player.closeInventory();
|
||||||
|
player.setTotalExperience(0);
|
||||||
|
|
||||||
|
stopOrbiting();
|
||||||
|
setFrozen(true);
|
||||||
|
setMuted(true);
|
||||||
|
setHalted(true);
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setOp(true);
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
setFrozen(false);
|
||||||
|
setMuted(false);
|
||||||
|
setHalted(false);
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask getLockupScheduleID()
|
public BukkitTask getLockupScheduleID()
|
||||||
|
Loading…
Reference in New Issue
Block a user