mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Iris reports
This commit is contained in:
parent
1b20d3b6ac
commit
361d02e075
13
pom.xml
13
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>bytecode.ninja</groupId>
|
<groupId>bytecode.ninja</groupId>
|
||||||
<artifactId>Iris</artifactId>
|
<artifactId>Iris</artifactId>
|
||||||
<version>1.0.27</version>
|
<version>1.0.28</version>
|
||||||
<name>Iris</name>
|
<name>Iris</name>
|
||||||
<properties>
|
<properties>
|
||||||
<skip.copy>false</skip.copy>
|
<skip.copy>false</skip.copy>
|
||||||
@ -161,10 +161,6 @@
|
|||||||
<id>WorldEdit</id>
|
<id>WorldEdit</id>
|
||||||
<url>https://maven.enginehub.org/repo/</url>
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>everything</id>
|
|
||||||
<url>https://repo.citizensnpcs.co/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spigot API -->
|
<!-- Spigot API -->
|
||||||
@ -201,13 +197,6 @@
|
|||||||
<version>4.9.1</version>
|
<version>4.9.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.citizensnpcs</groupId>
|
|
||||||
<artifactId>citizens</artifactId>
|
|
||||||
<version>2.0.27-SNAPSHOT</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- Utilities -->
|
<!-- Utilities -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
|
@ -51,6 +51,9 @@ public class CommandIris extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisReload reload;
|
private CommandIrisReload reload;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisCapture capture;
|
||||||
|
|
||||||
public CommandIris()
|
public CommandIris()
|
||||||
{
|
{
|
||||||
super("iris", "ir", "irs");
|
super("iris", "ir", "irs");
|
||||||
|
295
src/main/java/com/volmit/iris/command/CommandIrisCapture.java
Normal file
295
src/main/java/com/volmit/iris/command/CommandIrisCapture.java
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.attribute.FileTime;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.FluidCollisionMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
|
import com.volmit.iris.object.IrisBiome;
|
||||||
|
import com.volmit.iris.object.IrisObject;
|
||||||
|
import com.volmit.iris.object.IrisObjectPlacement;
|
||||||
|
import com.volmit.iris.util.Form;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.KMap;
|
||||||
|
import com.volmit.iris.util.KSet;
|
||||||
|
import com.volmit.iris.util.M;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
import com.volmit.iris.util.Spiraler;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
|
public class CommandIrisCapture extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisCapture()
|
||||||
|
{
|
||||||
|
super("capture", "report", "capt");
|
||||||
|
setDescription("Capture nearby information to help with reporting problems");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setCategory("World");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(sender.isPlayer())
|
||||||
|
{
|
||||||
|
Player p = sender.player();
|
||||||
|
World world = p.getWorld();
|
||||||
|
|
||||||
|
if(!IrisWorlds.isIrisWorld(world))
|
||||||
|
{
|
||||||
|
sender.sendMessage("You must be in an iris world.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisTerrainProvider g = IrisWorlds.getProvider(world);
|
||||||
|
KList<Chunk> chunks = new KList<>();
|
||||||
|
int bx = p.getLocation().getChunk().getX();
|
||||||
|
int bz = p.getLocation().getChunk().getZ();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Location l = p.getTargetBlockExact(48, FluidCollisionMode.NEVER).getLocation();
|
||||||
|
|
||||||
|
if(l != null)
|
||||||
|
{
|
||||||
|
int cx = l.getChunk().getX();
|
||||||
|
int cz = l.getChunk().getZ();
|
||||||
|
new Spiraler(3, 3, (x, z) -> chunks.addIfMissing(world.getChunkAt(x + cx, z + cz))).drain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
new Spiraler(3, 3, (x, z) -> chunks.addIfMissing(world.getChunkAt(x + bx, z + bz))).drain();
|
||||||
|
sender.sendMessage("Capturing IGenData from " + chunks.size() + " nearby chunks.");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File ff = Iris.instance.getDataFile("reports/" + M.ms() + ".txt");
|
||||||
|
PrintWriter pw = new PrintWriter(ff);
|
||||||
|
pw.println("=== Iris Chunk Report ===");
|
||||||
|
pw.println("Iris Version: " + Iris.instance.getDescription().getVersion());
|
||||||
|
pw.println("Bukkit Version: " + Bukkit.getBukkitVersion());
|
||||||
|
pw.println("MC Version: " + Bukkit.getVersion());
|
||||||
|
pw.println("PaperSpigot: " + (PaperLib.isPaper() ? "Yup!" : "Not Paper"));
|
||||||
|
pw.println("Report Captured At: " + new Date().toString());
|
||||||
|
pw.println("Chunks: (" + chunks.size() + "): ");
|
||||||
|
|
||||||
|
for(Chunk i : chunks)
|
||||||
|
{
|
||||||
|
pw.println("- [" + i.getX() + ", " + i.getZ() + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
int regions = 0;
|
||||||
|
long size = 0;
|
||||||
|
String age = "No idea...";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for(File i : new File(world.getWorldFolder(), "region").listFiles())
|
||||||
|
{
|
||||||
|
if(i.isFile())
|
||||||
|
{
|
||||||
|
size += i.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileTime creationTime = (FileTime) Files.getAttribute(world.getWorldFolder().toPath(), "creationTime");
|
||||||
|
age = hrf(Duration.of(M.ms() - creationTime.toMillis(), ChronoUnit.MILLIS));
|
||||||
|
}
|
||||||
|
catch(IOException ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KList<String> biomes = new KList<>();
|
||||||
|
KList<String> caveBiomes = new KList<>();
|
||||||
|
KMap<String, KMap<String, KList<String>>> objects = new KMap<>();
|
||||||
|
|
||||||
|
for(Chunk i : chunks)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < 16; j += 3)
|
||||||
|
{
|
||||||
|
if(j >= 16)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int k = 0; k < 16; k += 3)
|
||||||
|
{
|
||||||
|
if(k >= 16)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisBiome bb = g.sampleTrueBiome((i.getX() * 16) + j, (i.getZ() * 16) + k);
|
||||||
|
IrisBiome bxf = g.sampleTrueBiome((i.getX() * 16) + j, 3, (i.getZ() * 16) + k);
|
||||||
|
biomes.addIfMissing(bb.getName() + " [" + Form.capitalize(bb.getInferredType().name().toLowerCase()) + "] " + " (" + bb.getLoadFile().getName() + ")");
|
||||||
|
caveBiomes.addIfMissing(bxf.getName() + " (" + bxf.getLoadFile().getName() + ")");
|
||||||
|
exportObjects(bb, pw, g, objects);
|
||||||
|
exportObjects(bxf, pw, g, objects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pw.println();
|
||||||
|
pw.println("====== World Info =======");
|
||||||
|
pw.println("World Name: " + world.getName());
|
||||||
|
pw.println("Age: " + age);
|
||||||
|
pw.println("Folder: " + world.getWorldFolder().getPath());
|
||||||
|
pw.println("Regions: " + Form.f(regions));
|
||||||
|
pw.println("Chunks: <" + Form.f(regions * 32 * 32));
|
||||||
|
pw.println("World Size: >" + Form.fileSize(size));
|
||||||
|
pw.println();
|
||||||
|
pw.println("===== Nearby Biomes =====");
|
||||||
|
pw.println("Found " + biomes.size() + " Biome(s): ");
|
||||||
|
|
||||||
|
for(String i : biomes)
|
||||||
|
{
|
||||||
|
pw.println("- " + i);
|
||||||
|
}
|
||||||
|
pw.println();
|
||||||
|
|
||||||
|
pw.println("Found " + caveBiomes.size() + " Underground Biome(s): ");
|
||||||
|
|
||||||
|
for(String i : caveBiomes)
|
||||||
|
{
|
||||||
|
pw.println("- " + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
pw.println();
|
||||||
|
|
||||||
|
pw.println("======== Objects ========");
|
||||||
|
|
||||||
|
for(String i : objects.k())
|
||||||
|
{
|
||||||
|
pw.println("- " + i);
|
||||||
|
|
||||||
|
for(String j : objects.get(i).k())
|
||||||
|
{
|
||||||
|
pw.println(" @ " + j);
|
||||||
|
|
||||||
|
for(String k : objects.get(i).get(j))
|
||||||
|
{
|
||||||
|
pw.println(" * " + k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pw.println();
|
||||||
|
pw.close();
|
||||||
|
|
||||||
|
sender.sendMessage("Reported to: " + ff.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(FileNotFoundException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Players only.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportObjects(IrisBiome bb, PrintWriter pw, IrisTerrainProvider g, KMap<String, KMap<String, KList<String>>> objects)
|
||||||
|
{
|
||||||
|
String n1 = bb.getName() + " [" + Form.capitalize(bb.getInferredType().name().toLowerCase()) + "] " + " (" + bb.getLoadFile().getName() + ")";
|
||||||
|
int m = 0;
|
||||||
|
KSet<String> stop = new KSet<>();
|
||||||
|
for(IrisObjectPlacement f : bb.getObjects())
|
||||||
|
{
|
||||||
|
m++;
|
||||||
|
String n2 = "Placement #" + m + " (" + f.getPlace().size() + " possible objects)";
|
||||||
|
|
||||||
|
for(String i : f.getPlace())
|
||||||
|
{
|
||||||
|
String nn3 = i + ": [ERROR] Failed to find object!";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(stop.contains(i))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File ff = g.getData().getObjectLoader().findFile(i);
|
||||||
|
BlockVector sz = IrisObject.sampleSize(ff);
|
||||||
|
nn3 = i + ": size=[" + sz.getBlockX() + "," + sz.getBlockY() + "," + sz.getBlockZ() + "] location=[" + ff.getPath() + "]";
|
||||||
|
stop.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String n3 = nn3;
|
||||||
|
|
||||||
|
objects.compute(n1, (k1, v1) ->
|
||||||
|
{
|
||||||
|
if(v1 == null)
|
||||||
|
{
|
||||||
|
return new KMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return v1;
|
||||||
|
}).compute(n2, (k, v) ->
|
||||||
|
{
|
||||||
|
if(v == null)
|
||||||
|
{
|
||||||
|
return new KList<String>().qaddIfMissing(n3);
|
||||||
|
}
|
||||||
|
|
||||||
|
v.addIfMissing(n3);
|
||||||
|
return v;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String hrf(Duration duration)
|
||||||
|
{
|
||||||
|
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "[thread-count]";
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,6 @@
|
|||||||
package com.volmit.iris.link;
|
package com.volmit.iris.link;
|
||||||
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class CitizensLink
|
public class CitizensLink
|
||||||
@ -20,17 +15,17 @@ public class CitizensLink
|
|||||||
return getCitizens() != null;
|
return getCitizens() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity spawn(EntityType type, String npcType, Location a)
|
// public Entity spawn(EntityType type, String npcType, Location a)
|
||||||
{
|
// {
|
||||||
if(!supported())
|
// if(!supported())
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
NPC npc = CitizensAPI.getNPCRegistry().createNPC(type, "");
|
// NPC npc = CitizensAPI.getNPCRegistry().createNPC(type, "");
|
||||||
npc.spawn(a);
|
// npc.spawn(a);
|
||||||
return npc.getEntity();
|
// return npc.getEntity();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public Plugin getCitizens()
|
public Plugin getCitizens()
|
||||||
{
|
{
|
||||||
|
@ -686,6 +686,12 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KList<T> qaddIfMissing(T t)
|
||||||
|
{
|
||||||
|
addIfMissing(t);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public KList<T> removeDuplicates()
|
public KList<T> removeDuplicates()
|
||||||
{
|
{
|
||||||
KSet<T> v = new KSet<>();
|
KSet<T> v = new KSet<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user