Add FixChunk command

This commit is contained in:
dfsek
2020-10-10 18:58:29 -07:00
parent 8e1dd75ae9
commit c91d2a46ed
4 changed files with 53 additions and 2 deletions

View File

@@ -100,7 +100,7 @@
<dependency>
<groupId>org.polydev</groupId>
<artifactId>gaea</artifactId>
<version>1.11.2</version>
<version>1.11.3</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@@ -0,0 +1,44 @@
package com.dfsek.terra.command;
import com.dfsek.terra.generation.TerraChunkGenerator;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.polydev.gaea.command.WorldCommand;
import java.util.Collections;
import java.util.List;
public class FixChunkCommand extends WorldCommand {
public FixChunkCommand(org.polydev.gaea.command.Command parent) {
super(parent);
}
@Override
public boolean execute(@NotNull Player player, @NotNull Command command, @NotNull String s, @NotNull String[] strings, World world) {
TerraChunkGenerator.fixChunk(player.getLocation().getChunk());
return true;
}
@Override
public String getName() {
return "fixchunk";
}
@Override
public List<org.polydev.gaea.command.Command> getSubCommands() {
return Collections.emptyList();
}
@Override
public int arguments() {
return 0;
}
@Override
public List<String> getTabCompletions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
return Collections.emptyList();
}
}

View File

@@ -23,7 +23,8 @@ public class TerraCommand extends Command {
new SaveDataCommand(this),
new StructureCommand(this),
new ImageCommand(this),
new GeometryCommand(this));
new GeometryCommand(this),
new FixChunkCommand(this));
public TerraCommand(GaeaPlugin main) {
super(main);

View File

@@ -17,6 +17,7 @@ import com.dfsek.terra.population.TreePopulator;
import com.dfsek.terra.structure.StructureSpawnRequirement;
import com.dfsek.terra.util.DataUtil;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
@@ -156,6 +157,11 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
}
}
public static synchronized void fixChunk(Chunk c) {
if(!(c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
}
@Override
public int getNoiseOctaves(World world) {
return 4;