1560 lines
127 KiB
Java
1560 lines
127 KiB
Java
package games.dmg.fantasystick;
|
|
|
|
import com.comphenix.protocol.ProtocolLibrary;
|
|
import games.dmg.fantasystick.presentation.CharacterPresentation;
|
|
import games.dmg.fantasystick.presentation.CharacterChatNames;
|
|
import games.dmg.fantasystick.presentation.ProtocolPresentation;
|
|
import games.dmg.fantasystick.crafting.CharacterFactory;
|
|
import games.dmg.fantasystick.crafting.CharacterAnvilNames;
|
|
import games.dmg.fantasystick.crafting.ManualCraftingController;
|
|
import games.dmg.fantasystick.crafting.ManualCraftingGuard;
|
|
import games.dmg.fantasystick.crafting.PlayerSheetDrops;
|
|
import games.dmg.fantasystick.crafting.RecipeDiscovery;
|
|
import games.dmg.fantasystick.items.CharacterSheets;
|
|
import games.dmg.fantasystick.persistence.CharacterStorage;
|
|
import games.dmg.fantasystick.persistence.EquipmentSessionStore;
|
|
import games.dmg.fantasystick.session.EquipmentAdminCommand;
|
|
import games.dmg.fantasystick.session.EquipmentSessionEvents;
|
|
import games.dmg.fantasystick.session.EquipmentSessions;
|
|
import games.dmg.fantasystick.persistence.YamlCharacterRepository;
|
|
import games.dmg.fantasystick.progression.ProgressionRules;
|
|
import java.time.Clock;
|
|
import java.util.List;
|
|
import java.util.logging.Level;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
/** Crafting, native fantasy sessions, books, parties, names and permanent-stat progression. */
|
|
public final class FantasyStickPlugin extends JavaPlugin {
|
|
private CharacterStorage characters;
|
|
private ManualCraftingController crafting;
|
|
private ManualCraftingGuard guard;
|
|
private CharacterAnvilNames anvilNames;
|
|
private RecipeDiscovery recipeDiscovery;
|
|
private boolean recipeRegistered;
|
|
private EquipmentSessionStore receipts;
|
|
private EquipmentSessions sessions;
|
|
private EquipmentSessionEvents sessionEvents;
|
|
private games.dmg.fantasystick.book.CharacterBookController books;
|
|
private games.dmg.fantasystick.party.PartyRoster parties;
|
|
private games.dmg.fantasystick.party.CharacterPartyDirectory characterParties;
|
|
private games.dmg.fantasystick.party.PartyRegistrarDirectory partyRegistrars;
|
|
private games.dmg.fantasystick.party.PartyRegistrarController partyRegistrarController;
|
|
private games.dmg.fantasystick.training.TrainingDummyDirectory trainingDummies;
|
|
private games.dmg.fantasystick.training.TrainingDummyController trainingDummyController;
|
|
private games.dmg.fantasystick.party.PartyManagement partyManagement;
|
|
private games.dmg.fantasystick.party.PartyRegistrarMenus partyRegistrarMenus;
|
|
private games.dmg.fantasystick.party.PartyEvents partyEvents;
|
|
private games.dmg.fantasystick.shop.FantasyArmorerDirectory armorers;
|
|
private games.dmg.fantasystick.shop.FantasyArmorerController armorerController;
|
|
private games.dmg.fantasystick.shop.ArmorMarket armorMarket;
|
|
private games.dmg.fantasystick.shop.ArmorShop armorShop;
|
|
private games.dmg.fantasystick.shop.ArmorShopMenus armorShopMenus;
|
|
private org.bukkit.scheduler.BukkitTask armorMarketPulse;
|
|
private org.bukkit.scheduler.BukkitTask armorMenuPulse;
|
|
private games.dmg.fantasystick.persistence.RareSettings rareSettings;
|
|
private games.dmg.fantasystick.shop.RareInventoryDirectory rareInventory;
|
|
private games.dmg.fantasystick.shop.RareMerchantDirectory rareMerchants;
|
|
private games.dmg.fantasystick.shop.RareMerchantController rareMerchantController;
|
|
private games.dmg.fantasystick.shop.RareMarket rareMarket;
|
|
private games.dmg.fantasystick.shop.RareShop rareShop;
|
|
private games.dmg.fantasystick.shop.RareShopMenus rareShopMenus;
|
|
private games.dmg.fantasystick.shop.RarePotionService rarePotions;
|
|
private games.dmg.fantasystick.shop.RareReskillService rareReskills;
|
|
private games.dmg.fantasystick.shop.RareMagicCoreService rareMagicCores;
|
|
private games.dmg.fantasystick.shop.PhoenixDownService phoenixDowns;
|
|
private org.bukkit.scheduler.BukkitTask rareMarketPulse,rareMenuPulse;
|
|
private games.dmg.fantasystick.party.PartyCombat partyCombat;
|
|
private EquipmentAdminCommand admin;
|
|
private games.dmg.fantasystick.session.AdminCharacterRecovery characterRecovery;
|
|
private games.dmg.fantasystick.persistence.PlayerFeedbackPreferences feedbackPreferences;
|
|
private games.dmg.fantasystick.session.FantasyFeedbackCommand feedbackCommand;
|
|
private games.dmg.fantasystick.session.FantasyParticlesCommand particlesCommand;
|
|
private games.dmg.fantasystick.presentation.ParticleDelivery particleDelivery;
|
|
private games.dmg.fantasystick.presentation.CombatFeedback combatFeedback;
|
|
private volatile Object lifetime;
|
|
private CharacterPresentation presentation;
|
|
private ProtocolPresentation protocolPresentation;
|
|
private CharacterChatNames chatNames;
|
|
private games.dmg.fantasystick.persistence.AdventureSettings adventureSettings;
|
|
private games.dmg.fantasystick.session.AdventureModeLease gameModes;
|
|
private games.dmg.fantasystick.session.SessionVitals vitals;
|
|
private games.dmg.fantasystick.session.SessionVisuals sessionVisuals;
|
|
private games.dmg.fantasystick.combat.BasicAttack basicAttack;
|
|
private games.dmg.fantasystick.party.CombatExperience combatExperience;
|
|
private games.dmg.fantasystick.ability.AbilityRegistry abilityRegistry;
|
|
private games.dmg.fantasystick.ability.AbilityEngine abilityEngine;
|
|
private games.dmg.fantasystick.ability.Fireball fireball;
|
|
private games.dmg.fantasystick.persistence.FireballSettings fireballSettings;
|
|
private games.dmg.fantasystick.ability.FrostShard frostShard;
|
|
private games.dmg.fantasystick.persistence.FrostShardSettings frostShardSettings;
|
|
private games.dmg.fantasystick.ability.Longbow longbow;
|
|
private games.dmg.fantasystick.persistence.LongbowSettings longbowSettings;
|
|
private games.dmg.fantasystick.ability.Quickstep quickstep;
|
|
private games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings;
|
|
private games.dmg.fantasystick.ability.SecondWind secondWind;
|
|
private games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings;
|
|
private games.dmg.fantasystick.ability.CombatMitigation combatMitigation;
|
|
private games.dmg.fantasystick.ability.StoneSkin stoneSkin;
|
|
private games.dmg.fantasystick.ability.ShieldBash shieldBash;
|
|
private games.dmg.fantasystick.ability.OutgoingDamageMitigation outgoingDamageMitigation;
|
|
private games.dmg.fantasystick.ability.Hex hex;
|
|
private games.dmg.fantasystick.ability.TemporaryHealth temporaryHealth;
|
|
private games.dmg.fantasystick.ability.Inspire inspire;
|
|
private games.dmg.fantasystick.persistence.InspireSettings inspireSettings;
|
|
private games.dmg.fantasystick.ability.MendingLight mendingLight;
|
|
private games.dmg.fantasystick.persistence.MendingLightSettings mendingLightSettings;
|
|
private games.dmg.fantasystick.ability.Purify purify;
|
|
private games.dmg.fantasystick.persistence.PurifySettings purifySettings;
|
|
private games.dmg.fantasystick.ability.GuardianBond guardianBond;
|
|
private games.dmg.fantasystick.persistence.GuardianBondSettings guardianBondSettings;
|
|
private games.dmg.fantasystick.ability.OutgoingDamageBonus outgoingDamageBonus;
|
|
private games.dmg.fantasystick.ability.RallyingCry rallyingCry;
|
|
private games.dmg.fantasystick.persistence.RallyingCrySettings rallyingCrySettings;
|
|
private games.dmg.fantasystick.ability.FrostNova frostNova;
|
|
private games.dmg.fantasystick.persistence.FrostNovaSettings frostNovaSettings;
|
|
private games.dmg.fantasystick.ability.ChainLightning chainLightning;
|
|
private games.dmg.fantasystick.persistence.ChainLightningSettings chainLightningSettings;
|
|
private games.dmg.fantasystick.ability.Sanctuary sanctuary;
|
|
private games.dmg.fantasystick.persistence.SanctuarySettings sanctuarySettings;
|
|
private games.dmg.fantasystick.ability.WarBanner warBanner;
|
|
private games.dmg.fantasystick.persistence.WarBannerSettings warBannerSettings;
|
|
private games.dmg.fantasystick.ability.Meteor meteor;
|
|
private games.dmg.fantasystick.persistence.MeteorSettings meteorSettings;
|
|
private games.dmg.fantasystick.persistence.HexSettings hexSettings;
|
|
private games.dmg.fantasystick.persistence.ShieldBashSettings shieldBashSettings;
|
|
private games.dmg.fantasystick.persistence.StoneSkinSettings stoneSkinSettings;
|
|
private games.dmg.fantasystick.ability.GreatSword greatSword;
|
|
private games.dmg.fantasystick.ability.Revive revive;
|
|
private games.dmg.fantasystick.persistence.RevivalStore revivals;
|
|
private games.dmg.fantasystick.session.AdminRevival adminRevival;
|
|
private games.dmg.fantasystick.persistence.AdminReviveSettings adminReviveSettings;
|
|
private games.dmg.fantasystick.persistence.SwitchDelaySettings switchDelaySettings;
|
|
private games.dmg.fantasystick.persistence.RoleplaySettings roleplaySettings;
|
|
private games.dmg.fantasystick.persistence.PartySettings partySettings;
|
|
private games.dmg.fantasystick.persistence.PartyEconomySettings partyEconomySettings;
|
|
private games.dmg.fantasystick.persistence.GearSettings gearSettings;
|
|
private games.dmg.fantasystick.persistence.CoinSettings coinSettings;
|
|
private games.dmg.fantasystick.persistence.HardMobXpSettings hardMobXpSettings;
|
|
private games.dmg.fantasystick.persistence.AdventureQuestSettings adventureQuestSettings;
|
|
private games.dmg.fantasystick.adventure.AdventureQuestDirectory adventureQuests;
|
|
private games.dmg.fantasystick.adventure.AdventureQuestController adventureQuestController;
|
|
private games.dmg.fantasystick.adventure.AdventureQuestCommands adventureQuestCommands;
|
|
private games.dmg.fantasystick.adventure.FishingDirectory fishing;
|
|
private games.dmg.fantasystick.adventure.FishingController fishingController;
|
|
private games.dmg.fantasystick.dungeon.DungeonDirectory dungeons;
|
|
private games.dmg.fantasystick.session.DownedDirectory downed;
|
|
private games.dmg.fantasystick.session.DownedController downedController;
|
|
private games.dmg.fantasystick.persistence.DownedSettings downedSettings;
|
|
private games.dmg.fantasystick.dungeon.DungeonController dungeonController;
|
|
private games.dmg.fantasystick.dungeon.DungeonCommands dungeonCommands;
|
|
private games.dmg.fantasystick.persistence.SheetResourcePackSettings sheetResourcePackSettings;
|
|
private games.dmg.fantasystick.presentation.SheetResourcePack sheetResourcePack;
|
|
private games.dmg.fantasystick.session.NutritionPolicy nutritionPolicy;
|
|
private games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings outOfCombatRecoverySettings;
|
|
private games.dmg.fantasystick.session.OutOfCombatRecovery outOfCombatRecovery;
|
|
private games.dmg.fantasystick.persistence.QuickerRegenerationSettings quickerRegenerationSettings;
|
|
private games.dmg.fantasystick.passive.QuickerRegenerationI quickerRegeneration;
|
|
private games.dmg.fantasystick.persistence.QuickerRegenerationIISettings quickerRegenerationIISettings;
|
|
private games.dmg.fantasystick.passive.QuickerRegenerationII quickerRegenerationII;
|
|
private games.dmg.fantasystick.persistence.HealthStealSettings healthStealSettings;
|
|
private games.dmg.fantasystick.passive.HealthSteal healthSteal;
|
|
private games.dmg.fantasystick.passive.SpeedI speedI;
|
|
private games.dmg.fantasystick.passive.LowLightVision lowLightVision;
|
|
private games.dmg.fantasystick.passive.PassiveRegistry passiveRegistry;
|
|
private games.dmg.fantasystick.passive.PassiveEngine passiveEngine;
|
|
private games.dmg.fantasystick.events.LocalEventLog eventLog;
|
|
private games.dmg.fantasystick.events.PreferenceEventBridge preferenceEvents;
|
|
private games.dmg.fantasystick.events.EventCaptureListener eventCapture;
|
|
private games.dmg.fantasystick.events.DownedEventBridge downedEvents;
|
|
private games.dmg.fantasystick.events.RareEventBridge rareEvents;
|
|
private games.dmg.fantasystick.events.BookEventBridge bookEvents;
|
|
private games.dmg.fantasystick.events.ProgressionEventBridge progressionEvents;
|
|
private games.dmg.fantasystick.events.AbilityEventBridge abilityEvents;
|
|
private games.dmg.fantasystick.events.PassiveEventBridge passiveEvents;
|
|
private games.dmg.fantasystick.events.RecoveryEventBridge recoveryEvents;
|
|
private games.dmg.fantasystick.events.ReviveEventBridge reviveEvents;
|
|
private games.dmg.fantasystick.events.PartyEventBridge partyAuditEvents;
|
|
private games.dmg.fantasystick.events.CombatRewardEventBridge combatRewardEvents;
|
|
private games.dmg.fantasystick.events.CoinEventBridge coinEvents;
|
|
private games.dmg.fantasystick.events.SessionEventBridge sessionAuditEvents;
|
|
private games.dmg.fantasystick.events.SwitchDelayEventBridge switchAuditEvents;
|
|
private java.util.concurrent.CompletionStage<Void> switchAuditDrain = java.util.concurrent.CompletableFuture.completedFuture(null);
|
|
private games.dmg.fantasystick.events.CharacterIdentityEventBridge identityAuditEvents;
|
|
private java.util.concurrent.CompletionStage<Void> identityAuditDrain = java.util.concurrent.CompletableFuture.completedFuture(null);
|
|
private games.dmg.fantasystick.events.EquipmentEventBridge equipmentAuditEvents;
|
|
private java.util.concurrent.CompletionStage<Void> equipmentAuditDrain = java.util.concurrent.CompletableFuture.completedFuture(null);
|
|
private games.dmg.fantasystick.events.MessageEventBridge messageAuditEvents;
|
|
private java.util.concurrent.CompletionStage<Void> configurationDrain = java.util.concurrent.CompletableFuture.completedStage(null);
|
|
|
|
@Override public void onEnable() {
|
|
try {
|
|
Object generation = new Object();
|
|
lifetime = generation;
|
|
if (!configurationDrain.toCompletableFuture().isDone()) {
|
|
configurationDrain.whenComplete((ignored, failure) -> {
|
|
if (lifetime != generation) return;
|
|
try {
|
|
getServer().getScheduler().runTask(this, () -> {
|
|
if (lifetime == generation && isEnabled()) onEnable();
|
|
});
|
|
} catch (RuntimeException rejected) {
|
|
getLogger().log(Level.WARNING, "Configuration startup continuation unavailable", rejected);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
reloadConfig();
|
|
var adventure = games.dmg.fantasystick.persistence.AdventureSettings.validate(getConfig().get("adventure-mode"));
|
|
adventureSettings = new games.dmg.fantasystick.persistence.AdventureSettings(getDataFolder().toPath(), adventure);
|
|
var switchDelay = games.dmg.fantasystick.persistence.SwitchDelaySettings.parse(
|
|
getConfig().get(games.dmg.fantasystick.persistence.SwitchDelaySettings.KEY));
|
|
var roleplayDisabled = games.dmg.fantasystick.persistence.RoleplaySettings.parse(
|
|
getConfig().get(games.dmg.fantasystick.persistence.RoleplaySettings.KEY));
|
|
var partyMaximum = games.dmg.fantasystick.persistence.PartySettings.parse(
|
|
getConfig().get(games.dmg.fantasystick.persistence.PartySettings.KEY));
|
|
var partyEconomyConfiguration = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.PartyEconomySettings.keys()) partyEconomyConfiguration.put(key, getConfig().getString(key,games.dmg.fantasystick.persistence.PartyEconomySettings.defaultValue(key)));
|
|
var gearConfiguration=new java.util.LinkedHashMap<String,String>();for(String key:games.dmg.fantasystick.persistence.GearSettings.keys())gearConfiguration.put(key,getConfig().getString(key,games.dmg.fantasystick.persistence.GearSettings.defaultValue(key)));
|
|
var rareConfiguration=new java.util.LinkedHashMap<String,String>();for(String key:games.dmg.fantasystick.persistence.RareSettings.keys())rareConfiguration.put(key,getConfig().getString(key,games.dmg.fantasystick.persistence.RareSettings.defaultValue(key)));
|
|
var downedConfiguration=new java.util.LinkedHashMap<String,String>();for(String key:games.dmg.fantasystick.persistence.DownedSettings.keys())downedConfiguration.put(key,getConfig().getString(key,games.dmg.fantasystick.persistence.DownedSettings.defaultValue(key)));
|
|
var coinConfiguration = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.CoinSettings.keys()) {
|
|
coinConfiguration.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.CoinSettings.defaultValue(key)));
|
|
}
|
|
var adventureQuestConfiguration = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.AdventureQuestSettings.keys()) {
|
|
adventureQuestConfiguration.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.AdventureQuestSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.AdventureQuestSettings.parse(adventureQuestConfiguration);
|
|
var recoveryConfiguration = outOfCombatRecoveryConfiguration();
|
|
var recoveryInitial = games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.parse(recoveryConfiguration);
|
|
var quickerRegenerationInitial = games.dmg.fantasystick.persistence.QuickerRegenerationSettings.parse(
|
|
getConfig().getString(games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY,
|
|
games.dmg.fantasystick.persistence.QuickerRegenerationSettings.DEFAULT));
|
|
var quickerRegenerationIIInitial = games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.parse(
|
|
getConfig().getString(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY,
|
|
games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.DEFAULT));
|
|
var healthStealInitial = games.dmg.fantasystick.persistence.HealthStealSettings.parse(
|
|
getConfig().getString(games.dmg.fantasystick.persistence.HealthStealSettings.KEY,
|
|
games.dmg.fantasystick.persistence.HealthStealSettings.DEFAULT));
|
|
var sheetPackDefaults = games.dmg.fantasystick.persistence.SheetResourcePackSettings.packagedDefaults();
|
|
sheetResourcePackSettings = new games.dmg.fantasystick.persistence.SheetResourcePackSettings(getDataFolder().toPath(),
|
|
getConfig().get(games.dmg.fantasystick.persistence.SheetResourcePackSettings.URL_KEY),
|
|
getConfig().get(games.dmg.fantasystick.persistence.SheetResourcePackSettings.SHA1_KEY), sheetPackDefaults);
|
|
var rules = progressionRules();
|
|
var hardMobXpConfiguration = getConfig().getString(
|
|
games.dmg.fantasystick.persistence.HardMobXpSettings.KEY,
|
|
games.dmg.fantasystick.persistence.HardMobXpSettings.DEFAULT);
|
|
var hardMobXp = games.dmg.fantasystick.persistence.HardMobXpSettings.parse(hardMobXpConfiguration);
|
|
var rewardRules = combatRewardRules(hardMobXp);
|
|
var fireballConfiguration = fireballConfiguration();
|
|
var fireballInitial = games.dmg.fantasystick.persistence.FireballSettings.parse(fireballConfiguration);
|
|
var greatSwordSettings = greatSwordSettings();
|
|
var frostShardConfiguration = frostShardConfiguration();
|
|
var frostShardInitial = games.dmg.fantasystick.persistence.FrostShardSettings.parse(frostShardConfiguration);
|
|
var longbowConfiguration = longbowConfiguration();
|
|
var longbowInitial = games.dmg.fantasystick.persistence.LongbowSettings.parse(longbowConfiguration);
|
|
var quickstepConfiguration = quickstepConfiguration();
|
|
var quickstepInitial = games.dmg.fantasystick.persistence.QuickstepSettings.parse(quickstepConfiguration);
|
|
var secondWindConfiguration = secondWindConfiguration();
|
|
var secondWindInitial = games.dmg.fantasystick.persistence.SecondWindSettings.parse(secondWindConfiguration);
|
|
var stoneSkinConfiguration = stoneSkinConfiguration();
|
|
var stoneSkinInitial = games.dmg.fantasystick.persistence.StoneSkinSettings.parse(stoneSkinConfiguration);
|
|
var shieldBashConfiguration = shieldBashConfiguration();
|
|
var shieldBashInitial = games.dmg.fantasystick.persistence.ShieldBashSettings.parse(shieldBashConfiguration);
|
|
var hexConfiguration = hexConfiguration();
|
|
var hexInitial = games.dmg.fantasystick.persistence.HexSettings.parse(hexConfiguration);
|
|
var inspireConfiguration = inspireConfiguration();
|
|
var inspireInitial = games.dmg.fantasystick.persistence.InspireSettings.parse(inspireConfiguration);
|
|
var mendingLightConfiguration = mendingLightConfiguration();
|
|
var mendingLightInitial = games.dmg.fantasystick.persistence.MendingLightSettings.parse(mendingLightConfiguration);
|
|
var purifyConfiguration = purifyConfiguration();
|
|
var purifyInitial = games.dmg.fantasystick.persistence.PurifySettings.parse(purifyConfiguration);
|
|
var guardianBondConfiguration = guardianBondConfiguration();
|
|
var guardianBondInitial = games.dmg.fantasystick.persistence.GuardianBondSettings.parse(guardianBondConfiguration);
|
|
var rallyingCryConfiguration = rallyingCryConfiguration();
|
|
var rallyingCryInitial = games.dmg.fantasystick.persistence.RallyingCrySettings.parse(rallyingCryConfiguration);
|
|
var frostNovaConfiguration = frostNovaConfiguration();
|
|
var frostNovaInitial = games.dmg.fantasystick.persistence.FrostNovaSettings.parse(frostNovaConfiguration);
|
|
var chainLightningConfiguration = chainLightningConfiguration();
|
|
var chainLightningInitial = games.dmg.fantasystick.persistence.ChainLightningSettings.parse(chainLightningConfiguration);
|
|
var sanctuaryConfiguration = sanctuaryConfiguration();
|
|
var sanctuaryInitial = games.dmg.fantasystick.persistence.SanctuarySettings.parse(sanctuaryConfiguration);
|
|
var warBannerConfiguration = warBannerConfiguration();
|
|
var warBannerInitial = games.dmg.fantasystick.persistence.WarBannerSettings.parse(warBannerConfiguration);
|
|
var meteorConfiguration = meteorConfiguration();
|
|
var meteorInitial = games.dmg.fantasystick.persistence.MeteorSettings.parse(meteorConfiguration);
|
|
var adminReviveTimeout = games.dmg.fantasystick.persistence.AdminReviveSettings.parse(
|
|
getConfig().get(games.dmg.fantasystick.persistence.AdminReviveSettings.KEY));
|
|
partyEconomySettings = new games.dmg.fantasystick.persistence.PartyEconomySettings(
|
|
getDataFolder().toPath(), partyEconomyConfiguration);
|
|
gearSettings=new games.dmg.fantasystick.persistence.GearSettings(getDataFolder().toPath(),gearConfiguration);
|
|
rareSettings=new games.dmg.fantasystick.persistence.RareSettings(getDataFolder().toPath(),rareConfiguration);
|
|
downedSettings=new games.dmg.fantasystick.persistence.DownedSettings(getDataFolder().toPath(),downedConfiguration);
|
|
coinSettings = new games.dmg.fantasystick.persistence.CoinSettings(getDataFolder().toPath(), coinConfiguration);
|
|
hardMobXpSettings = new games.dmg.fantasystick.persistence.HardMobXpSettings(
|
|
getDataFolder().toPath(), hardMobXp.toString());
|
|
adventureQuestSettings = new games.dmg.fantasystick.persistence.AdventureQuestSettings(
|
|
getDataFolder().toPath(), adventureQuestConfiguration);
|
|
var factory = new CharacterFactory(coinSettings::rules);
|
|
characters = new CharacterStorage(new YamlCharacterRepository(getDataFolder().toPath()), Clock.systemUTC(),
|
|
coinSettings::rules, java.util.random.RandomGenerator.getDefault());
|
|
var armorRandom=java.util.random.RandomGenerator.getDefault();
|
|
armorMarket=new games.dmg.fantasystick.shop.ArmorMarket(
|
|
new games.dmg.fantasystick.persistence.YamlArmorCatalogRepository(getDataFolder().toPath()),
|
|
new games.dmg.fantasystick.persistence.ArmorPurchaseOperationStore(getDataFolder().toPath()),
|
|
characters,gearSettings::rules,Clock.systemUTC(),
|
|
(minimum,maximum)->(int)armorRandom.nextLong(minimum,(long)maximum+1));
|
|
try{rareInventory=new games.dmg.fantasystick.shop.RareInventoryDirectory(new games.dmg.fantasystick.persistence.YamlRareInventoryRepository(getDataFolder().toPath()));}catch(java.io.IOException invalidRareInventory){throw new java.io.UncheckedIOException("Rare Inventory could not be loaded",invalidRareInventory);}
|
|
var rareRandom=java.util.random.RandomGenerator.getDefault();rareMarket=new games.dmg.fantasystick.shop.RareMarket(new games.dmg.fantasystick.persistence.YamlRareCatalogRepository(getDataFolder().toPath()),new games.dmg.fantasystick.persistence.RarePurchaseOperationStore(getDataFolder().toPath()),characters,rareInventory,rareSettings::rules,Clock.systemUTC(),(minimum,maximum)->(int)rareRandom.nextLong(minimum,(long)maximum+1));
|
|
crafting = new ManualCraftingController(characters, () -> factory.create(rules),
|
|
task -> getServer().getScheduler().runTask(this, task),
|
|
player -> new PlayerSheetDrops(player, event -> getServer().getPluginManager().callEvent(event)),
|
|
problem -> getLogger().log(Level.WARNING, "Character craft " + problem.operation() + " for player "
|
|
+ problem.player() + "; character records " + problem.characters(), problem.cause()));
|
|
java.util.function.Consumer<Runnable> nextTick = task -> getServer().getScheduler().runTask(this, task);
|
|
try {
|
|
feedbackPreferences = new games.dmg.fantasystick.persistence.PlayerFeedbackPreferences(getDataFolder().toPath());
|
|
} catch (java.io.IOException invalidPreferences) {
|
|
throw new java.io.UncheckedIOException("Player feedback preferences could not be loaded", invalidPreferences);
|
|
}
|
|
particleDelivery = new games.dmg.fantasystick.presentation.ParticleDelivery(getServer(), feedbackPreferences,
|
|
failure -> getLogger().log(Level.WARNING, "Player particle delivery failed", failure));
|
|
feedbackCommand = new games.dmg.fantasystick.session.FantasyFeedbackCommand(feedbackPreferences, nextTick,
|
|
failure -> getLogger().log(Level.WARNING, "Player feedback preference failed", failure));
|
|
particlesCommand = new games.dmg.fantasystick.session.FantasyParticlesCommand(feedbackPreferences, nextTick,
|
|
failure -> getLogger().log(Level.WARNING, "Player particle preference failed", failure));
|
|
java.util.function.Consumer<Throwable> presentationFailures = problem ->
|
|
getLogger().log(Level.WARNING, "Character presentation failed", problem);
|
|
// This supplier belongs to one enable, never the mutable plugin field after re-enable.
|
|
var localPresentation = new java.util.concurrent.atomic.AtomicReference<CharacterPresentation>();
|
|
var installationFailure = new java.util.concurrent.atomic.AtomicReference<Throwable>();
|
|
protocolPresentation = new ProtocolPresentation(this, ProtocolLibrary.getProtocolManager(),
|
|
() -> localPresentation.get().snapshot(), problem -> {
|
|
installationFailure.compareAndSet(null, problem);
|
|
presentationFailures.accept(problem);
|
|
});
|
|
presentation = new CharacterPresentation(protocolPresentation, nextTick,
|
|
() -> getServer().isPrimaryThread(), presentationFailures, characters::find);
|
|
localPresentation.set(presentation);
|
|
chatNames = new CharacterChatNames(presentation::name);
|
|
protocolPresentation.install();
|
|
if (installationFailure.get() != null) {
|
|
throw new IllegalStateException("Could not install character presentation", installationFailure.get());
|
|
}
|
|
guard = new ManualCraftingGuard();
|
|
anvilNames = new CharacterAnvilNames(characters,
|
|
problem -> getLogger().log(Level.WARNING, "Character name update was refused or failed for player "
|
|
+ problem.player() + "; character " + problem.character(), problem.cause()), getServer().getItemFactory(),
|
|
presentation::acknowledged);
|
|
receipts = new EquipmentSessionStore(getDataFolder().toPath(), Clock.systemUTC());
|
|
java.util.function.Consumer<EquipmentSessions.Failure> diagnostics = problem ->
|
|
getLogger().log(Level.WARNING, "Equipment transition/recovery for player " + problem.player()
|
|
+ "; session " + problem.session(), problem.cause());
|
|
gameModes = new games.dmg.fantasystick.session.AdventureModeLease();
|
|
switchDelaySettings = new games.dmg.fantasystick.persistence.SwitchDelaySettings(getDataFolder().toPath(), switchDelay);
|
|
roleplaySettings = new games.dmg.fantasystick.persistence.RoleplaySettings(getDataFolder().toPath(), roleplayDisabled);
|
|
partySettings = new games.dmg.fantasystick.persistence.PartySettings(getDataFolder().toPath(), partyMaximum);
|
|
try {
|
|
characterParties = new games.dmg.fantasystick.party.CharacterPartyDirectory(
|
|
new games.dmg.fantasystick.persistence.YamlPartyRepository(getDataFolder().toPath()), partySettings::maximum);
|
|
partyRegistrars = new games.dmg.fantasystick.party.PartyRegistrarDirectory(
|
|
new games.dmg.fantasystick.persistence.YamlPartyRegistrarRepository(getDataFolder().toPath()));
|
|
trainingDummies = new games.dmg.fantasystick.training.TrainingDummyDirectory(
|
|
new games.dmg.fantasystick.persistence.YamlTrainingDummyRepository(getDataFolder().toPath()));
|
|
var adventureRepository=new games.dmg.fantasystick.persistence.YamlAdventureQuestRepository(getDataFolder().toPath());
|
|
adventureQuests = new games.dmg.fantasystick.adventure.AdventureQuestDirectory(
|
|
adventureRepository, Clock.systemUTC(), adventureQuestSettings::rules, java.util.random.RandomGenerator.getDefault());
|
|
fishing = new games.dmg.fantasystick.adventure.FishingDirectory(
|
|
new games.dmg.fantasystick.persistence.YamlFishingRepository(getDataFolder().toPath()));
|
|
dungeons = new games.dmg.fantasystick.dungeon.DungeonDirectory(
|
|
new games.dmg.fantasystick.persistence.YamlDungeonRepository(getDataFolder().toPath()),
|
|
() -> adventureQuestSettings.rules().dungeonRoomLinkDistance());
|
|
downed = new games.dmg.fantasystick.session.DownedDirectory(getDataFolder().toPath(),Clock.systemUTC());
|
|
if(adventureRepository.requiresDungeonRewardMigration())adventureQuests.migrateLegacyDungeonRewards(id->dungeons.find(id).flatMap(value->value.rooms().stream().filter(room->room.boss()!=null).findFirst().map(room->new games.dmg.fantasystick.adventure.AdventureQuestDirectory.LegacyDungeonReward(new games.dmg.fantasystick.adventure.AdventureQuestDirectory.Reward(value.completionReward().xp(),value.completionReward().coins()),room.id(),dungeons.runView(id,adventureQuests.snapshot().catalog()==null?new java.util.UUID(0,0):adventureQuests.snapshot().catalog().revision()).map(games.dmg.fantasystick.dungeon.DungeonState.Run::defeated).orElse(false))))).join();
|
|
armorers=new games.dmg.fantasystick.shop.FantasyArmorerDirectory(new games.dmg.fantasystick.persistence.YamlFantasyArmorerRepository(getDataFolder().toPath()));
|
|
rareMerchants=new games.dmg.fantasystick.shop.RareMerchantDirectory(new games.dmg.fantasystick.persistence.YamlRareMerchantRepository(getDataFolder().toPath()));
|
|
} catch (java.io.IOException invalidManagedState) {
|
|
throw new java.io.UncheckedIOException("Persistent party, shop, training or adventure state could not be loaded", invalidManagedState);
|
|
}
|
|
characterParties.suspend();
|
|
sheetResourcePack = new games.dmg.fantasystick.presentation.SheetResourcePack(sheetResourcePackSettings,
|
|
(player, failure) -> getLogger().log(Level.WARNING, "Sheet resource-pack delivery failed for " + player, failure));
|
|
sessions = new EquipmentSessions(characters, receipts, switchDelay, Clock.systemUTC(), nextTick,
|
|
notice -> notifyPlayer(generation, notice), diagnostics, presentation, adventureSettings::enabled, gameModes);
|
|
sessions.attachSwitchDelay(switchDelaySettings::delay);
|
|
sessions.attachRoleplayDisabled(roleplaySettings::disabled);
|
|
downedController=new games.dmg.fantasystick.session.DownedController(this,sessions,downed,Clock.systemUTC(),failure->getLogger().log(Level.WARNING,"Downed transition failed",failure));
|
|
phoenixDowns=new games.dmg.fantasystick.shop.PhoenixDownService(rareInventory,rareSettings,downed,sessions,Clock.systemUTC(),nextTick,downedController::revive,failure->getLogger().log(Level.WARNING,"Phoenix Down use failed",failure));
|
|
downedController.attachPhoenix(phoenixDowns);phoenixDowns.install();
|
|
sessions.attachDowned(downed,downedSettings::timeout,downedController::open);
|
|
combatFeedback = new games.dmg.fantasystick.presentation.CombatFeedback(feedbackPreferences, sessions);
|
|
trainingDummyController = new games.dmg.fantasystick.training.TrainingDummyController(this, trainingDummies);
|
|
parties = new games.dmg.fantasystick.party.PartyRoster(characterParties, sessions, partySettings::maximum);
|
|
characterParties.attachEnded(former -> nextTick.accept(() -> {
|
|
String message = "Party ended: " + former.displayName();
|
|
for (java.util.UUID member : former.members()) {
|
|
var activeMember = sessions.activeCharacter(member).filter(sessions::current).orElse(null);
|
|
org.bukkit.entity.Player online = activeMember == null ? null : getServer().getPlayer(activeMember.player());
|
|
if (online != null && online.isOnline()) online.showTitle(net.kyori.adventure.title.Title.title(
|
|
net.kyori.adventure.text.Component.text(message), net.kyori.adventure.text.Component.empty()));
|
|
}
|
|
}));
|
|
sessions.attachPartyDefeat(character->{var before=characterParties.partyOf(character).orElse(null);return characterParties.defeat(character).thenApply(outcome->{var bridge=partyAuditEvents;if(bridge!=null)bridge.finalDefeat(character,before,outcome);return outcome;});});
|
|
var reconcilingParties = characterParties;
|
|
var partyCharacters = reconcilingParties.all().stream().flatMap(party -> java.util.stream.Stream.concat(
|
|
party.members().stream(), party.invitations().stream().map(games.dmg.fantasystick.party.CharacterParty.Invitation::character))).distinct().toList();
|
|
java.util.concurrent.CompletableFuture.allOf(partyCharacters.stream().map(character -> characters.find(character)
|
|
.thenCompose(record -> record.isEmpty() || record.orElseThrow().dead()
|
|
? reconcilingParties.defeat(character) : java.util.concurrent.CompletableFuture.completedFuture(
|
|
games.dmg.fantasystick.party.CharacterPartyDirectory.Defeat.UNCHANGED))).toArray(java.util.concurrent.CompletableFuture[]::new))
|
|
.whenComplete((ignored, failure) -> { if (failure == null) reconcilingParties.resume();
|
|
else getLogger().log(Level.SEVERE, "Dead-character party reconciliation failed; party authority remains suspended", failure); });
|
|
partyEvents = new games.dmg.fantasystick.party.PartyEvents(parties);
|
|
partyCombat = new games.dmg.fantasystick.party.PartyCombat(parties, sessions);
|
|
combatExperience = new games.dmg.fantasystick.party.CombatExperience(characters, rules, rewardRules,
|
|
sessions, parties, coinSettings::rules, java.util.random.RandomGenerator.getDefault(),
|
|
Clock.systemUTC(), nextTick, id -> getServer().getPlayer(id),
|
|
problem -> getLogger().log(Level.WARNING, "Combat reward failed for character " + problem.character(), problem.cause()),
|
|
particleDelivery);
|
|
sessions.attachDefeatCapture(combatExperience::captureDownedDefeat);
|
|
sessions.attachDownedRewardAllocation(combatExperience::allocateDownedDefeat);
|
|
sessions.attachDownedDefeatRewards(combatExperience::settleDownedDefeat);
|
|
abilityRegistry = new games.dmg.fantasystick.ability.AbilityRegistry();
|
|
fireballSettings = new games.dmg.fantasystick.persistence.FireballSettings(
|
|
getDataFolder().toPath(), fireballConfiguration);
|
|
fireball = new games.dmg.fantasystick.ability.Fireball(fireballInitial, particleDelivery);
|
|
frostShardSettings = new games.dmg.fantasystick.persistence.FrostShardSettings(
|
|
getDataFolder().toPath(), frostShardConfiguration);
|
|
frostShard = new games.dmg.fantasystick.ability.FrostShard(frostShardInitial, particleDelivery);
|
|
longbowSettings = new games.dmg.fantasystick.persistence.LongbowSettings(
|
|
getDataFolder().toPath(), longbowConfiguration);
|
|
longbow = new games.dmg.fantasystick.ability.Longbow(longbowInitial);
|
|
quickstepSettings = new games.dmg.fantasystick.persistence.QuickstepSettings(
|
|
getDataFolder().toPath(), quickstepConfiguration);
|
|
quickstep = new games.dmg.fantasystick.ability.Quickstep(quickstepInitial,
|
|
event -> getServer().getPluginManager().callEvent(event));
|
|
secondWindSettings = new games.dmg.fantasystick.persistence.SecondWindSettings(
|
|
getDataFolder().toPath(), secondWindConfiguration);
|
|
secondWind = new games.dmg.fantasystick.ability.SecondWind(secondWindInitial, characters, sessions, nextTick,
|
|
event -> getServer().getPluginManager().callEvent(event), games.dmg.fantasystick.session.NativeHealthLimit::read);
|
|
stoneSkinSettings = new games.dmg.fantasystick.persistence.StoneSkinSettings(
|
|
getDataFolder().toPath(), stoneSkinConfiguration);
|
|
combatMitigation = new games.dmg.fantasystick.ability.CombatMitigation();
|
|
stoneSkin = new games.dmg.fantasystick.ability.StoneSkin(stoneSkinInitial, combatMitigation);
|
|
shieldBashSettings = new games.dmg.fantasystick.persistence.ShieldBashSettings(
|
|
getDataFolder().toPath(), shieldBashConfiguration);
|
|
shieldBash = new games.dmg.fantasystick.ability.ShieldBash(
|
|
shieldBashInitial,
|
|
event -> getServer().getPluginManager().callEvent(event));
|
|
outgoingDamageMitigation = new games.dmg.fantasystick.ability.OutgoingDamageMitigation(sessions, parties,
|
|
support -> combatExperience.support(support.target(), support.supportingCharacter(), support.aided(), support.amount()));
|
|
hexSettings = new games.dmg.fantasystick.persistence.HexSettings(getDataFolder().toPath(), hexConfiguration);
|
|
hex = new games.dmg.fantasystick.ability.Hex(hexInitial, outgoingDamageMitigation);
|
|
temporaryHealth = new games.dmg.fantasystick.ability.TemporaryHealth(sessions, parties, nextTick,
|
|
support -> combatExperience.support(support.target(), support.supportingCharacter(), support.aided(), support.amount()));
|
|
inspireSettings = new games.dmg.fantasystick.persistence.InspireSettings(getDataFolder().toPath(), inspireConfiguration);
|
|
inspire = new games.dmg.fantasystick.ability.Inspire(inspireInitial, temporaryHealth);
|
|
mendingLightSettings = new games.dmg.fantasystick.persistence.MendingLightSettings(
|
|
getDataFolder().toPath(), mendingLightConfiguration);
|
|
mendingLight = new games.dmg.fantasystick.ability.MendingLight(mendingLightInitial, characters, sessions, parties,
|
|
nextTick, event -> getServer().getPluginManager().callEvent(event),
|
|
games.dmg.fantasystick.session.NativeHealthLimit::read,
|
|
support -> combatExperience.support(support.supportingCharacter(), support.aided(), support.amount()));
|
|
purifySettings = new games.dmg.fantasystick.persistence.PurifySettings(getDataFolder().toPath(), purifyConfiguration);
|
|
purify = new games.dmg.fantasystick.ability.Purify(purifyInitial, sessions, parties,
|
|
support -> combatExperience.support(support.supportingCharacter(), support.aided(), support.amount()));
|
|
guardianBondSettings = new games.dmg.fantasystick.persistence.GuardianBondSettings(
|
|
getDataFolder().toPath(), guardianBondConfiguration);
|
|
guardianBond = new games.dmg.fantasystick.ability.GuardianBond(guardianBondInitial, sessions, parties,
|
|
support -> combatExperience.support(support.target(), support.supportingCharacter(), support.aided(), support.amount()));
|
|
outgoingDamageBonus = new games.dmg.fantasystick.ability.OutgoingDamageBonus(sessions, parties,
|
|
support -> combatExperience.support(support.target(), support.supportingCharacter(), support.aided(), support.amount()));
|
|
rallyingCrySettings = new games.dmg.fantasystick.persistence.RallyingCrySettings(
|
|
getDataFolder().toPath(), rallyingCryConfiguration);
|
|
rallyingCry = new games.dmg.fantasystick.ability.RallyingCry(
|
|
rallyingCryInitial, sessions, parties, outgoingDamageBonus);
|
|
frostNovaSettings = new games.dmg.fantasystick.persistence.FrostNovaSettings(
|
|
getDataFolder().toPath(), frostNovaConfiguration);
|
|
frostNova = new games.dmg.fantasystick.ability.FrostNova(frostNovaInitial, sessions, parties, particleDelivery);
|
|
chainLightningSettings = new games.dmg.fantasystick.persistence.ChainLightningSettings(
|
|
getDataFolder().toPath(), chainLightningConfiguration);
|
|
chainLightning = new games.dmg.fantasystick.ability.ChainLightning(
|
|
chainLightningInitial, sessions, parties, particleDelivery);
|
|
sanctuarySettings = new games.dmg.fantasystick.persistence.SanctuarySettings(
|
|
getDataFolder().toPath(), sanctuaryConfiguration);
|
|
sanctuary = new games.dmg.fantasystick.ability.Sanctuary(sanctuaryInitial, characters, sessions, parties,
|
|
combatMitigation, nextTick, event -> getServer().getPluginManager().callEvent(event),
|
|
games.dmg.fantasystick.session.NativeHealthLimit::read,
|
|
support -> combatExperience.support(support.supportingCharacter(), support.aided(), support.amount()),
|
|
particleDelivery);
|
|
warBannerSettings = new games.dmg.fantasystick.persistence.WarBannerSettings(
|
|
getDataFolder().toPath(), warBannerConfiguration);
|
|
warBanner = new games.dmg.fantasystick.ability.WarBanner(
|
|
warBannerInitial, sessions, parties, outgoingDamageBonus, particleDelivery);
|
|
meteorSettings = new games.dmg.fantasystick.persistence.MeteorSettings(getDataFolder().toPath(), meteorConfiguration);
|
|
meteor = new games.dmg.fantasystick.ability.Meteor(meteorInitial, sessions, parties, particleDelivery);
|
|
greatSword = new games.dmg.fantasystick.ability.GreatSword(greatSwordSettings);
|
|
revivals = new games.dmg.fantasystick.persistence.RevivalStore(getDataFolder().toPath());
|
|
revive = new games.dmg.fantasystick.ability.Revive(characters, revivals, Clock.systemUTC(), nextTick,
|
|
(size, title) -> getServer().createInventory(null, size, title),
|
|
problem -> getLogger().log(Level.WARNING, "Revive transition failed", problem));
|
|
revive.attachDowned(downedController,downedSettings::protection);
|
|
abilityRegistry.register(fireball.definition());
|
|
abilityRegistry.register(frostShard.definition());
|
|
abilityRegistry.register(longbow.definition());
|
|
abilityRegistry.register(quickstep.definition());
|
|
abilityRegistry.register(secondWind.definition());
|
|
abilityRegistry.register(stoneSkin.definition());
|
|
abilityRegistry.register(shieldBash.definition());
|
|
abilityRegistry.register(hex.definition());
|
|
abilityRegistry.register(inspire.definition());
|
|
abilityRegistry.register(mendingLight.definition());
|
|
abilityRegistry.register(purify.definition());
|
|
abilityRegistry.register(guardianBond.definition());
|
|
abilityRegistry.register(rallyingCry.definition());
|
|
abilityRegistry.register(frostNova.definition());
|
|
abilityRegistry.register(chainLightning.definition());
|
|
abilityRegistry.register(sanctuary.definition());
|
|
abilityRegistry.register(warBanner.definition());
|
|
abilityRegistry.register(meteor.definition());
|
|
abilityRegistry.register(greatSword.definition());
|
|
abilityRegistry.register(revive.definition());
|
|
sessions.attachAbilityRegistry(abilityRegistry);
|
|
var gearItems=new games.dmg.fantasystick.items.GearItems(this);sessions.attachGear(gearItems);
|
|
vitals = new games.dmg.fantasystick.session.SessionVitals();
|
|
sessions.attachVitals(vitals);
|
|
nutritionPolicy = new games.dmg.fantasystick.session.NutritionPolicy(sessions);
|
|
outOfCombatRecoverySettings = new games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings(
|
|
getDataFolder().toPath(), recoveryConfiguration);
|
|
outOfCombatRecovery = new games.dmg.fantasystick.session.OutOfCombatRecovery(recoveryInitial, characters, sessions,
|
|
Clock.systemUTC(), nextTick, event -> getServer().getPluginManager().callEvent(event),
|
|
games.dmg.fantasystick.session.NativeHealthLimit::read,
|
|
problem -> getLogger().log(Level.WARNING,
|
|
"Out-of-combat recovery failed for character " + problem.character(), problem.cause()), combatFeedback);
|
|
quickerRegenerationSettings = new games.dmg.fantasystick.persistence.QuickerRegenerationSettings(
|
|
getDataFolder().toPath(), quickerRegenerationInitial.bonus().toString());
|
|
quickerRegeneration = new games.dmg.fantasystick.passive.QuickerRegenerationI(quickerRegenerationInitial);
|
|
quickerRegenerationIISettings = new games.dmg.fantasystick.persistence.QuickerRegenerationIISettings(
|
|
getDataFolder().toPath(), quickerRegenerationIIInitial.bonus().toString());
|
|
quickerRegenerationII = new games.dmg.fantasystick.passive.QuickerRegenerationII(quickerRegenerationIIInitial);
|
|
healthStealSettings = new games.dmg.fantasystick.persistence.HealthStealSettings(
|
|
getDataFolder().toPath(), healthStealInitial.healing().toString());
|
|
healthSteal = new games.dmg.fantasystick.passive.HealthSteal(healthStealInitial, characters, sessions, nextTick,
|
|
event -> getServer().getPluginManager().callEvent(event), games.dmg.fantasystick.session.NativeHealthLimit::read,
|
|
problem -> getLogger().log(Level.WARNING, "Health Steal failed for character " + problem.character(), problem.cause()),
|
|
combatFeedback);
|
|
speedI = new games.dmg.fantasystick.passive.SpeedI(sessions);
|
|
lowLightVision = new games.dmg.fantasystick.passive.LowLightVision(sessions);
|
|
passiveRegistry = new games.dmg.fantasystick.passive.PassiveRegistry();
|
|
passiveRegistry.register(quickerRegeneration.definition());
|
|
passiveRegistry.register(quickerRegenerationII.definition());
|
|
passiveRegistry.register(healthSteal.definition());
|
|
passiveRegistry.register(speedI.definition());
|
|
passiveRegistry.register(lowLightVision.definition());
|
|
passiveRegistry.register(new games.dmg.fantasystick.passive.StickKnockback().definition());
|
|
passiveEngine = new games.dmg.fantasystick.passive.PassiveEngine(passiveRegistry, characters, sessions, nextTick,
|
|
problem -> getLogger().log(Level.WARNING, "Passive change failed for character " + problem.character()
|
|
+ "; passive " + problem.passive(), problem.cause()));
|
|
outOfCombatRecovery.attachBonusHealing(record -> {
|
|
if (!record.passives().contains(games.dmg.fantasystick.passive.QuickerRegenerationI.ID)) {
|
|
return java.math.BigInteger.ZERO;
|
|
}
|
|
var bonus = quickerRegeneration.bonus();
|
|
return record.passives().contains(games.dmg.fantasystick.passive.QuickerRegenerationII.ID)
|
|
? bonus.add(quickerRegenerationII.bonus()) : bonus;
|
|
});
|
|
games.dmg.fantasystick.ability.AbilityScheduler abilityScheduler = (delay, action) -> {
|
|
long ticks = Math.max(1, (delay.toNanos() + 49_999_999L) / 50_000_000L);
|
|
var task = getServer().getScheduler().runTaskLater(this, action, ticks);
|
|
return task::cancel;
|
|
};
|
|
adminReviveSettings = new games.dmg.fantasystick.persistence.AdminReviveSettings(getDataFolder().toPath(), adminReviveTimeout);
|
|
adminRevival = new games.dmg.fantasystick.session.AdminRevival(characters, revivals, Clock.systemUTC(), nextTick,
|
|
abilityScheduler::later, (size, title) -> getServer().createInventory(null, size, title),
|
|
problem -> getLogger().log(Level.WARNING, "Admin revival failed", problem));
|
|
abilityEngine = new games.dmg.fantasystick.ability.AbilityEngine(abilityRegistry, characters, sessions, parties,
|
|
Clock.systemUTC(), nextTick, abilityScheduler, report -> {var current=dungeonController;if(current!=null)current.accept(report);}, combatFeedback, trainingDummyController,
|
|
problem -> getLogger().log(Level.WARNING, "Ability engine failed for character " + problem.character()
|
|
+ "; ability " + problem.ability(), problem.cause()));
|
|
abilityEngine.install(this);
|
|
books = new games.dmg.fantasystick.book.CharacterBookController(characters, rules, sessions, nextTick,
|
|
problem -> getLogger().log(Level.WARNING, "Character book failed for player " + problem.player()
|
|
+ "; character " + problem.character(), problem.cause()), parties, getServer(), id -> {
|
|
String name = localPresentation.get().name(id);
|
|
var player = getServer().getPlayer(id);
|
|
return net.kyori.adventure.text.Component.text(name != null ? name : player == null ? id.toString() : player.getName());
|
|
}, abilityRegistry, abilityEngine, passiveRegistry, passiveEngine);
|
|
var localBasicAttack = new games.dmg.fantasystick.combat.BasicAttack(
|
|
sessions, Clock.systemUTC(), combatFeedback, trainingDummyController);
|
|
basicAttack = localBasicAttack;
|
|
sessionEvents = new EquipmentSessionEvents(sessions, nextTick, diagnostics, input -> {
|
|
books.accept(input);
|
|
localBasicAttack.accept(input);
|
|
abilityEngine.accept(input);
|
|
});
|
|
sessionEvents.attachAbilityRegistry(abilityRegistry);
|
|
sessionEvents.attachGear(gearItems);
|
|
partyManagement = new games.dmg.fantasystick.party.PartyManagement(characterParties, partyRegistrars,
|
|
characters, sessions, partyEconomySettings,
|
|
new games.dmg.fantasystick.persistence.PartyOperationStore(getDataFolder().toPath()), nextTick,
|
|
failure -> getLogger().log(Level.WARNING, "Party Registrar mutation failed", failure));
|
|
partyRegistrarMenus = new games.dmg.fantasystick.party.PartyRegistrarMenus(this, partyManagement);
|
|
partyRegistrarController = new games.dmg.fantasystick.party.PartyRegistrarController(this, partyRegistrars,
|
|
partyRegistrarMenus::open);
|
|
armorShop=new games.dmg.fantasystick.shop.ArmorShop(armorers,sessions,armorMarket,nextTick,
|
|
failure->getLogger().log(Level.WARNING,"Fantasy Armorer purchase failed",failure));
|
|
armorShopMenus=new games.dmg.fantasystick.shop.ArmorShopMenus(this,armorShop);
|
|
var localArmorMenus=armorShopMenus;
|
|
armorMarket.attachListener(catalog->{if(lifetime!=generation)return;try{nextTick.accept(()->{
|
|
if(lifetime==generation)localArmorMenus.refreshOpen();});}
|
|
catch(RuntimeException failure){if(lifetime==generation)getLogger().log(Level.WARNING,"Fantasy Armorer menu refresh failed",failure);}});
|
|
armorerController=new games.dmg.fantasystick.shop.FantasyArmorerController(this,armorers,armorShopMenus::open);
|
|
rareShop=new games.dmg.fantasystick.shop.RareShop(rareMerchants,sessions,rareMarket,rareInventory,nextTick,failure->getLogger().log(Level.WARNING,"Rare Items purchase failed",failure));
|
|
rareShopMenus=new games.dmg.fantasystick.shop.RareShopMenus(this,rareShop);var localRareMenus=rareShopMenus;
|
|
rareMarket.attachListener(catalog->{if(lifetime!=generation)return;if(rareEvents!=null)rareEvents.catalogRefreshed(catalog);try{nextTick.accept(()->{if(lifetime==generation)localRareMenus.refreshOpen();});}catch(RuntimeException failure){if(lifetime==generation)getLogger().log(Level.WARNING,"Rare Items menu refresh failed",failure);}});
|
|
rareMerchantController=new games.dmg.fantasystick.shop.RareMerchantController(this,rareMerchants,rareShopMenus::open);
|
|
rarePotions=new games.dmg.fantasystick.shop.RarePotionService(rareInventory,rareSettings,characters,sessions,event->getServer().getPluginManager().callEvent(event),nextTick,failure->getLogger().log(Level.WARNING,"Rare potion use failed",failure));
|
|
rareReskills=new games.dmg.fantasystick.shop.RareReskillService(rareInventory,characters,sessions,nextTick,record->{for(String ability:record.learned())abilityEngine.remove(record.id(),ability);speedI.sweep();lowLightVision.sweep();},failure->getLogger().log(Level.WARNING,"Rare Reskill use failed",failure));
|
|
rareMagicCores=new games.dmg.fantasystick.shop.RareMagicCoreService(rareInventory,characters,sessions,nextTick,failure->getLogger().log(Level.WARNING,"Rare Magic Core use failed",failure));
|
|
rarePotions.install();rareReskills.install();rareMagicCores.install();books.attachRareInventory(rareInventory,rarePotions,rareReskills,rareMagicCores);
|
|
adventureQuestController = new games.dmg.fantasystick.adventure.AdventureQuestController(this,
|
|
adventureQuests, adventureQuestSettings, sessions, parties, characters, rules, nextTick,
|
|
Clock.systemUTC(), java.util.random.RandomGenerator.getDefault(), particleDelivery);
|
|
adventureQuestCommands = new games.dmg.fantasystick.adventure.AdventureQuestCommands(
|
|
this, adventureQuests, adventureQuestController, nextTick);
|
|
fishing.registerLabels(value->adventureQuests.findSite(value.site()).map(games.dmg.fantasystick.adventure.AdventureQuestState.Site::fishing).filter(java.util.Objects::nonNull).filter(definition->definition.itemId().equals(value.item())).map(games.dmg.fantasystick.adventure.AdventureQuestState.FishingDefinition::itemName).orElse(value.name()));
|
|
fishingController=new games.dmg.fantasystick.adventure.FishingController(this,adventureQuests,fishing,
|
|
adventureQuestSettings,sessions,parties,characters,rules,nextTick,java.util.random.RandomGenerator.getDefault(),
|
|
failure->getLogger().log(Level.WARNING,"Fishing "+failure.phase()+" failed for character "+failure.character()+"; operation "+failure.operation(),failure.cause()));
|
|
adventureQuestController.registerFishing(fishingController);adventureQuestController.registerResetParticipant(fishingController);books.attachFishingInventory(fishing);
|
|
sessionEvents.attachNativeUseControl(fishingController::nativeUse);
|
|
var bossRecoverySettings=outOfCombatRecoverySettings;var bossQuickerRegeneration=quickerRegeneration;var bossQuickerRegenerationII=quickerRegenerationII;var bossHealthStealSettings=healthStealSettings;
|
|
dungeonController = new games.dmg.fantasystick.dungeon.DungeonController(this,dungeons,adventureQuests,sessions,parties,characters,rules,nextTick,java.util.random.RandomGenerator.getDefault(),abilityRegistry,passiveRegistry,bossRecoverySettings::settings,record->{if(!record.passives().contains(games.dmg.fantasystick.passive.QuickerRegenerationI.ID))return java.math.BigInteger.ZERO;var bonus=bossQuickerRegeneration.bonus();return record.passives().contains(games.dmg.fantasystick.passive.QuickerRegenerationII.ID)?bonus.add(bossQuickerRegenerationII.bonus()):bonus;},()->bossHealthStealSettings.settings().healing(),particleDelivery);
|
|
dungeonController.registerFishing(fishingController);
|
|
var custodyDirectory=dungeons;var downedDirectory=downed;
|
|
java.util.function.Predicate<java.util.UUID> unavailableCharacter=character->custodyDirectory.custody(character).isPresent()||downedDirectory.all().stream().anyMatch(value->value.character().equals(character)&&value.phase()==games.dmg.fantasystick.session.DownedEpisode.Phase.PENDING);
|
|
sessions.attachUnavailableCharacter(unavailableCharacter);
|
|
characters.attachUnavailableCharacter(unavailableCharacter);
|
|
characterParties.attachUnavailableCharacter(unavailableCharacter);
|
|
dungeonCommands = new games.dmg.fantasystick.dungeon.DungeonCommands(this,dungeons,dungeonController,adventureQuests,nextTick,characters::find,character->sessions.activeCharacter(character).isPresent(),character->characterParties.partyOf(character).isPresent());
|
|
adventureQuests.registerDungeonRewards(site->dungeons.find(site.id()).map(value->new games.dmg.fantasystick.adventure.AdventureQuestDirectory.Reward(value.maximumXp(),value.maximumCoins())).orElse(new games.dmg.fantasystick.adventure.AdventureQuestDirectory.Reward(java.math.BigInteger.ZERO,java.math.BigInteger.ZERO)));
|
|
adventureQuests.registerDungeonSites(()->dungeons.snapshot().dungeons().stream().filter(value->dungeons.eligibleForFutureOffer(value.id())).map(value->new games.dmg.fantasystick.adventure.AdventureQuestState.Site(value.id(),games.dmg.fantasystick.adventure.AdventureQuestState.SiteType.DUNGEON,value.name(),value.world(),value.entrance().x(),value.entrance().y(),value.entrance().z(),null,value.participationMode())).toList());
|
|
adventureQuests.registerDungeonAvailability(site->{var definition=dungeons.find(site.id());if(definition.isEmpty()||!definition.orElseThrow().enabled())return false;var catalog=adventureQuests.snapshot().catalog();return catalog==null||dungeons.runView(site.id(),catalog.revision()).map(run->!run.defeated()).orElse(true);});
|
|
adventureQuestController.registerResetParticipant(dungeonController);
|
|
adventureQuestController.registerDungeonRoomPresence((dungeon,location)->location.getWorld()!=null&&dungeons.find(dungeon).filter(value->value.world().equals(location.getWorld().getUID())).isPresent()&&dungeons.roomAt(dungeon,location.getBlockX(),location.getBlockY(),location.getBlockZ()).isPresent());
|
|
combatExperience.attachManagedOrigins(entity->adventureQuestController.encounterOrigin(entity).or(()->dungeonController.encounterOrigin(entity)));
|
|
combatExperience.attachManagedSettlement(dungeonController::settleKill);
|
|
combatExperience.attachExcluded(adventureQuestController::managed);
|
|
sessionEvents.attachManagedInteractionTarget(entity -> partyRegistrarController.tagged(entity)
|
|
|| armorerController.tagged(entity) || rareMerchantController.tagged(entity) || adventureQuestController.giver(entity));
|
|
admin = new EquipmentAdminCommand(receipts, sessions, getServer(), nextTick,
|
|
problem -> getLogger().log(Level.WARNING, "Equipment admin " + problem.operation()
|
|
+ " for player " + problem.player(), problem.cause()), adventureSettings,
|
|
frostShardSettings, frostShard, longbowSettings, longbow,
|
|
quickstepSettings, quickstep, secondWindSettings, secondWind,
|
|
stoneSkinSettings, stoneSkin, shieldBashSettings, shieldBash, hexSettings, hex,
|
|
inspireSettings, inspire, abilityRegistry);
|
|
admin.attachFireball(fireballSettings, fireball);
|
|
admin.attachMendingLight(mendingLightSettings, mendingLight);
|
|
admin.attachPurify(purifySettings, purify);
|
|
admin.attachGuardianBond(guardianBondSettings, guardianBond);
|
|
admin.attachRallyingCry(rallyingCrySettings, rallyingCry);
|
|
admin.attachFrostNova(frostNovaSettings, frostNova);
|
|
admin.attachChainLightning(chainLightningSettings, chainLightning);
|
|
admin.attachSanctuary(sanctuarySettings, sanctuary);
|
|
admin.attachWarBanner(warBannerSettings, warBanner);
|
|
admin.attachMeteor(meteorSettings, meteor);
|
|
admin.attachAdminRevival(adminRevival, adminReviveSettings);
|
|
admin.attachExperienceGrant(new games.dmg.fantasystick.session.AdminExperienceGrant(
|
|
characters, rules, sessions, nextTick, getServer()::getPlayer,
|
|
problem -> getLogger().log(Level.WARNING,
|
|
"Admin experience grant for character " + problem.character(), problem.cause()), particleDelivery));
|
|
admin.attachSwitchDelay(switchDelaySettings);
|
|
admin.attachRoleplaySettings(roleplaySettings);
|
|
admin.attachPartySettings(partySettings);
|
|
admin.attachPartyEconomySettings(partyEconomySettings);
|
|
admin.attachPartyRegistrars(partyRegistrars, partyRegistrarController);
|
|
admin.attachTrainingDummies(trainingDummies, trainingDummyController);
|
|
admin.attachGearSettings(gearSettings);
|
|
admin.attachArmorers(armorers,armorerController);
|
|
admin.attachArmorMarket(armorMarket);
|
|
admin.attachRareMarket(rareMerchants,rareMerchantController,rareMarket,rareSettings);
|
|
admin.attachDownedSettings(downedSettings);
|
|
admin.attachCoinSettings(coinSettings);
|
|
admin.attachHardMobXpSettings(hardMobXpSettings, combatExperience);
|
|
admin.attachAdventureQuests(adventureQuestCommands, adventureQuestSettings);
|
|
admin.attachDungeons(dungeonCommands);
|
|
admin.attachSheetResourcePack(sheetResourcePackSettings, sheetResourcePack);
|
|
admin.attachOutOfCombatRecovery(outOfCombatRecoverySettings, outOfCombatRecovery);
|
|
admin.attachQuickerRegeneration(quickerRegenerationSettings, quickerRegeneration, passiveRegistry);
|
|
admin.attachQuickerRegenerationII(quickerRegenerationIISettings, quickerRegenerationII, passiveRegistry);
|
|
admin.attachHealthSteal(healthStealSettings, healthSteal, passiveRegistry);
|
|
admin.attachCharacterIssuer(new games.dmg.fantasystick.session.AdminCharacterIssuer(characters,
|
|
() -> factory.create(rules), nextTick, problem -> getLogger().log(Level.WARNING,
|
|
"Admin character issue " + problem.operation() + " for player " + problem.player()
|
|
+ "; character " + problem.character(), problem.cause())));
|
|
admin.attachCharacterBooks(books, characters);
|
|
characterRecovery = new games.dmg.fantasystick.session.AdminCharacterRecovery(
|
|
characters, receipts, revivals, sessions, getServer(), nextTick,
|
|
problem -> getLogger().log(Level.WARNING,
|
|
"Saved character recovery " + problem.operation() + " for character "
|
|
+ problem.character() + " and recipient " + problem.recipient(), problem.cause()));
|
|
admin.attachCharacterRecovery(characterRecovery);
|
|
var playerRoot = new games.dmg.fantasystick.session.FantasyPlayerCommand(
|
|
admin, feedbackCommand, particlesCommand);
|
|
var playerCommand = java.util.Objects.requireNonNull(getCommand("fstick"),
|
|
"Missing packaged fstick command");
|
|
playerCommand.setExecutor(playerRoot);
|
|
playerCommand.setTabCompleter(playerRoot);
|
|
var adminCommand = java.util.Objects.requireNonNull(getCommand("fstickadmin"),
|
|
"Missing packaged fstickadmin command");
|
|
adminCommand.setExecutor(admin);
|
|
adminCommand.setTabCompleter(admin);
|
|
try {
|
|
eventLog = games.dmg.fantasystick.events.LocalEventLog.open(getDataFolder().toPath(), Clock.systemUTC(),
|
|
new games.dmg.fantasystick.events.LocalEventLog.RuntimeInfo("FantasyStick",
|
|
getServer().getVersion(), getServer().getMinecraftVersion(), getDescription().getVersion()), 1024, 134_217_728L,
|
|
message -> getLogger().warning(message));
|
|
eventCapture = new games.dmg.fantasystick.events.EventCaptureListener(eventLog, sessions, Clock.systemUTC());
|
|
preferenceEvents = new games.dmg.fantasystick.events.PreferenceEventBridge(
|
|
eventLog::emit, Clock.systemUTC(), sessions, feedbackPreferences,
|
|
failure -> getLogger().log(Level.WARNING, "Preference event publication proof failed", failure));
|
|
particlesCommand.attachEvents(preferenceEvents);
|
|
feedbackCommand.attachEvents(preferenceEvents);
|
|
eventCapture.excludeOwnedDamage(fireball::ownsAcceptedDamage);
|
|
eventCapture.excludeOwnedDamage(guardianBond::ownsAcceptedRedirect);
|
|
eventCapture.excludeOwnedDamage(frostNova::ownsAcceptedDamage);
|
|
eventCapture.excludeOwnedDamage(chainLightning::ownsAcceptedDamage);
|
|
eventCapture.excludeOwnedDamage(meteor::ownsAcceptedDamage);
|
|
downedEvents = new games.dmg.fantasystick.events.DownedEventBridge(eventLog::emit, Clock.systemUTC());
|
|
rareEvents = new games.dmg.fantasystick.events.RareEventBridge(eventLog::emit, Clock.systemUTC());rareShop.attachEvents(rareEvents);
|
|
bookEvents = new games.dmg.fantasystick.events.BookEventBridge(eventLog::emit, Clock.systemUTC());books.attachEvents(bookEvents);
|
|
progressionEvents = new games.dmg.fantasystick.events.ProgressionEventBridge(eventLog::emit, Clock.systemUTC());books.attachProgressionEvents(progressionEvents);
|
|
abilityEvents = new games.dmg.fantasystick.events.AbilityEventBridge(eventLog::emit, Clock.systemUTC());books.attachAbilityEvents(abilityEvents);
|
|
abilityEngine.attachCastEvents(new games.dmg.fantasystick.events.AbilityCastEventBridge(eventLog::emit, Clock.systemUTC()));
|
|
abilityEngine.enableCastEventsFor("fireball");
|
|
abilityEngine.enableCastEventsFor("mending_light");
|
|
abilityEngine.enableCastEventsFor("purify");
|
|
abilityEngine.enableCastEventsFor("guardian_bond");
|
|
abilityEngine.enableCastEventsFor("rallying_cry");
|
|
abilityEngine.enableCastEventsFor("frost_nova");
|
|
abilityEngine.enableCastEventsFor("chain_lightning");
|
|
abilityEngine.enableCastEventsFor("sanctuary");
|
|
abilityEngine.enableCastEventsFor("war_banner");
|
|
abilityEngine.enableCastEventsFor("meteor");
|
|
admin.attachAbilityConfigEvents(new games.dmg.fantasystick.events.AbilityConfigEventBridge(eventLog::emit, Clock.systemUTC()));
|
|
passiveEvents = new games.dmg.fantasystick.events.PassiveEventBridge(eventLog::emit, Clock.systemUTC());books.attachPassiveEvents(passiveEvents);admin.attachPassiveEvents(passiveEvents);
|
|
recoveryEvents = new games.dmg.fantasystick.events.RecoveryEventBridge(eventLog::emit, Clock.systemUTC());outOfCombatRecovery.attachEvents(recoveryEvents,record->record.passives().contains(games.dmg.fantasystick.passive.QuickerRegenerationI.ID)?quickerRegeneration.bonus():java.math.BigInteger.ZERO);
|
|
reviveEvents = new games.dmg.fantasystick.events.ReviveEventBridge(eventLog::emit, Clock.systemUTC());revive.attachEvents(reviveEvents);
|
|
partyAuditEvents = new games.dmg.fantasystick.events.PartyEventBridge(eventLog::emit, Clock.systemUTC());partyManagement.attachEvents(partyAuditEvents);admin.attachPartyEvents(partyAuditEvents);
|
|
combatRewardEvents = new games.dmg.fantasystick.events.CombatRewardEventBridge(eventLog::emit,Clock.systemUTC());combatExperience.attachEvents(combatRewardEvents);
|
|
coinEvents = new games.dmg.fantasystick.events.CoinEventBridge(eventLog::emit,Clock.systemUTC());characters.attachCoinEvents(coinEvents);admin.attachCoinEvents(coinEvents);
|
|
sessionAuditEvents = new games.dmg.fantasystick.events.SessionEventBridge(eventLog::emit,Clock.systemUTC());sessions.attachSessionEvents(sessionAuditEvents);
|
|
switchAuditEvents = new games.dmg.fantasystick.events.SwitchDelayEventBridge(
|
|
eventLog::emit, Clock.systemUTC(), getDataFolder().toPath(),
|
|
failure -> getLogger().log(Level.WARNING, "Switch deadline event intent failed", failure));
|
|
sessions.attachSwitchEvents(switchAuditEvents);
|
|
var identitySessions = sessions;
|
|
identityAuditEvents = new games.dmg.fantasystick.events.CharacterIdentityEventBridge(
|
|
eventLog::emit, Clock.systemUTC(), getDataFolder().toPath(),
|
|
playerId -> identitySessions.active(playerId).map(games.dmg.fantasystick.session.EquipmentSessions.Active::session),
|
|
failure -> getLogger().log(Level.WARNING, "Character identity event intent failed", failure));
|
|
crafting.attachIdentityEvents(identityAuditEvents);
|
|
anvilNames.attachIdentityEvents(identityAuditEvents);
|
|
sessions.attachIdentityEvents(identityAuditEvents);
|
|
equipmentAuditEvents = new games.dmg.fantasystick.events.EquipmentEventBridge(
|
|
eventLog::emit, Clock.systemUTC(), getDataFolder().toPath(),
|
|
failure -> getLogger().log(Level.WARNING, "Equipment event intent failed", failure));
|
|
sessions.attachEquipmentEvents(equipmentAuditEvents);
|
|
sessions.attachDownedEvents(downedEvents);
|
|
downedController.attachEvents(downedEvents);
|
|
revive.attachDownedEvents(downedEvents);
|
|
admin.attachDownedEvents(downedEvents);
|
|
getServer().getPluginManager().registerEvents(eventCapture, this);
|
|
messageAuditEvents = new games.dmg.fantasystick.events.MessageEventBridge(
|
|
id -> presentation.snapshot().get(id),sessionAuditEvents,eventLog::emit,Clock.systemUTC());
|
|
getServer().getPluginManager().registerEvents(messageAuditEvents,this);
|
|
} catch (java.io.IOException failure) {
|
|
eventLog = null; eventCapture = null; downedEvents = null; rareEvents = null; bookEvents = null; progressionEvents = null; reviveEvents = null; partyAuditEvents = null; combatRewardEvents = null; coinEvents = null; sessionAuditEvents = null; switchAuditEvents = null; identityAuditEvents = null; equipmentAuditEvents = null; messageAuditEvents = null;
|
|
getLogger().log(Level.WARNING,"Fantasy Stick local events are unavailable; gameplay remains enabled",failure);
|
|
}
|
|
getServer().getPluginManager().registerEvents(crafting, this);
|
|
getServer().getPluginManager().registerEvents(guard, this);
|
|
getServer().getPluginManager().registerEvents(anvilNames, this);
|
|
getServer().getPluginManager().registerEvents(sessionEvents, this);
|
|
getServer().getPluginManager().registerEvents(downedController, this);
|
|
getServer().getPluginManager().registerEvents(characterRecovery, this);
|
|
getServer().getPluginManager().registerEvents(chatNames, this);
|
|
getServer().getPluginManager().registerEvents(partyEvents, this);
|
|
getServer().getPluginManager().registerEvents(partyCombat, this);
|
|
getServer().getPluginManager().registerEvents(partyRegistrarController, this);
|
|
getServer().getPluginManager().registerEvents(trainingDummyController, this);
|
|
getServer().getPluginManager().registerEvents(partyRegistrarMenus, this);
|
|
getServer().getPluginManager().registerEvents(armorerController,this);
|
|
getServer().getPluginManager().registerEvents(armorShopMenus,this);
|
|
getServer().getPluginManager().registerEvents(rareMerchantController,this);
|
|
getServer().getPluginManager().registerEvents(rareShopMenus,this);
|
|
getServer().getPluginManager().registerEvents(adventureQuestController,this);
|
|
getServer().getPluginManager().registerEvents(fishingController,this);
|
|
getServer().getPluginManager().registerEvents(dungeonController,this);
|
|
downedController.install();
|
|
partyRegistrarController.install();
|
|
trainingDummyController.install();
|
|
armorerController.install();
|
|
rareMerchantController.install();
|
|
dungeonController.install();
|
|
adventureQuestController.install();
|
|
fishingController.install();
|
|
var localArmorMarket=armorMarket;
|
|
armorMarketPulse=getServer().getScheduler().runTaskTimer(this,()->{if(lifetime!=generation)return;
|
|
localArmorMarket.current().whenComplete((catalog,failure)->{
|
|
if(failure!=null&&lifetime==generation)getLogger().log(Level.WARNING,"Scheduled Fantasy Armorer restock check failed",failure);});},20L,20L);
|
|
armorMenuPulse=getServer().getScheduler().runTaskTimer(this,localArmorMenus::refreshOpen,1200L,1200L);
|
|
var localRareMarket=rareMarket;rareMarketPulse=getServer().getScheduler().runTaskTimer(this,()->{if(lifetime!=generation)return;localRareMarket.current().whenComplete((catalog,failure)->{if(failure!=null&&lifetime==generation)getLogger().log(Level.WARNING,"Scheduled Rare Items restock check failed",failure);});},20L,20L);
|
|
rareMenuPulse=getServer().getScheduler().runTaskTimer(this,localRareMenus::refreshOpen,1200L,1200L);
|
|
partyCombat.install(this);
|
|
getServer().getPluginManager().registerEvents(healthSteal, this);
|
|
getServer().getPluginManager().registerEvents(combatExperience, this);
|
|
combatExperience.install(this);
|
|
getServer().getPluginManager().registerEvents(fireball, this);
|
|
getServer().getPluginManager().registerEvents(frostShard, this);
|
|
getServer().getPluginManager().registerEvents(frostNova, this);
|
|
getServer().getPluginManager().registerEvents(chainLightning, this);
|
|
getServer().getPluginManager().registerEvents(meteor, this);
|
|
getServer().getPluginManager().registerEvents(longbow, this);
|
|
getServer().getPluginManager().registerEvents(quickstep, this);
|
|
getServer().getPluginManager().registerEvents(combatMitigation, this);
|
|
getServer().getPluginManager().registerEvents(guardianBond, this);
|
|
guardianBond.install(this);
|
|
getServer().getPluginManager().registerEvents(shieldBash, this);
|
|
getServer().getPluginManager().registerEvents(outgoingDamageMitigation, this);
|
|
getServer().getPluginManager().registerEvents(outgoingDamageBonus, this);
|
|
rallyingCry.install(this);
|
|
warBanner.install(this);
|
|
getServer().getPluginManager().registerEvents(temporaryHealth, this);
|
|
getServer().getPluginManager().registerEvents(greatSword, this);
|
|
getServer().getPluginManager().registerEvents(revive, this);
|
|
getServer().getPluginManager().registerEvents(adminRevival, this);
|
|
getServer().getPluginManager().registerEvents(localBasicAttack, this);
|
|
getServer().getPluginManager().registerEvents(nutritionPolicy, this);
|
|
getServer().getPluginManager().registerEvents(outOfCombatRecovery, this);
|
|
outOfCombatRecovery.install(this);
|
|
speedI.install(this);
|
|
lowLightVision.install(this);
|
|
getServer().getPluginManager().registerEvents(books, this);
|
|
getServer().getPluginManager().registerEvents(gameModes, this);
|
|
getServer().getPluginManager().registerEvents(sheetResourcePack, this);
|
|
sessionVisuals = new games.dmg.fantasystick.session.SessionVisuals(sessions, particleDelivery,
|
|
failure -> getLogger().log(Level.WARNING, "Fantasy session particle delivery failed", failure));
|
|
sessionVisuals.install(this);
|
|
recipeRegistered = getServer().addRecipe(new CharacterSheets().recipe());
|
|
if (!recipeRegistered) throw new IllegalStateException("Character-sheet recipe key is already registered");
|
|
recipeDiscovery = new RecipeDiscovery(CharacterSheets.RECIPE, getLogger());
|
|
if (eventLog != null) {
|
|
var recipeEvents = new games.dmg.fantasystick.events.RecipeDiscoveryEventBridge(
|
|
eventLog::emit, Clock.systemUTC(), getDataFolder().toPath(),
|
|
failure -> getLogger().log(Level.WARNING, "Recipe discovery event intent failed", failure));
|
|
recipeDiscovery.attachEvents(recipeEvents);
|
|
eventLog.ready(); // Queue startup recovery before any recipe event handoff.
|
|
var replaySwitchEvents = switchAuditEvents;
|
|
switchAuditDrain.whenComplete((ignored, failure) -> {
|
|
if (failure != null) getLogger().log(Level.WARNING, "Previous switch event intent drain failed", failure);
|
|
if (replaySwitchEvents != null) replaySwitchEvents.replay();
|
|
});
|
|
var replayIdentityEvents = identityAuditEvents;
|
|
identityAuditDrain.whenComplete((ignored, failure) -> {
|
|
if (failure != null) getLogger().log(Level.WARNING, "Previous identity event intent drain failed", failure);
|
|
if (replayIdentityEvents != null) replayIdentityEvents.replay();
|
|
});
|
|
var replayEquipmentEvents = equipmentAuditEvents;
|
|
equipmentAuditDrain.whenComplete((ignored, failure) -> {
|
|
if (failure != null) getLogger().log(Level.WARNING, "Previous equipment event intent drain failed", failure);
|
|
if (replayEquipmentEvents != null) replayEquipmentEvents.replay();
|
|
});
|
|
recipeEvents.replay(); // Serial worker replays old intents before new discoveries are captured.
|
|
}
|
|
getServer().getPluginManager().registerEvents(recipeDiscovery, this);
|
|
var onlinePlayers = List.copyOf(getServer().getOnlinePlayers());
|
|
recipeDiscovery.discoverAll(onlinePlayers);
|
|
for (var player : onlinePlayers) { sessions.arrive(player); revive.reconcile(player); }
|
|
sheetResourcePack.deliverAll(onlinePlayers);
|
|
if (eventLog != null) {
|
|
var preferenceReplay = preferenceEvents;
|
|
var savedPreferences = feedbackPreferences;
|
|
eventLog.ready().whenComplete((delivery, failure) -> {
|
|
if (failure == null && delivery != games.dmg.fantasystick.events.LocalEventLog.Delivery.REJECTED
|
|
&& preferenceReplay != null && savedPreferences != null)
|
|
for (var pendingPreference : savedPreferences.pendingEvents()) preferenceReplay.replay(pendingPreference);
|
|
});
|
|
}
|
|
} catch (RuntimeException | LinkageError failure) {
|
|
try { onDisable(); }
|
|
catch (RuntimeException | LinkageError cleanupFailure) { failure.addSuppressed(cleanupFailure); }
|
|
throw failure;
|
|
}
|
|
}
|
|
|
|
@Override public void onDisable() {
|
|
lifetime = null;
|
|
// Detach this enable's resources before any native callback can reenter disable.
|
|
var closingPresentation = presentation; presentation = null;
|
|
var closingProtocol = protocolPresentation; protocolPresentation = null;
|
|
var closingChat = chatNames; chatNames = null;
|
|
var closingAdmin = admin; admin = null;
|
|
var closingCharacterRecovery = characterRecovery; characterRecovery = null;
|
|
var closingFeedbackCommand = feedbackCommand; feedbackCommand = null;
|
|
var closingParticlesCommand = particlesCommand; particlesCommand = null;
|
|
var closingFeedbackPreferences = feedbackPreferences; feedbackPreferences = null;
|
|
particleDelivery = null;
|
|
combatFeedback = null;
|
|
var closingEvents = sessionEvents; sessionEvents = null;
|
|
var closingEventLog = eventLog; eventLog = null; preferenceEvents = null;
|
|
var closingSwitchAuditEvents = switchAuditEvents; switchAuditEvents = null;
|
|
var closingIdentityAuditEvents = identityAuditEvents; identityAuditEvents = null;
|
|
var closingEquipmentAuditEvents = equipmentAuditEvents; equipmentAuditEvents = null;
|
|
var closingEventCapture = eventCapture; eventCapture = null; var closingMessageAuditEvents = messageAuditEvents; messageAuditEvents = null; downedEvents = null; rareEvents = null; bookEvents = null; progressionEvents = null; abilityEvents = null; passiveEvents = null; recoveryEvents = null; reviveEvents = null; partyAuditEvents = null; combatRewardEvents = null; coinEvents = null; sessionAuditEvents = null;
|
|
var closingBooks = books; books = null;
|
|
var closingPartyEvents = partyEvents; partyEvents = null;
|
|
var closingPartyCombat = partyCombat; partyCombat = null;
|
|
var closingParties = parties; parties = null;
|
|
var closingCharacterParties = characterParties; characterParties = null;
|
|
var closingPartyRegistrars = partyRegistrars; partyRegistrars = null;
|
|
var closingPartyRegistrarController = partyRegistrarController; partyRegistrarController = null;
|
|
var closingTrainingDummies = trainingDummies; trainingDummies = null;
|
|
var closingTrainingDummyController = trainingDummyController; trainingDummyController = null;
|
|
var closingAdventureQuests = adventureQuests; adventureQuests = null;
|
|
var closingAdventureQuestController = adventureQuestController; adventureQuestController = null;
|
|
adventureQuestCommands = null;
|
|
var closingFishing=fishing;fishing=null;var closingFishingController=fishingController;fishingController=null;
|
|
var closingDungeons=dungeons;dungeons=null;var closingDowned=downed;downed=null;var closingDownedController=downedController;downedController=null;phoenixDowns=null;var closingDungeonController=dungeonController;dungeonController=null;dungeonCommands=null;
|
|
var closingPartyRegistrarMenus = partyRegistrarMenus; partyRegistrarMenus = null;
|
|
var closingPartyManagement = partyManagement; partyManagement = null;
|
|
var closingArmorers=armorers;armorers=null;var closingArmorerController=armorerController;armorerController=null;
|
|
var closingArmorShopMenus=armorShopMenus;armorShopMenus=null;armorShop=null;
|
|
var closingArmorMarket=armorMarket;armorMarket=null;var closingArmorMarketPulse=armorMarketPulse;armorMarketPulse=null;
|
|
var closingArmorMenuPulse=armorMenuPulse;armorMenuPulse=null;
|
|
var closingRareSettings=rareSettings;rareSettings=null;var closingDownedSettings=downedSettings;downedSettings=null;var closingRareInventory=rareInventory;rareInventory=null;
|
|
var closingRareMerchants=rareMerchants;rareMerchants=null;var closingRareMerchantController=rareMerchantController;rareMerchantController=null;
|
|
var closingRareMarket=rareMarket;rareMarket=null;var closingRareShopMenus=rareShopMenus;rareShopMenus=null;rareShop=null;rarePotions=null;rareReskills=null;rareMagicCores=null;
|
|
var closingRareMarketPulse=rareMarketPulse;rareMarketPulse=null;var closingRareMenuPulse=rareMenuPulse;rareMenuPulse=null;
|
|
var closingCrafting = crafting; crafting = null;
|
|
var closingGuard = guard; guard = null;
|
|
var closingAnvil = anvilNames; anvilNames = null;
|
|
var closingRecipeDiscovery = recipeDiscovery; recipeDiscovery = null;
|
|
var closingSessions = sessions; sessions = null;
|
|
var closingReceipts = receipts; receipts = null;
|
|
var closingCharacters = characters; characters = null;
|
|
var closingSettings = adventureSettings; adventureSettings = null;
|
|
var closingModes = gameModes; gameModes = null;
|
|
var closingVitals = vitals; vitals = null;
|
|
var closingVisuals = sessionVisuals; sessionVisuals = null;
|
|
var closingBasicAttack = basicAttack; basicAttack = null;
|
|
var closingCombatExperience = combatExperience; combatExperience = null;
|
|
var closingAbilityEngine = abilityEngine; abilityEngine = null;
|
|
var closingFireball = fireball; fireball = null;
|
|
var closingFireballSettings = fireballSettings; fireballSettings = null;
|
|
var closingFrostShard = frostShard; frostShard = null;
|
|
var closingFrostSettings = frostShardSettings; frostShardSettings = null;
|
|
var closingLongbow = longbow; longbow = null;
|
|
var closingLongbowSettings = longbowSettings; longbowSettings = null;
|
|
var closingQuickstep = quickstep; quickstep = null;
|
|
var closingQuickstepSettings = quickstepSettings; quickstepSettings = null;
|
|
secondWind = null;
|
|
var closingStoneSkin = stoneSkin; stoneSkin = null;
|
|
var closingShieldBash = shieldBash; shieldBash = null;
|
|
var closingHex = hex; hex = null;
|
|
var closingInspire = inspire; inspire = null;
|
|
var closingInspireSettings = inspireSettings; inspireSettings = null;
|
|
mendingLight = null;
|
|
var closingMendingLightSettings = mendingLightSettings; mendingLightSettings = null;
|
|
purify = null;
|
|
var closingPurifySettings = purifySettings; purifySettings = null;
|
|
var closingGuardianBond = guardianBond; guardianBond = null;
|
|
var closingGuardianBondSettings = guardianBondSettings; guardianBondSettings = null;
|
|
var closingRallyingCry = rallyingCry; rallyingCry = null;
|
|
var closingRallyingCrySettings = rallyingCrySettings; rallyingCrySettings = null;
|
|
var closingFrostNova = frostNova; frostNova = null;
|
|
var closingFrostNovaSettings = frostNovaSettings; frostNovaSettings = null;
|
|
var closingChainLightning = chainLightning; chainLightning = null;
|
|
var closingChainLightningSettings = chainLightningSettings; chainLightningSettings = null;
|
|
var closingSanctuary = sanctuary; sanctuary = null;
|
|
var closingSanctuarySettings = sanctuarySettings; sanctuarySettings = null;
|
|
var closingWarBanner = warBanner; warBanner = null;
|
|
var closingWarBannerSettings = warBannerSettings; warBannerSettings = null;
|
|
var closingMeteor = meteor; meteor = null;
|
|
var closingMeteorSettings = meteorSettings; meteorSettings = null;
|
|
var closingOutgoingDamageBonus = outgoingDamageBonus; outgoingDamageBonus = null;
|
|
var closingAdminRevival = adminRevival; adminRevival = null;
|
|
var closingAdminReviveSettings = adminReviveSettings; adminReviveSettings = null;
|
|
var closingSwitchDelaySettings = switchDelaySettings; switchDelaySettings = null;
|
|
var closingRoleplaySettings = roleplaySettings; roleplaySettings = null;
|
|
var closingPartySettings = partySettings; partySettings = null;
|
|
var closingPartyEconomySettings = partyEconomySettings; partyEconomySettings = null;
|
|
var closingGearSettings=gearSettings;gearSettings=null;
|
|
var closingCoinSettings = coinSettings; coinSettings = null;
|
|
var closingHardMobXpSettings = hardMobXpSettings; hardMobXpSettings = null;
|
|
var closingAdventureQuestSettings = adventureQuestSettings; adventureQuestSettings = null;
|
|
var closingSheetResourcePackSettings = sheetResourcePackSettings; sheetResourcePackSettings = null;
|
|
var closingSheetResourcePack = sheetResourcePack; sheetResourcePack = null;
|
|
var closingTemporaryHealth = temporaryHealth; temporaryHealth = null;
|
|
var closingHexSettings = hexSettings; hexSettings = null;
|
|
var closingOutgoingDamageMitigation = outgoingDamageMitigation; outgoingDamageMitigation = null;
|
|
var closingShieldBashSettings = shieldBashSettings; shieldBashSettings = null;
|
|
var closingCombatMitigation = combatMitigation; combatMitigation = null;
|
|
var closingStoneSkinSettings = stoneSkinSettings; stoneSkinSettings = null;
|
|
var closingSecondWindSettings = secondWindSettings; secondWindSettings = null;
|
|
var closingGreatSword = greatSword; greatSword = null;
|
|
var closingRevive = revive; revive = null;
|
|
var closingRevivals = revivals; revivals = null;
|
|
abilityRegistry = null;
|
|
var closingNutrition = nutritionPolicy; nutritionPolicy = null;
|
|
var closingOutOfCombatRecovery = outOfCombatRecovery; outOfCombatRecovery = null;
|
|
var closingOutOfCombatRecoverySettings = outOfCombatRecoverySettings; outOfCombatRecoverySettings = null;
|
|
var closingQuickerRegenerationSettings = quickerRegenerationSettings; quickerRegenerationSettings = null;
|
|
var closingQuickerRegenerationIISettings = quickerRegenerationIISettings; quickerRegenerationIISettings = null;
|
|
var closingHealthStealSettings = healthStealSettings; healthStealSettings = null;
|
|
var closingHealthSteal = healthSteal; healthSteal = null;
|
|
var closingSpeedI = speedI; speedI = null;
|
|
var closingLowLightVision = lowLightVision; lowLightVision = null;
|
|
var closingPassiveEngine = passiveEngine; passiveEngine = null;
|
|
quickerRegeneration = null; quickerRegenerationII = null; passiveRegistry = null;
|
|
// Retire client resources independently of successful ordinary-equipment restoration.
|
|
if (closingPresentation != null) cleanup("presentation", closingPresentation::close);
|
|
if (closingProtocol != null) cleanup("protocol presentation", closingProtocol::close);
|
|
if (closingAdmin != null) cleanup("admin command", closingAdmin::close);
|
|
if (closingFeedbackCommand != null) cleanup("feedback command", closingFeedbackCommand::close);
|
|
if (closingParticlesCommand != null) cleanup("particles command", closingParticlesCommand::close);
|
|
if (closingFeedbackPreferences != null) cleanup("feedback preferences", closingFeedbackPreferences::close);
|
|
if (closingSettings != null) cleanup("configuration", closingSettings::close);
|
|
if (closingFireballSettings != null) cleanup("Fireball configuration", closingFireballSettings::close);
|
|
if (closingFrostSettings != null) cleanup("Frost Shard configuration", closingFrostSettings::close);
|
|
if (closingLongbowSettings != null) cleanup("Longbow configuration", closingLongbowSettings::close);
|
|
if (closingQuickstepSettings != null) cleanup("Quickstep configuration", closingQuickstepSettings::close);
|
|
if (closingSecondWindSettings != null) cleanup("Second Wind configuration", closingSecondWindSettings::close);
|
|
if (closingStoneSkinSettings != null) cleanup("Stone Skin configuration", closingStoneSkinSettings::close);
|
|
if (closingShieldBashSettings != null) cleanup("Shield Bash configuration", closingShieldBashSettings::close);
|
|
if (closingHexSettings != null) cleanup("Hex configuration", closingHexSettings::close);
|
|
if (closingInspireSettings != null) cleanup("Inspire configuration", closingInspireSettings::close);
|
|
if (closingMendingLightSettings != null) cleanup("Mending Light configuration", closingMendingLightSettings::close);
|
|
if (closingPurifySettings != null) cleanup("Purify configuration", closingPurifySettings::close);
|
|
if (closingGuardianBond != null) cleanup("Guardian Bond", closingGuardianBond::close);
|
|
if (closingGuardianBondSettings != null) cleanup("Guardian Bond configuration", closingGuardianBondSettings::close);
|
|
if (closingRallyingCry != null) cleanup("Rallying Cry", closingRallyingCry::close);
|
|
if (closingRallyingCrySettings != null) cleanup("Rallying Cry configuration", closingRallyingCrySettings::close);
|
|
if (closingFrostNova != null) cleanup("Frost Nova", closingFrostNova::close);
|
|
if (closingFrostNovaSettings != null) cleanup("Frost Nova configuration", closingFrostNovaSettings::close);
|
|
if (closingChainLightning != null) cleanup("Chain Lightning", closingChainLightning::close);
|
|
if (closingChainLightningSettings != null) cleanup("Chain Lightning configuration", closingChainLightningSettings::close);
|
|
if (closingSanctuary != null) cleanup("Sanctuary", closingSanctuary::close);
|
|
if (closingSanctuarySettings != null) cleanup("Sanctuary configuration", closingSanctuarySettings::close);
|
|
if (closingWarBanner != null) cleanup("War Banner", closingWarBanner::close);
|
|
if (closingWarBannerSettings != null) cleanup("War Banner configuration", closingWarBannerSettings::close);
|
|
if (closingMeteor != null) cleanup("Meteor", closingMeteor::close);
|
|
if (closingMeteorSettings != null) cleanup("Meteor configuration", closingMeteorSettings::close);
|
|
if (closingOutgoingDamageBonus != null) cleanup("outgoing damage bonuses", closingOutgoingDamageBonus::close);
|
|
if (closingAdminReviveSettings != null) cleanup("admin revival configuration", closingAdminReviveSettings::close);
|
|
if (closingSwitchDelaySettings != null) cleanup("switch delay configuration", closingSwitchDelaySettings::close);
|
|
if (closingRoleplaySettings != null) cleanup("roleplay configuration", closingRoleplaySettings::close);
|
|
if (closingPartySettings != null) cleanup("party configuration", closingPartySettings::close);
|
|
if (closingPartyEconomySettings != null) cleanup("party economy configuration", closingPartyEconomySettings::close);
|
|
if(closingGearSettings!=null)cleanup("gear configuration",closingGearSettings::close);
|
|
if(closingRareSettings!=null)cleanup("rare configuration",closingRareSettings::close);
|
|
if(closingDownedSettings!=null)cleanup("downed configuration",closingDownedSettings::close);
|
|
if (closingCoinSettings != null) cleanup("coin configuration", closingCoinSettings::close);
|
|
if (closingHardMobXpSettings != null) cleanup("hard-mob XP configuration", closingHardMobXpSettings::close);
|
|
if (closingAdventureQuestSettings != null) cleanup("adventure quest configuration", closingAdventureQuestSettings::close);
|
|
if (closingAdventureQuests != null) cleanup("adventure quest persistence", closingAdventureQuests::close);
|
|
if (closingAdventureQuestController != null) cleanup("adventure quests", closingAdventureQuestController::close);
|
|
if(closingFishingController!=null)cleanup("fishing",closingFishingController::close);
|
|
if(closingFishing!=null)cleanup("fishing persistence",closingFishing::close);
|
|
if (closingDungeonController != null) cleanup("dungeons", closingDungeonController::close);
|
|
if (closingDungeons != null) cleanup("dungeon persistence", closingDungeons::close);
|
|
if (closingDownedController != null) cleanup("downed controller", closingDownedController::close);
|
|
if (closingDowned != null) cleanup("downed persistence", closingDowned::close);
|
|
if (closingSheetResourcePackSettings != null) cleanup("sheet resource-pack configuration", closingSheetResourcePackSettings::close);
|
|
if (closingSheetResourcePack != null) cleanup("sheet resource-pack", closingSheetResourcePack::close);
|
|
if (closingOutOfCombatRecoverySettings != null) cleanup("out-of-combat recovery configuration", closingOutOfCombatRecoverySettings::close);
|
|
if (closingQuickerRegenerationSettings != null) cleanup("Quicker Regeneration I configuration", closingQuickerRegenerationSettings::close);
|
|
if (closingQuickerRegenerationIISettings != null) cleanup("Quicker Regeneration II configuration", closingQuickerRegenerationIISettings::close);
|
|
if (closingHealthStealSettings != null) cleanup("Health Steal configuration", closingHealthStealSettings::close);
|
|
configurationDrain = java.util.concurrent.CompletableFuture.allOf(
|
|
closingFeedbackPreferences == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingFeedbackPreferences.drained().toCompletableFuture(),
|
|
closingCharacterParties == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingCharacterParties.drained().toCompletableFuture(),
|
|
closingPartyRegistrars == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingPartyRegistrars.drained().toCompletableFuture(),
|
|
closingTrainingDummies == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingTrainingDummies.drained().toCompletableFuture(),
|
|
closingPartyManagement == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingPartyManagement.drained().toCompletableFuture(),
|
|
closingArmorers==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingArmorers.drained().toCompletableFuture(),
|
|
closingArmorMarket==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingArmorMarket.drained().toCompletableFuture(),
|
|
closingGearSettings==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingGearSettings.drained().toCompletableFuture(),
|
|
closingRareSettings==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingRareSettings.drained().toCompletableFuture(),
|
|
closingDownedSettings==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingDownedSettings.drained().toCompletableFuture(),
|
|
closingRareInventory==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingRareInventory.drained().toCompletableFuture(),
|
|
closingRareMerchants==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingRareMerchants.drained().toCompletableFuture(),
|
|
closingRareMarket==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingRareMarket.drained().toCompletableFuture(),
|
|
closingPartyEconomySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingPartyEconomySettings.drained().toCompletableFuture(),
|
|
closingHardMobXpSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingHardMobXpSettings.drained().toCompletableFuture(),
|
|
closingAdventureQuestSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingAdventureQuestSettings.drained().toCompletableFuture(),
|
|
closingAdventureQuests == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingAdventureQuests.drained().toCompletableFuture(),
|
|
closingFishing==null?java.util.concurrent.CompletableFuture.completedFuture(null):closingFishing.drained().toCompletableFuture(),
|
|
closingDungeons == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingDungeons.drained().toCompletableFuture(),
|
|
closingDowned == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingDowned.drained().toCompletableFuture(),
|
|
closingSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingSettings.drained().toCompletableFuture(),
|
|
closingFireballSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingFireballSettings.drained().toCompletableFuture(),
|
|
closingFrostSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingFrostSettings.drained().toCompletableFuture(),
|
|
closingLongbowSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingLongbowSettings.drained().toCompletableFuture(),
|
|
closingQuickstepSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingQuickstepSettings.drained().toCompletableFuture(),
|
|
closingSecondWindSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingSecondWindSettings.drained().toCompletableFuture(),
|
|
closingStoneSkinSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingStoneSkinSettings.drained().toCompletableFuture(),
|
|
closingShieldBashSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingShieldBashSettings.drained().toCompletableFuture(),
|
|
closingHexSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingHexSettings.drained().toCompletableFuture(),
|
|
closingInspireSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingInspireSettings.drained().toCompletableFuture(),
|
|
closingMendingLightSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingMendingLightSettings.drained().toCompletableFuture(),
|
|
closingPurifySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingPurifySettings.drained().toCompletableFuture(),
|
|
closingGuardianBondSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingGuardianBondSettings.drained().toCompletableFuture(),
|
|
closingRallyingCrySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingRallyingCrySettings.drained().toCompletableFuture(),
|
|
closingFrostNovaSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingFrostNovaSettings.drained().toCompletableFuture(),
|
|
closingChainLightningSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingChainLightningSettings.drained().toCompletableFuture(),
|
|
closingSanctuarySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingSanctuarySettings.drained().toCompletableFuture(),
|
|
closingWarBannerSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingWarBannerSettings.drained().toCompletableFuture(),
|
|
closingMeteorSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingMeteorSettings.drained().toCompletableFuture(),
|
|
closingAdminReviveSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingAdminReviveSettings.drained().toCompletableFuture(),
|
|
closingSwitchDelaySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingSwitchDelaySettings.drained().toCompletableFuture(),
|
|
closingRoleplaySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingRoleplaySettings.drained().toCompletableFuture(),
|
|
closingPartySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingPartySettings.drained().toCompletableFuture(),
|
|
closingSheetResourcePackSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingSheetResourcePackSettings.drained().toCompletableFuture(),
|
|
closingOutOfCombatRecoverySettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingOutOfCombatRecoverySettings.drained().toCompletableFuture(),
|
|
closingQuickerRegenerationSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingQuickerRegenerationSettings.drained().toCompletableFuture(),
|
|
closingQuickerRegenerationIISettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingQuickerRegenerationIISettings.drained().toCompletableFuture(),
|
|
closingHealthStealSettings == null ? java.util.concurrent.CompletableFuture.completedFuture(null)
|
|
: closingHealthStealSettings.drained().toCompletableFuture());
|
|
if (closingBooks != null) cleanup("character book", closingBooks::close);
|
|
if (closingAdminRevival != null) cleanup("admin revival", closingAdminRevival::close);
|
|
if (closingBasicAttack != null) cleanup("basic attack", closingBasicAttack::close);
|
|
if (closingCombatExperience != null) cleanup("combat experience", closingCombatExperience::close);
|
|
if (closingFireball != null) cleanup("Fireball", closingFireball::close);
|
|
if (closingFrostShard != null) cleanup("Frost Shard", closingFrostShard::close);
|
|
if (closingLongbow != null) cleanup("Longbow", closingLongbow::close);
|
|
if (closingQuickstep != null) cleanup("Quickstep", closingQuickstep::close);
|
|
if (closingStoneSkin != null) cleanup("Stone Skin", closingStoneSkin::close);
|
|
if (closingShieldBash != null) cleanup("Shield Bash", closingShieldBash::close);
|
|
if (closingHex != null) cleanup("Hex", closingHex::close);
|
|
if (closingInspire != null) cleanup("Inspire", closingInspire::close);
|
|
if (closingTemporaryHealth != null) cleanup("temporary health", closingTemporaryHealth::close);
|
|
if (closingOutgoingDamageMitigation != null) cleanup("outgoing damage mitigation", closingOutgoingDamageMitigation::close);
|
|
if (closingCombatMitigation != null) cleanup("combat mitigation", closingCombatMitigation::close);
|
|
if (closingGreatSword != null) cleanup("Great Sword", closingGreatSword::close);
|
|
if (closingRevive != null) cleanup("Revive", closingRevive::close);
|
|
if (closingAbilityEngine != null) cleanup("ability engine", closingAbilityEngine::close);
|
|
if (closingNutrition != null) cleanup("nutrition policy", closingNutrition::close);
|
|
if (closingOutOfCombatRecovery != null) cleanup("out-of-combat recovery", closingOutOfCombatRecovery::close);
|
|
if (closingPassiveEngine != null) cleanup("passive engine", closingPassiveEngine::close);
|
|
if (closingHealthSteal != null) cleanup("Health Steal", closingHealthSteal::close);
|
|
if (closingSpeedI != null) cleanup("Speed I", closingSpeedI::close);
|
|
if (closingLowLightVision != null) cleanup("Low-Light Vision", closingLowLightVision::close);
|
|
if (closingVisuals != null) cleanup("session particles", closingVisuals::close);
|
|
if (closingParties != null) cleanup("parties", closingParties::close);
|
|
if (closingCharacterParties != null) cleanup("character parties", closingCharacterParties::close);
|
|
if (closingPartyRegistrarMenus != null) cleanup("party registrar menus", closingPartyRegistrarMenus::close);
|
|
if (closingPartyManagement != null) cleanup("party management", closingPartyManagement::close);
|
|
if (closingPartyRegistrarController != null) cleanup("party registrar entities", closingPartyRegistrarController::close);
|
|
if (closingPartyRegistrars != null) cleanup("party registrars", closingPartyRegistrars::close);
|
|
if (closingTrainingDummyController != null) cleanup("training dummy entities", closingTrainingDummyController::close);
|
|
if (closingTrainingDummies != null) cleanup("training dummies", closingTrainingDummies::close);
|
|
if(closingArmorMarketPulse!=null)cleanup("armor market schedule",closingArmorMarketPulse::cancel);
|
|
if(closingArmorMenuPulse!=null)cleanup("armor menu schedule",closingArmorMenuPulse::cancel);
|
|
if(closingArmorShopMenus!=null)cleanup("armor shop menus",closingArmorShopMenus::close);
|
|
if(closingArmorerController!=null)cleanup("armorer entities",closingArmorerController::close);
|
|
if(closingArmorMarket!=null)cleanup("armor market",closingArmorMarket::close);
|
|
if(closingArmorers!=null)cleanup("armorers",closingArmorers::close);
|
|
if(closingRareMarketPulse!=null)cleanup("rare market schedule",closingRareMarketPulse::cancel);
|
|
if(closingRareMenuPulse!=null)cleanup("rare menu schedule",closingRareMenuPulse::cancel);
|
|
if(closingRareShopMenus!=null)cleanup("rare shop menus",closingRareShopMenus::close);
|
|
if(closingRareMerchantController!=null)cleanup("rare merchant entities",closingRareMerchantController::close);
|
|
if(closingRareMarket!=null)cleanup("rare market",closingRareMarket::close);
|
|
if(closingRareInventory!=null){if(closingRareMarket==null)cleanup("rare inventory",closingRareInventory::close);else closingRareMarket.drained().whenComplete((ignored,failure)->cleanup("rare inventory",closingRareInventory::close));}
|
|
if(closingRareMerchants!=null)cleanup("rare merchants",closingRareMerchants::close);
|
|
if (closingPartyCombat != null) cleanup("party combat", closingPartyCombat::close);
|
|
if (closingEvents != null) cleanup("session events", closingEvents::close);
|
|
if (closingCrafting != null) cleanup("craft attempts", closingCrafting::close);
|
|
if (closingSessions != null) cleanup("equipment sessions", closingSessions::close);
|
|
if (closingRecipeDiscovery != null) cleanup("recipe discovery event intents", closingRecipeDiscovery::close);
|
|
if (closingSwitchAuditEvents != null) cleanup("switch event intent drain", () -> {
|
|
var sessionsDrained = closingSessions == null
|
|
? java.util.concurrent.CompletableFuture.<Void>completedFuture(null) : closingSessions.drained();
|
|
switchAuditDrain = sessionsDrained.handle((ignored, failure) -> {
|
|
if (failure != null) getLogger().log(Level.WARNING, "Switch exit drain failed", failure);
|
|
closingSwitchAuditEvents.close();
|
|
return null;
|
|
}).thenCompose(ignored -> closingSwitchAuditEvents.drained());
|
|
});
|
|
if (closingEquipmentAuditEvents != null) cleanup("equipment event intent drain", () -> {
|
|
var sessionsDrained = closingSessions == null
|
|
? java.util.concurrent.CompletableFuture.<Void>completedFuture(null) : closingSessions.drained();
|
|
equipmentAuditDrain = sessionsDrained.handle((ignored, failure) -> {
|
|
if (failure != null) getLogger().log(Level.WARNING, "Equipment session drain failed", failure);
|
|
closingEquipmentAuditEvents.close();
|
|
return null;
|
|
}).thenCompose(ignored -> closingEquipmentAuditEvents.drained());
|
|
});
|
|
if (closingEventLog != null) cleanup("local events", closingEventLog::close);
|
|
if (closingVitals != null) cleanup("native health hooks", closingVitals::close);
|
|
unregister(closingModes);
|
|
unregister(closingChat);
|
|
unregister(closingEventCapture);
|
|
unregister(closingMessageAuditEvents);
|
|
unregister(closingPartyEvents);
|
|
unregister(closingPartyCombat);
|
|
unregister(closingPartyRegistrarController);
|
|
unregister(closingTrainingDummyController);
|
|
unregister(closingPartyRegistrarMenus);
|
|
unregister(closingArmorerController);unregister(closingArmorShopMenus);
|
|
unregister(closingRareMerchantController);unregister(closingRareShopMenus);
|
|
unregister(closingAdventureQuestController);
|
|
unregister(closingFishingController);
|
|
unregister(closingDungeonController);
|
|
unregister(closingDownedController);
|
|
unregister(closingCombatExperience);
|
|
unregister(closingHealthSteal);
|
|
unregister(closingFireball);
|
|
unregister(closingFrostShard);
|
|
unregister(closingLongbow);
|
|
unregister(closingQuickstep);
|
|
unregister(closingCombatMitigation);
|
|
unregister(closingShieldBash);
|
|
unregister(closingOutgoingDamageMitigation);
|
|
unregister(closingTemporaryHealth);
|
|
unregister(closingGreatSword);
|
|
unregister(closingRevive);
|
|
unregister(closingAdminRevival);
|
|
unregister(closingCharacterRecovery);
|
|
unregister(closingBasicAttack);
|
|
unregister(closingNutrition);
|
|
unregister(closingOutOfCombatRecovery);
|
|
unregister(closingBooks);
|
|
unregister(closingEvents);
|
|
unregister(closingCrafting);
|
|
unregister(closingGuard);
|
|
unregister(closingAnvil);
|
|
unregister(closingRecipeDiscovery);
|
|
if (recipeRegistered) cleanup("character-sheet recipe", () -> {
|
|
getServer().removeRecipe(CharacterSheets.RECIPE);
|
|
recipeRegistered = false; // Retain ownership for a later retry if removal failed.
|
|
});
|
|
if (closingCharacters != null) cleanup("character storage", closingCharacters::close);
|
|
if (closingIdentityAuditEvents != null) cleanup("character identity event intent drain", () -> {
|
|
var charactersDrained = closingCharacters == null
|
|
? java.util.concurrent.CompletableFuture.<Void>completedFuture(null) : closingCharacters.drained();
|
|
identityAuditDrain = charactersDrained.handle((ignored, failure) -> {
|
|
if (failure != null) getLogger().log(Level.WARNING, "Character save drain failed", failure);
|
|
closingIdentityAuditEvents.close();
|
|
return null;
|
|
}).thenCompose(ignored -> closingIdentityAuditEvents.drained());
|
|
});
|
|
if (closingRevivals != null) cleanup("revival storage", closingRevivals::close);
|
|
// Never await IO on the server thread or close receipts ahead of accepted preparations.
|
|
if (closingReceipts != null) cleanup("equipment receipt drain", () -> {
|
|
if (closingSessions == null) closingReceipts.close();
|
|
else closingSessions.drained().whenComplete((ignored, failure) -> closingReceipts.close());
|
|
});
|
|
}
|
|
|
|
private void unregister(org.bukkit.event.Listener listener) {
|
|
if (listener != null) cleanup("listener " + listener.getClass().getSimpleName(),
|
|
() -> org.bukkit.event.HandlerList.unregisterAll(listener));
|
|
}
|
|
|
|
private void cleanup(String resource, Runnable action) {
|
|
try { action.run(); }
|
|
catch (RuntimeException | LinkageError failure) {
|
|
try { getLogger().log(Level.WARNING, "Could not close " + resource + "; continuing shutdown cleanup", failure); }
|
|
catch (RuntimeException | LinkageError ignored) { /* Diagnostics must not prevent remaining cleanup. */ }
|
|
}
|
|
}
|
|
|
|
private ProgressionRules progressionRules() {
|
|
try {
|
|
var starting = new java.math.BigInteger(getConfig().getString("starting-points", "40"));
|
|
var threshold = new java.math.BigInteger(getConfig().getString("xp-per-level", "100"));
|
|
var maximum = new java.math.BigInteger(getConfig().getString("maximum-level", "30")).intValueExact();
|
|
return new ProgressionRules(starting, threshold, maximum);
|
|
} catch (ArithmeticException invalid) {
|
|
throw new IllegalArgumentException("maximum-level exceeds the supported integer range", invalid);
|
|
}
|
|
}
|
|
|
|
private games.dmg.fantasystick.progression.CombatRewardRules combatRewardRules(java.math.BigInteger hard) {
|
|
try {
|
|
var passive = new java.math.BigInteger(getConfig().getString("passive-xp", "1"));
|
|
var ordinary = new java.math.BigInteger(getConfig().getString("ordinary-xp", "10"));
|
|
var boss = new java.math.BigInteger(getConfig().getString("boss-xp", "100"));
|
|
var spacing = new java.math.BigDecimal(getConfig().getString("restricted-kill-spacing-blocks", "3"));
|
|
return new games.dmg.fantasystick.progression.CombatRewardRules(passive, ordinary, hard, boss, spacing);
|
|
} catch (NumberFormatException invalid) {
|
|
throw new IllegalArgumentException("Combat reward settings must be decimal numbers", invalid);
|
|
}
|
|
}
|
|
|
|
private java.util.Map<String, String> fireballConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.FireballSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.FireballSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.FireballSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> outOfCombatRecoveryConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> frostShardConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.FrostShardSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.FrostShardSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.FrostShardSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> longbowConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.LongbowSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.LongbowSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.LongbowSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> quickstepConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.QuickstepSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.QuickstepSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.QuickstepSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> secondWindConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.SecondWindSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.SecondWindSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.SecondWindSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> stoneSkinConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.StoneSkinSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.StoneSkinSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.StoneSkinSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> shieldBashConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.ShieldBashSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.ShieldBashSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.ShieldBashSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> hexConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.HexSettings.keys()) {
|
|
values.put(key, getConfig().getString(key, games.dmg.fantasystick.persistence.HexSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.HexSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> inspireConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.InspireSettings.keys()) {
|
|
values.put(key, getConfig().getString(key, games.dmg.fantasystick.persistence.InspireSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.InspireSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> mendingLightConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.MendingLightSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.MendingLightSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.MendingLightSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> purifyConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.PurifySettings.keys()) {
|
|
values.put(key, getConfig().getString(key, games.dmg.fantasystick.persistence.PurifySettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.PurifySettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> guardianBondConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.GuardianBondSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.GuardianBondSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.GuardianBondSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> rallyingCryConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.RallyingCrySettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.RallyingCrySettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.RallyingCrySettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> frostNovaConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.FrostNovaSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.FrostNovaSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.FrostNovaSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> chainLightningConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.ChainLightningSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.ChainLightningSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.ChainLightningSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> sanctuaryConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.SanctuarySettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.SanctuarySettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.SanctuarySettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> warBannerConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.WarBannerSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.WarBannerSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.WarBannerSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private java.util.Map<String, String> meteorConfiguration() {
|
|
var values = new java.util.LinkedHashMap<String, String>();
|
|
for (String key : games.dmg.fantasystick.persistence.MeteorSettings.keys()) {
|
|
values.put(key, getConfig().getString(key,
|
|
games.dmg.fantasystick.persistence.MeteorSettings.defaultValue(key)));
|
|
}
|
|
games.dmg.fantasystick.persistence.MeteorSettings.parse(values);
|
|
return java.util.Map.copyOf(values);
|
|
}
|
|
|
|
private games.dmg.fantasystick.ability.GreatSword.Settings greatSwordSettings() {
|
|
try {
|
|
var base = new java.math.BigInteger(getConfig().getString("great-sword-base-damage", "7"));
|
|
var seconds = new java.math.BigDecimal(getConfig().getString("great-sword-recovery-seconds", "0.75"));
|
|
var recovery = java.time.Duration.ofNanos(seconds.movePointRight(9).toBigIntegerExact().longValueExact());
|
|
return new games.dmg.fantasystick.ability.GreatSword.Settings(base, recovery);
|
|
} catch (ArithmeticException | NumberFormatException invalid) {
|
|
throw new IllegalArgumentException("Great Sword settings must use supported nonnegative numeric values", invalid);
|
|
}
|
|
}
|
|
|
|
private void notifyPlayer(Object generation, EquipmentSessions.Notice notice) {
|
|
Runnable delivery = () -> {
|
|
if (lifetime != generation) return;
|
|
var player = getServer().getPlayer(notice.player());
|
|
if (player == null || !player.isOnline()) return;
|
|
String message = switch (notice.code()) {
|
|
case "NO_SPACE" -> "Equipment entry refused: free one slot in your main inventory for the Fantasy Storage Box.";
|
|
case "INELIGIBLE_EQUIPMENT" -> "Equipment entry refused: a hotbar or armor item cannot fit in a vanilla shulker box. Move it before retrying.";
|
|
default -> notice.message();
|
|
};
|
|
player.sendMessage(message);
|
|
var particles = particleDelivery;
|
|
if (particles == null) return;
|
|
if (notice.code().equals("DEFEAT")) particles.world(org.bukkit.Particle.DUST,
|
|
player.getLocation().add(0, 1, 0), 12, 0.3, 0.4, 0.3, 0,
|
|
new org.bukkit.Particle.DustOptions(org.bukkit.Color.RED, 1));
|
|
else particles.viewer(player, org.bukkit.Particle.ANGRY_VILLAGER,
|
|
player.getLocation().add(0, 1, 0), 8, 0.3, 0.4, 0.3, 0);
|
|
};
|
|
if (lifetime != generation) return;
|
|
if (getServer().isPrimaryThread()) delivery.run();
|
|
else getServer().getScheduler().runTask(this, delivery);
|
|
}
|
|
}
|