-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldUtils.java
More file actions
48 lines (39 loc) · 1.39 KB
/
Copy pathWorldUtils.java
File metadata and controls
48 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package ru.cwcode.cwutils.world;
import org.bukkit.*;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
public class WorldUtils {
private static final ChunkGenerator emptyGenerator = new ChunkGenerator() {
@Override
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) {
return createChunkData(world);
}
};
public static World createEmptyWorld(String name) {
if (Bukkit.getWorld(name) != null) {
return null;
}
World world = WorldCreator.name(name)
.type(WorldType.FLAT)
.generator(emptyGenerator)
.createWorld();
if (world != null) {
world.setGameRule(GameRule.RANDOM_TICK_SPEED, 0);
world.setGameRule(GameRule.DO_MOB_SPAWNING, false);
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
world.setTime(6000);
world.setClearWeatherDuration(1000);
}
return world;
}
public static World createWorld(String name, WorldType worldType) {
if (Bukkit.getWorld(name) != null) {
return null;
}
return WorldCreator.name(name)
.type(worldType)
.createWorld();
}
}