From d64dce4a26b69d202f9d2943da8da0d3bc9ddad2 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Tue, 9 Aug 2022 13:43:20 -0400 Subject: block solidify time, seeker lobby --- src/main/java/net/tylermurphy/hideAndSeek/game/Game.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java/net/tylermurphy/hideAndSeek/game/Game.java') diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index b3fd457..ac210a3 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -333,6 +333,7 @@ public class Game { if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return true; if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return true; if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return true; + if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0) return true; if (mapSaveEnabled) { File destination = new File(Main.getInstance().getWorldContainer() + File.separator + getGameWorld()); if (!destination.exists()) return true; -- cgit v1.2.3-freya From 7a082c860e79f6204e49b4e113dd64269c44dd36 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Tue, 16 Aug 2022 08:46:16 -0400 Subject: Fix Board Join Exceptions on 1.8, and fixed Failed to Select Seeker --- .../java/net/tylermurphy/hideAndSeek/game/Board.java | 12 ------------ .../java/net/tylermurphy/hideAndSeek/game/Game.java | 5 +---- .../tylermurphy/hideAndSeek/world/VoidGenerator.java | 20 ++++++++++++++++++-- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src/main/java/net/tylermurphy/hideAndSeek/game/Game.java') diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java index 6bf0bfb..55dfa3c 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java @@ -104,9 +104,6 @@ public class Board { } public void addHider(Player player) { - if(!Main.getInstance().supports(9)){ - player.spigot().setCollidesWithEntities(false); - } Hider.add(player.getUniqueId().toString()); Seeker.remove(player.getUniqueId().toString()); Spectator.remove(player.getUniqueId().toString()); @@ -114,9 +111,6 @@ public class Board { } public void addSeeker(Player player) { - if(!Main.getInstance().supports(9)){ - player.spigot().setCollidesWithEntities(false); - } Hider.remove(player.getUniqueId().toString()); Seeker.add(player.getUniqueId().toString()); Spectator.remove(player.getUniqueId().toString()); @@ -124,9 +118,6 @@ public class Board { } public void addSpectator(Player player) { - if(!Main.getInstance().supports(9)){ - player.spigot().setCollidesWithEntities(false); - } Hider.remove(player.getUniqueId().toString()); Seeker.remove(player.getUniqueId().toString()); Spectator.add(player.getUniqueId().toString()); @@ -134,9 +125,6 @@ public class Board { } public void remove(Player player) { - if(!Main.getInstance().supports(9)){ - player.spigot().setCollidesWithEntities(true); - } Hider.remove(player.getUniqueId().toString()); Seeker.remove(player.getUniqueId().toString()); Spectator.remove(player.getUniqueId().toString()); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index ac210a3..7c5eaf2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -107,10 +107,7 @@ public class Game { public void start() { try { Optional rand = board.getPlayers().stream().skip(new Random().nextInt(board.size())).findFirst(); - Player picked = rand.orElse(board.getPlayers().get(0)); - String seekerName = picked.getName(); - Player temp = Bukkit.getPlayer(seekerName); - Player seeker = board.getPlayer(temp.getUniqueId()); + Player seeker = rand.orElse(board.getPlayers().get(0)); start(seeker); } catch (Exception e){ Main.getInstance().getLogger().warning("Failed to select random seeker."); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java index a81aa51..eadd0a9 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java @@ -29,7 +29,7 @@ import java.util.List; import java.util.Random; @SuppressWarnings({"unused"}) -public class VoidGenerator extends ChunkGenerator{ +public class VoidGenerator extends ChunkGenerator { // 1.14 And On public @NotNull List getDefaultPopulators(@NotNull World world) { @@ -69,6 +69,22 @@ public class VoidGenerator extends ChunkGenerator{ } // 1.13 And Prev - public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) { return createChunkData(world); } + public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) { + return createChunkData(world); + } + + // 1.8 + public byte[] generate(World world, Random random, int x, int z) { + return null; + } + + public short[][] generateExtBlockSections(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes) { + return null; + } + + public byte[][] generateBlockSections(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biomes) { + return null; + } + } -- cgit v1.2.3-freya From 0bbf648c458edfa189f5edbd5615544c4040b684 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Tue, 16 Aug 2022 20:08:04 -0400 Subject: delayed respawn --- .../net/tylermurphy/hideAndSeek/configuration/Config.java | 10 ++++++++-- src/main/java/net/tylermurphy/hideAndSeek/game/Game.java | 7 ++++++- .../hideAndSeek/game/listener/DamageHandler.java | 14 ++++++++++++-- src/main/resources/config.yml | 8 ++++++++ src/main/resources/lang/localization_de-DE.yml | 1 + src/main/resources/lang/localization_en-US.yml | 1 + 6 files changed, 36 insertions(+), 5 deletions(-) (limited to 'src/main/java/net/tylermurphy/hideAndSeek/game/Game.java') diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java index 853b6a2..a71369f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java @@ -93,7 +93,8 @@ public class Config { mapSaveEnabled, allowNaturalCauses, saveInventory, - blockhuntEnabled; + blockhuntEnabled, + delayedRespawn; public static int minPlayers, @@ -119,7 +120,8 @@ public class Config { lobbyItemStartPosition, flightToggleItemPosition, teleportItemPosition, - solidifyTime; + solidifyTime, + delayedRespawnDelay; public static float seekerPingLeadingVolume, @@ -365,6 +367,10 @@ public class Config { Main.getInstance().getLogger().warning("databaseType: "+databaseType+" is not a valid configuration option!"); databaseType = "SQLITE"; } + + delayedRespawn = config.getBoolean("delayedRespawn.enabled"); + delayedRespawnDelay = Math.max(0,config.getInt("delayedRespawn.delay")); + } public static void addToConfig(String path, Object value) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index 7c5eaf2..71c3e84 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -254,7 +254,12 @@ public class Game { if (startingTimer == 0) { message = message("START").toString(); status = Status.PLAYING; - board.getPlayers().forEach(player -> PlayerLoader.resetPlayer(player, board)); + board.getPlayers().forEach(player -> { + PlayerLoader.resetPlayer(player, board); + if(board.isSeeker(player)){ + player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); + } + }); } else if (startingTimer == 1){ message = message("START_COUNTDOWN_LAST").addAmount(startingTimer).toString(); } else { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DamageHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DamageHandler.java index cb4cba5..d03d5d6 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DamageHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DamageHandler.java @@ -80,7 +80,7 @@ public class DamageHandler implements Listener { return; } // Players cannot take damage while game is not in session - if (board.contains(player) && (game.getStatus() == Status.STANDBY || game.getStatus() == Status.STARTING)){ + if (board.contains(player) && game.getStatus() != Status.PLAYING){ event.setCancelled(true); return; } @@ -97,7 +97,17 @@ public class DamageHandler implements Listener { // Reveal player if they are disguised Main.getInstance().getDisguiser().reveal(player); // Teleport player to seeker spawn - player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); + if(delayedRespawn){ + player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), seekerLobbyPosition.getX(), seekerLobbyPosition.getY(), seekerLobbyPosition.getZ())); + player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay)); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> { + if(game.getStatus() == Status.PLAYING){ + player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); + } + }, delayedRespawnDelay * 20L); + } else { + player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); + } // Add leaderboard stats board.addDeath(player.getUniqueId()); if (attacker != null) board.addKill(attacker.getUniqueId()); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b648c8b..1d61cdc 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -100,6 +100,14 @@ mapSaveEnabled: true # default: false saveInventory: false +# By default, if you die in game, you will have to wait [delay] seconds until you respawn. This make is so that if you are killed as a seeker, you cannot +# instally go to where the Hider that killed you was. Or if you were a Hider and died, you cant instally go to where you know other Hiders are. It gives some +# breathing room. This can be disabled. +# default: true +delayedRespawn: + enabled: true + delay: 5 + # How you want to store game data. If you are running a single server, sqlite is fine, as no setup is necessary. # But if you want the data to go across multiple servers, you can switch it to mysql. # WARNING: Data is not saved across databases. You have to migrate the data yourself! diff --git a/src/main/resources/lang/localization_de-DE.yml b/src/main/resources/lang/localization_de-DE.yml index 4e6e74e..75523b2 100644 --- a/src/main/resources/lang/localization_de-DE.yml +++ b/src/main/resources/lang/localization_de-DE.yml @@ -74,6 +74,7 @@ Localization: BLOCKED_COMMAND: "Command blocked by Kenshin's Hide And Seek" FLYING_ENABLED: "Fliegen aktiviert" FLYING_DISABLED: "Fliegen deaktiviert" + RESPAWN_NOTICE: "Du wirst in {AMOUNT} Sekunden respawnen." # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE version: 3 diff --git a/src/main/resources/lang/localization_en-US.yml b/src/main/resources/lang/localization_en-US.yml index ef3fe88..02bc942 100644 --- a/src/main/resources/lang/localization_en-US.yml +++ b/src/main/resources/lang/localization_en-US.yml @@ -75,6 +75,7 @@ Localization: BLOCKED_COMMAND: "Command blocked by Hide And Seek plugin." FLYING_ENABLED: "&l&bFlying Enabled" FLYING_DISABLED: "&l&bFlying Disabled" + RESPAWN_NOTICE: "You will respawn in {AMOUNT} seconds." # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE version: 3 -- cgit v1.2.3-freya