diff options
| author | Myles <mylesandmore9@gmail.com> | 2022-12-10 17:53:00 -0600 | 
|---|---|---|
| committer | Myles <mylesandmore9@gmail.com> | 2022-12-10 17:53:00 -0600 | 
| commit | 6aab3dfcbb7636e1b11cd54e10bddff45f5ef8e9 (patch) | |
| tree | 1117c831f21579f65a4ec62abb083248df2bcd4f | |
| parent | cf6bdc376b91e3c1ab5403e018470a7fee589986 (diff) | |
| download | Tumble-6aab3dfcbb7636e1b11cd54e10bddff45f5ef8e9.tar.gz Tumble-6aab3dfcbb7636e1b11cd54e10bddff45f5ef8e9.tar.bz2 Tumble-6aab3dfcbb7636e1b11cd54e10bddff45f5ef8e9.zip | |
musik
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/EventListener.java | 4 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/Game.java | 47 | 
3 files changed, 36 insertions, 18 deletions
| @@ -23,7 +23,6 @@ once this list is complete and all bugs are fixed, we *should* be ready for rele  - [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 -- [ ] set some limits on the spectator mode in-game; make it so they can't fly outside of the map  - [ ] make it so rounds end in a draw after 5m  - [ ] make it so that players get snowballs instead of shovels in shovels rounds after 2m 30s  - [x] remove snowball knockback @@ -48,4 +47,4 @@ once this list is complete and all bugs are fixed, we *should* be ready for rele  - [x] refactor EventListener null checker code    - if (TumbleManager.getGameWorld() == null && TumbleManager.getLobbyWorld() == null) { return; } -- [ ] add game music? but probably only for us; I feel like the og music must be copyrighted +- [x] add game music? but probably only for us; I feel like the og music must be copyrighted diff --git a/src/main/java/com/MylesAndMore/tumble/EventListener.java b/src/main/java/com/MylesAndMore/tumble/EventListener.java index 7e7bf94..8e07509 100644 --- a/src/main/java/com/MylesAndMore/tumble/EventListener.java +++ b/src/main/java/com/MylesAndMore/tumble/EventListener.java @@ -128,8 +128,8 @@ public class EventListener implements Listener {          if (event.getEntity().getWorld() == Bukkit.getWorld(TumbleManager.getGameWorld())) {              if (event.getEntity() instanceof Snowball) {                  if (event.getEntity().getShooter() instanceof Player player) { -                    // Check to see if the last snowball was thrown less than 210ms ago, if so, don't allow another -                    if ((System.currentTimeMillis() - lastTimeP) < 205) { event.setCancelled(true); } +                    // Check to see if the last snowball was thrown less than 200ms ago, if so, don't allow another +                    if ((System.currentTimeMillis() - lastTimeP) < 200) { event.setCancelled(true); }                      else {                          // Otherwise, continue with logic                          lastTimeP = System.currentTimeMillis(); diff --git a/src/main/java/com/MylesAndMore/tumble/Game.java b/src/main/java/com/MylesAndMore/tumble/Game.java index 789edff..b5932e3 100644 --- a/src/main/java/com/MylesAndMore/tumble/Game.java +++ b/src/main/java/com/MylesAndMore/tumble/Game.java @@ -130,19 +130,20 @@ public class Game {              // Wait 5s (100t) for the clients to load in              Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> {                  // Begin the countdown sequence -                playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 1); +                playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 1);                  displayTitles(gamePlayers, ChatColor.DARK_GREEN + "3", null, 3, 10, 7);                  Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { -                    playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 1); +                    playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 1);                      displayTitles(gamePlayers, ChatColor.YELLOW + "2", null, 3, 10, 7);                      Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { -                        playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 1); +                        playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 1);                          displayTitles(gamePlayers, ChatColor.DARK_RED + "1", null, 3, 10, 7);                          Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { -                            playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 2); +                            playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 2);                              displayTitles(gamePlayers, ChatColor.GREEN + "Go!", null, 1, 5, 1);                              setGamemode(gamePlayers, GameMode.SURVIVAL);                              gameState = "running"; +                            playMusic(gamePlayers, SoundCategory.NEUTRAL, 1, 1);                          }, 20);                      }, 20);                  }, 20); @@ -351,6 +352,26 @@ public class Game {          }      } +    private void playMusic(@NotNull List<Player> players, @NotNull SoundCategory category, float volume, float pitch) { +        List<String> sounds = new ArrayList<>(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")); +        for (Player aPlayer : players) { +            aPlayer.playSound(aPlayer.getLocation(), sounds.get(Random.nextInt(sounds.size())), category, volume, pitch); +        } +        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 @@ -361,17 +382,15 @@ public class Game {          double y = gameSpawn.getY();          double z = gameSpawn.getZ();          // Create the scatter locations based off the game's spawn -        List<Location> scatterLocations = new ArrayList<>(); -        scatterLocations.addAll(List.of( -                new Location(gameWorld, (x - 14.5), y, (z + 0.5) , -90, 0), +        List<Location> scatterLocations = new ArrayList<>(List.of( +                new Location(gameWorld, (x - 14.5), y, (z + 0.5), -90, 0),                  new Location(gameWorld, (x + 0.5), y, (z - 14.5), 0, 0),                  new Location(gameWorld, (x + 15.5), y, (z + 0.5), 90, 0), -                new Location(gameWorld, (x + 0.5), y, (z + 15.5), 180, 0 ), +                new Location(gameWorld, (x + 0.5), y, (z + 15.5), 180, 0),                  new Location(gameWorld, (x - 10.5), y, (z - 10.5), -45, 0),                  new Location(gameWorld, (x - 10.5), y, (z + 11.5), -135, 0),                  new Location(gameWorld, (x + 11.5), y, (z - 10.5), 45, 0), -                new Location(gameWorld, (x + 11.5), y, (z + 11.5), 135, 0)) -        ); +                new Location(gameWorld, (x + 11.5), y, (z + 11.5), 135, 0)));          // Shuffle the list (randomize)          Collections.shuffle(scatterLocations);          // While there are still unteleported players from the list, teleport them @@ -409,16 +428,16 @@ public class Game {                      // Re-scatter players                      gameState = "starting";                      scatterPlayers(gamePlayers); -                    playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 1); +                    playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 1);                      displayTitles(gamePlayers, ChatColor.DARK_GREEN + "3", null, 3, 10, 7);                      Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { -                        playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 1); +                        playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 1);                          displayTitles(gamePlayers, ChatColor.YELLOW + "2", null, 3, 10, 7);                          Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { -                            playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 1); +                            playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 1);                              displayTitles(gamePlayers, ChatColor.DARK_RED + "1", null, 3, 10, 7);                              Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TumbleManager.getPlugin(), () -> { -                                playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 1, 2); +                                playSound(gamePlayers, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 5, 2);                                  displayTitles(gamePlayers, ChatColor.GREEN + "Go!", null, 1, 5, 1);                                  setGamemode(gamePlayers, GameMode.SURVIVAL);                                  gameState = "running"; | 
