summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Panić <david@panic.tk>2019-05-04 00:15:43 +0200
committerDavid Panić <david@panic.tk>2019-06-02 21:14:20 +0200
commit53ec8d8846518e35aa02c4b6f457db9f80afec4c (patch)
tree97f05e6a2443bdb79d4f23078c0729f0d6f6eb6d
parent6e2bf1b5fa32fd23847163f66f8f22804afffa66 (diff)
Created CrashUtils + implemented findnear command
-rw-r--r--src/main/java/com/redstoner/modules/crashutils/CrashUtils.cmd9
-rw-r--r--src/main/java/com/redstoner/modules/crashutils/CrashUtils.java53
-rw-r--r--src/main/java/com/redstoner/modules/crashutils/module.info3
3 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/com/redstoner/modules/crashutils/CrashUtils.cmd b/src/main/java/com/redstoner/modules/crashutils/CrashUtils.cmd
new file mode 100644
index 0000000..a330dca
--- /dev/null
+++ b/src/main/java/com/redstoner/modules/crashutils/CrashUtils.cmd
@@ -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;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/com/redstoner/modules/crashutils/CrashUtils.java b/src/main/java/com/redstoner/modules/crashutils/CrashUtils.java
new file mode 100644
index 0000000..eb9590f
--- /dev/null
+++ b/src/main/java/com/redstoner/modules/crashutils/CrashUtils.java
@@ -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;
+ }
+}
diff --git a/src/main/java/com/redstoner/modules/crashutils/module.info b/src/main/java/com/redstoner/modules/crashutils/module.info
new file mode 100644
index 0000000..742c9ba
--- /dev/null
+++ b/src/main/java/com/redstoner/modules/crashutils/module.info
@@ -0,0 +1,3 @@
+displayName: CrashUtils
+category: Staff
+description: A collection of commands to help crashed players \ No newline at end of file