mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +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
@@ -1,7 +1,9 @@
|
||||
package me.william278.huskhomes2.commands;
|
||||
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.data.DataManager;
|
||||
import me.william278.huskhomes2.integrations.VaultIntegration;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -11,11 +13,6 @@ public class BackCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(p);
|
||||
if (lastPosition != null) {
|
||||
TeleportManager.queueTimedTeleport(p, lastPosition);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_no_last_position");
|
||||
}
|
||||
TeleportManager.queueBackTeleport(p);
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ public class Settings {
|
||||
private double setHomeCost;
|
||||
private double publicHomeCost;
|
||||
private double rtpCost;
|
||||
private double backCost;
|
||||
|
||||
// Vanished player checks
|
||||
private boolean checkVanishedPlayers;
|
||||
@@ -154,6 +155,7 @@ public class Settings {
|
||||
this.setHomeCost = config.getDouble("economy_integration.costs.additional_home_slot");
|
||||
this.publicHomeCost = config.getDouble("economy_integration.costs.make_home_public");
|
||||
this.rtpCost = config.getDouble("economy_integration.costs.random_teleport");
|
||||
this.backCost = config.getDouble("economy_integration.costs.back");
|
||||
|
||||
// Retrieve sounds used in plugin; if invalid, use defaults.
|
||||
try {
|
||||
@@ -321,6 +323,10 @@ public class Settings {
|
||||
return setHomeCost;
|
||||
}
|
||||
|
||||
public double getBackCost() {
|
||||
return backCost;
|
||||
}
|
||||
|
||||
public double getPublicHomeCost() {
|
||||
return publicHomeCost;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ error_tp_self: '&4Fehler: &cDu kannst dich nicht zu dir selbst teleportieren!'
|
||||
error_rtp_invalid_dimension: '&4Fehler: &cDer Zufallsteleport klappt nur in der Oberwelt!'
|
||||
error_rtp_cooldown: '&4Fehler: &cDu musst %1% Minuten warten bevor du dich wieder teleportieren kannst.'
|
||||
rtp_spent_money: '&7%1% ausgegeben für zufälligen Teleport.'
|
||||
back_spent_money: '&7Spent %1% to return to your last position.'
|
||||
error_command_disabled: '&4Fehler: &cDieser Befehl ist deaktiviert!'
|
||||
error_console_only: '&4Fehler: &cDieser Befehl kann nur in der Konsole ausgeführt werden.'
|
||||
error_tp_invalid_world: '&4Fehler: &cDiese Welt existiert nicht.'
|
||||
|
||||
@@ -73,6 +73,7 @@ error_tp_self: '&4Error: &cYou can''t teleport to yourself!'
|
||||
error_rtp_invalid_dimension: '&4Error: &cYou can only randomly teleport in the Overworld!'
|
||||
error_rtp_cooldown: '&4Error: &cYou must wait %1% minutes before randomly teleporting again.'
|
||||
rtp_spent_money: '&7Spent %1% to randomly teleport.'
|
||||
back_spent_money: '&7Spent %1% to return to your last position.'
|
||||
error_command_disabled: '&4Error: &cThat command is disabled!'
|
||||
error_console_only: '&4Error: &cThat command can only be run from the server console.'
|
||||
error_tp_invalid_world: '&4Error: &cPlease specify a valid server world.'
|
||||
|
||||
@@ -69,6 +69,7 @@ error_tp_self: '&4Fehler: &cDu kannst dich nicht zu dir selbst teleportieren!'
|
||||
error_rtp_invalid_dimension: '&4Fehler: &cDer Zufallsteleport klappt nur in der Oberwelt!'
|
||||
error_rtp_cooldown: '&4Fehler: &cDu musst %1% Minuten warten bevor du dich wieder teleportieren kannst.'
|
||||
rtp_spent_money: '&7%1% ausgegeben für zufälligen Teleport.'
|
||||
back_spent_money: '&7Spent %1% to return to your last position.'
|
||||
error_command_disabled: '&4Fehler: &cDieser Befehl ist deaktiviert!'
|
||||
error_console_only: '&4Fehler: &cDieser Befehl kann nur in der Konsole ausgeführt werden.'
|
||||
error_tp_invalid_world: '&4Fehler: &cDiese Welt existiert nicht.'
|
||||
|
||||
@@ -73,6 +73,7 @@ error_tp_self: '&4Ошибка: &cВы не можете телепортиро
|
||||
error_rtp_invalid_dimension: '&4Ошибка: &cВы можете случайно телепортироваться лишь в обычном мире!'
|
||||
error_rtp_cooldown: '&4Ошибка: &cВы должны подождать %1% минут, прежде чем снова случайно телепортироваться.'
|
||||
rtp_spent_money: '&7На случайную телепортацию потрачено %1%.'
|
||||
back_spent_money: '&7Spent %1% to return to your last position.'
|
||||
error_command_disabled: '&4Ошибка: &cЭта команда отключена!'
|
||||
error_console_only: '&4Ошибка: &cЭта команда может быть использована лишь из консоли.'
|
||||
error_tp_invalid_world: '&4Ошибка: &cПожалуйста, введите существующий мир.'
|
||||
|
||||
@@ -65,6 +65,7 @@ error_rtp_invalid_dimension: '&4錯誤: &c你只能在目前在世界裏隨機
|
||||
error_rtp_cooldown: '&4錯誤: &c你需要在下次隨機傳送前等待 %1% 分鐘.'
|
||||
error_rtp_randomization_timeout: '&4Error: &cFailed to find a safe random location to teleport you.'
|
||||
rtp_spent_money: '&7使用 %1% 以隨機傳送.'
|
||||
back_spent_money: '&7Spent %1% to return to your last position.'
|
||||
error_command_disabled: '&4錯誤: &c此指令已被關閉!'
|
||||
error_console_only: '&4錯誤: &c該指令只能被伺服器使用.'
|
||||
error_tp_invalid_world: '&4錯誤: &c請輸入正確的世界名稱.'
|
||||
|
||||
@@ -67,5 +67,6 @@ economy_integration:
|
||||
additional_home_slot: 100
|
||||
make_home_public: 50
|
||||
random_teleport: 20
|
||||
back: 0
|
||||
handle_vanished_players: true
|
||||
config_file_version: 2
|
||||
Reference in new issue
Block a user