mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
More classes moving
This commit is contained in:
47 files changed
+230
-234
No files matched your search
@@ -12,6 +12,9 @@ import me.william278.huskhomes2.commands.WarpCommand;
|
||||
import me.william278.huskhomes2.data.DataManager;
|
||||
import me.william278.huskhomes2.integrations.DynMapIntegration;
|
||||
import me.william278.huskhomes2.integrations.VaultIntegration;
|
||||
import me.william278.huskhomes2.teleport.points.Home;
|
||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||
import me.william278.huskhomes2.teleport.points.Warp;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -160,4 +163,88 @@ public class SettingHandler {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SetWarpConditions {
|
||||
|
||||
private boolean conditionsMet;
|
||||
private String conditionsNotMetReason;
|
||||
|
||||
public SetWarpConditions(String warpName) {
|
||||
conditionsMet = false;
|
||||
if (DataManager.warpExists(warpName)) {
|
||||
conditionsNotMetReason = "error_set_warp_name_taken";
|
||||
return;
|
||||
}
|
||||
if (warpName.length() > 16) {
|
||||
conditionsNotMetReason = "error_set_warp_invalid_length";
|
||||
return;
|
||||
}
|
||||
if (!warpName.matches("[A-Za-z0-9_\\-]+")) {
|
||||
conditionsNotMetReason = "error_set_warp_invalid_characters";
|
||||
return;
|
||||
}
|
||||
conditionsMet = true;
|
||||
}
|
||||
|
||||
public boolean areConditionsMet() {
|
||||
return conditionsMet;
|
||||
}
|
||||
|
||||
public String getConditionsNotMetReason() {
|
||||
return conditionsNotMetReason;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SetHomeConditions {
|
||||
|
||||
private boolean conditionsMet;
|
||||
private String conditionsNotMetReason;
|
||||
|
||||
public SetHomeConditions(Player player, String homeName) {
|
||||
conditionsMet = false;
|
||||
int currentHomeCount = DataManager.getPlayerHomeCount(player);
|
||||
if (currentHomeCount > (Home.getSetHomeLimit(player) - 1)) {
|
||||
conditionsNotMetReason = "error_set_home_maximum_homes";
|
||||
return;
|
||||
}
|
||||
if (DataManager.homeExists(player, homeName)) {
|
||||
conditionsNotMetReason = "error_set_home_name_taken";
|
||||
return;
|
||||
}
|
||||
if (homeName.length() > 16) {
|
||||
conditionsNotMetReason = "error_set_home_invalid_length";
|
||||
return;
|
||||
}
|
||||
if (!homeName.matches("[A-Za-z0-9_\\-]+")) {
|
||||
conditionsNotMetReason = "error_set_home_invalid_characters";
|
||||
return;
|
||||
}
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double setHomeCost = HuskHomes.settings.getSetHomeCost();
|
||||
if (setHomeCost > 0) {
|
||||
int currentPlayerHomeSlots = DataManager.getPlayerHomeSlots(player);
|
||||
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
||||
if (!VaultIntegration.takeMoney(player, setHomeCost)) {
|
||||
conditionsNotMetReason = "error_insufficient_funds";
|
||||
return;
|
||||
} else {
|
||||
DataManager.incrementPlayerHomeSlots(player);
|
||||
MessageManager.sendMessage(player, "set_home_spent_money", VaultIntegration.format(setHomeCost));
|
||||
}
|
||||
} else if (currentHomeCount == (currentPlayerHomeSlots - 1)) {
|
||||
MessageManager.sendMessage(player, "set_home_used_free_slots", Integer.toString(Home.getFreeHomes(player)), VaultIntegration.format(setHomeCost));
|
||||
}
|
||||
}
|
||||
}
|
||||
conditionsMet = true;
|
||||
}
|
||||
|
||||
public boolean areConditionsMet() {
|
||||
return conditionsMet;
|
||||
}
|
||||
|
||||
public String getConditionsNotMetReason() {
|
||||
return conditionsNotMetReason;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user