diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07dd6b1..6d8a454 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,11 +14,11 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: 16 + java-version: 17 - name: Cache SonarCloud packages uses: actions/cache@v2 with: diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..525681c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target/ +/.classpath +/.project diff --git a/pom.xml b/pom.xml index e88f8e0..48a5636 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,7 @@ skygrid ${revision} + SkyGrid Skygrid is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like BSkyBlock or AcidIsland. https://github.com/BentoBoxWorld/SkyGrid 2017 @@ -53,18 +54,18 @@ UTF-8 UTF-8 - 16 + 17 2.0.2 - 1.17.1-R0.1-SNAPSHOT - 1.17.1 + 1.19.1-R0.1-SNAPSHOT + 1.21.0 ${build.version}-SNAPSHOT -LOCAL - 1.17.0 + 1.18.0 BentoBoxWorld_SkyGrid bentobox-world @@ -315,6 +316,4 @@ - - SkyGrid \ No newline at end of file diff --git a/src/main/java/world/bentobox/skygrid/Settings.java b/src/main/java/world/bentobox/skygrid/Settings.java index fabdb91..1d83c89 100644 --- a/src/main/java/world/bentobox/skygrid/Settings.java +++ b/src/main/java/world/bentobox/skygrid/Settings.java @@ -13,6 +13,7 @@ import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.flags.Flag; import world.bentobox.bentobox.database.objects.adapters.Adapter; +import world.bentobox.bentobox.database.objects.adapters.FlagBooleanSerializer; import world.bentobox.bentobox.database.objects.adapters.FlagSerializer; import world.bentobox.bentobox.database.objects.adapters.FlagSerializer2; @@ -107,10 +108,6 @@ public class Settings implements WorldSettings { private boolean makeEndPortals = false; /* SkyGrid */ - @ConfigComment("Biomes - this will affect some block types and tree types.") - @ConfigEntry(path = "world.create-biomes") - private boolean createBiomes = true; - @ConfigComment("The probability of a frame being created in a chunk. Frames are always at y=0.") @ConfigEntry(path = "world.end-frame-probability") private double endFrameProb = 0.1; @@ -178,13 +175,12 @@ public class Settings implements WorldSettings { @ConfigComment("The value is the minimum island rank required to do the action") @ConfigComment("Ranks are: Visitor = 0, Member = 900, Owner = 1000") @ConfigEntry(path = "world.default-protection-flags") - @Adapter(FlagSerializer.class) - private Map defaultIslandFlags = new HashMap<>(); + private Map defaultIslandFlagNames = new HashMap<>(); @ConfigComment("These are the default settings for new protected areas") @ConfigEntry(path = "world.default-settings") - @Adapter(FlagSerializer2.class) - private Map defaultIslandSettings = new HashMap<>(); + @Adapter(FlagBooleanSerializer.class) + private Map defaultIslandSettingNames = new HashMap<>(); @ConfigComment("These settings/flags are hidden from users") @ConfigComment("Ops can toggle hiding in-game using SHIFT-LEFT-CLICK on flags in settings") @@ -479,20 +475,6 @@ public void setEndBlocks(Map endBlocks) { this.endBlocks = endBlocks; } - /** - * @return the createBiomes - */ - public boolean isCreateBiomes() { - return createBiomes; - } - - /** - * @param createBiomes the createBiomes to set - */ - public void setCreateBiomes(boolean createBiomes) { - this.createBiomes = createBiomes; - } - /** * @return the endFrameProb */ @@ -738,32 +720,56 @@ public void setWorldFlags(Map worldFlags) { /** * @return the defaultIslandFlags + * @deprecated since 1.21 */ @Override public Map getDefaultIslandFlags() { - return defaultIslandFlags; + return Collections.emptyMap(); } + + /** + * @return defaultIslandFlagNames + */ + @Override + public Map getDefaultIslandFlagNames() + { + return defaultIslandFlagNames; + } + + /** * @param defaultIslandFlags the defaultIslandFlags to set */ - public void setDefaultIslandFlags(Map defaultIslandFlags) { - this.defaultIslandFlags = defaultIslandFlags; + public void setDefaultIslandFlagNames(Map defaultIslandFlags) { + this.defaultIslandFlagNames = defaultIslandFlags; } /** * @return the defaultIslandSettings + * @deprecated since 1.21 */ @Override public Map getDefaultIslandSettings() { - return defaultIslandSettings; + return Collections.emptyMap(); + } + + + /** + * @return defaultIslandSettingNames + */ + @Override + public Map getDefaultIslandSettingNames() + { + return defaultIslandSettingNames; } + /** * @param defaultIslandSettings the defaultIslandSettings to set */ - public void setDefaultIslandSettings(Map defaultIslandSettings) { - this.defaultIslandSettings = defaultIslandSettings; + public void setDefaultIslandSettingNames(Map defaultIslandSettings) { + this.defaultIslandSettingNames = defaultIslandSettings; } /** diff --git a/src/main/java/world/bentobox/skygrid/SkyGrid.java b/src/main/java/world/bentobox/skygrid/SkyGrid.java index d7f2fe7..3c15765 100644 --- a/src/main/java/world/bentobox/skygrid/SkyGrid.java +++ b/src/main/java/world/bentobox/skygrid/SkyGrid.java @@ -2,7 +2,6 @@ import org.bukkit.World; import org.bukkit.WorldCreator; -import org.bukkit.WorldType; import org.bukkit.generator.ChunkGenerator; import org.eclipse.jdt.annotation.NonNull; @@ -90,24 +89,21 @@ public void createWorlds() { getLogger().info("Creating SkyGrid world ..."); } // Create the world if it does not exist - islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(gen) - .createWorld(); + islandWorld = WorldCreator.name(worldName).environment(World.Environment.NORMAL).generator(gen).createWorld(); // Make the nether if it does not exist if (settings.isNetherGenerate()) { if (getServer().getWorld(worldName + NETHER) == null) { log("Creating SkyGrid's Nether..."); } - netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(gen) - .environment(World.Environment.NETHER).createWorld(); + netherWorld = WorldCreator.name(worldName + NETHER).generator(gen).environment(World.Environment.NETHER).createWorld(); } // Make the end if it does not exist if (settings.isEndGenerate()) { if (getServer().getWorld(worldName + THE_END) == null) { log("Creating SkyGrid's End World..."); } - endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(gen) - .environment(World.Environment.THE_END).createWorld(); + endWorld = WorldCreator.name(worldName + THE_END).generator(gen).environment(World.Environment.THE_END).createWorld(); } } diff --git a/src/main/java/world/bentobox/skygrid/generators/BiomeGenerator.java b/src/main/java/world/bentobox/skygrid/generators/BiomeGenerator.java deleted file mode 100644 index b091184..0000000 --- a/src/main/java/world/bentobox/skygrid/generators/BiomeGenerator.java +++ /dev/null @@ -1,51 +0,0 @@ -package world.bentobox.skygrid.generators; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; - -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Biome; -import org.bukkit.util.noise.PerlinOctaveGenerator; - -public class BiomeGenerator { - - private final PerlinOctaveGenerator temperatureGen; - private final PerlinOctaveGenerator rainfallGen; - private final Environment env; - - public BiomeGenerator(World world) { - temperatureGen = new PerlinOctaveGenerator(world.getSeed(), 16); - temperatureGen.setScale(1.0/100.0); - - rainfallGen = new PerlinOctaveGenerator(world.getSeed() + 1, 15); - rainfallGen.setScale(1.0/100.0); - - env = world.getEnvironment(); - } - - /** - * Get the biome for this coordinate - * @param realX - x - * @param realZ - z - * @return Biome - */ - public Biome getDominantBiome(int realX, int realZ) { - //We get the 3 closest biome's to the temperature and rainfall at this block - Map biomes = Biomes.getBiomes(env, Math.abs(temperatureGen.noise(realX, realZ, 0.5, 0.5)*100.0), - Math.abs(rainfallGen.noise(realX, realZ, 0.5, 0.5)*100.0)); - //And tell bukkit (who tells the client) what the biggest biome here is - double maxNoiz = 0.0; - Biomes maxBiome = null; - - for (Entry biome : biomes.entrySet()) { - if (biome.getValue() >= maxNoiz) { - maxNoiz = biome.getValue(); - maxBiome = biome.getKey(); - } - } - return Objects.requireNonNull(maxBiome).biome; - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/skygrid/generators/Biomes.java b/src/main/java/world/bentobox/skygrid/generators/Biomes.java index 74ec42d..4fa641c 100644 --- a/src/main/java/world/bentobox/skygrid/generators/Biomes.java +++ b/src/main/java/world/bentobox/skygrid/generators/Biomes.java @@ -20,19 +20,17 @@ public enum Biomes { //We store the biome, the temperature and rainfall for each biome. - SNOWY_TUNDRA(Environment.NORMAL, Biome.SNOWY_TUNDRA, 0, 100), + SNOWY_PLAINS(Environment.NORMAL, Biome.SNOWY_PLAINS, 0, 100), SNOWY_TAIGA(Environment.NORMAL, Biome.SNOWY_TAIGA, 0, 100), FROZEN_RIVER(Environment.NORMAL, Biome.FROZEN_RIVER, 0, 10), SNOWY_BEACH(Environment.NORMAL, Biome.SNOWY_BEACH, 0, 100), - MOUNTAINS(Environment.NORMAL, Biome.MOUNTAINS, 20, 60), - WOODED_MOUNTAINS(Environment.NORMAL, Biome.WOODED_MOUNTAINS, 20, 60), + STONY_PEAKS(Environment.NORMAL, Biome.STONY_PEAKS, 20, 60), DESERT(Environment.NORMAL, Biome.DESERT, 60, 4), FOREST(Environment.NORMAL, Biome.FOREST, 50, 60), PLAINS(Environment.NORMAL, Biome.PLAINS, 40, 30), SWAMP(Environment.NORMAL, Biome.SWAMP, 40, 70), JUNGLE(Environment.NORMAL, Biome.JUNGLE, 60, 50), SAVANNA(Environment.NORMAL, Biome.SAVANNA, 40, 10), - DESERT_HILLS(Environment.NORMAL, Biome.DESERT_HILLS, 60, 5), TAIGA(Environment.NORMAL, Biome.TAIGA, 30, 5), // Nether NETHER_WASTES(Environment.NETHER, Biome.NETHER_WASTES, 40, 30), diff --git a/src/main/java/world/bentobox/skygrid/generators/SkyGridGen.java b/src/main/java/world/bentobox/skygrid/generators/SkyGridGen.java index eaf1c6b..7a58b0a 100644 --- a/src/main/java/world/bentobox/skygrid/generators/SkyGridGen.java +++ b/src/main/java/world/bentobox/skygrid/generators/SkyGridGen.java @@ -1,17 +1,15 @@ package world.bentobox.skygrid.generators; import java.util.Collections; -import java.util.EnumMap; import java.util.List; -import java.util.Map; import java.util.Random; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.WorldInfo; import world.bentobox.skygrid.SkyGrid; @@ -19,10 +17,7 @@ public class SkyGridGen extends ChunkGenerator { private final SkyGrid addon; - private final Map biomeGenerator; - private final BlockPopulator populator; - private final SkyGridChunks preMade; /** @@ -32,30 +27,14 @@ public SkyGridGen(SkyGrid addon) { this.addon = addon; this.populator = new SkyGridPop(addon); preMade = new SkyGridChunks(addon); - biomeGenerator = new EnumMap<>(Environment.class); } @Override - public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) { - // The chunk we are making - ChunkData result = createChunkData(world); - preMade.getSkyGridChunk(world.getEnvironment()).forEach(b -> result.setBlock(b.getX(), b.getY(), b.getZ(), b.getBd())); - // Set biome - if (addon.getSettings().isCreateBiomes()) { - for (int x = 0; x < 16; x +=4) { - for (int z = 0; z < 16; z +=4) { - int realX = x + chunkX * 16; //used so that the noise function gives us - int realZ = z + chunkZ * 16; //different values each chunk - Biome b = biomeGenerator.computeIfAbsent(world.getEnvironment(), k -> new BiomeGenerator(world)).getDominantBiome(realX, realZ); - for (int y = 0; y < world.getMaxHeight(); y+=4) { - biomeGrid.setBiome(x, y, z, b); - } - } - } - } - return result; - } + public void generateNoise(WorldInfo worldInfo, Random r, int x, int z, ChunkData result) { + result.setRegion(0, worldInfo.getMinHeight(), 0, 16, worldInfo.getMaxHeight(), 16, Material.AIR); + preMade.getSkyGridChunk(worldInfo.getEnvironment()).forEach(b -> result.setBlock(b.getX(), b.getY(), b.getZ(), b.getBd())); + } @Override public List getDefaultPopulators(World world) { @@ -68,5 +47,4 @@ public Location getFixedSpawnLocation(World world, Random random) { } - } \ No newline at end of file diff --git a/src/main/java/world/bentobox/skygrid/generators/SkyGridPop.java b/src/main/java/world/bentobox/skygrid/generators/SkyGridPop.java index 43976d3..137b6ba 100644 --- a/src/main/java/world/bentobox/skygrid/generators/SkyGridPop.java +++ b/src/main/java/world/bentobox/skygrid/generators/SkyGridPop.java @@ -152,7 +152,7 @@ private void setSaplingType(Block b) { break; case SWAMP: break; - case DESERT, DESERT_HILLS: + case DESERT: b.setType(Material.DEAD_BUSH, false); break; case SAVANNA: diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index 9a80f81..1f9b41e 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -4,7 +4,7 @@ version: ${version}${build.number} metrics: true repository: "BentoBoxWorld/SkyGrid" icon: "COBWEB" -api-version: 1.14 +api-version: 1.21 authors: tastybento diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 487e620..30b7ae7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1030,8 +1030,6 @@ world: # when player enters the end world. # Added since 1.16. create-obsidian-platform: false - # Biomes - this will affect some block types and tree types. - create-biomes: true # The probability of a frame being created in a chunk. Frames are always at y=0. end-frame-probability: 0.1 # Friendly name for this world. Used in admin commands. Must be a single word diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e88ac5c..edd241a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Pladdon main: world.bentobox.skygrid.SkyGrid version: ${version} -api-version: 1.17 +api-version: 1.19 description: SkyGrid author: tastybento depend: [BentoBox]