Archived
0

Created CrashUtils + implemented findnear command

This commit is contained in:
David Panić
2019-05-04 00:15:43 +02:00
parent 6e2bf1b5fa
commit 53ec8d8846
3 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
command findnear {
perm utils.crashutils;
[int:range] [string:block] {
help Finds the specified block in the specified range.;
type player;
run findnear range block;
}
}

View File

@@ -0,0 +1,53 @@
package com.redstoner.modules.crashutils;
import com.nemez.cmdmgr.Command;
import com.redstoner.annotations.AutoRegisterListener;
import com.redstoner.annotations.Commands;
import com.redstoner.annotations.Version;
import com.redstoner.misc.CommandHolderType;
import com.redstoner.modules.Module;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@Commands (CommandHolderType.File)
@AutoRegisterListener
@Version (major = 5, minor = 0, revision = 0, compatible = 4)
public class CrashUtils implements Module {
@Command (hook = "findnear", async = Command.AsyncType.ALWAYS)
public boolean findNear(CommandSender sender, int range, String block) {
Player player = (Player) sender;
Material mat = Material.matchMaterial(block);
if (mat == null) {
getLogger().message(sender, true, block + " is not a valid block.");
return true;
}
Location playerLoc = player.getLocation();
for (int x = playerLoc.getBlockX() - range; x < playerLoc.getBlockX() + range; x++) {
for (int z = playerLoc.getBlockZ() - range; z < playerLoc.getBlockZ() + range; z++) {
for (int y = 0; y < 256; y++) {
Block b = player.getWorld().getBlockAt(x, y, z);
if (b.getType() == mat) {
Location loc = b.getLocation();
getLogger().message(
sender,
false,
String.format("Found %s @ %d %d %d", mat.toString(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
}
}
}
getLogger().message(sender, false, String.format("Done searching for %s in a %d block radius.", mat.toString(), range));
return true;
}
}

View File

@@ -0,0 +1,3 @@
displayName: CrashUtils
category: Staff
description: A collection of commands to help crashed players