feat: Add option to return to spawn when dies (#540)

* feat: user return to spawn when dies

* feat: add return to spawn in config docs

* feat: improve respawn feature variable name
This commit is contained in:
Davi Duarte authored and GitHub committed 2023-12-30 10:59:06 +00:00
1 parent b07a558211
commit 5496b9d1ec
3 files changed
+12 -1

No files matched your search

@@ -165,6 +165,9 @@ public class Settings {
@YamlKey("general.description_regex") @YamlKey("general.description_regex")
private String descriptionRegex = "\\A\\p{ASCII}*\\z"; private String descriptionRegex = "\\A\\p{ASCII}*\\z";
@YamlComment("Whether the user should back to spawn when they die")
@YamlKey("general.always_respawn_at_spawn")
private boolean alwaysRespawnAtSpawn = false;
// Back command settings // Back command settings
@YamlComment("Whether /back should work to teleport the user to where they died") @YamlComment("Whether /back should work to teleport the user to where they died")
@@ -439,6 +442,10 @@ public class Settings {
return descriptionRegex; return descriptionRegex;
} }
public boolean doAlwaysRespawnAtSpawn() {
return alwaysRespawnAtSpawn;
}
public boolean doBackCommandReturnByDeath() { public boolean doBackCommandReturnByDeath() {
return backCommandReturnByDeath; return backCommandReturnByDeath;
} }
@@ -298,7 +298,9 @@ public class EventListener {
* @param position the new spawn point * @param position the new spawn point
*/ */
protected final void handlePlayerUpdateSpawnPoint(@NotNull OnlineUser onlineUser, @NotNull Position position) { protected final void handlePlayerUpdateSpawnPoint(@NotNull OnlineUser onlineUser, @NotNull Position position) {
if (plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalRespawning()) { if (!plugin.getSettings().doAlwaysRespawnAtSpawn()
&& plugin.getSettings().doCrossServer()
&& plugin.getSettings().isGlobalRespawning()) {
plugin.getDatabase().setRespawnPosition(onlineUser, position); plugin.getDatabase().setRespawnPosition(onlineUser, position);
} }
} }
+2
View File
@@ -84,6 +84,8 @@ general:
back_command_return_by_death: true back_command_return_by_death: true
# Whether /back should work with other plugins that use the PlayerTeleportEvent (can cause conflicts) # Whether /back should work with other plugins that use the PlayerTeleportEvent (can cause conflicts)
back_command_save_teleport_event: false back_command_save_teleport_event: false
# Whether the user should back to spawn when they die (ensure that cross_server.enabled and cross_server.global_respawning are enabled)
always_respawn_at_spawn: true
# How many items should be displayed per-page in chat menu lists # How many items should be displayed per-page in chat menu lists
list_items_per_page: 12 list_items_per_page: 12
# Whether teleportation should be carried out asynchronously (ensuring chunks load before teleporting) # Whether teleportation should be carried out asynchronously (ensuring chunks load before teleporting)