Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/net/tfminecraft/simplefactions/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public static boolean requireProvinces(org.bukkit.command.CommandSender sender)
public static double mercenaryDefaultBreachRefund = 500.0;

public static double supplyHubMaxTax = 50.0;
public static double supplyHubMaxFee = 500.0;
public static int supplyHubOfferDays = 7;
public static int supplyHubAgreementDays = 14;

public static double infrastructureFull = 20;
public static double infrastructureTarget = 0.75;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.tfminecraft.simplefactions.guild.upgrade.Upgrade;
import net.tfminecraft.simplefactions.guild.upgrade.UpgradeExpansion;
import net.tfminecraft.simplefactions.guild.Guild;
import net.tfminecraft.simplefactions.guild.hub.HubAgreementService;
import net.tfminecraft.simplefactions.guild.hub.SupplyHubService;
import net.tfminecraft.simplefactions.guild.income.LedgerHistory;
import net.tfminecraft.simplefactions.loaders.BranchLoader;
Expand Down Expand Up @@ -166,7 +167,6 @@ public void loadFactions() {
data.laws,
data.governmentData
);
f.getTaxHandler().setHubTax(data.hubTax == null ? 0.0 : data.hubTax);
f.getVehicleFeeHandler().load(data.vehicleFees, data.vehicleTypeFees);
if (data.lawChangedAt != null) {
for (Map.Entry<String, Long> entry : data.lawChangedAt.entrySet()) {
Expand All @@ -192,8 +192,6 @@ public void loadFactions() {
if (data.installations != null) {
f.getInstallationHandler().load(data.installations);
}
f.loadHubPermits(data.hubPermits);

if (data.installationQueue != null) {
f.getInstallationHandler().loadConstruction(data.installationQueue);
}
Expand Down Expand Up @@ -330,7 +328,7 @@ public void saveFaction(Faction f) {
data.vassalTax = f.getTaxHandler().getVassalTax();
data.dividendTax = f.getTaxHandler().getDividendTax();
data.tariffs = f.getTaxHandler().getTariffs();
data.hubTax = f.getTaxHandler().getHubTax();
data.hubTax = null;
data.specificTaxes = serializeSpecificTaxes(f.getTaxHandler());
data.vehicleFees = new HashMap<>(f.getVehicleFeeHandler().serializeRates());
data.vehicleTypeFees = new HashMap<>();
Expand All @@ -348,7 +346,7 @@ public void saveFaction(Faction f) {

data.settlements = f.getSettlementHandler().serialize();
data.installations = f.getInstallationHandler().serialize();
data.hubPermits = new ArrayList<>(f.getHubPermits());
data.hubPermits = null;
data.installationQueue = f.getInstallationHandler().serializeConstruction();

for (int p : f.getProvinces()) data.provinces.add(p);
Expand Down Expand Up @@ -425,6 +423,8 @@ public void saveFaction(Faction f) {
gd.depositsToday = depositsToday.isEmpty() ? null : depositsToday;
gd.company = g.getCompany() != null ? g.getCompany().serialize() : null;
gd.supplyHubs = SupplyHubService.toData(g.getSupplyHubs());
gd.hubAgreements = HubAgreementService.toAgreementData(g.getHubAgreements());
gd.hubOffers = HubAgreementService.toOfferData(g.getHubOffers());
gd.supplyHubTutorialDismissals = g.getSupplyHubTutorialDismissals();

// --- Bank ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ public class FactionData {
public List<WarReparationsObligationData> warReparationsObligations = new ArrayList<>();

@SerializedName("hub permits")
public List<String> hubPermits = new ArrayList<>();
public List<String> hubPermits;
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public class GuildData {
@SerializedName("supply hubs")
public List<SupplyHubData> supplyHubs = new ArrayList<>();

@SerializedName("hub agreements")
public List<HubAgreementData> hubAgreements = new ArrayList<>();

@SerializedName("hub offers")
public List<HubOfferData> hubOffers = new ArrayList<>();

@SerializedName("supply hub tutorial dismissals")
public List<String> supplyHubTutorialDismissals = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.tfminecraft.simplefactions.database;

import com.google.gson.annotations.SerializedName;

public class HubAgreementData {
public String faction;
public String installation;
public Integer rate;

/** Denars, whole cents. */
@SerializedName("daily fee")
public Double dailyFee;

@SerializedName("days remaining")
public Integer daysRemaining;

@SerializedName("guild renews")
public Boolean guildRenews;

@SerializedName("host renews")
public Boolean hostRenews;

@SerializedName("next rate")
public Integer nextRate;

@SerializedName("next fee")
public Double nextFee;

/** Set once the guild leader has been told that a dormant hub still costs its fee. */
@SerializedName("dormant notice")
public Boolean dormantNotice;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.tfminecraft.simplefactions.database;

import com.google.gson.annotations.SerializedName;

public class HubOfferData {
public String faction;
public String installation;
public Integer rate;

@SerializedName("daily fee")
public Double dailyFee;

/** {@code guild} or {@code host}. */
public String awaiting;

@SerializedName("last actor")
public String lastActor;

@SerializedName("created at")
public Long createdAt;

/** {@code new} or {@code next}. */
public String kind;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public void apply(Cause cause) {
gov.getFaction().applyLaw(law, group);
} else if (isTaxProposal()) {
TaxTarget target = tax.getTarget();
if (target == TaxTarget.HUB_TAX) {
return;
}
gov.getFaction().getTaxHandler().setTaxRate(target, tax.getId(), tax.getNewTax());
} else if (isFeeProposal()) {
gov.getFaction().getVehicleFeeHandler().setRate(fee.getKind(), fee.getVehicleTypeId(), fee.getNewRate());
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/tfminecraft/simplefactions/guild/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
import net.tfminecraft.simplefactions.database.Database;
import net.tfminecraft.simplefactions.database.GuildBranchData;
import net.tfminecraft.simplefactions.database.GuildData;
import net.tfminecraft.simplefactions.guild.hub.HubAgreement;
import net.tfminecraft.simplefactions.guild.hub.HubAgreementService;
import net.tfminecraft.simplefactions.guild.hub.HubOffer;
import net.tfminecraft.simplefactions.guild.hub.SupplyHub;
import net.tfminecraft.simplefactions.guild.hub.SupplyHubService;
import net.tfminecraft.simplefactions.database.StabilityModifierData;
Expand Down Expand Up @@ -107,6 +110,8 @@ public class Guild {
private List<String> dividendEligible = new ArrayList<>();
private MercenaryCompany company;
private final List<SupplyHub> supplyHubs = new ArrayList<>();
private final List<HubAgreement> hubAgreements = new ArrayList<>();
private final List<HubOffer> hubOffers = new ArrayList<>();
private final Set<String> supplyHubTutorialDismissals = new HashSet<>();

public Guild(Faction f) {
Expand Down Expand Up @@ -248,6 +253,8 @@ public Guild(GuildData data, Faction host) {
this, data.company, MercenaryCompany.cloneMercenaryRegiment());
}
this.supplyHubs.addAll(SupplyHubService.fromData(data.supplyHubs));
this.hubAgreements.addAll(HubAgreementService.fromAgreementData(data.hubAgreements));
this.hubOffers.addAll(HubAgreementService.fromOfferData(data.hubOffers));
if (data.supplyHubTutorialDismissals != null) {
supplyHubTutorialDismissals.addAll(data.supplyHubTutorialDismissals);
}
Expand Down Expand Up @@ -433,6 +440,14 @@ public List<SupplyHub> getSupplyHubs() {
return supplyHubs;
}

public List<HubAgreement> getHubAgreements() {
return hubAgreements;
}

public List<HubOffer> getHubOffers() {
return hubOffers;
}

public boolean hasDismissedSupplyHubTutorial(String playerId) {
return playerId != null && supplyHubTutorialDismissals.contains(playerId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.tfminecraft.simplefactions.guild.hub;

/**
* Terms for one guild hub at another realm's installation.
* The rate is a whole percent. The fee is whole cents of a denar.
*/
public record HubAgreement(
String hostFactionId,
String installationId,
int taxRatePercent,
long feeCents,
int daysRemaining,
boolean guildRenews,
boolean hostRenews,
HubTerms nextTerms,
boolean dormantNoticeSent) {

public HubAgreement withDays(int days) {
return new HubAgreement(hostFactionId, installationId, taxRatePercent, feeCents, days,
guildRenews, hostRenews, nextTerms, dormantNoticeSent);
}

public HubAgreement withRenewal(boolean guildRenews, boolean hostRenews) {
return new HubAgreement(hostFactionId, installationId, taxRatePercent, feeCents, daysRemaining,
guildRenews, hostRenews, nextTerms, dormantNoticeSent);
}

public HubAgreement withNextTerms(HubTerms nextTerms) {
return new HubAgreement(hostFactionId, installationId, taxRatePercent, feeCents, daysRemaining,
guildRenews, hostRenews, nextTerms, dormantNoticeSent);
}

public HubAgreement withDormantNotice(boolean sent) {
return new HubAgreement(hostFactionId, installationId, taxRatePercent, feeCents, daysRemaining,
guildRenews, hostRenews, nextTerms, sent);
}

public boolean willRenew() {
return guildRenews && hostRenews;
}
}
Loading
Loading