mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 03:49:15 +00:00
improve debug commands
This commit is contained in:
@@ -44,8 +44,10 @@ public class DebugAppearanceStateUsageCommand extends BukkitCommandFeature<Comma
|
||||
List<Integer> appearances = blockManager.blockAppearanceArranger().get(baseBlockId);
|
||||
if (appearances == null) return;
|
||||
int i = 0;
|
||||
Component component = Component.text(baseBlockId + ": ");
|
||||
List<Component> children = new ArrayList<>();
|
||||
Component block = Component.text(baseBlockId + ": ");
|
||||
plugin().senderFactory().wrap(context.sender()).sendMessage(block);
|
||||
|
||||
List<Component> batch = new ArrayList<>();
|
||||
for (int appearance : appearances) {
|
||||
Component text = Component.text("|");
|
||||
List<Integer> reals = blockManager.appearanceToRealStates(appearance);
|
||||
@@ -64,11 +66,19 @@ public class DebugAppearanceStateUsageCommand extends BukkitCommandFeature<Comma
|
||||
}
|
||||
text = text.color(NamedTextColor.RED).hoverEvent(HoverEvent.showText(hover.children(hoverChildren)));
|
||||
}
|
||||
children.add(text);
|
||||
batch.add(text);
|
||||
i++;
|
||||
if (batch.size() == 100) {
|
||||
plugin().senderFactory().wrap(context.sender())
|
||||
.sendMessage(Component.text("").children(batch));
|
||||
batch.clear();
|
||||
}
|
||||
}
|
||||
if (!batch.isEmpty()) {
|
||||
plugin().senderFactory().wrap(context.sender())
|
||||
.sendMessage(Component.text("").children(batch));
|
||||
batch.clear();
|
||||
}
|
||||
plugin().senderFactory().wrap(context.sender())
|
||||
.sendMessage(component.children(children));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -44,22 +44,32 @@ public class DebugRealStateUsageCommand extends BukkitCommandFeature<CommandSend
|
||||
List<Integer> reals = blockManager.realBlockArranger().get(baseBlockId);
|
||||
if (reals == null) return;
|
||||
int i = 0;
|
||||
Component component = Component.text(baseBlockId + ": ");
|
||||
List<Component> children = new ArrayList<>();
|
||||
Component block = Component.text(baseBlockId + ": ");
|
||||
plugin().senderFactory().wrap(context.sender()).sendMessage(block);
|
||||
|
||||
List<Component> batch = new ArrayList<>(100);
|
||||
for (int real : reals) {
|
||||
ImmutableBlockState state = blockManager.getImmutableBlockStateUnsafe(real);
|
||||
if (state.isEmpty()) {
|
||||
Component hover = Component.text("craftengine:" + baseBlockId.value() + "_" + i).color(NamedTextColor.GREEN);
|
||||
children.add(Component.text("|").color(NamedTextColor.GREEN).hoverEvent(HoverEvent.showText(hover)));
|
||||
batch.add(Component.text("|").color(NamedTextColor.GREEN).hoverEvent(HoverEvent.showText(hover)));
|
||||
} else {
|
||||
Component hover = Component.text("craftengine:" + baseBlockId.value() + "_" + i).color(NamedTextColor.RED);
|
||||
hover = hover.append(Component.newline()).append(Component.text(state.toString()).color(NamedTextColor.GRAY));
|
||||
children.add(Component.text("|").color(NamedTextColor.RED).hoverEvent(HoverEvent.showText(hover)));
|
||||
batch.add(Component.text("|").color(NamedTextColor.RED).hoverEvent(HoverEvent.showText(hover)));
|
||||
}
|
||||
i++;
|
||||
if (batch.size() == 100) {
|
||||
plugin().senderFactory().wrap(context.sender())
|
||||
.sendMessage(Component.text("").children(batch));
|
||||
batch.clear();
|
||||
}
|
||||
}
|
||||
if (!batch.isEmpty()) {
|
||||
plugin().senderFactory().wrap(context.sender())
|
||||
.sendMessage(Component.text("").children(batch));
|
||||
batch.clear();
|
||||
}
|
||||
plugin().senderFactory().wrap(context.sender())
|
||||
.sendMessage(component.children(children));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature;
|
||||
import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.Reflections;
|
||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||
import net.momirealms.craftengine.core.plugin.command.sender.Sender;
|
||||
import net.momirealms.craftengine.core.world.BlockPos;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -50,6 +52,8 @@ public class DebugTargetBlockCommand extends BukkitCommandFeature<CommandSender>
|
||||
if (immutableBlockState != null) {
|
||||
sender.sendMessage(Component.text(immutableBlockState.toString()));
|
||||
}
|
||||
ImmutableBlockState dataInCache = plugin().worldManager().getWorld(block.getWorld().getUID()).getBlockStateAtIfLoaded(LocationUtils.toBlockPos(block.getLocation()));
|
||||
sender.sendMessage(Component.text("cache-state: " + !dataInCache.isEmpty()));
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Object> tags = (Set<Object>) Reflections.field$Holder$Reference$tags.get(holder);
|
||||
|
||||
Reference in New Issue
Block a user