Add option for setting the /back position on the player teleport event Close #97

This commit is contained in:
William committed 2022-08-23 00:51:13 +01:00
1 parent ceafcf3f38
commit 6cba6f866b
3 files changed
+37 -3

No files matched your search

@@ -89,9 +89,6 @@ 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;
@@ -109,6 +106,12 @@ public class Settings {
@KeyPath("general.allow_unicode_descriptions")
public boolean allowUnicodeDescriptions = true;
@KeyPath("general.back_command_return_by_death")
public boolean backCommandReturnByDeath = true;
@KeyPath("general.back_command_on_teleport_event")
public boolean backCommandOnTeleportEvent = true;
@KeyPath("general.list_items_per_page")
public int listItemsPerPage = 12;
@@ -3,6 +3,7 @@ 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.position.Location;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.teleport.TeleportType;
import net.william278.huskhomes.util.Permission;
@@ -175,6 +176,19 @@ public class EventListener {
}
}
/**
* Handle when a player teleports
*
* @param onlineUser the {@link OnlineUser} who teleported
* @param sourcePosition the source {@link Position} they came from
*/
protected final void handlePlayerTeleport(@NotNull OnlineUser onlineUser, @NotNull Position sourcePosition) {
if (!plugin.getSettings().backCommandOnTeleportEvent) return;
plugin.getDatabase().getUserData(onlineUser.uuid).thenAccept(userData ->
userData.ifPresent(data -> plugin.getDatabase().setLastPosition(data.user(), sourcePosition).join()));
}
/**
* Handle when an {@link OnlineUser}'s spawn point is updated
*