Add Coal Cents economy

This commit is contained in:
CoalGov Deploy
2026-05-04 17:00:05 +00:00
commit c8cc200004
73 changed files with 6873 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package com.librewiki.coalgov.service;
import com.librewiki.coalgov.CoalGovPlugin;
import com.librewiki.coalgov.model.Claim;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.sql.SQLException;
import java.util.Optional;
public final class BuildProtectionService {
private final CoalGovPlugin plugin;
private final ClaimService claimService;
public BuildProtectionService(CoalGovPlugin plugin, ClaimService claimService) {
this.plugin = plugin;
this.claimService = claimService;
}
public BuildDecision canModify(Player player, Location location) throws SQLException {
if (plugin.hasAdminBypass(player)) {
return BuildDecision.allow();
}
Optional<Claim> claim = claimService.claimAt(location);
if (claim.isEmpty()) {
return BuildDecision.deny("This land is unclaimed and protected by the Ministry.");
}
if (!claim.get().ownerUuid().equals(player.getUniqueId())) {
return BuildDecision.deny("This claim belongs to another citizen.");
}
return BuildDecision.allow();
}
public record BuildDecision(boolean allowed, String message) {
public static BuildDecision allow() {
return new BuildDecision(true, "");
}
public static BuildDecision deny(String message) {
return new BuildDecision(false, message);
}
}
}