import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin
{
@Override
public void onEnable()
{
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if(label.equalsIgnoreCase("commandblockfinder") && sender instanceof Player)
{
if(sender.hasPermission("commandblockfinder"))
{
if(args.length > 0)
{
try
{
int rayon = Integer.valueOf(args[0]);
Location loc = ((Player) sender).getLocation();
for(int x = -rayon; x < rayon; x++)
for(int z = -rayon; z < rayon; z++)
for(int y = 0; y < 256; y++)
if(new Location(loc.getWorld(), x + loc.getBlockX(), y, z + loc.getBlockZ()).getBlock().getType().equals(Material.COMMAND))
sender.sendMessage("Command block: "+(x + loc.getBlockX())+";"+y+";"+(z + loc.getBlockZ()));
}
catch(NumberFormatException e) { sender.sendMessage(ChatColor.RED+"Veuillez entrer un nombre valide !"); }
}
else sender.sendMessage(ChatColor.GRAY+"/commandblockfinder <rayon>");
}
else sender.sendMessage(ChatColor.RED+"Vous n'avez pas la permission d'éxécuter cette commande !");
}
return false;
}
}