Added test

This commit is contained in:
Butzlabben 2019-06-14 12:33:44 +02:00
parent 41b5ed6bc2
commit e117fda5e8
3 changed files with 47 additions and 20 deletions

15
pom.xml
View File

@ -40,6 +40,7 @@
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version> <version>3.0.1</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version> <version>3.3</version>
@ -48,6 +49,7 @@
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
@ -61,6 +63,19 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -18,27 +18,24 @@ public class AsyncCreatorAdapter implements CreatorAdapter {
// Create worlds async to close #16 // Create worlds async to close #16
@Override @Override
public void create(WorldCreator creator, SystemWorld sw, Runnable r) { public void create(WorldCreator creator, SystemWorld sw, Runnable r) {
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(() -> {
@Override AsyncWorld world;
public void run() { if (Bukkit.getWorld(creator.name()) == null)
AsyncWorld world; world = AsyncWorld.create(creator);
if (Bukkit.getWorld(creator.name()) == null) else
world = AsyncWorld.create(creator); world = AsyncWorld.wrap(Objects.requireNonNull(Bukkit.getWorld(creator.name())));
else
world = AsyncWorld.wrap(Objects.requireNonNull(Bukkit.getWorld(creator.name())));
Block block = world.getBlockAt(0, 0, 0); Block block = world.getBlockAt(0, 0, 0);
block.setType(Material.BEDROCK); block.setType(Material.BEDROCK);
// When you are done // When you are done
world.commit(); world.commit();
Bukkit.getWorlds().add(world); Bukkit.getWorlds().add(world);
if (sw != null) if (sw != null)
sw.setCreating(false); sw.setCreating(false);
// Send the message // Send the message
r.run(); r.run();
}
}); });
} }

View File

@ -0,0 +1,15 @@
package de.butzlabben.world.wrapper;
import org.bukkit.WorldCreator;
import org.junit.Test;
import static org.junit.Assert.*;
public class GeneratorSettingsTest {
@Test
public void asWorldCreator() {
GeneratorSettings settings = new GeneratorSettings();
WorldCreator creator = settings.asWorldCreator("test");
}
}