More improvements. (#15)

* This is rediculous

* Forgot some final and this

* Fixed and improved skull caging

* Windows wanted this yeah
This commit is contained in:
Seth 2017-12-31 20:43:10 -07:00 committed by Lemon
parent d9d1d4fa9b
commit 059bf14d90
16 changed files with 381 additions and 278 deletions

View File

@ -85,7 +85,7 @@ public class Monitors extends FreedomService
{ {
if (plugin.al.isAdmin(p) && plugin.pl.getPlayer(p).isPotionMonitorEnabled()) if (plugin.al.isAdmin(p) && plugin.pl.getPlayer(p).isPotionMonitorEnabled())
{ {
FUtil.playerMsg(p, player.getName() + " splashed " + event.getPotion().getItem().getAmount() + " " + this.getMaterial(droppedItem) + " at [" + decimalFormat.format(location.getX()) + ", " + decimalFormat.format(location.getY()) + ", " + decimalFormat.format(location.getZ()) + "] in the world '" + location.getWorld().getName() + "'."); FUtil.playerMsg(p, player.getName() + " splashed " + event.getPotion().getItem().getAmount() + " " + getMaterial(droppedItem) + " at [" + decimalFormat.format(location.getX()) + ", " + decimalFormat.format(location.getY()) + ", " + decimalFormat.format(location.getZ()) + "] in the world '" + location.getWorld().getName() + "'.");
} }
} }
} }

View File

@ -182,7 +182,7 @@ public class EventBlocker extends FreedomService
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void FireworkExplodeEvent(final FireworkExplodeEvent event public void onFireworkExplode(final FireworkExplodeEvent event
) )
{ {
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean()) if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
@ -192,7 +192,7 @@ public class EventBlocker extends FreedomService
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void BlockPistonRetractEvent(final BlockPistonRetractEvent event) public void onBlockPistonRetract(BlockPistonRetractEvent event)
{ {
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {
@ -201,7 +201,7 @@ public class EventBlocker extends FreedomService
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void BlockPistonExtendEvent(final BlockPistonExtendEvent event) public void onBlockPistonExtend(BlockPistonExtendEvent event)
{ {
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {
@ -210,7 +210,7 @@ public class EventBlocker extends FreedomService
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void BlockRedstoneEvent(final BlockRedstoneEvent event) public void onBlockRedstone(BlockRedstoneEvent event)
{ {
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {

View File

@ -49,18 +49,21 @@ public class SignBlocker extends FreedomService
String line2 = bet.getString("Text2"); String line2 = bet.getString("Text2");
String line3 = bet.getString("Text3"); String line3 = bet.getString("Text3");
String line4 = bet.getString("Text4"); String line4 = bet.getString("Text4");
if(line1.contains("run_command") || line2.contains("run_command") || line3.contains("run_command") || line4.contains("run_command")) if (line1.contains("run_command") || line2.contains("run_command") || line3.contains("run_command") || line4.contains("run_command"))
{ {
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs."); player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteractSign(PlayerInteractEvent event) public void onPlayerInteractSign(PlayerInteractEvent event)
{ {
if(event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return; {
return;
}
if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN))
{ {

View File

@ -21,11 +21,13 @@ public class CommandBlockerEntry
@Getter @Getter
private final String message; private final String message;
public CommandBlockerEntry(final CommandBlockerRank rank, final CommandBlockerAction action, final String command, final String message) { public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
{
this(rank, action, command, null, message); this(rank, action, command, null, message);
} }
public CommandBlockerEntry(final CommandBlockerRank rank, final CommandBlockerAction action, final String command, final String subCommand, final String message) { public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, String message)
{
this.rank = rank; this.rank = rank;
this.action = action; this.action = action;
this.command = command; this.command = command;
@ -33,36 +35,44 @@ public class CommandBlockerEntry
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message); this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
} }
public void doActions(final CommandSender sender) { public void doActions(CommandSender sender)
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) { {
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + this.command); if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED); FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
return; return;
} }
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN) { if (action == CommandBlockerAction.BLOCK_UNKNOWN)
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET); {
FUtil.playerMsg(sender, "Unknown command. Type \"/help\" for help.", ChatColor.RESET);
return; return;
} }
FUtil.playerMsg(sender, FUtil.colorize(this.message)); FUtil.playerMsg(sender, FUtil.colorize(message));
} }
public CommandBlockerRank getRank() { public CommandBlockerRank getRank()
return this.rank; {
return rank;
} }
public CommandBlockerAction getAction() { public CommandBlockerAction getAction()
return this.action; {
return action;
} }
public String getCommand() { public String getCommand()
return this.command; {
return command;
} }
public String getSubCommand() { public String getSubCommand()
return this.subCommand; {
return subCommand;
} }
public String getMessage() { public String getMessage()
return this.message; {
return message;
} }
} }

View File

@ -17,7 +17,6 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit;
import me.totalfreedom.totalfreedommod.command.Command_vanish; import me.totalfreedom.totalfreedommod.command.Command_vanish;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import com.earth2me.essentials.Essentials; import com.earth2me.essentials.Essentials;
@ -26,12 +25,11 @@ import me.totalfreedom.totalfreedommod.FreedomService;
public class EssentialsBridge extends FreedomService public class EssentialsBridge extends FreedomService
{ {
private Essentials essentialsPlugin; private Essentials essentialsPlugin = null;
public EssentialsBridge(final TotalFreedomMod plugin) public EssentialsBridge(TotalFreedomMod plugin)
{ {
super(plugin); super(plugin);
this.essentialsPlugin = null;
} }
@Override @Override
@ -42,19 +40,19 @@ public class EssentialsBridge extends FreedomService
@Override @Override
protected void onStop() protected void onStop()
{ {
Command_vanish.vanished.clear(); Command_vanish.VANISHED.clear();
} }
public Essentials getEssentialsPlugin() public Essentials getEssentialsPlugin()
{ {
if (this.essentialsPlugin == null) if (essentialsPlugin == null)
{ {
try try
{ {
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials"); final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
if (essentials != null && essentials instanceof Essentials) if (essentials != null && essentials instanceof Essentials)
{ {
this.essentialsPlugin = (Essentials) essentials; essentialsPlugin = (Essentials) essentials;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -62,14 +60,14 @@ public class EssentialsBridge extends FreedomService
FLog.severe(ex); FLog.severe(ex);
} }
} }
return this.essentialsPlugin; return essentialsPlugin;
} }
public User getEssentialsUser(final String username) public User getEssentialsUser(String username)
{ {
try try
{ {
final Essentials essentials = this.getEssentialsPlugin(); Essentials essentials = getEssentialsPlugin();
if (essentials != null) if (essentials != null)
{ {
return essentials.getUserMap().getUser(username); return essentials.getUserMap().getUser(username);
@ -82,11 +80,11 @@ public class EssentialsBridge extends FreedomService
return null; return null;
} }
public void setNickname(final String username, final String nickname) public void setNickname(String username, String nickname)
{ {
try try
{ {
final User user = this.getEssentialsUser(username); User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
user.setNickname(nickname); user.setNickname(nickname);
@ -99,11 +97,11 @@ public class EssentialsBridge extends FreedomService
} }
} }
public String getNickname(final String username) public String getNickname(String username)
{ {
try try
{ {
final User user = this.getEssentialsUser(username); User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
return user.getNickname(); return user.getNickname();
@ -116,11 +114,11 @@ public class EssentialsBridge extends FreedomService
return null; return null;
} }
public long getLastActivity(final String username) public long getLastActivity(String username)
{ {
try try
{ {
final User user = this.getEssentialsUser(username); User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
return FUtil.getField(user, "lastActivity"); return FUtil.getField(user, "lastActivity");
@ -133,11 +131,11 @@ public class EssentialsBridge extends FreedomService
return 0L; return 0L;
} }
public void setVanished(final String username, final boolean vanished) public void setVanished(String username, boolean vanished)
{ {
try try
{ {
final User user = this.getEssentialsUser(username); User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
user.setVanished(vanished); user.setVanished(vanished);
@ -150,76 +148,76 @@ public class EssentialsBridge extends FreedomService
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClickEvent(final InventoryClickEvent event) public void onInventoryClick(InventoryClickEvent event)
{ {
Player refreshPlayer = null; Player refreshPlayer = null;
final Inventory top = event.getView().getTopInventory(); Inventory inventory = event.getView().getTopInventory();
final InventoryType type = top.getType(); InventoryType inventoryType = inventory.getType();
final Player playerdata = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
final FPlayer fPlayer = ((TotalFreedomMod) this.plugin).pl.getPlayer(playerdata); FPlayer fPlayer = plugin.pl.getPlayer(player);
if (type == InventoryType.PLAYER && fPlayer.isInvSee()) if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
{ {
final InventoryHolder invHolder = top.getHolder(); final InventoryHolder inventoryHolder = inventory.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity) if (inventoryHolder != null && inventoryHolder instanceof HumanEntity)
{ {
final Player invOwner = (Player) invHolder; Player invOwner = (Player) inventoryHolder;
final Rank recieverRank = ((TotalFreedomMod) this.plugin).rm.getRank(playerdata); Rank recieverRank = plugin.rm.getRank(player);
final Rank playerRank = ((TotalFreedomMod) this.plugin).rm.getRank(invOwner); Rank playerRank = plugin.rm.getRank(invOwner);
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline()) if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
{ {
event.setCancelled(true); event.setCancelled(true);
refreshPlayer = playerdata; refreshPlayer = player;
} }
} }
} }
if (refreshPlayer != null) if (refreshPlayer != null)
{ {
final Player player = refreshPlayer; final Player p = refreshPlayer;
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override
public void run() public void run()
{ {
player.updateInventory(); p.updateInventory();
} }
}.runTaskLater((Plugin) this.plugin, 20L); }.runTaskLater(plugin, 20L);
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event) public void onInventoryClose(InventoryCloseEvent event)
{ {
Player refreshPlayer = null; Player refreshPlayer = null;
final Inventory top = event.getView().getTopInventory(); Inventory inventory = event.getView().getTopInventory();
final InventoryType type = top.getType(); InventoryType inventoryType = inventory.getType();
final Player playerdata = (Player) event.getPlayer(); Player player = (Player) event.getPlayer();
final FPlayer fPlayer = ((TotalFreedomMod) this.plugin).pl.getPlayer(playerdata); FPlayer fPlayer = plugin.pl.getPlayer(player);
if (type == InventoryType.PLAYER && fPlayer.isInvSee()) if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
{ {
fPlayer.setInvSee(false); fPlayer.setInvSee(false);
refreshPlayer = playerdata; refreshPlayer = player;
} }
if (refreshPlayer != null) if (refreshPlayer != null)
{ {
final Player player = refreshPlayer; final Player p = refreshPlayer;
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override
public void run() public void run()
{ {
player.updateInventory(); p.updateInventory();
} }
}.runTaskLater((Plugin) this.plugin, 20L); }.runTaskLater(plugin, 20L);
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuitEvent(final PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
final Player player = event.getPlayer(); Player player = event.getPlayer();
if (Command_vanish.vanished.contains(player)) if (Command_vanish.VANISHED.contains(player))
{ {
Command_vanish.vanished.remove(player); Command_vanish.VANISHED.remove(player);
} }
} }
@ -227,7 +225,7 @@ public class EssentialsBridge extends FreedomService
{ {
try try
{ {
final Essentials essentials = this.getEssentialsPlugin(); Essentials essentials = getEssentialsPlugin();
if (essentials != null) if (essentials != null)
{ {
return essentials.isEnabled(); return essentials.isEnabled();

View File

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.caging;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import me.totalfreedom.totalfreedommod.command.Command_cage;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -26,6 +25,8 @@ public class CageData
private Material outerMaterial = Material.GLASS; private Material outerMaterial = Material.GLASS;
@Getter @Getter
private Material innerMaterial = Material.AIR; private Material innerMaterial = Material.AIR;
@Getter
private static String input = null;
public CageData(FPlayer player) public CageData(FPlayer player)
{ {
@ -58,6 +59,24 @@ public class CageData
this.location = location; this.location = location;
this.outerMaterial = outer; this.outerMaterial = outer;
this.innerMaterial = inner; this.innerMaterial = inner;
this.input = null;
buildHistory(location, 2, fPlayer);
regenerate();
}
public void cage(Location location, Material outer, Material inner, String input)
{
if (isCaged())
{
setCaged(false);
}
this.caged = true;
this.location = location;
this.outerMaterial = outer;
this.innerMaterial = inner;
this.input = input;
buildHistory(location, 2, fPlayer); buildHistory(location, 2, fPlayer);
regenerate(); regenerate();
@ -86,7 +105,7 @@ public class CageData
return; return;
} }
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial); cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
} }
public void playerQuit() public void playerQuit()
@ -177,7 +196,7 @@ public class CageData
block.setType(material); block.setType(material);
} }
else // Darth mode else
{ {
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length) if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
{ {
@ -186,10 +205,13 @@ public class CageData
} }
block.setType(Material.SKULL); block.setType(Material.SKULL);
final Skull skull = (Skull) block.getState(); if (input != null)
skull.setSkullType(SkullType.PLAYER); {
skull.setOwner(Command_cage.playerSkullName); Skull skull = (Skull) block.getState();
skull.update(); skull.setSkullType(SkullType.PLAYER);
skull.setOwner(input);
skull.update();
}
} }
} }
} }

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -30,7 +29,7 @@ public class Command_blockredstone extends FreedomCommand
ConfigEntry.ALLOW_REDSTONE.setBoolean(true); ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
} }
} }
}.runTaskLater((Plugin) this.plugin, 6000L); }.runTaskLater(plugin, 6000L);
} }
else else
{ {

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -16,49 +15,64 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [skull | block] [blockname | skullname]") @CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [skull | block] [blockname | skullname]")
public class Command_cage extends FreedomCommand public class Command_cage extends FreedomCommand
{ {
public static String playerSkullName;
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) { public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
if (args.length == 0) { {
if (args.length == 0)
{
return false; return false;
} }
if ("off".equals(args[0]) && sender instanceof Player) { String skullName = null;
if ("off".equals(args[0]) && sender instanceof Player)
{
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true); FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(playerSender); final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.getCageData().setCaged(false); playerdata.getCageData().setCaged(false);
return true; return true;
} }
if ("purge".equals(args[0])) { if ("purge".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Uncaging all players", true); FUtil.adminAction(sender.getName(), "Uncaging all players", true);
for (final Player player : this.server.getOnlinePlayers()) { for (Player player : server.getOnlinePlayers())
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player); {
playerdata2.getCageData().setCaged(false); final FPlayer fPlayer = plugin.pl.getPlayer(player);
fPlayer.getCageData().setCaged(false);
} }
return true; return true;
} }
final Player player2 = this.getPlayer(args[0]); Player player = getPlayer(args[0]);
if (player2 == null) { if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true; return true;
} }
final FPlayer playerdata3 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2); final FPlayer fPlayer = plugin.pl.getPlayer(player);
Material outerMaterial = Material.GLASS; Material outerMaterial = Material.GLASS;
Material innerMaterial = Material.AIR; Material innerMaterial = Material.AIR;
if (args.length >= 2 && null != args[1]) { if (args.length >= 2 && args[1] != null)
{
final String s = args[1]; final String s = args[1];
switch (s) { switch (s)
case "off": { {
FUtil.adminAction(sender.getName(), "Uncaging " + player2.getName(), true); case "off":
playerdata3.getCageData().setCaged(false); {
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
fPlayer.getCageData().setCaged(false);
return true; return true;
} }
case "skull": { case "skull":
{
outerMaterial = Material.SKULL; outerMaterial = Material.SKULL;
Command_cage.playerSkullName = args[2]; if (args.length >= 3)
{
skullName = args[2];
}
break; break;
} }
case "block": { case "block":
if (Material.matchMaterial(args[2]) != null) { {
if (Material.matchMaterial(args[2]) != null)
{
outerMaterial = Material.matchMaterial(args[2]); outerMaterial = Material.matchMaterial(args[2]);
break; break;
} }
@ -67,22 +81,34 @@ public class Command_cage extends FreedomCommand
} }
} }
} }
if (args.length >= 3) { if (args.length >= 3)
if (args[2].equalsIgnoreCase("water")) { {
if (args[2].equalsIgnoreCase("water"))
{
innerMaterial = Material.STATIONARY_WATER; innerMaterial = Material.STATIONARY_WATER;
} }
else if (args[2].equalsIgnoreCase("lava")) { else if (args[2].equalsIgnoreCase("lava"))
{
innerMaterial = Material.STATIONARY_LAVA; innerMaterial = Material.STATIONARY_LAVA;
} }
} }
final Location targetPos = player2.getLocation().clone().add(0.0, 1.0, 0.0); Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
playerdata3.getCageData().cage(targetPos, outerMaterial, innerMaterial); if (skullName != null)
player2.setGameMode(GameMode.SURVIVAL); {
if (outerMaterial != Material.SKULL) { fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
FUtil.adminAction(sender.getName(), "Caging " + player2.getName(), true);
} }
else { else
FUtil.adminAction(sender.getName(), "Caging " + player2.getName() + " in " + Command_cage.playerSkullName, true); {
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
}
player.setGameMode(GameMode.SURVIVAL);
if (outerMaterial == Material.SKULL && skullName != null)
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
}
else
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
} }
return true; return true;
} }

View File

@ -1,9 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Displayable; import me.totalfreedom.totalfreedommod.rank.Displayable;
import java.util.Iterator;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
@ -21,90 +18,110 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
public class Command_list extends FreedomCommand public class Command_list extends FreedomCommand
{ {
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) { public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
if (args.length > 1) { if (args.length > 1)
{
return false; return false;
} }
if (FUtil.isFromHostConsole(sender.getName())) { if (FUtil.isFromHostConsole(sender.getName()))
final List<String> names = new ArrayList<String>(); {
for (final Player player : this.server.getOnlinePlayers()) { List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers())
{
names.add(player.getName()); names.add(player.getName());
} }
this.msg("There are " + names.size() + "/" + this.server.getMaxPlayers() + " players online:\n" + StringUtils.join((Iterable)names, ", "), ChatColor.WHITE); msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join((Iterable)names, ", "), ChatColor.WHITE);
return true; return true;
} }
ListFilter listFilter = null; ListFilter listFilter = null;
if (args.length == 1) { if (args.length == 1)
final String s = args[0]; {
switch (s) { String s = args[0];
case "-a": { switch (s)
{
case "-a":
{
listFilter = ListFilter.ADMINS; listFilter = ListFilter.ADMINS;
break; break;
} }
case "-v": { case "-v":
{
listFilter = ListFilter.VANISHED_ADMINS; listFilter = ListFilter.VANISHED_ADMINS;
break; break;
} }
case "-i": { case "-i":
{
listFilter = ListFilter.IMPOSTORS; listFilter = ListFilter.IMPOSTORS;
break; break;
} }
case "-f": { case "-f":
{
listFilter = ListFilter.FAMOUS_PLAYERS; listFilter = ListFilter.FAMOUS_PLAYERS;
break; break;
} }
default: { default:
{
return false; return false;
} }
} }
} }
else { else
{
listFilter = ListFilter.PLAYERS; listFilter = ListFilter.PLAYERS;
} }
if (listFilter == ListFilter.VANISHED_ADMINS && !((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)playerSender)) { StringBuilder onlineStats = new StringBuilder();
this.msg("/list [-a | -i | -f ]", ChatColor.WHITE); StringBuilder onlineUsers = new StringBuilder();
return true; onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - Command_vanish.VANISHED.size())
.append(ChatColor.BLUE)
.append(" out of a maximum ")
.append(ChatColor.RED)
.append(server.getMaxPlayers())
.append(" players online.");
List<String> n = new ArrayList<String>();
for (Player p : server.getOnlinePlayers())
{
if (listFilter == ListFilter.ADMINS && plugin.al.isAdmin(p))
{
continue;
}
if (listFilter == ListFilter.ADMINS && Command_vanish.VANISHED.contains(p))
{
continue;
}
if (listFilter == ListFilter.VANISHED_ADMINS && !Command_vanish.VANISHED.contains(p))
{
continue;
}
if (listFilter == ListFilter.IMPOSTORS && !((TotalFreedomMod)this.plugin).al.isAdminImpostor(p))
{
continue;
}
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
{
continue;
}
if (listFilter == ListFilter.PLAYERS && Command_vanish.VANISHED.contains(p))
{
continue;
}
final Displayable display = plugin.rm.getDisplay(p);
n.add(display.getColoredTag() + p.getName());
} }
final StringBuilder onlineStats = new StringBuilder(); String playerType = (listFilter == null) ? "players" : listFilter.toString().toLowerCase().replace('_', ' ');
final StringBuilder onlineUsers = new StringBuilder(); onlineUsers.append("Connected ")
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(this.server.getOnlinePlayers().size() - Command_vanish.vanished.size()); .append(playerType + ": ")
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(this.server.getMaxPlayers()); .append(playerType + ": ")
onlineStats.append(ChatColor.BLUE).append(" players online."); .append(StringUtils.join((Iterable)n, ChatColor.WHITE + ", "));
final List<String> names2 = new ArrayList<String>(); if (senderIsConsole)
for (final Player player2 : this.server.getOnlinePlayers()) { {
if (listFilter == ListFilter.ADMINS && !((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) {
continue;
}
if (listFilter == ListFilter.ADMINS && Command_vanish.vanished.contains(player2)) {
continue;
}
if (listFilter == ListFilter.VANISHED_ADMINS && !Command_vanish.vanished.contains(player2)) {
continue;
}
if (listFilter == ListFilter.IMPOSTORS && !((TotalFreedomMod)this.plugin).al.isAdminImpostor(player2)) {
continue;
}
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(player2.getName().toLowerCase())) {
continue;
}
if (listFilter == ListFilter.PLAYERS && Command_vanish.vanished.contains(player2)) {
continue;
}
final Displayable display = ((TotalFreedomMod)this.plugin).rm.getDisplay((CommandSender)player2);
names2.add(display.getColoredTag() + player2.getName());
}
final String playerType = (listFilter == null) ? "players" : listFilter.toString().toLowerCase().replace('_', ' ');
onlineUsers.append("Connected ");
onlineUsers.append(playerType + ": ");
onlineUsers.append(StringUtils.join((Iterable)names2, ChatColor.WHITE + ", "));
if (senderIsConsole) {
sender.sendMessage(ChatColor.stripColor(onlineStats.toString())); sender.sendMessage(ChatColor.stripColor(onlineStats.toString()));
sender.sendMessage(ChatColor.stripColor(onlineUsers.toString())); sender.sendMessage(ChatColor.stripColor(onlineUsers.toString()));
} }
else { else
{
sender.sendMessage(onlineStats.toString()); sender.sendMessage(onlineStats.toString());
sender.sendMessage(onlineUsers.toString()); sender.sendMessage(onlineUsers.toString());
} }
names2.clear(); n.clear();
return true; return true;
} }

View File

@ -38,7 +38,7 @@ public class Command_opall extends FreedomCommand
player.setOp(true); player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP); player.sendMessage(FreedomCommand.YOU_ARE_OP);
if (doSetGamemode) if (doSetGamemode && !plugin.al.isAdmin(player))
{ {
player.setGameMode(targetGamemode); player.setGameMode(targetGamemode);
} }

View File

@ -1,38 +1,44 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import me.totalfreedom.totalfreedommod.rank.Rank; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Quickly change your own gamemode to spectator.", usage = "/<command>", aliases = "gmsp") @CommandParameters(description = "Quickly change your own gamemode to spectator, or define someone's username to change theirs.", usage = "/<command> <[partialname]>", aliases = "gmsp")
public class Command_spectator extends FreedomCommand public class Command_spectator extends FreedomCommand
{ {
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
if (args.length == 0) { @Override
if (this.isConsole()) { public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player."); sender.sendMessage("When used from the console, you must define a target player.");
return true; return true;
} }
playerSender.setGameMode(GameMode.SPECTATOR); playerSender.setGameMode(GameMode.SPECTATOR);
this.msg("Gamemode set to spectator."); msg("Gamemode set to spectator.");
return true; return true;
} }
else {
this.checkRank(Rank.SUPER_ADMIN); Player player = getPlayer(args[0]);
final Player player = this.getPlayer(args[0]);
if (player == null) { if (player == null)
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); {
return true; sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
}
this.msg("Setting " + player.getName() + " to game mode spectator");
this.msg((CommandSender)player, sender.getName() + " set your game mode to spectator");
player.setGameMode(GameMode.SPECTATOR);
return true; return true;
} }
msg("Setting " + player.getName() + " to game mode spectator");
msg(player, sender.getName() + " set your game mode to spectator");
player.setGameMode(GameMode.SPECTATOR);
return true;
} }
} }

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.GameRuleHandler; import me.totalfreedom.totalfreedommod.GameRuleHandler;
import me.totalfreedom.totalfreedommod.GameRuleHandler.GameRule;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
@ -38,103 +37,129 @@ public class Command_toggle extends FreedomCommand
return false; return false;
} }
if (args[0].equals("waterplace")) { if (args[0].equals("waterplace"))
this.toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE); {
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
return true; return true;
} }
if (args[0].equals("frostwalk")) { else if (args[0].equals("frostwalk"))
this.toggle("Frost walker enchantment is ", ConfigEntry.ALLOW_FROSTWALKER); {
toggle("Frost walker enchantment is ", ConfigEntry.ALLOW_FROSTWALKER);
return true; return true;
} }
if (args[0].equals("fireplace")) { else if (args[0].equals("fireplace"))
this.toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE); {
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
return true; return true;
} }
if (args[0].equals("lavaplace")) { else if (args[0].equals("lavaplace"))
this.toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE); {
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
return true; return true;
} }
/*if (args[0].equals("explosivearrows")) else if (args[0].equals("fluidspread"))
{ {
toggle("Explosive arrows are now", ConfigEntry.MAKE_ARROW_EXPLOSIVE); toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
return true;
}*/
if (args[0].equals("fluidspread")) {
this.toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
return true; return true;
} }
if (args[0].equals("lavadmg")) { else if (args[0].equals("lavadmg"))
this.toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE); {
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
return true; return true;
} }
if (args[0].equals("firespread")) { else if (args[0].equals("firespread"))
this.toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD); {
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
((TotalFreedomMod)this.plugin).gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean()); ((TotalFreedomMod)this.plugin).gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
return true; return true;
} }
if (args[0].equals("prelog")) { else if (args[0].equals("prelog"))
this.toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG); {
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
return true; return true;
} }
if (args[0].equals("lockdown")) { else if (args[0].equals("lockdown"))
final boolean active = !((TotalFreedomMod)this.plugin).lp.isLockdownEnabled(); {
((TotalFreedomMod)this.plugin).lp.setLockdownEnabled(active); boolean active = !plugin.lp.isLockdownEnabled();
plugin.lp.setLockdownEnabled(active);
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true); FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
return true; return true;
} }
if (args[0].equals("petprotect")) { else if (args[0].equals("petprotect"))
this.toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT); {
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
return true; return true;
} }
if (args[0].equals("entitywipe")) { else if (args[0].equals("entitywipe"))
this.toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE); {
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
return true; return true;
} }
if (args[0].equals("firework")) { else if (args[0].equals("firework"))
this.toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION); {
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
return true; return true;
} }
if (args[0].equals("nonuke")) { else if (args[0].equals("nonuke"))
if (args.length >= 2) { {
try { if (args.length >= 2)
{
try
{
ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1])))); ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
} }
catch (NumberFormatException ex2) {} catch (NumberFormatException ex)
{
}
} }
if (args.length >= 3) { if (args.length >= 3)
try { {
try
{
ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2])))); ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
} }
catch (NumberFormatException ex3) {} catch (NumberFormatException ex)
{
}
} }
this.toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED); toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED);
if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean()) { if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
this.msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks."); {
this.msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds."); msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
} }
return true; return true;
} }
if (args[0].equals("explosives")) { else if (args[0].equals("explosives"))
if (args.length == 2) { {
try { if (args.length == 2)
{
try
{
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1])))); ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
} }
catch (NumberFormatException ex) { catch (NumberFormatException ex)
this.msg(ex.getMessage()); {
msg("The input provided is not a valid integer.");
return true; return true;
} }
} }
this.toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS); toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
this.msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble()); {
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
} }
return true; return true;
} }
return false; else
{
return false;
}
} }
private void toggle(final String name, final ConfigEntry entry) { private void toggle(final String name, final ConfigEntry entry)
this.msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled.")); {
msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
} }
} }

View File

@ -1,5 +1,3 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator; import java.util.Iterator;
@ -18,51 +16,50 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME, blockHostConsole = true) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command>", aliases = "v") @CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command>", aliases = "v")
public class Command_vanish extends FreedomCommand public class Command_vanish extends FreedomCommand
{ {
public static ArrayList<Player> vanished; public static ArrayList<Player> VANISHED = new ArrayList<Player>();
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) { public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
final Displayable display = ((TotalFreedomMod)this.plugin).rm.getDisplay((CommandSender)playerSender); Displayable display = plugin.rm.getDisplay(playerSender);
String loginMsg = display.getColoredLoginMessage(); String loginMsg = display.getColoredLoginMessage();
final String displayName = display.getColor() + playerSender.getName(); String displayName = display.getColor() + playerSender.getName();
final Admin admin = ((TotalFreedomMod)this.plugin).al.getAdmin(playerSender); Admin admin = plugin.al.getAdmin(playerSender);
if (Command_vanish.vanished.contains(playerSender)) { if (VANISHED.contains(playerSender))
this.msg(ChatColor.GOLD + "You have been unvanished."); {
if (admin.hasLoginMessage()) { msg(ChatColor.GOLD + "You have been unvanished.");
if (admin.hasLoginMessage())
{
loginMsg = FUtil.colorize(admin.getLoginMessage()); loginMsg = FUtil.colorize(admin.getLoginMessage());
} }
FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg); FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg);
FUtil.bcastMsg(playerSender.getName() + " joined the game", ChatColor.YELLOW); FUtil.bcastMsg(playerSender.getName() + " joined the game", ChatColor.YELLOW);
((TotalFreedomMod)this.plugin).pl.getPlayer(playerSender).setTag(display.getColoredTag()); plugin.pl.getPlayer(playerSender).setTag(display.getColoredTag());
FLog.info(playerSender.getName() + " is no longer vanished."); FLog.info(playerSender.getName() + " is no longer vanished.");
for (final Player player : this.server.getOnlinePlayers()) { for (Player player : server.getOnlinePlayers())
{
player.showPlayer(playerSender); player.showPlayer(playerSender);
} }
((TotalFreedomMod)this.plugin).esb.setVanished(playerSender.getName(), false); plugin.esb.setVanished(playerSender.getName(), false);
playerSender.removePotionEffect(PotionEffectType.INVISIBILITY); playerSender.removePotionEffect(PotionEffectType.INVISIBILITY);
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16)); playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
Command_vanish.vanished.remove(playerSender); VANISHED.remove(playerSender);
return true;
} }
if (!Command_vanish.vanished.contains(playerSender)) { else
this.msg(ChatColor.GOLD + "You have been vanished."); {
msg("You have been vanished.", ChatColor.GOLD);
FUtil.bcastMsg(playerSender.getName() + " left the game", ChatColor.YELLOW); FUtil.bcastMsg(playerSender.getName() + " left the game", ChatColor.YELLOW);
FLog.info(playerSender.getName() + " is now vanished."); FLog.info(playerSender.getName() + " is now vanished.");
for (final Player player : this.server.getOnlinePlayers()) { for (Player player : server.getOnlinePlayers())
{
player.hidePlayer(playerSender); player.hidePlayer(playerSender);
} }
((TotalFreedomMod)this.plugin).esb.setVanished(playerSender.getName(), true); plugin.esb.setVanished(playerSender.getName(), true);
playerSender.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 1000000, true, false)); playerSender.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 1000000, true, false));
Command_vanish.vanished.add(playerSender); VANISHED.add(playerSender);
return true;
} }
return true; return true;
} }
static {
Command_vanish.vanished = new ArrayList<Player>();
}
} }

View File

@ -6,7 +6,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
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;
import org.bukkit.plugin.Plugin; import com.earth2me.essentials.Essentials;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true) @CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes essentials warps", usage = "/<command>") @CommandParameters(description = "Removes essentials warps", usage = "/<command>")
@ -22,11 +22,12 @@ public class Command_wipewarps extends FreedomCommand
return true; return true;
} }
Plugin essentials = server.getPluginManager().getPlugin("Essentials"); Essentials essentials = plugin.esb.getEssentialsPlugin();
FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true); File warps = new File(essentials.getDataFolder(), "warps");
server.getPluginManager().disablePlugin(essentials); FUtil.adminAction(sender.getName(), "Wiping Essentials warps", true);
FUtil.deleteFolder(new File(essentials.getDataFolder(), "warps")); FUtil.deleteFolder(warps);
server.getPluginManager().enablePlugin(essentials); warps.mkdir();
essentials.reload();
msg("All warps deleted."); msg("All warps deleted.");
return true; return true;
} }

View File

@ -40,7 +40,6 @@ public enum ConfigEntry
SERVER_ADDRESS(String.class, "server.address"), SERVER_ADDRESS(String.class, "server.address"),
SERVER_MOTD(String.class, "server.motd"), SERVER_MOTD(String.class, "server.motd"),
SERVER_OWNERS(List.class, "server.owners"), SERVER_OWNERS(List.class, "server.owners"),
SERVER_FOUNDER(List.class, "server.founders"),
SERVER_BAN_URL(String.class, "server.ban_url"), SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_PERMBAN_URL(String.class, "server.permban_url"), SERVER_PERMBAN_URL(String.class, "server.permban_url"),
// //

View File

@ -130,7 +130,7 @@ public class FUtil
Math.round(location.getZ())); Math.round(location.getZ()));
} }
public static boolean deleteFolder(final File file) public static boolean deleteFolder(File file)
{ {
if (file.exists() && file.isDirectory()) if (file.exists() && file.isDirectory())
{ {
@ -375,8 +375,8 @@ public class FUtil
{ {
CHAT_COLOR_ITERATOR = CHAT_COLOR_POOL.iterator(); CHAT_COLOR_ITERATOR = CHAT_COLOR_POOL.iterator();
final StringBuilder newString = new StringBuilder(); StringBuilder newString = new StringBuilder();
final char[] chars = string.toCharArray(); char[] chars = string.toCharArray();
for (char c : chars) for (char c : chars)
{ {