feat: add strict standard /tpa requests too (#898)

* improv. add strict tpa request

* improv. add strict tpa request

* improv. move tpa strict above tpahere strict
This commit is contained in:
nivcoo authored and GitHub committed 2025-12-10 23:24:25 +00:00
1 parent 539a151f50
commit e747e42228
3 files changed
+22 -4

No files matched your search

@@ -157,6 +157,9 @@ public final class Settings {
@Comment("How long before received teleport requests expire (in seconds)")
private int teleportRequestExpiryTime = 60;
@Comment("Whether /tpa should use the location of the sender when accepted. ")
private boolean strictTpaRequests = false;
@Comment("Whether /tpahere should use the location of the sender when sent. "
+ "Docs: https://william278.net/docs/huskhomes/strict-tpahere/")
private boolean strictTpaHereRequests = true;
@@ -308,6 +308,12 @@ public class RequestsManager {
"teleport_request_" + (accepted ? "accepted" : "declined") + "_confirmation",
request.getRequesterName()
).ifPresent(recipient::sendMessage);
// snapshot the recipient's position if the request is a strict tpa request
if (accepted && request.getType() == TeleportRequest.Type.TPA) {
if (plugin.getSettings().getGeneral().isStrictTpaRequests()) {
request.setRecipientPosition(recipient.getPosition());
}
}
// Find the requester and inform them of the response
final Optional<OnlineUser> localRequester = plugin.getOnlineUserExact(request.getRequesterName());
@@ -363,11 +369,17 @@ public class RequestsManager {
// If the request is a tpa request, teleport the requester to the recipient
if (accepted && (request.getType() == TeleportRequest.Type.TPA)) {
Teleport.builder(plugin)
final TeleportBuilder builder = Teleport.builder(plugin)
.teleporter(requester)
.target(request.getRecipientName())
.actions(TransactionResolver.Action.ACCEPT_TELEPORT_REQUEST)
.buildAndComplete(true);
.actions(TransactionResolver.Action.ACCEPT_TELEPORT_REQUEST);
// strictTPA: use the recipient's position at the time of acceptance
if (plugin.getSettings().getGeneral().isStrictTpaRequests() && request.getRecipientPosition() != null) {
builder.target(request.getRecipientPosition());
} else {
builder.target(request.getRecipientName());
}
builder.buildAndComplete(true);
}
}
@@ -46,6 +46,9 @@ public class TeleportRequest {
@SerializedName("requester_position")
private Position requesterPosition;
@Expose
@SerializedName("recipient_position")
private Position recipientPosition;
@Expose
@SerializedName("expiry_time")
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)