Skip to content

Commit

Permalink
Extend timer when player is killed.
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Oct 12, 2024
1 parent 4e6ce9d commit f2621d5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/dev/tylerm/khs/configuration/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class Config {
public static int
minPlayers,
gameLength,
extendPerKill,
tauntDelay,
glowLength,
countdown,
Expand Down Expand Up @@ -187,6 +188,7 @@ public static void loadConfig() {
nameTagsVisible = config.getBoolean("nametagsVisible");
permissionsRequired = config.getBoolean("permissionsRequired");
gameLength = config.getInt("gameLength");
extendPerKill = config.getInt("extendPerKill");
pvpEnabled = config.getBoolean("pvp");
allowNaturalCauses = config.getBoolean("allowNaturalCauses");
autoJoin = config.getBoolean("autoJoin");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/tylerm/khs/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public int getTimeLeft(){
return gameTimer;
}

public void extendTime(){
gameTimer += extendPerKill;
}

public int getLobbyTime(){
return lobbyTimer;
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/dev/tylerm/khs/game/listener/DamageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ else if (((EntityDamageByEntityEvent) event).getDamager() instanceof Projectile)
if (board.isSeeker(player)) {
game.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(player).toString());
} else if (board.isHider(player)) {
// icybear: update the timer
game.extendTime();
if (attacker == null) {
game.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(player).toString());
game.broadcastMessage(message("GAME_PLAYER_FOUND")
.addPlayer(player).addAmount(extendPerKill).toString());
} else {
game.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(player).addPlayer(attacker).toString());
game.broadcastMessage(message("GAME_PLAYER_FOUND_BY")
.addPlayer(player).addPlayer(attacker).addAmount(extendPerKill).toString());
}
if (respawnAsSpectator) {
board.addSpectator(player);
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
spawnPatch: false

# How long in seconds will the game last, set it < 1 to disable
# default: 1200 aka 20min
gameLength: 1200
# default: 300 aka 5min
gameLength: 300

# How long will be added into the timer when a seeker is found
extendPerKill: 30

# How long in seconds will the initial hiding period last, minimum is 10 seconds
# default: 30
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/lang/localization_en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Localization:
COMMAND_ERROR: "An internal error has occurred."
COMMAND_INVALID_ARG: "Invalid argument: {AMOUNT}"
GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed."
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found"
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f"
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found! (+{AMOUNT}s)"
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f (+{AMOUNT}s)"
GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found."
GAME_GAMEOVER_LAST_HIDER: "The last hider, &e{PLAYER}&f, has won!"
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
Expand Down

0 comments on commit f2621d5

Please sign in to comment.