delayed respawn

This commit is contained in:
Tyler Murphy 2022-08-16 20:08:04 -04:00
parent 7a082c860e
commit 0bbf648c45
6 changed files with 36 additions and 5 deletions

View file

@ -93,7 +93,8 @@ public class Config {
mapSaveEnabled, mapSaveEnabled,
allowNaturalCauses, allowNaturalCauses,
saveInventory, saveInventory,
blockhuntEnabled; blockhuntEnabled,
delayedRespawn;
public static int public static int
minPlayers, minPlayers,
@ -119,7 +120,8 @@ public class Config {
lobbyItemStartPosition, lobbyItemStartPosition,
flightToggleItemPosition, flightToggleItemPosition,
teleportItemPosition, teleportItemPosition,
solidifyTime; solidifyTime,
delayedRespawnDelay;
public static float public static float
seekerPingLeadingVolume, seekerPingLeadingVolume,
@ -365,6 +367,10 @@ public class Config {
Main.getInstance().getLogger().warning("databaseType: "+databaseType+" is not a valid configuration option!"); Main.getInstance().getLogger().warning("databaseType: "+databaseType+" is not a valid configuration option!");
databaseType = "SQLITE"; databaseType = "SQLITE";
} }
delayedRespawn = config.getBoolean("delayedRespawn.enabled");
delayedRespawnDelay = Math.max(0,config.getInt("delayedRespawn.delay"));
} }
public static void addToConfig(String path, Object value) { public static void addToConfig(String path, Object value) {

View file

@ -254,7 +254,12 @@ public class Game {
if (startingTimer == 0) { if (startingTimer == 0) {
message = message("START").toString(); message = message("START").toString();
status = Status.PLAYING; 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){ } else if (startingTimer == 1){
message = message("START_COUNTDOWN_LAST").addAmount(startingTimer).toString(); message = message("START_COUNTDOWN_LAST").addAmount(startingTimer).toString();
} else { } else {

View file

@ -80,7 +80,7 @@ public class DamageHandler implements Listener {
return; return;
} }
// Players cannot take damage while game is not in session // 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); event.setCancelled(true);
return; return;
} }
@ -97,7 +97,17 @@ public class DamageHandler implements Listener {
// Reveal player if they are disguised // Reveal player if they are disguised
Main.getInstance().getDisguiser().reveal(player); Main.getInstance().getDisguiser().reveal(player);
// Teleport player to seeker spawn // Teleport player to seeker spawn
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())); 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 // Add leaderboard stats
board.addDeath(player.getUniqueId()); board.addDeath(player.getUniqueId());
if (attacker != null) board.addKill(attacker.getUniqueId()); if (attacker != null) board.addKill(attacker.getUniqueId());

View file

@ -100,6 +100,14 @@ mapSaveEnabled: true
# default: false # default: false
saveInventory: 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. # 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. # 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! # WARNING: Data is not saved across databases. You have to migrate the data yourself!

View file

@ -74,6 +74,7 @@ Localization:
BLOCKED_COMMAND: "Command blocked by Kenshin's Hide And Seek" BLOCKED_COMMAND: "Command blocked by Kenshin's Hide And Seek"
FLYING_ENABLED: "Fliegen aktiviert" FLYING_ENABLED: "Fliegen aktiviert"
FLYING_DISABLED: "Fliegen deaktiviert" FLYING_DISABLED: "Fliegen deaktiviert"
RESPAWN_NOTICE: "Du wirst in {AMOUNT} Sekunden respawnen."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 3 version: 3

View file

@ -75,6 +75,7 @@ Localization:
BLOCKED_COMMAND: "Command blocked by Hide And Seek plugin." BLOCKED_COMMAND: "Command blocked by Hide And Seek plugin."
FLYING_ENABLED: "&l&bFlying Enabled" FLYING_ENABLED: "&l&bFlying Enabled"
FLYING_DISABLED: "&l&bFlying Disabled" FLYING_DISABLED: "&l&bFlying Disabled"
RESPAWN_NOTICE: "You will respawn in {AMOUNT} seconds."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 3 version: 3