Skip to content

Commit

Permalink
- Add optional title message showing how long until a player will
Browse files Browse the repository at this point in the history
spawn, when using the spawning warmup timer.
    - Partially fills #7303.
  - New Config Option: spawning.spawning_warmups.uses_title_message
    - Default: false
    - When set to true, players get a large Title message showing how
long until their teleport will happen,
      as well as a message telling them not to move if
movement_cancels_spawn_warmup is true.
  • Loading branch information
LlmDl committed Mar 8, 2024
1 parent 188f49d commit 15e8dd6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,12 @@ public enum ConfigNodes {
"false",
"",
"# When set to true, if players are damaged in any way while in a spawn warmup, their spawning will be cancelled."),
SPAWNING_WARMUP_USES_TITLE_MESSAGE(
"spawning.spawning_warmups.uses_title_message",
"false",
"",
"# When set to true, players get a large Title message showing how long until their teleport will happen,",
"# as well as a message telling them not to move if movement_cancels_spawn_warmup is true."),

SPAWNING_TOWN_SPAWN_ROOT("spawning.town_spawn","",""),
SPAWNING_ALLOW_TOWN_SPAWN(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2972,6 +2972,10 @@ public static boolean isDamageCancellingSpawnWarmup() {
return getBoolean(ConfigNodes.SPAWNING_DAMAGE_CANCELS_SPAWN_WARMUP);
}

public static boolean isTeleportWarmupUsingTitleMessage() {
return getBoolean(ConfigNodes.SPAWNING_WARMUP_USES_TITLE_MESSAGE);
}

public static int getSpawnCooldownTime() {

return getInt(ConfigNodes.SPAWNING_TOWN_SPAWN_COOLDOWN_TIMER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public void run() {
Map.Entry<Resident, TeleportRequest> next = iterator.next();
final Resident resident = next.getKey();
final TeleportRequest request = next.getValue();
long teleportTime = request.requestTime() + (TownySettings.getTeleportWarmupTime() * 1000L);

if (currentTime > request.requestTime() + (TownySettings.getTeleportWarmupTime() * 1000L)) {
if (currentTime > teleportTime) {
iterator.remove();

Player player = resident.getPlayer();
Expand All @@ -62,6 +63,18 @@ public void run() {

if (request.cooldown() > 0)
CooldownTimerTask.addCooldownTimer(resident.getName(), "teleport", request.cooldown());
continue;
}

// Send a title message.
if (TownySettings.isTeleportWarmupUsingTitleMessage()) {
String title = TownySettings.isMovementCancellingSpawnWarmup() ? Translatable.of("teleport_warmup_title_dont_move").forLocale(resident) : "";
long millis = teleportTime - currentTime;
if (millis < 1000)
continue;
int seconds = (int) Math.max(1, millis/1000);
String subtitle = Translatable.of("teleport_warmup_subtitle_seconds_remaining", seconds).forLocale(resident);
resident.getPlayer().sendTitle(title, subtitle, 0, 25, (seconds == 1 ? 15 : 0));
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9587,4 +9587,10 @@ v0.92.0.11:
- When using Paper, Towny can now treat Firework_Rockets as an item_use item, preventing players using boosting while gliding on an Elytra.
- Closes #7286.
- Fix the TownBlockType migrator running opposite of when it ought to, resulting in farm plot allowed blocks being reset when Towny is updated.
- Closes #7300.
- Closes #7300.
- Add optional title message showing how long until a player will spawn, when using the spawning warmup timer.
- Partially fills #7303.
- New Config Option: spawning.spawning_warmups.uses_title_message
- Default: false
- When set to true, players get a large Title message showing how long until their teleport will happen,
as well as a message telling them not to move if movement_cancels_spawn_warmup is true.
4 changes: 4 additions & 0 deletions Towny/src/main/resources/lang/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2466,3 +2466,7 @@ outlawed_in: "Outlawed in"
msg_warning_town_deposit_hint: "To put money in your town bank use /town deposit [amount]."

msg_warning_nation_deposit_hint: "To put money in your nation bank use /nation deposit [amount]."

teleport_warmup_title_dont_move: "&6Don't move!"

teleport_warmup_subtitle_seconds_remaining: "&c%s &7seconds remaining until teleport."

0 comments on commit 15e8dd6

Please sign in to comment.