aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2024-08-01 15:08:43 -0400
committersowgro <tpoke.ferrari@gmail.com>2024-08-01 15:08:43 -0400
commitfa20be5af2c8d260393a26ba01c2193eba047ba6 (patch)
treea2097048a41b95352ec3b2a5605362ee7ebb71b5
parentac7778112934593d65e2e7c06794a141ed47ab63 (diff)
downloadTumble-fa20be5af2c8d260393a26ba01c2193eba047ba6.tar.gz
Tumble-fa20be5af2c8d260393a26ba01c2193eba047ba6.tar.bz2
Tumble-fa20be5af2c8d260393a26ba01c2193eba047ba6.zip
layers.yml (not tested)
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/Main.java2
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/config/ArenaManager.java4
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/config/LanguageManager.java2
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/config/LayerManager.java66
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/game/Generator.java67
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/game/Layers.java310
-rw-r--r--src/main/resources/layers.yml202
7 files changed, 305 insertions, 348 deletions
diff --git a/src/main/java/com/MylesAndMore/Tumble/Main.java b/src/main/java/com/MylesAndMore/Tumble/Main.java
index eb1c4e0..b85636d 100644
--- a/src/main/java/com/MylesAndMore/Tumble/Main.java
+++ b/src/main/java/com/MylesAndMore/Tumble/Main.java
@@ -5,6 +5,7 @@ import com.MylesAndMore.Tumble.config.ArenaManager;
import com.MylesAndMore.Tumble.config.ConfigManager;
import com.MylesAndMore.Tumble.config.LanguageManager;
+import com.MylesAndMore.Tumble.config.LayerManager;
import com.MylesAndMore.Tumble.game.Arena;
import org.bstats.bukkit.Metrics;
@@ -23,6 +24,7 @@ public class Main extends JavaPlugin{
LanguageManager.readConfig();
ConfigManager.readConfig();
ArenaManager.readConfig();
+ LayerManager.readConfig();
Objects.requireNonNull(this.getCommand("tumble")).setExecutor(new Tumble());
new Metrics(this, 16940);
diff --git a/src/main/java/com/MylesAndMore/Tumble/config/ArenaManager.java b/src/main/java/com/MylesAndMore/Tumble/config/ArenaManager.java
index ac7767a..5e6e571 100644
--- a/src/main/java/com/MylesAndMore/Tumble/config/ArenaManager.java
+++ b/src/main/java/com/MylesAndMore/Tumble/config/ArenaManager.java
@@ -120,9 +120,7 @@ public class ArenaManager {
* z:
* world:
* @param path The section in the yaml with x, y, z, and world as its children
- * @return Result of either:
- * Result#success = true and Result#value OR
- * Result#success = false and Result#error
+ * @return The location specified by the section, or null if the location is not valid
*/
private static Location readWorld(String path) {
diff --git a/src/main/java/com/MylesAndMore/Tumble/config/LanguageManager.java b/src/main/java/com/MylesAndMore/Tumble/config/LanguageManager.java
index 6625b26..843d7c0 100644
--- a/src/main/java/com/MylesAndMore/Tumble/config/LanguageManager.java
+++ b/src/main/java/com/MylesAndMore/Tumble/config/LanguageManager.java
@@ -12,11 +12,11 @@ import static com.MylesAndMore.Tumble.Main.plugin;
* Manages language.yml and allows retrieval of keys
*/
public class LanguageManager {
+ private static final CustomConfig languageYml = new CustomConfig("language.yml");
private static Configuration config;
private static Configuration defaultConfig;
public static void readConfig() {
- CustomConfig languageYml = new CustomConfig("language.yml");
languageYml.saveDefaultConfig();
config = languageYml.getConfig();
defaultConfig = Objects.requireNonNull(config.getDefaults());
diff --git a/src/main/java/com/MylesAndMore/Tumble/config/LayerManager.java b/src/main/java/com/MylesAndMore/Tumble/config/LayerManager.java
new file mode 100644
index 0000000..d995305
--- /dev/null
+++ b/src/main/java/com/MylesAndMore/Tumble/config/LayerManager.java
@@ -0,0 +1,66 @@
+package com.MylesAndMore.Tumble.config;
+
+import com.MylesAndMore.Tumble.plugin.CustomConfig;
+import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import static com.MylesAndMore.Tumble.Main.plugin;
+
+public class LayerManager {
+ public static List<List<Material>> layers;
+
+ private static final CustomConfig layersYml = new CustomConfig("layers.yml");
+ private static final FileConfiguration config = layersYml.getConfig();
+
+ /**
+ * Read layers from layers.yml and populate this.layers
+ */
+ public static void readConfig() {
+ layersYml.saveDefaultConfig();
+
+ ConfigurationSection layersSection = config.getConfigurationSection("layers");
+ if (layersSection == null) {
+ plugin.getLogger().warning("layers.yml is missing section 'layers'");
+ return;
+ }
+ for (String layerPath : layersSection.getKeys(false)) {
+ List<Material> layer = readLayer(layerPath);
+ if (layer == null) {
+ plugin.getLogger().warning("layers.yml: error loading layer at'"+layerPath+"'");
+ } else {
+ layers.add(layer);
+ }
+ }
+ }
+
+ /**
+ * Read the list of materials for a layer.
+ * @param path The path of the layer in the config
+ * @return The list of materials for the layer to be composed of
+ */
+ public static List<Material> readLayer(String path) {
+ List<String> list = (List<String>) config.getList(path);
+ if (list == null) {
+ return null;
+ }
+ List<Material> layer = new ArrayList<>();
+ for (String entry : list) {
+ Material tmp = Material.getMaterial(entry);
+ if (tmp == null) {
+
+ return null;
+ }
+ layer.add(tmp);
+ }
+ return layer;
+ }
+
+ public static List<Material> getRandom() {
+ return layers.get(new Random().nextInt(layers.size()));
+ }
+}
diff --git a/src/main/java/com/MylesAndMore/Tumble/game/Generator.java b/src/main/java/com/MylesAndMore/Tumble/game/Generator.java
index c8ecb06..2ef0957 100644
--- a/src/main/java/com/MylesAndMore/Tumble/game/Generator.java
+++ b/src/main/java/com/MylesAndMore/Tumble/game/Generator.java
@@ -1,5 +1,6 @@
package com.MylesAndMore.Tumble.game;
+import com.MylesAndMore.Tumble.config.LayerManager;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -17,37 +18,36 @@ public class Generator {
*/
public static void generateLayersShovels(Location layer) {
Random random = new Random();
- Layers layers = new Layers();
layer.setY(layer.getY() - 1);
// Choose a random type of generation; a circular layer, a square layer, or a multi-tiered layer of either variety
if (random.nextInt(4) == 0) {
// Circular layer
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), LayerManager.getRandom());
}
else if (random.nextInt(4) == 1) {
// Square layer
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.SNOW_BLOCK), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.SNOW_BLOCK), LayerManager.getRandom());
}
else if (random.nextInt(4) == 2) {
// Multi-tiered circle
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), LayerManager.getRandom());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRASS_BLOCK), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRASS_BLOCK), LayerManager.getRandom());
Generator.generateLayer(layer, 4, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.PODZOL), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.PODZOL), LayerManager.getRandom());
}
else {
// Multi-tiered square
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.SNOW_BLOCK), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.SNOW_BLOCK), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRASS_BLOCK), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRASS_BLOCK), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.PODZOL), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.PODZOL), LayerManager.getRandom());
}
}
@@ -57,81 +57,80 @@ public class Generator {
*/
public static void generateLayersSnowballs(Location layer) {
Random random = new Random();
- Layers layers = new Layers();
layer.setY(layer.getY() - 1);
// Similar generation to shovels, except there are three layers
if (random.nextInt(4) == 0) {
// Circular layer
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), LayerManager.getRandom());
}
else if (random.nextInt(4) == 1) {
// Square layer
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), LayerManager.getRandom());
}
else if (random.nextInt(4) == 2) {
// Multi-tiered circle
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), LayerManager.getRandom());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), LayerManager.getRandom());
Generator.generateLayer(layer, 4, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), LayerManager.getRandom());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), LayerManager.getRandom());
Generator.generateLayer(layer, 4, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), LayerManager.getRandom());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), LayerManager.getRandom());
Generator.generateLayer(layer, 4, 1, Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), LayerManager.getRandom());
}
else {
// Multi-tiered square
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRANITE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRANITE), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.LIME_GLAZED_TERRACOTTA), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRANITE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRANITE), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.LIME_GLAZED_TERRACOTTA), LayerManager.getRandom());
layer.setY(layer.getY() - 6);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), layers.getSafeMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 17, layer.getY(), layer.getZ() - 17), new Location(layer.getWorld(), layer.getX() + 17, layer.getY(), layer.getZ() + 17), Material.STONE), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRANITE), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 13, layer.getY(), layer.getZ() - 13), new Location(layer.getWorld(), layer.getX() + 13, layer.getY(), layer.getZ() + 13), Material.GRANITE), LayerManager.getRandom());
Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.AIR);
layer.setY(layer.getY() - 1);
- Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
+ Generator.generateClumps(Generator.generateCuboid(new Location(layer.getWorld(), layer.getX() - 7, layer.getY(), layer.getZ() - 7), new Location(layer.getWorld(), layer.getX() + 7, layer.getY(), layer.getZ() + 7), Material.LIME_GLAZED_TERRACOTTA), LayerManager.getRandom());
}
}
diff --git a/src/main/java/com/MylesAndMore/Tumble/game/Layers.java b/src/main/java/com/MylesAndMore/Tumble/game/Layers.java
deleted file mode 100644
index 8954732..0000000
--- a/src/main/java/com/MylesAndMore/Tumble/game/Layers.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package com.MylesAndMore.Tumble.game;
-
-import org.bukkit.Material;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Stores the different types of layers that can be generated
- */
-public class Layers {
-
- public Layers() {
- List<Material> gen2 = new ArrayList<>() {{
- add(Material.PINK_TERRACOTTA);
- add(Material.PURPLE_TERRACOTTA);
- add(Material.GRAY_TERRACOTTA);
- add(Material.BLUE_TERRACOTTA);
- add(Material.LIGHT_BLUE_TERRACOTTA);
- add(Material.WHITE_TERRACOTTA);
- add(Material.BROWN_TERRACOTTA);
- add(Material.GREEN_TERRACOTTA);
- add(Material.YELLOW_TERRACOTTA);
- add(Material.PINK_TERRACOTTA);
- add(Material.PURPLE_TERRACOTTA);
- add(Material.GRAY_TERRACOTTA);
- add(Material.BLUE_TERRACOTTA);
- add(Material.LIGHT_BLUE_TERRACOTTA);
- add(Material.WHITE_TERRACOTTA);
- add(Material.BROWN_TERRACOTTA);
- add(Material.GREEN_TERRACOTTA);
- add(Material.YELLOW_TERRACOTTA);
- add(Material.WHITE_STAINED_GLASS);
- add(Material.HONEYCOMB_BLOCK);
- add(Material.HONEYCOMB_BLOCK);
- }};
- List<Material> gen4 = new ArrayList<>() {{
- add(Material.DIAMOND_BLOCK);
- add(Material.GOLD_BLOCK);
- add(Material.REDSTONE_BLOCK);
- add(Material.REDSTONE_BLOCK);
- add(Material.LAPIS_BLOCK);
- add(Material.LAPIS_BLOCK);
- add(Material.IRON_BLOCK);
- add(Material.COAL_BLOCK);
- add(Material.IRON_BLOCK);
- add(Material.COAL_BLOCK);
- add(Material.IRON_BLOCK);
- add(Material.COAL_BLOCK);
- add(Material.COAL_BLOCK);
- }};
- List<Material> gen5 = new ArrayList<>() {{
- add(Material.WHITE_TERRACOTTA);
- add(Material.BLUE_ICE);
- add(Material.SOUL_SAND);
- add(Material.STONE_SLAB);
- add(Material.WHITE_TERRACOTTA);
- add(Material.BLUE_ICE);
- add(Material.SOUL_SAND);
- add(Material.STONE_SLAB);
- add(Material.WHITE_TERRACOTTA);
- add(Material.BLUE_ICE);
- add(Material.SOUL_SAND);
- add(Material.STONE_SLAB);
- add(Material.GLOWSTONE);
- add(Material.GLOWSTONE);
- add(Material.HONEY_BLOCK);
- add(Material.SLIME_BLOCK);
- }};
- List<Material> gen7 = new ArrayList<>() {{
- add(Material.END_STONE);
- add(Material.END_STONE_BRICKS);
- add(Material.END_STONE);
- add(Material.END_STONE_BRICKS);
- add(Material.END_STONE);
- add(Material.END_STONE_BRICKS);
- add(Material.END_STONE);
- add(Material.END_STONE_BRICKS);
- add(Material.OBSIDIAN);
- add(Material.PURPUR_BLOCK);
- add(Material.PURPUR_PILLAR);
- add(Material.COBBLESTONE);
- }};
- List<Material> gen9 = new ArrayList<>() {{
- add(Material.PRISMARINE);
- add(Material.DARK_PRISMARINE);
- add(Material.BLUE_STAINED_GLASS);
- add(Material.WET_SPONGE);
- add(Material.PRISMARINE_BRICKS);
- add(Material.PRISMARINE_BRICK_SLAB);
- add(Material.DARK_PRISMARINE);
- add(Material.SEA_LANTERN);
- add(Material.TUBE_CORAL_BLOCK);
- add(Material.BRAIN_CORAL_BLOCK);
- add(Material.BUBBLE_CORAL_BLOCK);
- }};
- List<Material> gen10 = new ArrayList<>() {{
- add(Material.OAK_LOG);
- add(Material.SPRUCE_LOG);
- add(Material.ACACIA_LOG);
- add(Material.STRIPPED_OAK_LOG);
- add(Material.STRIPPED_SPRUCE_LOG);
- add(Material.STRIPPED_ACACIA_LOG);
- add(Material.OAK_WOOD);
- add(Material.SPRUCE_WOOD);
- add(Material.ACACIA_WOOD);
- add(Material.OAK_LEAVES);
- add(Material.SPRUCE_LEAVES);
- add(Material.ACACIA_LEAVES);
- add(Material.OAK_LEAVES);
- add(Material.SPRUCE_LEAVES);
- add(Material.ACACIA_LEAVES);
- }};
- List<Material> gen1 = new ArrayList<>() {{
- add(Material.YELLOW_GLAZED_TERRACOTTA);
- add(Material.LIGHT_BLUE_GLAZED_TERRACOTTA);
- add(Material.GRAY_GLAZED_TERRACOTTA);
- add(Material.PODZOL);
- add(Material.PODZOL);
- add(Material.PODZOL);
- add(Material.ORANGE_GLAZED_TERRACOTTA);
- }};
- for (int i = 0; i < 3; i++) {
- List<Material> gen0 = new ArrayList<>() {{
- add(Material.COAL_ORE);
- add(Material.COAL_ORE);
- add(Material.COAL_ORE);
- add(Material.COAL_ORE);
- add(Material.COAL_ORE);
- add(Material.IRON_ORE);
- add(Material.REDSTONE_ORE);
- add(Material.EMERALD_ORE);
- add(Material.GOLD_ORE);
- add(Material.LAPIS_ORE);
- add(Material.DIAMOND_ORE);
- add(Material.GRASS_BLOCK);
- add(Material.GRASS_BLOCK);
- add(Material.GRASS_BLOCK);
- add(Material.GRASS_BLOCK);
- add(Material.COBWEB);
- }};
- matList.add(gen0);
- matList.add(gen1);
- matList.add(gen2);
- List<Material> gen3 = new ArrayList<>() {{
- add(Material.PACKED_ICE);
- add(Material.PACKED_ICE);
- add(Material.JUKEBOX);
- add(Material.TNT);
- add(Material.LIGHT_BLUE_CONCRETE);
- add(Material.GLASS);
- add(Material.PACKED_ICE);
- add(Material.PACKED_ICE);
- add(Material.JUKEBOX);
- add(Material.TNT);
- add(Material.LIGHT_BLUE_CONCRETE);
- add(Material.GLASS);
- add(Material.SOUL_SAND);
- }};
- matList.add(gen3);
- matList.add(gen4);
- matList.add(gen5);
- List<Material> gen6 = new ArrayList<>() {{
- add(Material.NETHERRACK);
- add(Material.NETHERRACK);
- add(Material.NETHERRACK);
- add(Material.NETHER_BRICKS);
- add(Material.NETHER_BRICKS);
- add(Material.NETHERRACK);
- add(Material.NETHERRACK);
- add(Material.NETHERRACK);
- add(Material.NETHER_BRICKS);
- add(Material.NETHER_BRICKS);
- add(Material.NETHER_GOLD_ORE);
- add(Material.NETHER_GOLD_ORE);
- add(Material.CRIMSON_NYLIUM);
- add(Material.WARPED_NYLIUM);
- add(Material.SOUL_SOIL);
- add(Material.CRACKED_NETHER_BRICKS);
- add(Material.RED_NETHER_BRICKS);
- add(Material.NETHER_WART_BLOCK);
- add(Material.CRYING_OBSIDIAN);
- add(Material.MAGMA_BLOCK);
- }};
- matList.add(gen6);
- matList.add(gen7);
- List<Material> gen8 = new ArrayList<>() {{
- add(Material.REDSTONE_BLOCK);
- add(Material.REDSTONE_BLOCK);
- add(Material.REDSTONE_LAMP);
- add(Material.TARGET);
- add(Material.SLIME_BLOCK);
- add(Material.OBSERVER);
- }};
- matList.add(gen8);
- matList.add(gen9);
- matList.add(gen10);
- List<Material> gen12 = new ArrayList<>() {{
- add(Material.DIRT);
- add(Material.GRASS_PATH);
- add(Material.GRASS_BLOCK);
- add(Material.OAK_SLAB);
- add(Material.BRICK_WALL);
- add(Material.BRICK_STAIRS);
- }};
- matList.add(gen12);
- List<Material> gen14 = new ArrayList<>() {{
- add(Material.OAK_PLANKS);
- add(Material.OBSIDIAN);
- add(Material.SPONGE);
- add(Material.BEEHIVE);
- add(Material.DRIED_KELP_BLOCK);
- }};
- matList.add(gen14);
- List<Material> gen15 = new ArrayList<>() {{
- add(Material.SANDSTONE);
- add(Material.SANDSTONE_SLAB);
- add(Material.RED_SANDSTONE);
- add(Material.RED_SANDSTONE_SLAB);
- add(Material.RED_TERRACOTTA);
- add(Material.TERRACOTTA);
- add(Material.YELLOW_TERRACOTTA);
- }};
- matList.add(gen15);
- List<Material> gen16 = new ArrayList<>() {{
- add(Material.JUNGLE_LOG);
- add(Material.STRIPPED_JUNGLE_LOG);
- add(Material.JUNGLE_WOOD);
- add(Material.STRIPPED_JUNGLE_WOOD);
- add(Material.MOSSY_COBBLESTONE);
- add(Material.MOSSY_COBBLESTONE);
- add(Material.MOSSY_COBBLESTONE);
- add(Material.JUNGLE_LEAVES);
- add(Material.JUNGLE_SLAB);
- add(Material.JUNGLE_TRAPDOOR);
- }};
- matList.add(gen16);
- }
- List<Material> gen11 = new ArrayList<>() {{
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.GLASS);
- add(Material.WHITE_STAINED_GLASS);
- }};
- matList.add(gen11); // Troll glass layer
-
- for (int i = 0; i < 2; i++) {
- safeMatList.add(gen1);
- safeMatList.add(gen2);
- safeMatList.add(gen4);
- safeMatList.add(gen5);
- safeMatList.add(gen7);
- safeMatList.add(gen9);
- safeMatList.add(gen10);
- }
- safeMatList.add(gen11); // Troll glass layer
- }
-
- // Define Random class
- Random random = new Random();
- /**
- * @return A random predefined List of Materials that are okay to use in the clump generator
- */
- public List<Material> getMaterialList() {
- return matList.get(random.nextInt(matList.size()));
- }
-
- /**
- * @return A random predefined List of Materials that are okay to spawn players on top of
- */
- public List<Material> getSafeMaterialList() { return safeMatList.get(random.nextInt(safeMatList.size())); }
-
- // Template:
- // private final List<Material> gen = new ArrayList<>() {{
- // add(Material.
- // }};
-
- private final List<List<Material>> matList = new ArrayList<>();
-
- private final List<List<Material>> safeMatList = new ArrayList<>();
-
-}
diff --git a/src/main/resources/layers.yml b/src/main/resources/layers.yml
new file mode 100644
index 0000000..acc5be9
--- /dev/null
+++ b/src/main/resources/layers.yml
@@ -0,0 +1,202 @@
+layers:
+ 1:
+ - YELLOW_GLAZED_TERRACOTTA
+ - LIGHT_BLUE_GLAZED_TERRACOTTA
+ - GRAY_GLAZED_TERRACOTTA
+ - PODZOL
+ - PODZOL
+ - PODZOL
+ - ORANGE_GLAZED_TERRACOTTA
+ 2:
+ - PINK_TERRACOTTA
+ - PURPLE_TERRACOTTA
+ - GRAY_TERRACOTTA
+ - BLUE_TERRACOTTA
+ - LIGHT_BLUE_TERRACOTTA
+ - WHITE_TERRACOTTA
+ - BROWN_TERRACOTTA
+ - GREEN_TERRACOTTA
+ - YELLOW_TERRACOTTA
+ - PINK_TERRACOTTA
+ - PURPLE_TERRACOTTA
+ - GRAY_TERRACOTTA
+ - BLUE_TERRACOTTA
+ - LIGHT_BLUE_TERRACOTTA
+ - WHITE_TERRACOTTA
+ - BROWN_TERRACOTTA
+ - GREEN_TERRACOTTA
+ - YELLOW_TERRACOTTA
+ - WHITE_STAINED_GLASS
+ - HONEYCOMB_BLOCK
+ - HONEYCOMB_BLOCK
+ 3:
+ - DIAMOND_BLOCK
+ - GOLD_BLOCK
+ - REDSTONE_BLOCK
+ - REDSTONE_BLOCK
+ - LAPIS_BLOCK
+ - LAPIS_BLOCK
+ - IRON_BLOCK
+ - COAL_BLOCK
+ - IRON_BLOCK
+ - COAL_BLOCK
+ - IRON_BLOCK
+ - COAL_BLOCK
+ - COAL_BLOCK
+ 4:
+ - WHITE_TERRACOTTA
+ - BLUE_ICE
+ - SOUL_SAND
+ - STONE_SLAB
+ - WHITE_TERRACOTTA
+ - BLUE_ICE
+ - SOUL_SAND
+ - STONE_SLAB
+ - WHITE_TERRACOTTA
+ - BLUE_ICE
+ - SOUL_SAND
+ - STONE_SLAB
+ - GLOWSTONE
+ - GLOWSTONE
+ - HONEY_BLOCK
+ - SLIME_BLOCK
+ 5:
+ - END_STONE
+ - END_STONE_BRICKS
+ - END_STONE
+ - END_STONE_BRICKS
+ - END_STONE
+ - END_STONE_BRICKS
+ - END_STONE
+ - END_STONE_BRICKS
+ - OBSIDIAN
+ - PURPUR_BLOCK
+ - PURPUR_PILLAR
+ - COBBLESTONE
+ 6:
+ - PRISMARINE
+ - DARK_PRISMARINE
+ - BLUE_STAINED_GLASS
+ - WET_SPONGE
+ - PRISMARINE_BRICKS
+ - PRISMARINE_BRICK_SLAB
+ - DARK_PRISMARINE
+ - SEA_LANTERN
+ - TUBE_CORAL_BLOCK
+ - BRAIN_CORAL_BLOCK
+ - BUBBLE_CORAL_BLOCK
+ 7:
+ - OAK_LOG
+ - SPRUCE_LOG
+ - ACACIA_LOG
+ - STRIPPED_OAK_LOG
+ - STRIPPED_SPRUCE_LOG
+ - STRIPPED_ACACIA_LOG
+ - OAK_WOOD
+ - SPRUCE_WOOD
+ - ACACIA_WOOD
+ - OAK_LEAVES
+ - SPRUCE_LEAVES
+ - ACACIA_LEAVES
+ - OAK_LEAVES
+ - SPRUCE_LEAVES
+ - ACACIA_LEAVES
+ 8:
+ - YELLOW_GLAZED_TERRACOTTA
+ - LIGHT_BLUE_GLAZED_TERRACOTTA
+ - GRAY_GLAZED_TERRACOTTA
+ - PODZOL
+ - PODZOL
+ - PODZOL
+ - ORANGE_GLAZED_TERRACOTTA
+ 9:
+ - COAL_ORE
+ - COAL_ORE
+ - COAL_ORE
+ - COAL_ORE
+ - COAL_ORE
+ - IRON_ORE
+ - REDSTONE_ORE
+ - EMERALD_ORE
+ - GOLD_ORE
+ - LAPIS_ORE
+ - DIAMOND_ORE
+ - GRASS_BLOCK
+ - GRASS_BLOCK
+ - GRASS_BLOCK
+ - GRASS_BLOCK
+ - COBWEB
+ 10:
+ - PACKED_ICE
+ - PACKED_ICE
+ - JUKEBOX
+ - TNT
+ - LIGHT_BLUE_CONCRETE
+ - GLASS
+ - PACKED_ICE
+ - PACKED_ICE
+ - JUKEBOX
+ - TNT
+ - LIGHT_BLUE_CONCRETE
+ - GLASS
+ - SOUL_SAND
+ 11:
+ - NETHERRACK
+ - NETHERRACK
+ - NETHERRACK
+ - NETHER_BRICKS
+ - NETHER_BRICKS
+ - NETHERRACK
+ - NETHERRACK
+ - NETHERRACK
+ - NETHER_BRICKS
+ - NETHER_BRICKS
+ - NETHER_GOLD_ORE
+ - NETHER_GOLD_ORE
+ - CRIMSON_NYLIUM
+ - WARPED_NYLIUM
+ - SOUL_SOIL
+ - CRACKED_NETHER_BRICKS
+ - RED_NETHER_BRICKS
+ - NETHER_WART_BLOCK
+ - CRYING_OBSIDIAN
+ - MAGMA_BLOCK
+ 12:
+ - REDSTONE_BLOCK
+ - REDSTONE_BLOCK
+ - REDSTONE_LAMP
+ - TARGET
+ - SLIME_BLOCK
+ - OBSERVER
+ 13:
+ - DIRT
+ - GRASS_PATH
+ - GRASS_BLOCK
+ - OAK_SLAB
+ - BRICK_WALL
+ - BRICK_STAIRS
+ 14:
+ - OAK_PLANKS
+ - OBSIDIAN
+ - SPONGE
+ - BEEHIVE
+ - DRIED_KELP_BLOCK
+ 15:
+ - SANDSTONE
+ - SANDSTONE_SLAB
+ - RED_SANDSTONE
+ - RED_SANDSTONE_SLAB
+ - RED_TERRACOTTA
+ - TERRACOTTA
+ - YELLOW_TERRACOTTA
+ 16:
+ - JUNGLE_LOG
+ - STRIPPED_JUNGLE_LOG
+ - JUNGLE_WOOD
+ - STRIPPED_JUNGLE_WOOD
+ - MOSSY_COBBLESTONE
+ - MOSSY_COBBLESTONE
+ - MOSSY_COBBLESTONE
+ - JUNGLE_LEAVES
+ - JUNGLE_SLAB
+ - JUNGLE_TRAPDOOR \ No newline at end of file