2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2017-10-13 18:35:11 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2017-10-13 18:35:11 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2017-10-13 18:35:11 +00:00
|
|
|
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [skull | block] [blockname | skullname]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_cage extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2017-10-13 18:35:11 +00:00
|
|
|
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) {
|
2012-11-23 03:48:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
if ("off".equals(args[0]) && sender instanceof Player) {
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
2017-10-13 18:35:11 +00:00
|
|
|
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(playerSender);
|
2015-11-15 23:32:04 +00:00
|
|
|
playerdata.getCageData().setCaged(false);
|
2013-08-26 13:04:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
if ("purge".equals(args[0])) {
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
2017-10-13 18:35:11 +00:00
|
|
|
for (final Player player : this.server.getOnlinePlayers()) {
|
|
|
|
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player);
|
|
|
|
playerdata2.getCageData().setCaged(false);
|
2013-09-26 00:33:44 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
final Player player2 = this.getPlayer(args[0]);
|
|
|
|
if (player2 == null) {
|
2015-10-19 17:43:46 +00:00
|
|
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
2012-11-23 03:48:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
final FPlayer playerdata3 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
|
2013-08-25 23:08:53 +00:00
|
|
|
Material outerMaterial = Material.GLASS;
|
|
|
|
Material innerMaterial = Material.AIR;
|
2017-10-13 18:35:11 +00:00
|
|
|
if (args.length >= 2 && null != args[1]) {
|
|
|
|
final String s = args[1];
|
|
|
|
switch (s) {
|
|
|
|
case "off": {
|
|
|
|
FUtil.adminAction(sender.getName(), "Uncaging " + player2.getName(), true);
|
|
|
|
playerdata3.getCageData().setCaged(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case "skull": {
|
2013-08-25 23:08:53 +00:00
|
|
|
outerMaterial = Material.SKULL;
|
2017-10-13 18:35:11 +00:00
|
|
|
Command_cage.playerSkullName = args[2];
|
|
|
|
break;
|
2013-08-25 23:08:53 +00:00
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
case "block": {
|
|
|
|
if (Material.matchMaterial(args[2]) != null) {
|
|
|
|
outerMaterial = Material.matchMaterial(args[2]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sender.sendMessage(ChatColor.RED + "Invalid block!");
|
|
|
|
break;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-23 03:48:28 +00:00
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
if (args.length >= 3) {
|
|
|
|
if (args[2].equalsIgnoreCase("water")) {
|
2013-08-25 23:08:53 +00:00
|
|
|
innerMaterial = Material.STATIONARY_WATER;
|
2012-11-23 03:48:28 +00:00
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
else if (args[2].equalsIgnoreCase("lava")) {
|
2013-08-25 23:08:53 +00:00
|
|
|
innerMaterial = Material.STATIONARY_LAVA;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
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);
|
2013-08-25 23:08:53 +00:00
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
else {
|
|
|
|
FUtil.adminAction(sender.getName(), "Caging " + player2.getName() + " in " + Command_cage.playerSkullName, true);
|
2013-08-25 23:08:53 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|