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: 2 additions & 1 deletion src/main/java/net/tfminecraft/simplefactions/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public static boolean requireProvinces(org.bukkit.command.CommandSender sender)
public static double supplyHubMaxFee = 500.0;
public static int supplyHubOfferDays = 7;
public static int supplyHubAgreementDays = 14;
public static int supplyHubEstimateCandidates = 24;
/** Dev servers only. Sending hub terms also accepts them. */
public static boolean supplyHubAutoAccept = false;

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 @@ -361,6 +361,9 @@ public void onEnable() {
provinceManager.recalculate();
// Hub tax is assessed at the day change; do it once now so menus are right before then.
net.tfminecraft.simplefactions.guild.hub.HubTaxService.refresh(provinceManager);
if (Cache.supplyHubAutoAccept) {
getLogger().info("Hub auto-accept is on.");
}
long refreshTicks = Cache.infrastructureTrackRefreshSeconds * 20L;
trackInfrastructureRefreshTask = getServer().getScheduler().runTaskTimer(
this, () -> { refreshTrackProvinces(); }, refreshTicks, refreshTicks);
Expand Down Expand Up @@ -433,6 +436,8 @@ public void loadConfigs() {
public void registerListeners() {
getServer().getPluginManager().registerEvents(commands, this);
getServer().getPluginManager().registerEvents(inventoryManager, this);
getServer().getPluginManager().registerEvents(
new net.tfminecraft.simplefactions.managers.inventory.HubTermsPrompt(), this);
getServer().getPluginManager().registerEvents(bankManager, this);
getServer().getPluginManager().registerEvents(titleManager, this);
getServer().getPluginManager().registerEvents(playerManager, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
public final class HubAgreementService {
static final long DAY_MILLIS = 86_400_000L;
/** Not a player name. Used only while supply-hubs.auto-accept is on. */
static final String DEV_ACTOR = "dev-auto-accept";

private HubAgreementService() {
}
Expand Down Expand Up @@ -75,6 +77,24 @@ public static AgreementResult accept(
return result;
}

/**
* Finishes the current offer as the host. Does nothing unless
* {@code supply-hubs.auto-accept} is on, so a live server still needs the other side.
*/
public static AgreementResult acceptAutomatically(
Guild guild, String hostFactionId, String installationId) {
if (!net.tfminecraft.simplefactions.Cache.supplyHubAutoAccept) {
return AgreementResult.fail("搂cThat offer is waiting on the other side");
}
AgreementResult result = accept(
guild, DEV_ACTOR, hostFactionId, installationId, HubAgreementFacts.LIVE, System.currentTimeMillis());
if (result.builtHub()) {
SupplyHubCommands.recalculateTrade();
}
HubAgreementMessenger.deliver(result.notices());
return result;
}

public static AgreementResult decline(
Guild guild, String actorName, String hostFactionId, String installationId) {
AgreementResult result = decline(
Expand Down Expand Up @@ -258,7 +278,8 @@ static AgreementResult accept(
if (offer.lastActor() != null && offer.lastActor().equalsIgnoreCase(actorName)) {
return AgreementResult.fail("搂cYou can only accept terms the other side sent");
}
if (!actsFor(offer.awaiting(), guild, actorName, hostFactionId, facts)) {
boolean devHost = net.tfminecraft.simplefactions.Cache.supplyHubAutoAccept && DEV_ACTOR.equals(actorName);
if (!devHost && !actsFor(offer.awaiting(), guild, actorName, hostFactionId, facts)) {
OfferSide sender = offer.awaiting() == OfferSide.HOST ? OfferSide.GUILD : OfferSide.HOST;
if (actsFor(sender, guild, actorName, hostFactionId, facts)) {
return AgreementResult.fail("搂cYou can only accept terms the other side sent");
Expand Down
Loading
Loading