forked from Upstream/mmocore
Load chunks async when regenning blocks closes #75
This commit is contained in:
parent
47e145d384
commit
fff574c0dd
33
pom.xml
33
pom.xml
@ -51,6 +51,27 @@
|
|||||||
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
|
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -66,6 +87,10 @@
|
|||||||
<id>sk89q-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>https://maven.enginehub.org/repo/</url>
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
@ -99,11 +124,19 @@
|
|||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>19.0.0</version>
|
<version>19.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>5.1.41</version>
|
<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>
|
</dependency>
|
||||||
|
|
||||||
<!-- Other Plugins -->
|
<!-- Other Plugins -->
|
||||||
|
@ -16,6 +16,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.block.BlockInfo;
|
import net.Indyuce.mmocore.api.block.BlockInfo;
|
||||||
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
||||||
@ -91,9 +92,13 @@ public class CustomBlockManager extends MMOManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void regen(RegeneratingBlock info, boolean shutdown) {
|
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();
|
info.getLocation().getBlock().getState().update();
|
||||||
if(!shutdown) active.remove(info);
|
if(!shutdown) active.remove(info);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user