mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
Close #18 - Added option to charge per use of /back command
This commit is contained in:
1 parent
4f7b4a7e18
commit
da30aa9076
11 files changed
+62
-9
No files matched your search
@@ -65,7 +65,37 @@ public class TeleportManager {
|
||||
return;
|
||||
}
|
||||
|
||||
getQueuedTeleports().add(new TimedTeleport(player, point));
|
||||
getQueuedTeleports().add(new TimedTeleport(player, point, "point"));
|
||||
}
|
||||
|
||||
public static void queueBackTeleport(Player player) {
|
||||
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(player);
|
||||
if (lastPosition != null) {
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double backCost = HuskHomes.getSettings().getBackCost();
|
||||
if (backCost > 0) {
|
||||
if (!VaultIntegration.hasMoney(player, backCost)) {
|
||||
MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(backCost));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.hasPermission("huskhomes.bypass_timer")) {
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double backCost = HuskHomes.getSettings().getRtpCost();
|
||||
if (backCost > 0) {
|
||||
VaultIntegration.takeMoney(player, backCost);
|
||||
MessageManager.sendMessage(player, "rtp_spent_money", VaultIntegration.format(backCost));
|
||||
}
|
||||
}
|
||||
teleportPlayer(player, lastPosition);
|
||||
return;
|
||||
}
|
||||
|
||||
getQueuedTeleports().add(new TimedTeleport(player, lastPosition, "back"));
|
||||
} else {
|
||||
MessageManager.sendMessage(player, "error_no_last_position");
|
||||
}
|
||||
}
|
||||
|
||||
public static void queueRandomTeleport(Player player) {
|
||||
|
||||
@@ -201,6 +201,20 @@ public class TeleportRequestHandler {
|
||||
case "point":
|
||||
TeleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPoint());
|
||||
break;
|
||||
case "back":
|
||||
if (HuskHomes.getSettings().doEconomy()) {
|
||||
double backCost = HuskHomes.getSettings().getBackCost();
|
||||
if (backCost > 0) {
|
||||
if (!VaultIntegration.takeMoney(teleporter, backCost)) {
|
||||
MessageManager.sendMessage(teleporter, "error_insufficient_funds", VaultIntegration.format(backCost));
|
||||
break;
|
||||
} else {
|
||||
MessageManager.sendMessage(teleporter, "back_spent_money", VaultIntegration.format(backCost));
|
||||
}
|
||||
}
|
||||
}
|
||||
TeleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPoint());
|
||||
break;
|
||||
case "player":
|
||||
TeleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName());
|
||||
break;
|
||||
|
||||
@@ -20,11 +20,11 @@ public class TimedTeleport {
|
||||
private int timeRemaining;
|
||||
private final int warmupTime = HuskHomes.getSettings().getTeleportWarmupTime();
|
||||
|
||||
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
||||
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint, String targetType) {
|
||||
this.teleporter = teleporter;
|
||||
this.initialTeleporterLocation = teleporter.getLocation();
|
||||
this.initialTeleporterHealth = teleporter.getHealth();
|
||||
this.targetType = "point";
|
||||
this.targetType = targetType;
|
||||
this.targetPoint = targetPoint;
|
||||
this.timeRemaining = warmupTime;
|
||||
|
||||
|
||||
Reference in new issue
Block a user