Skip to content

Commit

Permalink
Merge pull request #3 (v.1.0.1) from MylesAndMore/beta
Browse files Browse the repository at this point in the history
v.1.0.1
  • Loading branch information
MylesAndMore authored Dec 14, 2022
2 parents 3b4e4b2 + aa054e8 commit 516927c
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group 'tumble'
version '1.0.0'
version '1.0.1'

repositories {
// Use Maven Central for resolving dependencies.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/MylesAndMore/tumble/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDropItemEvent;
import org.bukkit.event.entity.*;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
Expand Down Expand Up @@ -281,4 +282,15 @@ public void EntityDamageEvent(EntityDamageEvent event) {
}
}
}

@EventHandler
public void InventoryDragEvent(InventoryDragEvent event) {
if (TumbleManager.getGameWorld() == null) {
return;
}
if (event.getWhoClicked().getWorld() == Bukkit.getWorld((TumbleManager.getGameWorld()))) {
event.setCancelled(true);
}
}

}
24 changes: 12 additions & 12 deletions src/main/java/com/MylesAndMore/tumble/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ private boolean generateLayers(String type) {
// 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.getMaterialList());
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), layers.getSafeMaterialList());
}
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.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.SNOW_BLOCK), layers.getSafeMaterialList());
}
else if (Random.nextInt(4) == 2) {
// Multi-tiered circle
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), layers.getMaterialList());
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.SNOW_BLOCK), layers.getSafeMaterialList());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRASS_BLOCK), layers.getMaterialList());
Expand All @@ -237,7 +237,7 @@ else if (Random.nextInt(4) == 2) {
}
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.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.SNOW_BLOCK), layers.getSafeMaterialList());
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());
Expand Down Expand Up @@ -271,23 +271,23 @@ else if (Objects.equals(type, "snowballs")) {
// 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.getMaterialList());
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getSafeMaterialList());
layer.setY(layer.getY() - 6);
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getMaterialList());
layer.setY(layer.getY() - 6);
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getMaterialList());
}
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.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), layers.getSafeMaterialList());
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());
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());
}
else if (Random.nextInt(4) == 2) {
// Multi-tiered circle
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getMaterialList());
Generator.generateClumps(Generator.generateLayer(layer, 17, 1, Material.STONE), layers.getSafeMaterialList());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), layers.getMaterialList());
Expand All @@ -296,7 +296,7 @@ else if (Random.nextInt(4) == 2) {
Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
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), layers.getSafeMaterialList());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), layers.getMaterialList());
Expand All @@ -305,7 +305,7 @@ else if (Random.nextInt(4) == 2) {
Generator.generateClumps(Generator.generateLayer(layer, 4, 1, Material.LIME_GLAZED_TERRACOTTA), layers.getMaterialList());
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), layers.getSafeMaterialList());
Generator.generateLayer(layer, 13, 1, Material.AIR);
layer.setY(layer.getY() - 1);
Generator.generateClumps(Generator.generateLayer(layer, 13, 1, Material.GRANITE), layers.getMaterialList());
Expand All @@ -315,7 +315,7 @@ else if (Random.nextInt(4) == 2) {
}
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.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), layers.getSafeMaterialList());
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());
Expand All @@ -324,7 +324,7 @@ else if (Random.nextInt(4) == 2) {
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());
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), layers.getSafeMaterialList());
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());
Expand All @@ -333,7 +333,7 @@ else if (Random.nextInt(4) == 2) {
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());
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), layers.getSafeMaterialList());
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());
Expand Down
119 changes: 96 additions & 23 deletions src/main/java/com/MylesAndMore/tumble/api/Layers.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,77 @@
public class Layers {

public Layers(){
// Make the other layers more common than the glass layer
for (int i = 0; i < 10; i++) {
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(gen15);
matList.add(gen16);
}
// Glass layer
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
Expand All @@ -41,10 +93,11 @@ public Layers(){
public List<Material> getMaterialList() {
return matList.get(random.nextInt(matList.size()));
}

// Define the list that will store the material lists
private final List<List<Material>> matList = new ArrayList<>();


/**
* @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

Expand All @@ -68,7 +121,7 @@ public List<Material> getMaterialList() {
add(Material.GRASS_BLOCK);
add(Material.GRASS_BLOCK);
add(Material.GRASS_BLOCK);
// add(Material.COBWEB);
add(Material.COBWEB);
}};

private final List<Material> gen1 = new ArrayList<>() {{
Expand Down Expand Up @@ -262,6 +315,14 @@ public List<Material> getMaterialList() {
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);
}};

Expand All @@ -274,6 +335,14 @@ public List<Material> getMaterialList() {
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);
Expand All @@ -297,4 +366,8 @@ public List<Material> getMaterialList() {
add(Material.JUNGLE_TRAPDOOR);
}};

private final List<List<Material>> matList = new ArrayList<>();

private final List<List<Material>> safeMatList = new ArrayList<>();

}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main: com.MylesAndMore.tumble.Main
name: tumble
version: 1.0.0
version: 1.0.1
description: 'A Minecraft: Java Edition plugin recreating the Tumble minigame from Minecraft Legacy Console Edition.'
api-version: 1.19
load: STARTUP
Expand Down

0 comments on commit 516927c

Please sign in to comment.