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
10 changes: 0 additions & 10 deletions src/main/java/net/tfminecraft/simplefactions/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,6 @@ public static boolean requireProvinces(org.bukkit.command.CommandSender sender)
/** Share of a sea or rail delivery left in the provinces along the way. */
public static double supplyHubCorridorShare = 0.5;

public static double infrastructureFull = 20;
public static double infrastructureTarget = 0.75;
public static double infrastructureWildernessSpread = 0.25;
public static double infrastructureSpreadFloor = 0.5;
public static double infrastructureStation = 10;
public static double infrastructurePort = 10;
public static double infrastructureAirport = 5;
public static double infrastructureTrack = 10;
public static int infrastructureTrackRefreshSeconds = 300;

public static Map<Scope, LawEffect> baseEffects = new HashMap<>();

public static Map<Terrain, Double> tradeCarry = new HashMap<>();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/tfminecraft/simplefactions/SimpleFactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public class SimpleFactions extends JavaPlugin{
new net.tfminecraft.simplefactions.mercenary.contract.AttendanceService.Hook();
private ProvinceManager provinceSnapshot = new ProvinceManager();
private ProvinceGrid provinceGrid;
private BukkitTask trackInfrastructureRefreshTask;
private static final long TRACK_REFRESH_TICKS = 300L * 20L;
private BukkitTask trackRefreshTask;
private final PlayerVehicleRegistry vehicleRegistry = new PlayerVehicleRegistry();
private VehicleRegistryPersistence vehicleRegistryPersistence;
private final InstallationVehicleOwnerSync installationVehicleOwnerSync =
Expand Down Expand Up @@ -364,16 +365,15 @@ public void onEnable() {
if (Cache.supplyHubAutoAccept) {
getLogger().info("Hub auto-accept is on.");
}
long refreshTicks = Cache.infrastructureTrackRefreshSeconds * 20L;
trackInfrastructureRefreshTask = getServer().getScheduler().runTaskTimer(
this, () -> { refreshTrackProvinces(); }, refreshTicks, refreshTicks);
trackRefreshTask = getServer().getScheduler().runTaskTimer(
this, () -> { refreshTrackProvinces(); }, TRACK_REFRESH_TICKS, TRACK_REFRESH_TICKS);
}
inventoryManager.start();
vehicleMaintenanceDecayTask.start();
}
@Override
public void onDisable() {
if (trackInfrastructureRefreshTask != null) trackInfrastructureRefreshTask.cancel();
if (trackRefreshTask != null) trackRefreshTask.cancel();
net.tfminecraft.simplefactions.integration.rpcharacters.chat.RpCharactersChatIntegration.unregister();
MercenaryStatService.clearAll();
net.tfminecraft.simplefactions.mercenary.company.MercenaryEligibility.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ public enum GuildModifier {
TRADE_POWER("#92d665Trade Power", true),
TRADE_UPKEEP("#d6645aTrade Upkeep", false),
PRODUCTION("#f2c94cProduction", true),
INFRASTRUCTURE("#86d1b0Infrastructure", true),
INFRASTRUCTURE_UPKEEP("#86d1b0Infrastructure Upkeep", false),
TRADE_CARRY("#86d1b0Trade Carry", true),
HUB_LIMIT("#c99b70Supply Hub Limit", true),
HUB_UPKEEP("#d6645aSupply Hub Upkeep", false),
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.tfminecraft.simplefactions.map.ProvinceGrid;
import net.tfminecraft.simplefactions.map.provinces.Province;

/** Track infrastructure sampling uses the same VehicleFramework boundary as hub routes. */
/** Provinces crossed by railway track. Hub routes use the same VehicleFramework boundary. */
public final class VehicleFrameworkTrackProvinces {
private VehicleFrameworkTrackProvinces() {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.tfminecraft.simplefactions.guild.income;

import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

import net.tfminecraft.simplefactions.enums.GuildModifier;
Expand All @@ -11,9 +9,7 @@
import net.tfminecraft.simplefactions.guild.GuildModifierOverride;
import net.tfminecraft.simplefactions.guild.branch.Branch;
import net.tfminecraft.simplefactions.guild.branch.BranchModifier;
import net.tfminecraft.simplefactions.managers.FactionManager;
import net.tfminecraft.simplefactions.managers.ProvinceManager;
import net.tfminecraft.simplefactions.managers.RelationManager;
import net.tfminecraft.simplefactions.objects.Faction;

/**
Expand Down Expand Up @@ -63,58 +59,10 @@ public static double estimate(
ProvinceManager after = copy(prepared.snapshot);
double baseline = income(before, guild, current);
double changed = income(after, guild, hypothetical);
double upkeepChange = Math.max(0.0, hypothetical.getOrDefault(GuildModifier.INFRASTRUCTURE_UPKEEP, 0.0))
- Math.max(0.0, current.getOrDefault(GuildModifier.INFRASTRUCTURE_UPKEEP, 0.0));
double net = (changed - baseline) * (1.0 - taxFraction) - upkeepChange;
double net = (changed - baseline) * (1.0 - taxFraction);
return Math.round(net * 100.0) / 100.0;
}

/**
* The realm guild's infrastructure reaches every guild in the realm, so an
* up or down of that branch is their incomes added together.
*/
public static boolean showsRealm(Guild guild, Branch branch) {
return guild != null
&& guild.isBase()
&& branch != null
&& branch.getModifier(GuildModifier.INFRASTRUCTURE) != null;
}

/** Guilds and factions as they were on the server thread. The preview does not read the live lists. */
public static List<Guild> guildsNow() {
List<Guild> guilds = new ArrayList<>();
for (Guild guild : FactionManager.getAllGuilds()) {
if (guild != null) {
guilds.add(guild);
}
}
return List.copyOf(guilds);
}

public static List<Faction> factionsNow() {
List<Faction> factions = new ArrayList<>();
for (Faction faction : FactionManager.getCopy()) {
if (faction != null) {
factions.add(faction);
}
}
return List.copyOf(factions);
}

public static double estimateRealm(
Prepared prepared,
Guild realmGuild,
Map<GuildModifier, Double> current,
Map<GuildModifier, Double> hypothetical,
List<Guild> guilds,
List<Faction> factions) {
double before = realmIncome(prepared, realmGuild, current, guilds, factions);
double after = realmIncome(prepared, realmGuild, hypothetical, guilds, factions);
double upkeepChange = Math.max(0.0, hypothetical.getOrDefault(GuildModifier.INFRASTRUCTURE_UPKEEP, 0.0))
- Math.max(0.0, current.getOrDefault(GuildModifier.INFRASTRUCTURE_UPKEEP, 0.0));
return Math.round((after - before - upkeepChange) * 100.0) / 100.0;
}

public static Map<GuildModifier, Double> modifiers(Guild guild) {
EnumMap<GuildModifier, Double> amounts = new EnumMap<>(GuildModifier.class);
for (GuildModifier modifier : GuildModifier.values()) {
Expand Down Expand Up @@ -155,45 +103,6 @@ private static ProvinceManager copy(ProvinceManager source) {
return snapshot;
}

private static double realmIncome(
Prepared prepared,
Guild realmGuild,
Map<GuildModifier, Double> amounts,
List<Guild> guilds,
List<Faction> factions) {
ProvinceManager snapshot = copy(prepared.snapshot);
GuildModifierOverride.use(realmGuild, amounts);
try {
snapshot.recalculateQuiet(guilds, factions);
double sum = 0;
Faction realm = realmGuild.getFaction();
List<Guild> present = guilds == null ? List.of() : guilds;
for (Guild guild : present) {
if (guild == null || !sameRealm(realm, guild.getFaction())) {
continue;
}
sum += snapshot.getIncome(guild, false) * (1.0 - taxFraction(guild));
}
return sum;
} finally {
snapshot.clearPreviewLists();
GuildModifierOverride.clear();
}
}

private static boolean sameRealm(Faction realm, Faction guildFaction) {
if (realm == null || guildFaction == null) {
return false;
}
if (realm == guildFaction) {
return true;
}
if (realm.getId() != null && realm.getId().equalsIgnoreCase(guildFaction.getId())) {
return true;
}
return RelationManager.sameRealm(realm, guildFaction);
}

private static double income(ProvinceManager snapshot, Guild guild, Map<GuildModifier, Double> amounts) {
GuildModifierOverride.use(guild, amounts);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public enum Cashflow {
VEHICLE_UPKEEP("#a6659fVehicle Upkeep", true, false),
MILITARY_UPKEEP("#a6659fMilitary Upkeep", true, false),
NODES("#8a7a5cNodes", true, false),
SUPPLY_HUBS("#b5835aSupply hubs", true, false),
INFRASTRUCTURE_UPKEEP("#86d1b0Infrastructure", true, false);
SUPPLY_HUBS("#b5835aSupply hubs", true, false);

private final String display;
private final boolean affectsInflation;
Expand Down
Loading
Loading