From 42d0e0c663ee1ce7e69519b7264db2f33e9733fb Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 30 Jan 2024 18:01:20 +0800 Subject: [PATCH] dev: add network debug for debug fish --- .../listeners/DebugFishListener.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java index 40200894d2..97298232ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java @@ -2,15 +2,19 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback; import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; +import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils; import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.skins.PlayerHead; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.network.Network; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyRegulator; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; @@ -19,6 +23,7 @@ import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import net.milkbowl.vault.chat.Chat; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -208,6 +213,19 @@ private void sendInfo(Player p, Block b) { " &dChunk Timings: &e" + Slimefun.getProfiler().getTime(b.getChunk()))); } + if (item instanceof EnergyRegulator) { + p.sendMessage(ChatColors.color("&dEnergy Regulator")); + EnergyNet network = EnergyNet.getNetworkFromLocationOrCreate(b.getLocation()); + p.sendMessage(ChatColors.color("&dNetwork range: " + network.getRange())); + p.sendMessage(ChatColors.color("&dNetwork components:")); + p.sendMessage(ChatColors.color(" &d- Network capacitors:")); + network.getCapacitors().forEach((loc, component) -> p.sendMessage(ChatColors.color("&d " + component.getId() + " - " + LocationUtils.locationToString(loc)))); + p.sendMessage(ChatColors.color(" &d- Network consumers:")); + network.getConsumers().forEach((loc, component) -> p.sendMessage(ChatColors.color("&d " + component.getId() + " - " + LocationUtils.locationToString(loc)))); + p.sendMessage(ChatColors.color(" &d- Network generators:")); + network.getGenerators().forEach((loc, component) -> p.sendMessage(ChatColors.color("&d " + component.getId() + " - " + LocationUtils.locationToString(loc)))); + } + if (item instanceof EnergyNetComponent component) { p.sendMessage(ChatColors.color("&dEnergyNet Component")); p.sendMessage(ChatColors.color(" &dType: &e" + component.getEnergyComponentType()));