mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Add /back returning-by-death
This commit is contained in:
1 parent
6cd2a23770
commit
8dff4a123a
6 files changed
+24
-11
No files matched your search
@@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,4 +28,9 @@ public class BukkitEventListener extends EventListener implements Listener {
|
||||
super.handlePlayerLeave(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
super.handlePlayerDeath(BukkitPlayer.adapt(event.getEntity()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class BukkitPlayer extends OnlineUser {
|
||||
@Override
|
||||
public CompletableFuture<Position> getPosition() {
|
||||
final Location location = getLocation();
|
||||
return BukkitHuskHomes.getInstance().getServer(this).thenApplyAsync(server -> new Position(
|
||||
return BukkitHuskHomes.getInstance().getServer(this).thenApply(server -> new Position(
|
||||
location.x, location.y, location.z, location.yaw, location.pitch, location.world, server));
|
||||
|
||||
}
|
||||
@@ -131,9 +131,9 @@ public class BukkitPlayer extends OnlineUser {
|
||||
PaperLib.teleportAsync(player, bukkitLocation.get(), PlayerTeleportEvent.TeleportCause.COMMAND)
|
||||
.thenAccept(result -> {
|
||||
if (result) {
|
||||
resultCompletableFuture.completeAsync(() -> TeleportResult.COMPLETED_LOCALLY);
|
||||
resultCompletableFuture.complete(TeleportResult.COMPLETED_LOCALLY);
|
||||
} else {
|
||||
resultCompletableFuture.completeAsync(() -> TeleportResult.FAILED_INVALID_WORLD);
|
||||
resultCompletableFuture.complete(TeleportResult.FAILED_INVALID_WORLD);
|
||||
}
|
||||
}));
|
||||
return resultCompletableFuture.join();
|
||||
|
||||
@@ -89,6 +89,9 @@ public class Settings {
|
||||
@KeyPath("general.permission_restrict_warps")
|
||||
public boolean permissionRestrictWarps = false;
|
||||
|
||||
@KeyPath("general.back_command_return_by_death")
|
||||
public boolean backCommandReturnByDeath = true;
|
||||
|
||||
@KeyPath("general.teleport_warmup_time")
|
||||
public int teleportWarmupTime = 5;
|
||||
|
||||
@@ -97,10 +100,6 @@ public class Settings {
|
||||
|
||||
@KeyPath("general.teleport_request_expiry_time")
|
||||
public int teleportRequestExpiryTime = 60;
|
||||
|
||||
@KeyPath("general.list_items_per_page")
|
||||
public int listItemsPerPage = 12;
|
||||
|
||||
@KeyPath("general.strict_tpa_here_requests")
|
||||
public boolean strictTpaHereRequests = true;
|
||||
|
||||
@@ -110,6 +109,9 @@ public class Settings {
|
||||
@KeyPath("general.allow_unicode_descriptions")
|
||||
public boolean allowUnicodeDescriptions = true;
|
||||
|
||||
@KeyPath("general.list_items_per_page")
|
||||
public int listItemsPerPage = 12;
|
||||
|
||||
@KeyPath("general.use_paper_lib")
|
||||
public boolean usePaperLib = true;
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ package net.william278.huskhomes.listener;
|
||||
import de.themoep.minedown.MineDown;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -123,7 +125,11 @@ public class EventListener {
|
||||
* @param onlineUser the {@link OnlineUser} who died
|
||||
*/
|
||||
protected final void handlePlayerDeath(@NotNull OnlineUser onlineUser) {
|
||||
//todo
|
||||
// Set the player's last position to where they died
|
||||
if (plugin.getSettings().backCommandReturnByDeath
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
onlineUser.getPosition().thenAccept(position -> plugin.getDatabase().setLastPosition(onlineUser, position).join());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +145,7 @@ public class EventListener {
|
||||
* Handle when the plugin is disabling (server is shutting down)
|
||||
*/
|
||||
public final void handlePluginDisable() {
|
||||
//todo
|
||||
plugin.getLoggingAdapter().log(Level.INFO, "Successfully disabled HuskHomes v" + plugin.getPluginVersion());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public enum Permission {
|
||||
/**
|
||||
* Lets the user use {@code /back} to return to where they died
|
||||
*/
|
||||
COMMAND_BACK_ON_DEATH("huskhomes.command.back.death", DefaultAccess.EVERYONE),
|
||||
COMMAND_BACK_RETURN_BY_DEATH("huskhomes.command.back.death", DefaultAccess.EVERYONE),
|
||||
/**
|
||||
* Lets the user view plugin information
|
||||
*/
|
||||
|
||||
@@ -84,7 +84,6 @@ set_home_used_free_slots: '[You''ve used all of your free set home slots (%1%);
|
||||
set_home_success: '[Successfully set a new home called](#00fb9a) [%1%](#00fb9a bold)'
|
||||
set_warp_success: '[Successfully set a new warp called](#00fb9a) [%1%](#00fb9a bold)'
|
||||
set_spawn_success: '[Updated spawn position for this server to your current location.](#00fb9a)'
|
||||
return_by_death: '[Return to where you died?](gray) [/back](#00fb9a show_text=�fb9a&Click to return to where you died run_command=/back)'
|
||||
|
||||
home_default_description: '%1%''s home.'
|
||||
warp_default_description: 'A publicly accessible warp.'
|
||||
|
||||
Reference in new issue
Block a user