Load chunks async when regenning blocks closes #75

This commit is contained in:
HexedHero 2020-09-26 23:51:03 +01:00
parent 47e145d384
commit fff574c0dd
2 changed files with 43 additions and 5 deletions

33
pom.xml
View File

@ -51,6 +51,27 @@
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>net.indyuce.mmocore.shaded.paperlib</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
@ -66,6 +87,10 @@
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
@ -99,11 +124,19 @@
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.5</version>
<scope>compile</scope>
</dependency>
<!-- Other Plugins -->

View File

@ -16,6 +16,7 @@ import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import io.papermc.lib.PaperLib;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.block.BlockInfo;
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
@ -91,9 +92,13 @@ public class CustomBlockManager extends MMOManager {
}
private void regen(RegeneratingBlock info, boolean shutdown) {
info.getRegeneratingBlock().getBlock().place(info.getLocation(), info);
Location infoLocation = info.getLocation();
// Get the chunk and load it async if needed.
PaperLib.getChunkAtAsync(infoLocation).whenComplete((chunk, ex) -> {
info.getRegeneratingBlock().getBlock().place(infoLocation, info);
info.getLocation().getBlock().getState().update();
if(!shutdown) active.remove(info);
});
}
/*