Created CrashUtils + implemented findnear command
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
displayName: CrashUtils
|
||||||
|
category: Staff
|
||||||
|
description: A collection of commands to help crashed players
|
||||||
Reference in New Issue
Block a user