TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java

68 lines
2.1 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.command;
2011-10-21 19:28:03 +00:00
2014-07-19 21:34:12 +00:00
import java.util.Iterator;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.fun.Landminer.Landmine;
import me.totalfreedom.totalfreedommod.rank.Rank;
2011-10-24 02:43:52 +00:00
import org.bukkit.ChatColor;
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;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Set a landmine trap.", usage = "/<command>")
public class Command_landmine extends FreedomCommand
2011-10-21 19:28:03 +00:00
{
2011-10-21 19:28:03 +00:00
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
2011-10-21 19:28:03 +00:00
{
if (!ConfigEntry.LANDMINES_ENABLED.getBoolean())
2011-10-24 02:43:52 +00:00
{
msg("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
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
2011-10-24 02:43:52 +00:00
{
msg("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
{
if ("list".equals(args[0]))
2011-10-24 02:43:52 +00:00
{
final Iterator<Landmine> landmines = plugin.lm.getLandmines().iterator();
2014-07-19 21:34:12 +00:00
while (landmines.hasNext())
2011-10-24 02:43:52 +00:00
{
msg(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
}
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
}
final Block landmine = playerSender.getLocation().getBlock().getRelative(BlockFace.DOWN);
2014-07-19 21:34:12 +00:00
landmine.setType(Material.TNT);
plugin.lm.add(new Landmine(landmine.getLocation(), playerSender, radius));
2014-07-19 21:34:12 +00:00
msg("Landmine planted - Radius = " + radius + " blocks.", ChatColor.GREEN);
2014-07-19 21:34:12 +00:00
2011-10-21 19:28:03 +00:00
return true;
}
2011-10-21 19:28:03 +00:00
}