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

View File

@ -49,18 +49,21 @@ public class SignBlocker extends FreedomService
String line2 = bet.getString("Text2");
String line3 = bet.getString("Text3");
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.");
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteractSign(PlayerInteractEvent event)
{
if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
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))
{

View File

@ -21,11 +21,13 @@ public class CommandBlockerEntry
@Getter
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);
}
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.action = action;
this.command = command;
@ -33,36 +35,44 @@ public class CommandBlockerEntry
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
}
public void doActions(final 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);
public void doActions(CommandSender sender)
{
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);
return;
}
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN) {
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
{
FUtil.playerMsg(sender, "Unknown command. Type \"/help\" for help.", ChatColor.RESET);
return;
}
FUtil.playerMsg(sender, FUtil.colorize(this.message));
FUtil.playerMsg(sender, FUtil.colorize(message));
}
public CommandBlockerRank getRank() {
return this.rank;
public CommandBlockerRank getRank()
{
return rank;
}
public CommandBlockerAction getAction() {
return this.action;
public CommandBlockerAction getAction()
{
return action;
}
public String getCommand() {
return this.command;
public String getCommand()
{
return command;
}
public String getSubCommand() {
return this.subCommand;
public String getSubCommand()
{
return subCommand;
}
public String getMessage() {
return this.message;
public String getMessage()
{
return message;
}
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
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]")
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) {
if (args.length == 0) {
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)
{
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);
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(playerSender);
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.getCageData().setCaged(false);
return true;
}
if ("purge".equals(args[0])) {
if ("purge".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
for (final Player player : this.server.getOnlinePlayers()) {
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player);
playerdata2.getCageData().setCaged(false);
for (Player player : server.getOnlinePlayers())
{
final FPlayer fPlayer = plugin.pl.getPlayer(player);
fPlayer.getCageData().setCaged(false);
}
return true;
}
final Player player2 = this.getPlayer(args[0]);
if (player2 == null) {
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
final FPlayer playerdata3 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
final FPlayer fPlayer = plugin.pl.getPlayer(player);
Material outerMaterial = Material.GLASS;
Material innerMaterial = Material.AIR;
if (args.length >= 2 && null != args[1]) {
if (args.length >= 2 && args[1] != null)
{
final String s = args[1];
switch (s) {
case "off": {
FUtil.adminAction(sender.getName(), "Uncaging " + player2.getName(), true);
playerdata3.getCageData().setCaged(false);
switch (s)
{
case "off":
{
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
fPlayer.getCageData().setCaged(false);
return true;
}
case "skull": {
case "skull":
{
outerMaterial = Material.SKULL;
Command_cage.playerSkullName = args[2];
if (args.length >= 3)
{
skullName = args[2];
}
break;
}
case "block": {
if (Material.matchMaterial(args[2]) != null) {
case "block":
{
if (Material.matchMaterial(args[2]) != null)
{
outerMaterial = Material.matchMaterial(args[2]);
break;
}
@ -67,22 +81,34 @@ public class Command_cage extends FreedomCommand
}
}
}
if (args.length >= 3) {
if (args[2].equalsIgnoreCase("water")) {
if (args.length >= 3)
{
if (args[2].equalsIgnoreCase("water"))
{
innerMaterial = Material.STATIONARY_WATER;
}
else if (args[2].equalsIgnoreCase("lava")) {
else if (args[2].equalsIgnoreCase("lava"))
{
innerMaterial = Material.STATIONARY_LAVA;
}
}
final Location targetPos = player2.getLocation().clone().add(0.0, 1.0, 0.0);
playerdata3.getCageData().cage(targetPos, outerMaterial, innerMaterial);
player2.setGameMode(GameMode.SURVIVAL);
if (outerMaterial != Material.SKULL) {
FUtil.adminAction(sender.getName(), "Caging " + player2.getName(), true);
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
if (skullName != null)
{
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
}
else {
FUtil.adminAction(sender.getName(), "Caging " + player2.getName() + " in " + Command_cage.playerSkullName, true);
else
{
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;
}

View File

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

View File

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

View File

@ -1,38 +1,44 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.entity.Player;
@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 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 (this.isConsole()) {
@Override
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.");
return true;
}
playerSender.setGameMode(GameMode.SPECTATOR);
this.msg("Gamemode set to spectator.");
msg("Gamemode set to spectator.");
return true;
}
else {
this.checkRank(Rank.SUPER_ADMIN);
final Player player = this.getPlayer(args[0]);
if (player == null) {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
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);
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
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;
import me.totalfreedom.totalfreedommod.GameRuleHandler;
import me.totalfreedom.totalfreedommod.GameRuleHandler.GameRule;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
@ -38,103 +37,129 @@ public class Command_toggle extends FreedomCommand
return false;
}
if (args[0].equals("waterplace")) {
this.toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
return true;
}
if (args[0].equals("frostwalk")) {
this.toggle("Frost walker enchantment is ", ConfigEntry.ALLOW_FROSTWALKER);
return true;
}
if (args[0].equals("fireplace")) {
this.toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
return true;
}
if (args[0].equals("lavaplace")) {
this.toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
return true;
}
/*if (args[0].equals("explosivearrows"))
if (args[0].equals("waterplace"))
{
toggle("Explosive arrows are now", ConfigEntry.MAKE_ARROW_EXPLOSIVE);
return true;
}*/
if (args[0].equals("fluidspread")) {
this.toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE);
return true;
}
if (args[0].equals("lavadmg")) {
this.toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
else if (args[0].equals("frostwalk"))
{
toggle("Frost walker enchantment is ", ConfigEntry.ALLOW_FROSTWALKER);
return true;
}
if (args[0].equals("firespread")) {
this.toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
else if (args[0].equals("fireplace"))
{
toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE);
return true;
}
else if (args[0].equals("lavaplace"))
{
toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE);
return true;
}
else if (args[0].equals("fluidspread"))
{
toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD);
return true;
}
else if (args[0].equals("lavadmg"))
{
toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE);
return true;
}
else if (args[0].equals("firespread"))
{
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
((TotalFreedomMod)this.plugin).gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
return true;
}
if (args[0].equals("prelog")) {
this.toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
else if (args[0].equals("prelog"))
{
toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG);
return true;
}
if (args[0].equals("lockdown")) {
final boolean active = !((TotalFreedomMod)this.plugin).lp.isLockdownEnabled();
((TotalFreedomMod)this.plugin).lp.setLockdownEnabled(active);
else if (args[0].equals("lockdown"))
{
boolean active = !plugin.lp.isLockdownEnabled();
plugin.lp.setLockdownEnabled(active);
FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true);
return true;
}
if (args[0].equals("petprotect")) {
this.toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
else if (args[0].equals("petprotect"))
{
toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT);
return true;
}
if (args[0].equals("entitywipe")) {
this.toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
else if (args[0].equals("entitywipe"))
{
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
return true;
}
if (args[0].equals("firework")) {
this.toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
else if (args[0].equals("firework"))
{
toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION);
return true;
}
if (args[0].equals("nonuke")) {
if (args.length >= 2) {
try {
else if (args[0].equals("nonuke"))
{
if (args.length >= 2)
{
try
{
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) {
try {
if (args.length >= 3)
{
try
{
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);
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.");
toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED);
if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
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;
}
if (args[0].equals("explosives")) {
if (args.length == 2) {
try {
else if (args[0].equals("explosives"))
{
if (args.length == 2)
{
try
{
ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex) {
this.msg(ex.getMessage());
catch (NumberFormatException ex)
{
msg("The input provided is not a valid integer.");
return true;
}
}
this.toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) {
this.msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS);
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
}
return true;
}
return false;
else
{
return false;
}
}
private void toggle(final String name, final ConfigEntry entry) {
this.msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
private void toggle(final String name, final ConfigEntry entry)
{
msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
}
}

View File

@ -1,5 +1,3 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
@ -18,51 +16,50 @@ import org.bukkit.entity.Player;
import java.util.ArrayList;
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")
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) {
final Displayable display = ((TotalFreedomMod)this.plugin).rm.getDisplay((CommandSender)playerSender);
Displayable display = plugin.rm.getDisplay(playerSender);
String loginMsg = display.getColoredLoginMessage();
final String displayName = display.getColor() + playerSender.getName();
final Admin admin = ((TotalFreedomMod)this.plugin).al.getAdmin(playerSender);
if (Command_vanish.vanished.contains(playerSender)) {
this.msg(ChatColor.GOLD + "You have been unvanished.");
if (admin.hasLoginMessage()) {
String displayName = display.getColor() + playerSender.getName();
Admin admin = plugin.al.getAdmin(playerSender);
if (VANISHED.contains(playerSender))
{
msg(ChatColor.GOLD + "You have been unvanished.");
if (admin.hasLoginMessage())
{
loginMsg = FUtil.colorize(admin.getLoginMessage());
}
FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg);
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.");
for (final Player player : this.server.getOnlinePlayers()) {
for (Player player : server.getOnlinePlayers())
{
player.showPlayer(playerSender);
}
((TotalFreedomMod)this.plugin).esb.setVanished(playerSender.getName(), false);
plugin.esb.setVanished(playerSender.getName(), false);
playerSender.removePotionEffect(PotionEffectType.INVISIBILITY);
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
Command_vanish.vanished.remove(playerSender);
return true;
VANISHED.remove(playerSender);
}
if (!Command_vanish.vanished.contains(playerSender)) {
this.msg(ChatColor.GOLD + "You have been vanished.");
else
{
msg("You have been vanished.", ChatColor.GOLD);
FUtil.bcastMsg(playerSender.getName() + " left the game", ChatColor.YELLOW);
FLog.info(playerSender.getName() + " is now vanished.");
for (final Player player : this.server.getOnlinePlayers()) {
for (Player player : server.getOnlinePlayers())
{
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));
Command_vanish.vanished.add(playerSender);
return true;
VANISHED.add(playerSender);
}
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.CommandSender;
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)
@CommandParameters(description = "Removes essentials warps", usage = "/<command>")
@ -22,11 +22,12 @@ public class Command_wipewarps extends FreedomCommand
return true;
}
Plugin essentials = server.getPluginManager().getPlugin("Essentials");
FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true);
server.getPluginManager().disablePlugin(essentials);
FUtil.deleteFolder(new File(essentials.getDataFolder(), "warps"));
server.getPluginManager().enablePlugin(essentials);
Essentials essentials = plugin.esb.getEssentialsPlugin();
File warps = new File(essentials.getDataFolder(), "warps");
FUtil.adminAction(sender.getName(), "Wiping Essentials warps", true);
FUtil.deleteFolder(warps);
warps.mkdir();
essentials.reload();
msg("All warps deleted.");
return true;
}

View File

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

View File

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