9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-30 04:29:05 +00:00

Fix commands & support regeneration

This commit is contained in:
Daniel Mills
2020-10-12 00:18:05 -04:00
parent a46f57eaab
commit e72ea21b6b
21 changed files with 486 additions and 120 deletions

View File

@@ -34,6 +34,9 @@ public class CommandIris extends MortarCommand
@Command
private CommandIrisLMM lmm;
@Command
private CommandIrisRegen regen;
@Command
private CommandIrisPregen pregen;

View File

@@ -0,0 +1,72 @@
package com.volmit.iris.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.provisions.ProvisionBukkit;
import com.volmit.iris.gen.scaffold.Provisioned;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import com.volmit.iris.util.Spiraler;
public class CommandIrisRegen extends MortarCommand
{
public CommandIrisRegen()
{
super("regenerate", "regen", "rg");
setDescription("Regenerate chunks");
requiresPermission(Iris.perm.studio);
setCategory("Regen");
}
@Override
public boolean handle(MortarSender sender, String[] args)
{
if(sender.isPlayer())
{
Player p = sender.player();
World world = p.getWorld();
if(!(world.getGenerator() instanceof ProvisionBukkit))
{
sender.sendMessage("You must be in an iris world.");
return true;
}
Provisioned pr = (Provisioned) world.getGenerator();
pr.clearRegeneratedLists();
if(args.length == 0)
{
sender.sendMessage("Regenerating your chunk");
pr.regenerate(p.getLocation().getChunk().getX(), p.getLocation().getChunk().getZ());
return true;
}
try
{
int m = Integer.valueOf(args[0]);
sender.sendMessage("Regenerating " + (m * m) + " Chunks Surrounding you");
new Spiraler(m, m, (a, b) -> pr.regenerate(a + p.getLocation().getChunk().getX(), b + p.getLocation().getChunk().getZ())).drain();
}
catch(Throwable e)
{
sender.sendMessage("/iris regen [SIZE]");
}
return true;
}
else
{
sender.sendMessage("Players only.");
}
return true;
}
@Override
protected String getArgsUsage()
{
return "/iris regen [size]";
}
}