mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Verify MCA Chunks
This commit is contained in:
parent
0ae7b9c120
commit
8f57364547
@ -33,6 +33,9 @@ public class CommandIris extends MortarCommand {
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisCreate create;
|
private CommandIrisCreate create;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisVerify verify;
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
private CommandIrisFix fix;
|
private CommandIrisFix fix;
|
||||||
|
|
||||||
|
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.core.command.world;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.tools.IrisWorlds;
|
||||||
|
import com.volmit.iris.engine.data.mca.Chunk;
|
||||||
|
import com.volmit.iris.engine.data.mca.MCAFile;
|
||||||
|
import com.volmit.iris.engine.data.mca.MCAUtil;
|
||||||
|
import com.volmit.iris.engine.framework.IrisAccess;
|
||||||
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.collection.KSet;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.math.Position2;
|
||||||
|
import com.volmit.iris.util.math.Spiraler;
|
||||||
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class CommandIrisVerify extends MortarCommand {
|
||||||
|
public CommandIrisVerify() {
|
||||||
|
super("verifymca");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setDescription("Fix nearby chunks");
|
||||||
|
setCategory("Studio");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTabOptions(VolmitSender sender, String[] args, KList<String> list) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(VolmitSender sender, String[] args) {
|
||||||
|
try {
|
||||||
|
IrisAccess a = IrisWorlds.access(sender.player().getWorld());
|
||||||
|
File folder = a.getTarget().getWorld().worldFolder();
|
||||||
|
File r = new File(folder, "region");
|
||||||
|
BurstExecutor e = MultiBurst.burst.burst(r.listFiles().length);
|
||||||
|
AtomicInteger f = new AtomicInteger(0);
|
||||||
|
for(File i : r.listFiles())
|
||||||
|
{
|
||||||
|
e.queue(() -> {
|
||||||
|
MCAFile file = null;
|
||||||
|
try {
|
||||||
|
file = MCAUtil.read(i);
|
||||||
|
int rx = Integer.valueOf(i.getName().split("\\Q.\\E")[1]);
|
||||||
|
int rz = Integer.valueOf(i.getName().split("\\Q.\\E")[2]);
|
||||||
|
for(int j = 0; j < 32; j++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < 32; k++)
|
||||||
|
{
|
||||||
|
f.incrementAndGet();
|
||||||
|
Chunk c = file.getChunk(j, k);
|
||||||
|
if(c == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Found Missing Chunk " + i.getName() + ", chunk #" + j + "," + k + " (see " + (((rx << 5)<<4)+(j<<4)) + "," + (((rz << 5)<<4)+(k<<4)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
ioException.printStackTrace();
|
||||||
|
sender.sendMessage("Error loading region " + i.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
e.complete();
|
||||||
|
sender.sendMessage("Done! Checked " + f.get() + " chunks");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Iris.reportError(e);
|
||||||
|
sender.sendMessage("Not a valid Iris World (or bad argument)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage() {
|
||||||
|
return "[view-distance]";
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user