From 23429bbd3fe7e35ab9877e536f9ff9a2e71a9afc Mon Sep 17 00:00:00 2001 From: Myles <43725835+MylesAndMore@users.noreply.github.com> Date: Mon, 12 Dec 2022 19:21:09 +0000 Subject: refactoring to prep for release!! - refactor a bit of code - add a bit more documentations - remove music code--we can't redistribute the music in a pack :( - remove old readme--writing the new docs tonight or tmrw we got this! --- README.md | 51 +------------ .../com/MylesAndMore/tumble/EventListener.java | 4 +- src/main/java/com/MylesAndMore/tumble/Game.java | 35 +-------- .../com/MylesAndMore/tumble/TumbleManager.java | 3 + .../com/MylesAndMore/tumble/api/Generator.java | 3 + .../java/com/MylesAndMore/tumble/api/Layers.java | 85 ++++++---------------- 6 files changed, 36 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index 185e2b9..6c19f2d 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,5 @@ -# tumble-alphatest (@MylesAndMore @CraivMan) +# tumble -please let me know if there is anything more you think we should add @CraivMan! -once this list is complete and all bugs are fixed, we *should* be ready for release... +## Overview -## generation - -- [x] layers should be able to generate w/ "clumps" of blocks; instead of only one material as a whole - - [x] the clump size should be customizable (for later); be able to set a min/max val and it will choose randomly per each clump (not in config file yet, just internally) - - *Note: this is done through the amount of times each Material shows up in the List--there's no config for it.* -- [x] make shovels generation actually work properly - - make different types of platforms (square, circle, multi-tiered, etc.); still should be pseudo-random -- [x] make snowballs generation actually work properly (shocker) - - make three layers generate (same layer types as shovels, just multiple of them) - -## game realism - -- [x] make the shovel in shovels mode not lose any durabilty -- [x] make it so that you can't move until the game begins -- [x] make the game blocks breakable very fast, but **not instantly--very important for balancing!!** - - Basically, just set a "cooldown" on both snowballs and shovels--not a long one--but one at that -- [x] add infinite snowballs in the gamemanager for tumble mode -- [x] make it so that you can't remove any of the game items from your inventory -- [x] make snowballs actually break blocks (duh) -- [x] make the randomized mode logic -- [x] make it so rounds end in a draw after 5m -- [x] make it so that players get snowballs instead of shovels in shovels rounds after 2m 30s -- [x] remove snowball knockback - -## game logic - -- [x] make a Game class and object that we can initialize a new instance of with a gameType -- [x] prevent players from joining/autojoining during a game -- [x] keep track of when someone wins; start a new round when this happens -- [x] keep track of how many wins each player has; end the game when a player reaches 3 - - [x] add a section in the config for a place to tp the winning player - - [x] add logic to do this - -## configuration/customization - -- [x] add two configs where you can: - - [x] set if you want the game to auto-start - - [x] set the amt of players you want the game to auto-start at - - [x] program the auto-start (just add an if statement on the PlayerJoin listener to run the StartGame method on a certain amt of players in the config) - -## etc - -- [x] refactor EventListener null checker code - - if (TumbleManager.getGameWorld() == null && TumbleManager.getLobbyWorld() == null) { return; } -- [x] add game music? but probably only for us; I feel like the og music must be copyrighted +Cringe diff --git a/src/main/java/com/MylesAndMore/tumble/EventListener.java b/src/main/java/com/MylesAndMore/tumble/EventListener.java index d6b3ffa..5e46e87 100644 --- a/src/main/java/com/MylesAndMore/tumble/EventListener.java +++ b/src/main/java/com/MylesAndMore/tumble/EventListener.java @@ -4,7 +4,6 @@ import java.util.Objects; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; @@ -17,6 +16,9 @@ import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +/** + * Tumble event listener for all plugin and game-related events. + */ public class EventListener implements Listener { @EventHandler public void PlayerJoinEvent(PlayerJoinEvent event) { diff --git a/src/main/java/com/MylesAndMore/tumble/Game.java b/src/main/java/com/MylesAndMore/tumble/Game.java index 58c42a5..91c2770 100644 --- a/src/main/java/com/MylesAndMore/tumble/Game.java +++ b/src/main/java/com/MylesAndMore/tumble/Game.java @@ -17,6 +17,9 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; import java.util.*; +/** + * This class holds all methods relating to the tumble Game in any way! + */ public class Game { // Singleton class logic // Define the gameInstance @@ -46,8 +49,6 @@ public class Game { private int gameID = -1; // Define a variable for the autostart PID private int autoStartID = -1; - // Define a variable for music ID - private int musicID = -1; // Define a variable to keep the list of tracks that have already played in the game List sounds = new ArrayList<>(); @@ -56,9 +57,6 @@ public class Game { // Define the game world and its spawnpoint as a new Location for use later private final World gameWorld; private final Location gameSpawn; - -// // Make a list of the lobby's players for later -// private List lobbyPlayers = TumbleManager.getPlayersInLobby(); // Make a list of the game's players for later private List gamePlayers; // Make a list of the round's players @@ -130,7 +128,6 @@ public class Game { displayTitles(gamePlayers, ChatColor.GREEN + "Go!", null, 1, 5, 1); setGamemode(gamePlayers, GameMode.SURVIVAL); gameState = "running"; - playMusic(gamePlayers, SoundCategory.NEUTRAL, 1, 1); }, 20); }, 20); }, 20); @@ -443,30 +440,6 @@ public class Game { } } - private void playMusic(@NotNull List players, @NotNull SoundCategory category, float volume, float pitch) { - if (sounds.size() == 0) { - sounds.addAll(List.of( - "minecraft:tumble.0", - "minecraft:tumble.1", - "minecraft:tumble.2", - "minecraft:tumble.3", - "minecraft:tumble.4", - "minecraft:tumble.5", - "minecraft:tumble.6", - "minecraft:tumble.7", - "minecraft:tumble.8", - "minecraft:tumble.9")); - } - String currentSong = sounds.get(Random.nextInt(sounds.size())); - for (Player aPlayer : players) { - aPlayer.playSound(aPlayer.getLocation(), currentSong, category, volume, pitch); - } - sounds.remove(currentSong); - musicID = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { - playMusic(gamePlayers, SoundCategory.NEUTRAL, 1, 1); - }, 1460); - } - /** * Teleports a list of players to the specified scatter locations in the gameWorld * @param players a List of Players to teleport @@ -603,8 +576,6 @@ public class Game { displayActionbar(gamePlayers, ChatColor.BLUE + "Returning to lobby in ten seconds..."); // Wait 10s (200t), then Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { - // Stop music from replaying - Bukkit.getServer().getScheduler().cancelTask(musicID); // First, check to see if there is a separate location to tp the winner to if ((TumbleManager.getPlugin().getConfig().getDouble("winnerTeleport.x") != 0) && (TumbleManager.getPlugin().getConfig().getDouble("winnerTeleport.y") != 0) && (TumbleManager.getPlugin().getConfig().getDouble("winnerTeleport.z") != 0)) { // Tp the winner to that location diff --git a/src/main/java/com/MylesAndMore/tumble/TumbleManager.java b/src/main/java/com/MylesAndMore/tumble/TumbleManager.java index 7605717..43cc241 100644 --- a/src/main/java/com/MylesAndMore/tumble/TumbleManager.java +++ b/src/main/java/com/MylesAndMore/tumble/TumbleManager.java @@ -8,6 +8,9 @@ import org.bukkit.plugin.Plugin; import java.util.List; +/** + * Class to store long return methods to make writing this plugin slightly less painful. + */ public class TumbleManager { // Tumble plugin public static Plugin getPlugin() { diff --git a/src/main/java/com/MylesAndMore/tumble/api/Generator.java b/src/main/java/com/MylesAndMore/tumble/api/Generator.java index 0a35767..db8bacc 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -11,6 +11,9 @@ import java.util.Collections; import java.util.List; import java.util.Random; +/** + * This class holds the methods that generate blocks in-game such as cylinders, cubiods, and clump logic. + */ public class Generator { /** * Generates a layer (bascally just a cylinder) as best as it can w/ blocks diff --git a/src/main/java/com/MylesAndMore/tumble/api/Layers.java b/src/main/java/com/MylesAndMore/tumble/api/Layers.java index dad5ea8..8818631 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Layers.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Layers.java @@ -12,52 +12,24 @@ import java.util.Random; 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 + // 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(gen11); } @@ -70,6 +42,9 @@ public class Layers { return matList.get(random.nextInt(matList.size())); } + // Define the list that will store the material lists + private final List> matList = new ArrayList<>(); + // Begin lists @@ -287,14 +262,6 @@ public class Layers { 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); }}; @@ -307,14 +274,6 @@ public class Layers { add(Material.BRICK_STAIRS); }}; - private final List gen14 = new ArrayList<>() {{ - add(Material.LECTERN); - add(Material.OBSIDIAN); - add(Material.SPONGE); - add(Material.BEEHIVE); - add(Material.DRIED_KELP_BLOCK); - }}; - private final List gen15 = new ArrayList<>() {{ add(Material.SANDSTONE); add(Material.SANDSTONE_SLAB); @@ -338,6 +297,4 @@ public class Layers { add(Material.JUNGLE_TRAPDOOR); }}; - private final List> matList = new ArrayList<>(); - } -- cgit v1.2.3