2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2011-10-21 19:28:03 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
|
2013-09-14 02:13:07 +00:00
|
|
|
import java.util.ArrayList;
|
2014-07-19 21:34:12 +00:00
|
|
|
import java.util.Iterator;
|
2013-09-14 02:13:07 +00:00
|
|
|
import java.util.List;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
2011-10-24 02:43:52 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2013-09-14 02:13:07 +00:00
|
|
|
import org.bukkit.Location;
|
2011-10-21 19:28:03 +00:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.OP, source = SourceType.ONLY_IN_GAME)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Set a landmine trap.", usage = "/<command>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_landmine extends FreedomCommand
|
2011-10-21 19:28:03 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
if (!ConfigEntry.LANDMINES_ENABLED.getBoolean())
|
2011-10-24 02:43:52 +00:00
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("The landmine is currently disabled.", ChatColor.GREEN);
|
2014-07-19 21:34:12 +00:00
|
|
|
return true;
|
2011-10-24 02:43:52 +00:00
|
|
|
}
|
2014-07-19 21:34:12 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
2011-10-24 02:43:52 +00:00
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("Explosions are currently disabled.", ChatColor.GREEN);
|
2014-07-19 21:34:12 +00:00
|
|
|
return true;
|
2011-10-24 02:43:52 +00:00
|
|
|
}
|
2014-07-19 21:34:12 +00:00
|
|
|
|
|
|
|
double radius = 2.0;
|
|
|
|
|
|
|
|
if (args.length >= 1)
|
2011-10-21 19:28:03 +00:00
|
|
|
{
|
2014-07-19 21:34:12 +00:00
|
|
|
if ("list".equalsIgnoreCase(args[0]))
|
2011-10-24 02:43:52 +00:00
|
|
|
{
|
2014-07-19 21:34:12 +00:00
|
|
|
final Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
|
|
|
while (landmines.hasNext())
|
2011-10-24 02:43:52 +00:00
|
|
|
{
|
2014-07-19 21:34:12 +00:00
|
|
|
playerMsg(landmines.next().toString());
|
2011-10-24 02:43:52 +00:00
|
|
|
}
|
2014-07-19 21:34:12 +00:00
|
|
|
return true;
|
2011-10-24 02:43:52 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2014-07-19 21:34:12 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0])));
|
|
|
|
}
|
|
|
|
catch (NumberFormatException ex)
|
|
|
|
{
|
|
|
|
}
|
2011-10-21 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
2014-07-19 21:34:12 +00:00
|
|
|
final Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
|
|
|
landmine.setType(Material.TNT);
|
|
|
|
TFM_LandmineData.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p, radius));
|
|
|
|
|
|
|
|
playerMsg("Landmine planted - Radius = " + radius + " blocks.", ChatColor.GREEN);
|
|
|
|
|
2011-10-21 19:28:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-09-14 02:13:07 +00:00
|
|
|
|
|
|
|
public static class TFM_LandmineData
|
|
|
|
{
|
2014-07-19 21:34:12 +00:00
|
|
|
public static final List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
|
|
|
|
public final Location location;
|
|
|
|
public final Player player;
|
|
|
|
public final double radius;
|
|
|
|
|
|
|
|
public TFM_LandmineData(Location location, Player player, double radius)
|
2013-09-14 02:13:07 +00:00
|
|
|
{
|
2014-07-19 21:34:12 +00:00
|
|
|
this.location = location;
|
2013-09-14 02:13:07 +00:00
|
|
|
this.player = player;
|
|
|
|
this.radius = radius;
|
|
|
|
}
|
2014-07-19 21:34:12 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString()
|
|
|
|
{
|
|
|
|
return this.location.toString() + ", " + this.radius + ", " + this.player.getName();
|
|
|
|
}
|
2013-09-14 02:13:07 +00:00
|
|
|
}
|
2011-10-21 19:28:03 +00:00
|
|
|
}
|