Merge changes from magma branch (except downgrade)

This commit is contained in:
ThisTestUser
2024-09-18 21:17:35 +00:00
parent c2e2dd4c39
commit e9080595c6
11 changed files with 539 additions and 21 deletions

View File

@@ -16,6 +16,7 @@ import net.nuggetmc.tplus.command.commands.AICommand;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -23,12 +24,30 @@ import org.bukkit.permissions.ServerOperator;
import org.bukkit.util.Vector;
import java.beans.Statement;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.*;
import java.util.stream.Collectors;
public class Debugger {
private final CommandSender sender;
public static final Set<String> AUTOFILL_METHODS = new HashSet<>();
static {
for (Method method : Debugger.class.getDeclaredMethods()) {
if (!method.getName().equals("print") && !method.getName().equals("execute") && !method.getName().equals("buildObjects")
&& !method.getName().startsWith("lambda$")) {
String autofill = method.getName() + "(";
for (Parameter par : method.getParameters()) {
autofill += par.getType().getSimpleName() + ",";
}
autofill = method.getParameters().length > 0 ? autofill.substring(0, autofill.length() - 1) : autofill;
autofill += ")";
AUTOFILL_METHODS.add(autofill);
}
}
}
public Debugger(CommandSender sender) {
this.sender = sender;
@@ -447,4 +466,20 @@ public class Debugger {
print("The Bot Agent is now " + (b ? ChatColor.RED + "DISABLED" : ChatColor.GREEN + "ENABLED") + ChatColor.RESET + ".");
}
public void printSurroundingMobs(double dist) {
if (!(sender instanceof Player)) {
print("You must be a player to call this.");
return;
}
Player player = (Player) sender;
double distSq = Math.pow(dist, 2);
for (Entity en : player.getWorld().getEntities()) {
Location loc = en.getLocation();
if (loc.distanceSquared(player.getLocation()) < distSq)
print(String.format("Entity at " + ChatColor.BLUE + "(%d, %d, %d)" + ChatColor.RESET + ": Type " + ChatColor.GREEN + "%s" + ChatColor.RESET,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), en.getType().toString()));
}
}
}