Fixed for Spigot, added error reporting

This commit is contained in:
Norbi Peti 2018-01-08 21:48:45 +01:00
parent e25b3740b6
commit 509fe99294
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 77 additions and 73 deletions

124
pom.xml
View file

@ -1,59 +1,65 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>buttondevteam</groupId> <groupId>buttondevteam</groupId>
<artifactId>ChunkArchive</artifactId> <artifactId>ChunkArchive</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<excludes> <excludes>
<exclude>**/*.java</exclude> <exclude>**/*.java</exclude>
</excludes> </excludes>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version> <version>3.5.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io/</url> <url>https://jitpack.io/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.spigotmc</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>junit</artifactId> <artifactId>ButtonCore</artifactId>
<version>3.8.1</version> <version>master-SNAPSHOT</version>
<scope>test</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> <dependency>
</project> <groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -11,31 +11,29 @@ import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkPopulateEvent; import org.bukkit.event.world.ChunkPopulateEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.lib.TBMCCoreAPI;
import net.minecraft.server.v1_12_R1.ChunkRegionLoader; import net.minecraft.server.v1_12_R1.ChunkRegionLoader;
import net.minecraft.server.v1_12_R1.ExceptionWorldConflict; import net.minecraft.server.v1_12_R1.ExceptionWorldConflict;
public class Main extends JavaPlugin implements Listener public class Main extends JavaPlugin implements Listener {
{ public void onEnable() {
public void onEnable() TBMCCoreAPI.RegisterEventsForExceptions(this, this);
{
getServer().getPluginManager().registerEvents(this, this);
} }
/*------------------------------------------------------------*/ /*------------------------------------------------------------*/
private final ChunkRegionLoader chunkRegionLoader = private final ChunkRegionLoader chunkRegionLoader =
new ChunkRegionLoader(this.getDataFolder(), ((CraftServer) Bukkit.getServer()) new ChunkRegionLoader(this.getDataFolder(),
.getServer() ((CraftServer) Bukkit.getServer()).getServer().dataConverterManager);
.dataConverterManager);
/*------------------------------------------------------------*/ /*------------------------------------------------------------*/
@EventHandler @EventHandler
public void onChunkPopulate(ChunkPopulateEvent event) throws IOException, public void onChunkPopulate(ChunkPopulateEvent event) throws IOException,
ExceptionWorldConflict ExceptionWorldConflict
{ {
if (event.getWorld().getName().equals("world")) if (event.getWorld().getName().equals("world"))
chunkRegionLoader.saveChunk(((CraftWorld) event.getWorld()).getHandle(), chunkRegionLoader.saveChunk(((CraftWorld) event.getWorld()).getHandle(),
((CraftChunk) event.getChunk()).getHandle()); ((CraftChunk) event.getChunk()).getHandle(), false);
} }
} }