Crash fix, world time fix, Java 8 support

Skip dimensions that are already registered (#1)
Fix world time setting (#2)
Use Jabel to support Java 8
I'm not giving my vars up
This commit is contained in:
Norbi Peti 2020-09-15 00:19:36 +02:00
parent e18acc27e9
commit e596814669
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 55 additions and 5 deletions

46
pom.xml
View file

@ -6,15 +6,21 @@
<groupId>com.github.TBMCPlugins</groupId> <groupId>com.github.TBMCPlugins</groupId>
<artifactId>CustomDimensions</artifactId> <artifactId>CustomDimensions</artifactId>
<version>1.1</version> <version>1.2</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration> <configuration>
<source>10</source> <!-- Make sure we're not using Java 9+ APIs -->
<target>10</target> <release>8</release>
<source>14</source>
<target>14</target>
<compilerArgs>
<arg>-Xplugin:jabel</arg>
</compilerArgs>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
@ -25,6 +31,10 @@
<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>
<id>jitpack.io</id>
<url>https://jitpack.io/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -34,6 +44,36 @@
<version>1.16.3-R0.1-SNAPSHOT</version> <version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.bsideup.jabel</groupId>
<artifactId>jabel-javac-plugin</artifactId>
<version>0.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<profiles>
<profile>
<id>intellij-idea-only</id>
<activation>
<property>
<name>idea.maven.embedder.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>14</release>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

View file

@ -91,8 +91,16 @@ public class CustomDimensions extends JavaPlugin implements Listener {
List<MobSpawner> spawners = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); List<MobSpawner> spawners = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
ResourceKey<DimensionManager> dimManResKey = ResourceKey.a(IRegistry.K, dimKey.a()); ResourceKey<DimensionManager> dimManResKey = ResourceKey.a(IRegistry.K, dimKey.a());
var dimRegistry = ((RegistryMaterials<DimensionManager>) console.customRegistry.a());
{
var key = dimRegistry.getKey(dimensionmanager);
if (key != null) { //The loaded manager is the same
getLogger().warning("Dimension manager already loaded with key " + key + "! Skipping");
continue;
}
}
//Replace existing dimension manager, correctly setting the ID up (which is -1 for default worlds...) //Replace existing dimension manager, correctly setting the ID up (which is -1 for default worlds...)
((RegistryMaterials<DimensionManager>) console.customRegistry.a()).a(OptionalInt.empty(), dimManResKey, dimensionmanager, Lifecycle.stable()); dimRegistry.a(OptionalInt.empty(), dimManResKey, dimensionmanager, Lifecycle.stable());
var worldloadlistener = console.worldLoadListenerFactory.create(11); var worldloadlistener = console.worldLoadListenerFactory.create(11);
@ -100,7 +108,9 @@ public class CustomDimensions extends JavaPlugin implements Listener {
worlddata, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, worlddata, worldKey, dimensionmanager, worldloadlistener, chunkgenerator,
false, //isDebugWorld false, //isDebugWorld
BiomeManager.a(worlddata.getGeneratorSettings().getSeed()), //Biome seed BiomeManager.a(worlddata.getGeneratorSettings().getSeed()), //Biome seed
spawners, false, org.bukkit.World.Environment.NORMAL, null); spawners,
true, //Update world time
org.bukkit.World.Environment.NORMAL, null);
if (Bukkit.getWorld(name.toLowerCase(Locale.ENGLISH)) == null) { if (Bukkit.getWorld(name.toLowerCase(Locale.ENGLISH)) == null) {
getLogger().warning("Failed to load custom dimension " + name); getLogger().warning("Failed to load custom dimension " + name);