aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/MylesAndMore/tumble/api
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/game/Generator.java (renamed from src/main/java/com/MylesAndMore/tumble/api/Generator.java)32
-rw-r--r--src/main/java/com/MylesAndMore/Tumble/plugin/Metrics.java (renamed from src/main/java/com/MylesAndMore/tumble/api/Metrics.java)4
-rw-r--r--src/main/java/com/MylesAndMore/tumble/api/Layers.java373
3 files changed, 13 insertions, 396 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/api/Generator.java b/src/main/java/com/MylesAndMore/Tumble/game/Generator.java
index db8bacc..ecaa1b7 100644
--- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java
+++ b/src/main/java/com/MylesAndMore/Tumble/game/Generator.java
@@ -1,4 +1,4 @@
-package com.MylesAndMore.tumble.api;
+package com.MylesAndMore.Tumble.game;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -6,24 +6,20 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
+import java.util.*;
/**
- * This class holds the methods that generate blocks in-game such as cylinders, cubiods, and clump logic.
+ * Holds the methods that generate blocks in-game such as cylinders, cuboids, and block clumps.
*/
public class Generator {
/**
- * Generates a layer (bascally just a cylinder) as best as it can w/ blocks
- *
- * @return A list of Blocks containing all the blocks it just changed
- *
+ * Generates a layer (basically just a cylinder) as good as possible with blocks
* @param center The center of the layer (Location)
* @param radius The whole number radius of the circle
* @param height The whole number height of the circle (1 for a flat layer)
* @param material The Material to use for generation
+ *
+ * @return A list of Blocks containing all the blocks it just changed
*/
public static List<Block> generateLayer(Location center, int radius, int height, Material material) {
int Cx = center.getBlockX();
@@ -38,7 +34,7 @@ public class Generator {
for (int x = Cx - radius; x <= Cx + radius; x++) {
for (int z = Cz - radius; z <= Cz + radius; z++) {
if ((Cx - x) * (Cx - x) + (Cz - z) * (Cz - z) <= rSq) {
- world.getBlockAt(x, y, z).setType(material);
+ Objects.requireNonNull(world).getBlockAt(x, y, z).setType(material);
blocks.add(world.getBlockAt(x, y, z));
}
}
@@ -48,7 +44,7 @@ public class Generator {
}
/**
- * Generates a cubiod (literally just a ripoff fill command)
+ * Generates a cuboid (literally just a ripoff fill command)
* @param firstPos The first Location to fill (first three coords in a fill command)
* @param secondPos The second Location to fill to (second three coords)
* @param material The Material to fill
@@ -66,7 +62,7 @@ public class Generator {
for (int x = fX; x <= sX; x++) {
for (int y = fY; y <= sY; y++) {
for (int z = fZ; z <= sZ; z++) {
- world.getBlockAt(x, y, z).setType(material);
+ Objects.requireNonNull(world).getBlockAt(x, y, z).setType(material);
blocks.add(world.getBlockAt(x, y, z));
}
}
@@ -82,22 +78,16 @@ public class Generator {
* More Materials = more randomization
*/
public static void generateClumps(List<Block> blockList, List<Material> materialList) {
- // Define random class
Random random = new Random();
- // Define new blocks list so we can manipulate it
+ // Make new lists so we can manipulate them
List<Block> blocks = new ArrayList<>(blockList);
- // Define new shuffled Materials list
List<Material> materials = new ArrayList<>(materialList);
Collections.shuffle(materials);
- // This loop will run until there are no blocks left to change
while (blocks.size() > 0) {
- // Get a random Material from the provided materials list
Material randomMaterial = materials.get(random.nextInt(materials.size()));
- // Gets the first Block from the list, to modify
Block aBlock = blocks.get(0);
- // Modifies the block
aBlock.setType(randomMaterial);
- // Get the blocks around that and change it to that same material
+ // Get the blocks around that and change it to that same material (this is the basis of "clumps")
if (blocks.contains(aBlock.getRelative(BlockFace.NORTH))) {
aBlock.getRelative(BlockFace.NORTH).setType(randomMaterial);
blocks.remove(aBlock.getRelative(BlockFace.NORTH));
diff --git a/src/main/java/com/MylesAndMore/tumble/api/Metrics.java b/src/main/java/com/MylesAndMore/Tumble/plugin/Metrics.java
index 411a918..3432a93 100644
--- a/src/main/java/com/MylesAndMore/tumble/api/Metrics.java
+++ b/src/main/java/com/MylesAndMore/Tumble/plugin/Metrics.java
@@ -1,4 +1,4 @@
-// Do NOT remove this file! The build will fail--it is to enable bStats.
+// Tumble--do not remove or modify this file!
/*
* This Metrics class was auto-generated and can be copied into your project if you are
@@ -14,7 +14,7 @@
*
* Violations will result in a ban of your plugin and account from bStats.
*/
-package com.MylesAndMore.tumble.api;
+package com.MylesAndMore.Tumble.plugin;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
diff --git a/src/main/java/com/MylesAndMore/tumble/api/Layers.java b/src/main/java/com/MylesAndMore/tumble/api/Layers.java
deleted file mode 100644
index d0d5890..0000000
--- a/src/main/java/com/MylesAndMore/tumble/api/Layers.java
+++ /dev/null
@@ -1,373 +0,0 @@
-package com.MylesAndMore.tumble.api;
-
-import org.bukkit.Material;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * This class is dedicated to storing the different types of layers that can be generated.
- */
-public class Layers {
-
- public Layers(){
- matList.add(gen0);
- matList.add(gen1);
- matList.add(gen2);
- matList.add(gen3);
- matList.add(gen4);
- matList.add(gen5);
- matList.add(gen6);
- matList.add(gen7);
- matList.add(gen8);
- matList.add(gen9);
- matList.add(gen10);
- matList.add(gen12);
- matList.add(gen14);
- matList.add(gen15);
- matList.add(gen16);
- matList.add(gen0);
- matList.add(gen1);
- matList.add(gen2);
- matList.add(gen3);
- matList.add(gen4);
- matList.add(gen5);
- matList.add(gen6);
- matList.add(gen7);
- matList.add(gen8);
- matList.add(gen9);
- matList.add(gen10);
- matList.add(gen12);
- matList.add(gen14);
- matList.add(gen15);
- matList.add(gen16);
- matList.add(gen0);
- matList.add(gen1);
- matList.add(gen2);
- matList.add(gen3);
- matList.add(gen4);
- matList.add(gen5);
- matList.add(gen6);
- matList.add(gen7);
- matList.add(gen8);
- matList.add(gen9);
- matList.add(gen10);
- matList.add(gen12);
- matList.add(gen14);
- matList.add(gen15);
- matList.add(gen16);
- // Troll glass layer
- matList.add(gen11);
-
- safeMatList.add(gen1);
- safeMatList.add(gen2);
- safeMatList.add(gen4);
- safeMatList.add(gen5);
- safeMatList.add(gen7);
- safeMatList.add(gen9);
- safeMatList.add(gen10);
- safeMatList.add(gen1);
- safeMatList.add(gen2);
- safeMatList.add(gen4);
- safeMatList.add(gen5);
- safeMatList.add(gen7);
- safeMatList.add(gen9);
- safeMatList.add(gen10);
- safeMatList.add(gen1);
- safeMatList.add(gen2);
- safeMatList.add(gen4);
- safeMatList.add(gen5);
- safeMatList.add(gen7);
- safeMatList.add(gen9);
- safeMatList.add(gen10);
- // Troll glass layer
- safeMatList.add(gen11);
- }
-
- // 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())); }
-
- // Begin lists
-
- // private final List<Material> gen = new ArrayList<>() {{
- // add(Material.
- // }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final List<Material> gen3 = new ArrayList<>() {{
- add(Material.PACKED_ICE);
- add(Material.PACKED_ICE);
- add(Material.NOTE_BLOCK);
- add(Material.TNT);
- add(Material.LIGHT_BLUE_CONCRETE);
- add(Material.GLASS);
- add(Material.PACKED_ICE);
- add(Material.PACKED_ICE);
- add(Material.NOTE_BLOCK);
- add(Material.TNT);
- add(Material.LIGHT_BLUE_CONCRETE);
- add(Material.GLASS);
- add(Material.SOUL_SAND);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final List<Material> gen8 = new ArrayList<>() {{
- add(Material.REDSTONE_BLOCK);
- add(Material.REDSTONE_BLOCK);
- add(Material.REDSTONE_LAMP);
- add(Material.TARGET);
- add(Material.DAYLIGHT_DETECTOR);
- add(Material.PISTON);
- add(Material.STICKY_PISTON);
- add(Material.SLIME_BLOCK);
- add(Material.OBSERVER);
- add(Material.HOPPER);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final List<Material> gen12 = new ArrayList<>() {{
- add(Material.DIRT);
- add(Material.DIRT_PATH);
- add(Material.GRASS_BLOCK);
- add(Material.OAK_SLAB);
- add(Material.BRICK_WALL);
- add(Material.BRICK_STAIRS);
- }};
-
- private final List<Material> gen14 = new ArrayList<>() {{
- add(Material.LECTERN);
- add(Material.OBSIDIAN);
- add(Material.SPONGE);
- add(Material.BEEHIVE);
- add(Material.DRIED_KELP_BLOCK);
- }};
-
- private final 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);
- }};
-
- private final 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);
- }};
-
- private final List<List<Material>> matList = new ArrayList<>();
-
- private final List<List<Material>> safeMatList = new ArrayList<>();
-
-}