1906 lines
163 KiB
Java
1906 lines
163 KiB
Java
package games.dmg.fantasystick.session;
|
||
|
||
import games.dmg.fantasystick.persistence.EquipmentSessionStore;
|
||
import java.math.BigInteger;
|
||
import java.util.List;
|
||
import java.util.Objects;
|
||
import java.util.UUID;
|
||
import java.util.function.Consumer;
|
||
import org.bukkit.Server;
|
||
import org.bukkit.command.Command;
|
||
import org.bukkit.command.CommandSender;
|
||
import org.bukkit.command.TabExecutor;
|
||
|
||
/** Server-thread command entry; persistence callbacks never access senders or players. */
|
||
public final class EquipmentAdminCommand implements TabExecutor, AutoCloseable {
|
||
public static final String PERMISSION = "fantasystick.admin";
|
||
public record Failure(UUID player, String operation, Throwable cause) { }
|
||
private final EquipmentSessionStore receipts;
|
||
private final EquipmentSessions sessions;
|
||
private final Server server;
|
||
private final Consumer<Runnable> nextTick;
|
||
private final Consumer<Failure> diagnostics;
|
||
private final java.util.LinkedHashMap<UUID, String> savedCharacterCatalog = new java.util.LinkedHashMap<>();
|
||
private final java.util.concurrent.ConcurrentHashMap<Object, Object> savedSearches = new java.util.concurrent.ConcurrentHashMap<>();
|
||
private static final int SAVED_CATALOG_COMPLETION_LIMIT = 256;
|
||
private static final int SAVED_SEARCH_PAGE_SIZE = 8;
|
||
private volatile boolean closed;
|
||
private games.dmg.fantasystick.persistence.AdventureSettings settings;
|
||
private games.dmg.fantasystick.persistence.FireballSettings fireballSettings;
|
||
private games.dmg.fantasystick.events.AbilityConfigEventBridge abilityConfigEvents;
|
||
private games.dmg.fantasystick.ability.Fireball fireball;
|
||
private games.dmg.fantasystick.persistence.FrostShardSettings frostSettings;
|
||
private games.dmg.fantasystick.ability.FrostShard frostShard;
|
||
private games.dmg.fantasystick.ability.AbilityRegistry abilities;
|
||
private games.dmg.fantasystick.persistence.LongbowSettings longbowSettings;
|
||
private games.dmg.fantasystick.ability.Longbow longbow;
|
||
private games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings;
|
||
private games.dmg.fantasystick.ability.Quickstep quickstep;
|
||
private games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings;
|
||
private games.dmg.fantasystick.ability.SecondWind secondWind;
|
||
private games.dmg.fantasystick.persistence.StoneSkinSettings stoneSkinSettings;
|
||
private games.dmg.fantasystick.ability.StoneSkin stoneSkin;
|
||
private games.dmg.fantasystick.persistence.ShieldBashSettings shieldBashSettings;
|
||
private games.dmg.fantasystick.ability.ShieldBash shieldBash;
|
||
private games.dmg.fantasystick.persistence.HexSettings hexSettings;
|
||
private games.dmg.fantasystick.ability.Hex hex;
|
||
private games.dmg.fantasystick.persistence.InspireSettings inspireSettings;
|
||
private games.dmg.fantasystick.ability.Inspire inspire;
|
||
private games.dmg.fantasystick.persistence.MendingLightSettings mendingLightSettings;
|
||
private games.dmg.fantasystick.ability.MendingLight mendingLight;
|
||
private games.dmg.fantasystick.persistence.PurifySettings purifySettings;
|
||
private games.dmg.fantasystick.ability.Purify purify;
|
||
private games.dmg.fantasystick.persistence.GuardianBondSettings guardianBondSettings;
|
||
private games.dmg.fantasystick.ability.GuardianBond guardianBond;
|
||
private games.dmg.fantasystick.persistence.RallyingCrySettings rallyingCrySettings;
|
||
private games.dmg.fantasystick.ability.RallyingCry rallyingCry;
|
||
private games.dmg.fantasystick.persistence.FrostNovaSettings frostNovaSettings;
|
||
private games.dmg.fantasystick.ability.FrostNova frostNova;
|
||
private games.dmg.fantasystick.persistence.ChainLightningSettings chainLightningSettings;
|
||
private games.dmg.fantasystick.ability.ChainLightning chainLightning;
|
||
private games.dmg.fantasystick.persistence.SanctuarySettings sanctuarySettings;
|
||
private games.dmg.fantasystick.ability.Sanctuary sanctuary;
|
||
private games.dmg.fantasystick.persistence.WarBannerSettings warBannerSettings;
|
||
private games.dmg.fantasystick.ability.WarBanner warBanner;
|
||
private games.dmg.fantasystick.persistence.MeteorSettings meteorSettings;
|
||
private games.dmg.fantasystick.ability.Meteor meteor;
|
||
private AdminCharacterIssuer characterIssuer;
|
||
private AdminRevival adminRevival;
|
||
private AdminExperienceGrant experienceGrant;
|
||
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.events.CoinEventBridge coinEvents;
|
||
private games.dmg.fantasystick.persistence.HardMobXpSettings hardMobXpSettings;
|
||
private games.dmg.fantasystick.persistence.AdventureQuestSettings adventureQuestSettings;
|
||
private games.dmg.fantasystick.adventure.AdventureQuestCommands adventureQuestCommands;
|
||
private games.dmg.fantasystick.dungeon.DungeonCommands dungeonCommands;
|
||
private games.dmg.fantasystick.party.CombatExperience combatExperience;
|
||
private games.dmg.fantasystick.persistence.SheetResourcePackSettings sheetResourcePackSettings;
|
||
private games.dmg.fantasystick.presentation.SheetResourcePack sheetResourcePack;
|
||
private games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings outOfCombatRecoverySettings;
|
||
private OutOfCombatRecovery outOfCombatRecovery;
|
||
private games.dmg.fantasystick.persistence.QuickerRegenerationSettings quickerRegenerationSettings;
|
||
private games.dmg.fantasystick.passive.QuickerRegenerationI quickerRegeneration;
|
||
private games.dmg.fantasystick.events.PassiveEventBridge passiveEvents;
|
||
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.PassiveRegistry passiveRegistry;
|
||
private games.dmg.fantasystick.party.PartyRegistrarDirectory partyRegistrars;
|
||
private games.dmg.fantasystick.party.PartyRegistrarController partyRegistrarController;
|
||
private games.dmg.fantasystick.events.PartyEventBridge partyEvents;
|
||
private games.dmg.fantasystick.training.TrainingDummyDirectory trainingDummies;
|
||
private games.dmg.fantasystick.training.TrainingDummyController trainingDummyController;
|
||
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.RareMerchantDirectory rareMerchants;
|
||
private games.dmg.fantasystick.shop.RareMerchantController rareMerchantController;
|
||
private games.dmg.fantasystick.shop.RareMarket rareMarket;
|
||
private games.dmg.fantasystick.persistence.RareSettings rareSettings;
|
||
private games.dmg.fantasystick.persistence.DownedSettings downedSettings;
|
||
private games.dmg.fantasystick.events.DownedEventBridge downedEvents;
|
||
private games.dmg.fantasystick.book.CharacterBookController characterBooks;
|
||
private games.dmg.fantasystick.persistence.CharacterStorage characters;
|
||
private AdminCharacterRecovery characterRecovery;
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics) {
|
||
this.receipts = Objects.requireNonNull(receipts);
|
||
this.sessions = Objects.requireNonNull(sessions);
|
||
this.server = Objects.requireNonNull(server);
|
||
this.nextTick = Objects.requireNonNull(nextTick);
|
||
this.diagnostics = Objects.requireNonNull(diagnostics);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings) {
|
||
this(receipts, sessions, server, nextTick, diagnostics);
|
||
this.settings = Objects.requireNonNull(settings);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings);
|
||
this.frostSettings = Objects.requireNonNull(frostSettings);
|
||
this.frostShard = Objects.requireNonNull(frostShard);
|
||
this.abilities = Objects.requireNonNull(abilities);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard, abilities);
|
||
this.longbowSettings = Objects.requireNonNull(longbowSettings);
|
||
this.longbow = Objects.requireNonNull(longbow);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings,
|
||
games.dmg.fantasystick.ability.Quickstep quickstep,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard,
|
||
longbowSettings, longbow, abilities);
|
||
this.quickstepSettings = Objects.requireNonNull(quickstepSettings);
|
||
this.quickstep = Objects.requireNonNull(quickstep);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings,
|
||
games.dmg.fantasystick.ability.Quickstep quickstep,
|
||
games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings,
|
||
games.dmg.fantasystick.ability.SecondWind secondWind,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard,
|
||
longbowSettings, longbow, quickstepSettings, quickstep, abilities);
|
||
this.secondWindSettings = Objects.requireNonNull(secondWindSettings);
|
||
this.secondWind = Objects.requireNonNull(secondWind);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings,
|
||
games.dmg.fantasystick.ability.Quickstep quickstep,
|
||
games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings,
|
||
games.dmg.fantasystick.ability.SecondWind secondWind,
|
||
games.dmg.fantasystick.persistence.StoneSkinSettings stoneSkinSettings,
|
||
games.dmg.fantasystick.ability.StoneSkin stoneSkin,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard,
|
||
longbowSettings, longbow, quickstepSettings, quickstep, secondWindSettings, secondWind, abilities);
|
||
this.stoneSkinSettings = Objects.requireNonNull(stoneSkinSettings);
|
||
this.stoneSkin = Objects.requireNonNull(stoneSkin);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings,
|
||
games.dmg.fantasystick.ability.Quickstep quickstep,
|
||
games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings,
|
||
games.dmg.fantasystick.ability.SecondWind secondWind,
|
||
games.dmg.fantasystick.persistence.StoneSkinSettings stoneSkinSettings,
|
||
games.dmg.fantasystick.ability.StoneSkin stoneSkin,
|
||
games.dmg.fantasystick.persistence.ShieldBashSettings shieldBashSettings,
|
||
games.dmg.fantasystick.ability.ShieldBash shieldBash,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard,
|
||
longbowSettings, longbow, quickstepSettings, quickstep, secondWindSettings, secondWind,
|
||
stoneSkinSettings, stoneSkin, abilities);
|
||
this.shieldBashSettings = Objects.requireNonNull(shieldBashSettings);
|
||
this.shieldBash = Objects.requireNonNull(shieldBash);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings,
|
||
games.dmg.fantasystick.ability.Quickstep quickstep,
|
||
games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings,
|
||
games.dmg.fantasystick.ability.SecondWind secondWind,
|
||
games.dmg.fantasystick.persistence.StoneSkinSettings stoneSkinSettings,
|
||
games.dmg.fantasystick.ability.StoneSkin stoneSkin,
|
||
games.dmg.fantasystick.persistence.ShieldBashSettings shieldBashSettings,
|
||
games.dmg.fantasystick.ability.ShieldBash shieldBash,
|
||
games.dmg.fantasystick.persistence.HexSettings hexSettings,
|
||
games.dmg.fantasystick.ability.Hex hex,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard,
|
||
longbowSettings, longbow, quickstepSettings, quickstep, secondWindSettings, secondWind,
|
||
stoneSkinSettings, stoneSkin, shieldBashSettings, shieldBash, abilities);
|
||
this.hexSettings = Objects.requireNonNull(hexSettings); this.hex = Objects.requireNonNull(hex);
|
||
}
|
||
|
||
public EquipmentAdminCommand(EquipmentSessionStore receipts, EquipmentSessions sessions, Server server,
|
||
Consumer<Runnable> nextTick, Consumer<Failure> diagnostics,
|
||
games.dmg.fantasystick.persistence.AdventureSettings settings,
|
||
games.dmg.fantasystick.persistence.FrostShardSettings frostSettings,
|
||
games.dmg.fantasystick.ability.FrostShard frostShard,
|
||
games.dmg.fantasystick.persistence.LongbowSettings longbowSettings,
|
||
games.dmg.fantasystick.ability.Longbow longbow,
|
||
games.dmg.fantasystick.persistence.QuickstepSettings quickstepSettings,
|
||
games.dmg.fantasystick.ability.Quickstep quickstep,
|
||
games.dmg.fantasystick.persistence.SecondWindSettings secondWindSettings,
|
||
games.dmg.fantasystick.ability.SecondWind secondWind,
|
||
games.dmg.fantasystick.persistence.StoneSkinSettings stoneSkinSettings,
|
||
games.dmg.fantasystick.ability.StoneSkin stoneSkin,
|
||
games.dmg.fantasystick.persistence.ShieldBashSettings shieldBashSettings,
|
||
games.dmg.fantasystick.ability.ShieldBash shieldBash,
|
||
games.dmg.fantasystick.persistence.HexSettings hexSettings,
|
||
games.dmg.fantasystick.ability.Hex hex,
|
||
games.dmg.fantasystick.persistence.InspireSettings inspireSettings,
|
||
games.dmg.fantasystick.ability.Inspire inspire,
|
||
games.dmg.fantasystick.ability.AbilityRegistry abilities) {
|
||
this(receipts, sessions, server, nextTick, diagnostics, settings, frostSettings, frostShard,
|
||
longbowSettings, longbow, quickstepSettings, quickstep, secondWindSettings, secondWind,
|
||
stoneSkinSettings, stoneSkin, shieldBashSettings, shieldBash, hexSettings, hex, abilities);
|
||
this.inspireSettings=Objects.requireNonNull(inspireSettings);this.inspire=Objects.requireNonNull(inspire);
|
||
}
|
||
|
||
public void attachMendingLight(games.dmg.fantasystick.persistence.MendingLightSettings settings,
|
||
games.dmg.fantasystick.ability.MendingLight effect) {
|
||
if (closed || mendingLightSettings != null) throw new IllegalStateException("Mending Light already attached or command closed");
|
||
mendingLightSettings = Objects.requireNonNull(settings); mendingLight = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachPurify(games.dmg.fantasystick.persistence.PurifySettings settings,
|
||
games.dmg.fantasystick.ability.Purify effect) {
|
||
if (closed || purifySettings != null) throw new IllegalStateException("Purify already attached or command closed");
|
||
purifySettings = Objects.requireNonNull(settings); purify = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachGuardianBond(games.dmg.fantasystick.persistence.GuardianBondSettings settings,
|
||
games.dmg.fantasystick.ability.GuardianBond effect) {
|
||
if (closed || guardianBondSettings != null) throw new IllegalStateException("Guardian Bond already attached or command closed");
|
||
guardianBondSettings = Objects.requireNonNull(settings); guardianBond = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachRallyingCry(games.dmg.fantasystick.persistence.RallyingCrySettings settings,
|
||
games.dmg.fantasystick.ability.RallyingCry effect) {
|
||
if (closed || rallyingCrySettings != null) throw new IllegalStateException("Rallying Cry already attached or command closed");
|
||
rallyingCrySettings = Objects.requireNonNull(settings); rallyingCry = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachFrostNova(games.dmg.fantasystick.persistence.FrostNovaSettings settings,
|
||
games.dmg.fantasystick.ability.FrostNova effect) {
|
||
if (closed || frostNovaSettings != null) throw new IllegalStateException("Frost Nova already attached or command closed");
|
||
frostNovaSettings = Objects.requireNonNull(settings); frostNova = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachChainLightning(games.dmg.fantasystick.persistence.ChainLightningSettings settings,
|
||
games.dmg.fantasystick.ability.ChainLightning effect) {
|
||
if (closed || chainLightningSettings != null) throw new IllegalStateException("Chain Lightning already attached or command closed");
|
||
chainLightningSettings = Objects.requireNonNull(settings); chainLightning = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachSanctuary(games.dmg.fantasystick.persistence.SanctuarySettings settings,
|
||
games.dmg.fantasystick.ability.Sanctuary effect) {
|
||
if (closed || sanctuarySettings != null) throw new IllegalStateException("Sanctuary already attached or command closed");
|
||
sanctuarySettings = Objects.requireNonNull(settings); sanctuary = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachWarBanner(games.dmg.fantasystick.persistence.WarBannerSettings settings,
|
||
games.dmg.fantasystick.ability.WarBanner effect) {
|
||
if (closed || warBannerSettings != null) throw new IllegalStateException("War Banner already attached or command closed");
|
||
warBannerSettings = Objects.requireNonNull(settings); warBanner = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachMeteor(games.dmg.fantasystick.persistence.MeteorSettings settings,
|
||
games.dmg.fantasystick.ability.Meteor effect) {
|
||
if (closed || meteorSettings != null) throw new IllegalStateException("Meteor already attached or command closed");
|
||
meteorSettings = Objects.requireNonNull(settings); meteor = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachSwitchDelay(games.dmg.fantasystick.persistence.SwitchDelaySettings settings){if(closed||switchDelaySettings!=null)throw new IllegalStateException("Switch delay already attached or command closed");switchDelaySettings=Objects.requireNonNull(settings);}
|
||
public void attachRoleplaySettings(games.dmg.fantasystick.persistence.RoleplaySettings settings){if(closed||roleplaySettings!=null)throw new IllegalStateException("Roleplay settings already attached or command closed");roleplaySettings=Objects.requireNonNull(settings);}
|
||
public void attachPartySettings(games.dmg.fantasystick.persistence.PartySettings settings){if(closed||partySettings!=null)throw new IllegalStateException("Party settings already attached or command closed");partySettings=Objects.requireNonNull(settings);}
|
||
public void attachPartyEconomySettings(games.dmg.fantasystick.persistence.PartyEconomySettings settings){if(closed||partyEconomySettings!=null)throw new IllegalStateException("Party economy settings already attached or command closed");partyEconomySettings=Objects.requireNonNull(settings);}
|
||
public void attachGearSettings(games.dmg.fantasystick.persistence.GearSettings settings){if(closed||gearSettings!=null)throw new IllegalStateException("Gear settings already attached or command closed");gearSettings=Objects.requireNonNull(settings);}
|
||
public void attachCoinSettings(games.dmg.fantasystick.persistence.CoinSettings settings){if(closed||coinSettings!=null)throw new IllegalStateException("Coin settings already attached or command closed");coinSettings=Objects.requireNonNull(settings);}
|
||
public void attachCoinEvents(games.dmg.fantasystick.events.CoinEventBridge events){if(closed||coinEvents!=null)throw new IllegalStateException("Coin events already attached or command closed");coinEvents=Objects.requireNonNull(events);}
|
||
public void attachAbilityConfigEvents(games.dmg.fantasystick.events.AbilityConfigEventBridge events){if(closed||abilityConfigEvents!=null)throw new IllegalStateException("Ability config events already attached or command closed");abilityConfigEvents=Objects.requireNonNull(events);}
|
||
public void attachHardMobXpSettings(games.dmg.fantasystick.persistence.HardMobXpSettings settings,
|
||
games.dmg.fantasystick.party.CombatExperience experience) {
|
||
if (closed || hardMobXpSettings != null) throw new IllegalStateException("Hard-mob XP settings already attached or command closed");
|
||
hardMobXpSettings = Objects.requireNonNull(settings); combatExperience = Objects.requireNonNull(experience);
|
||
}
|
||
public void attachAdventureQuests(games.dmg.fantasystick.adventure.AdventureQuestCommands commands,
|
||
games.dmg.fantasystick.persistence.AdventureQuestSettings settings) {
|
||
if (closed || adventureQuestCommands != null) throw new IllegalStateException("Adventure quests already attached or command closed");
|
||
adventureQuestCommands = Objects.requireNonNull(commands); adventureQuestSettings = Objects.requireNonNull(settings);
|
||
}
|
||
public void attachDungeons(games.dmg.fantasystick.dungeon.DungeonCommands commands){if(closed||dungeonCommands!=null)throw new IllegalStateException("Dungeons already attached or command closed");dungeonCommands=Objects.requireNonNull(commands);}
|
||
public void attachSheetResourcePack(games.dmg.fantasystick.persistence.SheetResourcePackSettings settings,games.dmg.fantasystick.presentation.SheetResourcePack delivery){if(closed||sheetResourcePackSettings!=null)throw new IllegalStateException("Sheet resource pack already attached or command closed");sheetResourcePackSettings=Objects.requireNonNull(settings);sheetResourcePack=Objects.requireNonNull(delivery);}
|
||
public void attachOutOfCombatRecovery(games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings settings,
|
||
OutOfCombatRecovery recovery) {
|
||
if (closed || outOfCombatRecoverySettings != null) throw new IllegalStateException("Out-of-combat recovery already attached or command closed");
|
||
outOfCombatRecoverySettings = Objects.requireNonNull(settings);
|
||
outOfCombatRecovery = Objects.requireNonNull(recovery);
|
||
}
|
||
|
||
public void attachPassiveEvents(games.dmg.fantasystick.events.PassiveEventBridge events){if(closed||passiveEvents!=null)throw new IllegalStateException("Passive events already attached or command closed");passiveEvents=Objects.requireNonNull(events);}
|
||
|
||
public void attachQuickerRegeneration(games.dmg.fantasystick.persistence.QuickerRegenerationSettings settings,
|
||
games.dmg.fantasystick.passive.QuickerRegenerationI passive,
|
||
games.dmg.fantasystick.passive.PassiveRegistry registry) {
|
||
if (closed || quickerRegenerationSettings != null) throw new IllegalStateException("Quicker Regeneration I already attached or command closed");
|
||
quickerRegenerationSettings = Objects.requireNonNull(settings); quickerRegeneration = Objects.requireNonNull(passive);
|
||
passiveRegistry = Objects.requireNonNull(registry);
|
||
}
|
||
|
||
public void attachQuickerRegenerationII(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings settings,
|
||
games.dmg.fantasystick.passive.QuickerRegenerationII passive,
|
||
games.dmg.fantasystick.passive.PassiveRegistry registry) {
|
||
if (closed || quickerRegenerationIISettings != null) throw new IllegalStateException("Quicker Regeneration II already attached or command closed");
|
||
quickerRegenerationIISettings = Objects.requireNonNull(settings); quickerRegenerationII = Objects.requireNonNull(passive);
|
||
if (passiveRegistry != Objects.requireNonNull(registry)) throw new IllegalArgumentException("Passive registry mismatch");
|
||
}
|
||
|
||
public void attachHealthSteal(games.dmg.fantasystick.persistence.HealthStealSettings settings,
|
||
games.dmg.fantasystick.passive.HealthSteal passive,
|
||
games.dmg.fantasystick.passive.PassiveRegistry registry) {
|
||
if (closed || healthStealSettings != null) throw new IllegalStateException("Health Steal already attached or command closed");
|
||
healthStealSettings = Objects.requireNonNull(settings); healthSteal = Objects.requireNonNull(passive);
|
||
if (passiveRegistry != Objects.requireNonNull(registry)) throw new IllegalArgumentException("Passive registry mismatch");
|
||
}
|
||
|
||
public void attachExperienceGrant(AdminExperienceGrant grant) {
|
||
if (closed || experienceGrant != null) throw new IllegalStateException("Experience grant already attached or command closed");
|
||
experienceGrant = Objects.requireNonNull(grant);
|
||
}
|
||
|
||
public void attachAdminRevival(AdminRevival revival, games.dmg.fantasystick.persistence.AdminReviveSettings settings) {
|
||
if (closed || adminRevival != null) throw new IllegalStateException("Admin revival already attached or command closed");
|
||
adminRevival=Objects.requireNonNull(revival);adminReviveSettings=Objects.requireNonNull(settings);
|
||
}
|
||
|
||
public void attachCharacterIssuer(AdminCharacterIssuer issuer) {
|
||
if (closed || characterIssuer != null) throw new IllegalStateException("Character issuer already attached or command closed");
|
||
characterIssuer = Objects.requireNonNull(issuer);
|
||
}
|
||
|
||
public void attachCharacterBooks(games.dmg.fantasystick.book.CharacterBookController books,
|
||
games.dmg.fantasystick.persistence.CharacterStorage storage) {
|
||
if (closed || characterBooks != null) throw new IllegalStateException("Character books already attached or command closed");
|
||
characterBooks = Objects.requireNonNull(books);
|
||
characters = Objects.requireNonNull(storage);
|
||
}
|
||
|
||
public void attachCharacterRecovery(AdminCharacterRecovery recovery) {
|
||
if (closed || characterRecovery != null) throw new IllegalStateException("Character recovery already attached or command closed");
|
||
characterRecovery = Objects.requireNonNull(recovery);
|
||
}
|
||
|
||
public void attachPartyEvents(games.dmg.fantasystick.events.PartyEventBridge events){if(closed||partyEvents!=null)throw new IllegalStateException("Party events already attached or command closed");partyEvents=Objects.requireNonNull(events);}
|
||
|
||
public void attachPartyRegistrars(games.dmg.fantasystick.party.PartyRegistrarDirectory directory,
|
||
games.dmg.fantasystick.party.PartyRegistrarController controller) {
|
||
if (closed || partyRegistrars != null) throw new IllegalStateException("Party Registrars already attached or command closed");
|
||
partyRegistrars=Objects.requireNonNull(directory); partyRegistrarController=Objects.requireNonNull(controller);
|
||
}
|
||
|
||
public void attachFireball(games.dmg.fantasystick.persistence.FireballSettings settings,
|
||
games.dmg.fantasystick.ability.Fireball effect) {
|
||
if (closed || fireballSettings != null) throw new IllegalStateException("Fireball already attached or command closed");
|
||
fireballSettings = Objects.requireNonNull(settings); fireball = Objects.requireNonNull(effect);
|
||
}
|
||
|
||
public void attachTrainingDummies(games.dmg.fantasystick.training.TrainingDummyDirectory directory,
|
||
games.dmg.fantasystick.training.TrainingDummyController controller) {
|
||
if (closed || trainingDummies != null) throw new IllegalStateException("Training dummies already attached or command closed");
|
||
trainingDummies = Objects.requireNonNull(directory); trainingDummyController = Objects.requireNonNull(controller);
|
||
}
|
||
|
||
public void attachArmorers(games.dmg.fantasystick.shop.FantasyArmorerDirectory directory,games.dmg.fantasystick.shop.FantasyArmorerController controller){if(closed||armorers!=null)throw new IllegalStateException("Armorers already attached or command closed");armorers=Objects.requireNonNull(directory);armorerController=Objects.requireNonNull(controller);}
|
||
public void attachArmorMarket(games.dmg.fantasystick.shop.ArmorMarket market){if(closed||armorMarket!=null)throw new IllegalStateException("Armor market already attached or command closed");armorMarket=Objects.requireNonNull(market);}
|
||
public void attachRareMarket(games.dmg.fantasystick.shop.RareMerchantDirectory directory,games.dmg.fantasystick.shop.RareMerchantController controller,games.dmg.fantasystick.shop.RareMarket market,games.dmg.fantasystick.persistence.RareSettings settings){if(closed||rareMerchants!=null)throw new IllegalStateException("Rare market already attached or command closed");rareMerchants=Objects.requireNonNull(directory);rareMerchantController=Objects.requireNonNull(controller);rareMarket=Objects.requireNonNull(market);rareSettings=Objects.requireNonNull(settings);}
|
||
public void attachDownedSettings(games.dmg.fantasystick.persistence.DownedSettings settings){if(closed||downedSettings!=null)throw new IllegalStateException("Downed settings already attached or command closed");downedSettings=Objects.requireNonNull(settings);}
|
||
public void attachDownedEvents(games.dmg.fantasystick.events.DownedEventBridge events){if(closed||downedEvents!=null)throw new IllegalStateException("Downed events already attached or command closed");downedEvents=Objects.requireNonNull(events);}
|
||
|
||
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||
if (closed) return true;
|
||
if (!sender.hasPermission(PERMISSION)) {
|
||
sender.sendMessage("Permission denied: you need fantasystick.admin to administer Fantasy Stick.");
|
||
return true;
|
||
}
|
||
if (args.length == 0) {
|
||
adminUsage(sender);
|
||
return true;
|
||
}
|
||
if (adventureQuestCommands != null && args[0].equals("adventure")) {
|
||
if (args.length >= 2 && args[1].equals("reroll")) adventureQuestCommands.adventure(sender, args);
|
||
else sender.sendMessage("Usage: /fstickadmin adventure reroll [confirm]");
|
||
return true;
|
||
}
|
||
if (adventureQuestCommands != null && args.length > 0 && args[0].equals("adventure-site")) {
|
||
adventureQuestCommands.site(sender, args); return true;
|
||
}
|
||
if (adventureQuestCommands != null && args.length > 0 && args[0].equals("quest-giver")) {
|
||
adventureQuestCommands.giver(sender, args); return true;
|
||
}
|
||
if (args.length > 0 && args[0].equals("character")) {
|
||
characterCommand(sender, args); return true;
|
||
}
|
||
if(dungeonCommands!=null&&args.length>0&&args[0].equals("dungeon")){dungeonCommands.execute(sender,args);return true;}
|
||
if(args.length>0&&args[0].equals("shop")){shop(sender,args);return true;}
|
||
if(args.length>0&&args[0].equals("rare-shop")){rareShop(sender,args);return true;}
|
||
if (args.length > 0 && args[0].equals("training-dummy")) {
|
||
trainingDummy(sender, args); return true;
|
||
}
|
||
if (args.length > 0 && args[0].equals("party-registrar")) {
|
||
partyRegistrar(sender,args); return true;
|
||
}
|
||
if (args.length > 0 && args[0].equals("config")) {
|
||
configuration(sender, args);
|
||
return true;
|
||
}
|
||
if (args.length > 0 && args[0].equals("give")) {
|
||
give(sender, args);
|
||
return true;
|
||
}
|
||
if (args.length > 0 && args[0].equals("revive")) {
|
||
adminRevive(sender,args);return true;
|
||
}
|
||
if (args.length > 0 && args[0].equals("experience")) {
|
||
experience(sender, args); return true;
|
||
}
|
||
UUID owner;
|
||
try {
|
||
if (args.length != 2 || !(args[0].equals("inspect") || args[0].equals("recover"))) {
|
||
throw new IllegalArgumentException("Invalid command shape");
|
||
}
|
||
owner = UUID.fromString(args[1]);
|
||
if (!owner.toString().equalsIgnoreCase(args[1])) throw new IllegalArgumentException("Noncanonical UUID shape");
|
||
} catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Usage: /fstickadmin <inspect|recover> <player-uuid> (full UUID required)");
|
||
return true;
|
||
}
|
||
if (args[0].equals("recover")) {
|
||
var player = server.getPlayer(owner);
|
||
if (player == null || !player.isOnline()) {
|
||
sender.sendMessage("Recovery refused: target " + owner + " must be online. No items changed.");
|
||
return true;
|
||
}
|
||
sessions.recover(player);
|
||
sender.sendMessage("Validated equipment recovery requested for " + owner
|
||
+ ". This is not confirmation of restoration; ambiguous items and receipts are retained.");
|
||
return true;
|
||
}
|
||
receipts.find(owner).whenComplete((state, failure) -> {
|
||
if (failure != null) report(owner, "inspect", failure);
|
||
if (closed) return;
|
||
try {
|
||
nextTick.accept(() -> {
|
||
if (closed || !sender.hasPermission(PERMISSION)) return;
|
||
if (sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) {
|
||
sender.sendMessage("Equipment inspection failed for " + owner + "; retained state requires inspection. See server diagnostics.");
|
||
return;
|
||
}
|
||
sender.sendMessage("Equipment receipt player=" + owner + " (file and native observations are not atomic)");
|
||
if (state.isEmpty()) sender.sendMessage("Saved receipt: none; pending=none; last exit=none.");
|
||
else {
|
||
var saved = state.orElseThrow();
|
||
var pending = saved.pending();
|
||
sender.sendMessage(pending == null ? "pending=none" : "pending session=" + pending.sessionId()
|
||
+ " character=" + pending.characterId() + " prepared=" + pending.preparedAt());
|
||
var exit = saved.lastExit();
|
||
sender.sendMessage(exit == null ? "last exit=none; deadline=none" : "last exit session=" + exit.sessionId()
|
||
+ " character=" + exit.characterId() + " exited=" + exit.exitedAt() + " deadline=" + exit.deadline());
|
||
}
|
||
var player = server.getPlayer(owner);
|
||
if (player == null || !player.isOnline()) sender.sendMessage("Native state: offline; not inspected.");
|
||
else {
|
||
var marker = EquipmentSessionMarker.read(player);
|
||
sender.sendMessage("Online native marker=" + marker.map(token -> "session=" + token.session()
|
||
+ " character=" + token.character() + " phase=" + token.phase()).orElseGet(() ->
|
||
EquipmentSessionMarker.present(player) ? "malformed (retained)" : "none"));
|
||
sender.sendMessage("Online active=" + sessions.active(owner).map(active -> "session=" + active.session()
|
||
+ " character=" + active.character()).orElse("none"));
|
||
}
|
||
});
|
||
} catch (RuntimeException rejected) { report(owner, "inspect-response", rejected); }
|
||
});
|
||
return true;
|
||
}
|
||
|
||
public boolean playerAdventure(CommandSender sender, String[] args) {
|
||
if (closed) return true;
|
||
if (adventureQuestCommands == null || args.length == 0 || !args[0].equals("adventure")
|
||
|| args.length >= 2 && args[1].equals("reroll")) {
|
||
sender.sendMessage("Usage: /fstick adventure [tracking [on|off]]");
|
||
return true;
|
||
}
|
||
adventureQuestCommands.adventure(sender, args);
|
||
return true;
|
||
}
|
||
|
||
public List<String> completePlayerAdventure(CommandSender sender, String[] args) {
|
||
if (closed || adventureQuestCommands == null || args.length == 0 || !args[0].equals("adventure"))
|
||
return List.of();
|
||
return adventureQuestCommands.complete(sender, args).stream()
|
||
.filter(value -> !value.equals("reroll"))
|
||
.toList();
|
||
}
|
||
|
||
private static void adminUsage(CommandSender sender) {
|
||
sender.sendMessage("Usage: /fstickadmin <adventure reroll [confirm]|adventure-site|character view|config|dungeon|experience|give|inspect|party-registrar|quest-giver|rare-shop|recover|revive|shop|training-dummy> ...");
|
||
}
|
||
|
||
private void characterCommand(CommandSender sender, String[] args) {
|
||
if (args.length >= 2 && args[1].equals("find")) {
|
||
characterFind(sender, args);
|
||
return;
|
||
}
|
||
if (args.length >= 2 && args[1].equals("show")) {
|
||
characterShow(sender, args);
|
||
return;
|
||
}
|
||
if (args.length >= 2 && args[1].equals("recover")) {
|
||
characterRecover(sender, args);
|
||
return;
|
||
}
|
||
if (args.length == 3 && args[1].equals("view")
|
||
&& !(sender instanceof org.bukkit.entity.Player)) {
|
||
sender.sendMessage("Character view requires an in-game administrator.");
|
||
return;
|
||
}
|
||
if (characterBooks == null || !(sender instanceof org.bukkit.entity.Player administrator)
|
||
|| args.length != 3 || !args[1].equals("view") || args[2].isBlank()) {
|
||
sender.sendMessage("Usage: /fstickadmin character <find <name...>|show <character-uuid>|recover <character-uuid> <online-player>|view <online-player>>");
|
||
return;
|
||
}
|
||
var matches = server.getOnlinePlayers().stream()
|
||
.filter(org.bukkit.entity.Player::isOnline)
|
||
.filter(player -> player.getName().equals(args[2]))
|
||
.toList();
|
||
if (matches.size() != 1) {
|
||
sender.sendMessage("Character view refused: target must exactly name one online player.");
|
||
return;
|
||
}
|
||
characterBooks.openReadOnly(administrator, matches.getFirst());
|
||
}
|
||
|
||
private void characterFind(CommandSender sender, String[] args) {
|
||
if (args.length < 3 || String.join(" ", java.util.Arrays.copyOfRange(args, 2, args.length)).isBlank()) {
|
||
sender.sendMessage("Usage: /fstickadmin character find <name...>");
|
||
return;
|
||
}
|
||
String query = String.join(" ", java.util.Arrays.copyOfRange(args, 2, args.length));
|
||
String folded = query.toLowerCase(java.util.Locale.ROOT);
|
||
Object ticket = new Object();
|
||
Object requestKey = sender instanceof org.bukkit.entity.Player player
|
||
? player.getUniqueId() : EquipmentAdminCommand.class;
|
||
savedSearches.put(requestKey, ticket);
|
||
characters.catalog().whenComplete((catalog, failure) -> {
|
||
if (closed || savedSearches.get(requestKey) != ticket) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed || !savedSearches.remove(requestKey, ticket) || !sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) {
|
||
sender.sendMessage("Saved character search failed; no records were changed.");
|
||
return;
|
||
}
|
||
rememberSavedCharacters(catalog.records());
|
||
var matches = catalog.records().stream()
|
||
.filter(record -> record.name().toLowerCase(java.util.Locale.ROOT).contains(folded))
|
||
.sorted(java.util.Comparator.comparing(
|
||
(games.dmg.fantasystick.persistence.CharacterRecord record) ->
|
||
record.name().toLowerCase(java.util.Locale.ROOT))
|
||
.thenComparing(record -> record.id().toString()))
|
||
.toList();
|
||
if (matches.isEmpty()) {
|
||
sender.sendMessage(catalog.complete()
|
||
? "No saved characters match '" + query + "'."
|
||
: "No readable saved characters match '" + query
|
||
+ "'; results are incomplete because " + catalog.unreadable() + " record(s) could not be examined.");
|
||
return;
|
||
}
|
||
int pages = (matches.size() + SAVED_SEARCH_PAGE_SIZE - 1) / SAVED_SEARCH_PAGE_SIZE;
|
||
for (int page = 0; page < pages; page++) {
|
||
sender.sendMessage("Saved character results " + (page + 1) + "/" + pages
|
||
+ (catalog.complete() ? "" : " (incomplete: " + catalog.unreadable() + " unreadable)"));
|
||
int from = page * SAVED_SEARCH_PAGE_SIZE;
|
||
for (var record : matches.subList(from, Math.min(matches.size(), from + SAVED_SEARCH_PAGE_SIZE))) {
|
||
boolean active = sessions.activeCharacter(record.id()).filter(sessions::current).isPresent();
|
||
var result = net.kyori.adventure.text.Component.text(record.name() + " — " + record.id()
|
||
+ " — level " + record.level() + " — " + (record.dead() ? "dead" : "alive")
|
||
+ " — " + (active ? "active" : "inactive"))
|
||
.clickEvent(net.kyori.adventure.text.event.ClickEvent.suggestCommand(
|
||
"/fstickadmin character show " + record.id()));
|
||
sender.sendMessage(result);
|
||
}
|
||
}
|
||
}); } catch (RuntimeException rejected) {
|
||
savedSearches.remove(requestKey, ticket);
|
||
report(null, "character-find-response", rejected);
|
||
}
|
||
});
|
||
}
|
||
|
||
private void characterRecover(CommandSender sender, String[] args) {
|
||
if (characterRecovery == null || !(sender instanceof org.bukkit.entity.Player administrator)) {
|
||
sender.sendMessage("Saved character recovery requires an in-game administrator.");
|
||
return;
|
||
}
|
||
UUID character;
|
||
try {
|
||
if (args.length != 4) throw new IllegalArgumentException("Invalid shape");
|
||
character = UUID.fromString(args[2]);
|
||
if (!character.toString().equals(args[2])) throw new IllegalArgumentException("Noncanonical UUID");
|
||
} catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Usage: /fstickadmin character recover <full-character-uuid> <online-player>");
|
||
return;
|
||
}
|
||
var matches = server.getOnlinePlayers().stream().filter(org.bukkit.entity.Player::isOnline)
|
||
.filter(player -> player.getName().equals(args[3])).toList();
|
||
if (matches.size() != 1) {
|
||
sender.sendMessage("Character recovery refused: recipient must exactly name one online player.");
|
||
return;
|
||
}
|
||
characterRecovery.open(administrator, character, matches.getFirst());
|
||
}
|
||
|
||
private void characterShow(CommandSender sender, String[] args) {
|
||
if (characterBooks == null || !(sender instanceof org.bukkit.entity.Player administrator)) {
|
||
sender.sendMessage("Saved character books require an in-game administrator.");
|
||
return;
|
||
}
|
||
UUID character;
|
||
try {
|
||
if (args.length != 3) throw new IllegalArgumentException("Invalid shape");
|
||
character = UUID.fromString(args[2]);
|
||
if (!character.toString().equals(args[2])) throw new IllegalArgumentException("Noncanonical UUID");
|
||
} catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Usage: /fstickadmin character show <full-character-uuid>");
|
||
return;
|
||
}
|
||
characterBooks.openSavedReadOnly(administrator, character);
|
||
}
|
||
|
||
private synchronized void rememberSavedCharacters(
|
||
java.util.Collection<games.dmg.fantasystick.persistence.CharacterRecord> records) {
|
||
for (var record : records.stream().sorted(java.util.Comparator.comparing(value -> value.id().toString())).toList()) {
|
||
savedCharacterCatalog.put(record.id(), record.name());
|
||
while (savedCharacterCatalog.size() > SAVED_CATALOG_COMPLETION_LIMIT)
|
||
savedCharacterCatalog.remove(savedCharacterCatalog.keySet().iterator().next());
|
||
}
|
||
}
|
||
|
||
private synchronized java.util.Map<UUID, String> savedCharacterSuggestions() {
|
||
return java.util.Map.copyOf(savedCharacterCatalog);
|
||
}
|
||
|
||
private void experience(CommandSender sender, String[] args) {
|
||
if (experienceGrant == null || args.length < 4 || !args[1].equals("give")) {
|
||
sender.sendMessage("Usage: /fstickadmin experience give <active-character-name...> <positive-amount>"); return;
|
||
}
|
||
BigInteger amount;
|
||
try { amount = new BigInteger(args[args.length - 1]); }
|
||
catch (NumberFormatException invalid) {
|
||
sender.sendMessage("Experience amount is invalid; enter a positive whole number."); return;
|
||
}
|
||
if (amount.signum() <= 0) {
|
||
sender.sendMessage("Experience amount is invalid; enter a positive whole number."); return;
|
||
}
|
||
String name = String.join(" ", java.util.Arrays.copyOfRange(args, 2, args.length - 1));
|
||
if (name.isBlank()) {
|
||
sender.sendMessage("Usage: /fstickadmin experience give <active-character-name...> <positive-amount>"); return;
|
||
}
|
||
var matches = sessions.activeCharacters().stream().filter(active -> active.record().name().equals(name)).toList();
|
||
if (matches.isEmpty()) {
|
||
sender.sendMessage("Experience grant refused: character '" + name + "' is not active. No fantasy XP changed."); return;
|
||
}
|
||
if (matches.size() != 1) {
|
||
sender.sendMessage("Experience grant refused: active character name '" + name
|
||
+ "' is ambiguous. No fantasy XP changed."); return;
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) {
|
||
sender.sendMessage("Experience grant refused before persistence. No fantasy XP changed."); return;
|
||
}
|
||
var target = matches.getFirst();
|
||
boolean accepted = experienceGrant.grant(target.session(), target.record(), amount, result -> {
|
||
if (closed || !sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(switch (result.status()) {
|
||
case APPLIED -> "Granted " + result.requested() + " fantasy XP to " + result.name()
|
||
+ "; applied " + result.applied() + " after cap clamping; resulting level " + result.level() + ".";
|
||
case AT_CAP -> "Granted 0 of requested " + result.requested() + " fantasy XP to " + result.name()
|
||
+ "; the character is already capped at level " + result.level() + ".";
|
||
case STALE -> "Experience grant refused: " + result.name()
|
||
+ " changed concurrently. No grant success was recorded.";
|
||
case UNAVAILABLE -> "Experience grant refused: " + result.name()
|
||
+ " is unavailable or dead. No fantasy XP changed.";
|
||
case FAILED -> "Experience grant failed before acknowledgment for " + result.name()
|
||
+ "; no success was reported. See server diagnostics.";
|
||
});
|
||
});
|
||
if (!accepted) sender.sendMessage("Experience grant refused: the captured character session changed before persistence. No fantasy XP changed.");
|
||
}
|
||
|
||
private void adminRevive(CommandSender sender,String[] args){if(args.length!=2||args[1].isBlank()||adminRevival==null||!(sender instanceof org.bukkit.entity.Player admin)){sender.sendMessage("Usage: /fstickadmin revive <online-player> (an in-game administrator must select the Tail)");return;}var matches=server.getOnlinePlayers().stream().filter(player->player.isOnline()&&player.getName().equalsIgnoreCase(args[1])).toList();if(matches.size()!=1){sender.sendMessage("Admin revival refused: target must name one online player. No item changed.");return;}adminRevival.open(admin,matches.getFirst(),adminReviveSettings.timeout());}
|
||
|
||
private void shop(CommandSender sender,String[] args){
|
||
if(armorers==null||armorerController==null||args.length<2){shopUsage(sender);return;}
|
||
if(args[1].equals("restock")&&args.length==2&&armorMarket!=null){armorMarket.restock().whenComplete((catalog,failure)->{
|
||
if(failure!=null)report(null,"shop-restock",failure);if(closed)return;try{nextTick.accept(()->{
|
||
if(closed||!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;
|
||
if(failure!=null)sender.sendMessage("Fantasy Armorer restock failed; the prior catalog is unchanged.");
|
||
else sender.sendMessage("Restocked all Fantasy Armorers with catalog "+catalog.revision()+"; the next automatic restock remains 00:00 UTC.");
|
||
});}catch(RuntimeException rejected){report(null,"shop-restock-response",rejected);}});return;}
|
||
if(args[1].equals("list")&&args.length==2){var values=armorers.all();if(values.isEmpty())sender.sendMessage("No Fantasy Armorers are registered.");else for(var value:values)sender.sendMessage(value.id()+" "+(value.name().isBlank()?"Fantasy Armorer":value.name())+" @ "+value.world()+" "+value.x()+" "+value.y()+" "+value.z());return;}
|
||
if(args[1].equals("place")&&sender instanceof org.bukkit.entity.Player player){String name=args.length<3?"":String.join(" ",java.util.Arrays.copyOfRange(args,2,args.length));var location=player.getLocation().clone();java.util.concurrent.CompletableFuture<games.dmg.fantasystick.shop.FantasyArmorer> operation;try{operation=armorers.place(name,location.getWorld().getUID(),location.getX(),location.getY(),location.getZ(),location.getYaw(),location.getPitch());}catch(IllegalArgumentException invalid){sender.sendMessage("Fantasy Armorer name is invalid.");return;}operation.whenComplete((saved,failure)->placeShopResponse(player,location,saved,failure));return;}
|
||
if(args[1].equals("remove")&&args.length==3){UUID id;try{id=UUID.fromString(args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Fantasy Armorer UUID is invalid.");return;}armorers.remove(id).whenComplete((removed,failure)->removeShopResponse(sender,id,removed,failure));return;}
|
||
shopUsage(sender);
|
||
}
|
||
private static void shopUsage(CommandSender sender){sender.sendMessage("Usage: /fstickadmin shop <place [name...]|remove <shop-uuid>|list|restock>");}
|
||
private void placeShopResponse(org.bukkit.entity.Player player,org.bukkit.Location location,games.dmg.fantasystick.shop.FantasyArmorer saved,Throwable failure){if(failure!=null)report(player.getUniqueId(),"shop-place",failure);if(closed)return;nextTick.accept(()->{if(closed)return;if(failure!=null){if(player.isOnline())player.sendMessage("Fantasy Armorer placement failed; no registration or entity changed.");return;}try{int x=location.getBlockX()>>4,z=location.getBlockZ()>>4;if(location.getWorld().isChunkLoaded(x,z))armorerController.reconcile(location.getWorld().getChunkAt(x,z));if(player.isOnline())player.sendMessage("Placed Fantasy Armorer "+saved.id()+".");}catch(RuntimeException entityFailure){report(player.getUniqueId(),"shop-entity",entityFailure);armorers.remove(saved.id()).whenComplete((ignored,rollback)->nextTick.accept(()->{armorerController.removeLoaded(saved.id());if(player.isOnline())player.sendMessage("Fantasy Armorer placement failed; no registration or entity changed.");}));}});}
|
||
private void removeShopResponse(CommandSender sender,UUID id,java.util.Optional<games.dmg.fantasystick.shop.FantasyArmorer> removed,Throwable failure){if(failure!=null)report(null,"shop-remove",failure);if(closed)return;nextTick.accept(()->{if(failure!=null)sender.sendMessage("Fantasy Armorer removal failed; registration and entity are unchanged.");else if(removed.isEmpty())sender.sendMessage("Fantasy Armorer not found.");else try{armorerController.removeLoaded(id);sender.sendMessage("Removed Fantasy Armorer "+id+".");}catch(RuntimeException entityFailure){var value=removed.orElseThrow();report(null,"shop-entity-remove",entityFailure);armorers.restore(value).whenComplete((restored,rollback)->{if(rollback!=null)report(null,"shop-remove-rollback",rollback);if(closed)return;nextTick.accept(()->{if(rollback==null){var world=server.getWorld(value.world());if(world!=null&&world.isChunkLoaded(((int)Math.floor(value.x()))>>4,((int)Math.floor(value.z()))>>4))armorerController.reconcile(world.getChunkAt(((int)Math.floor(value.x()))>>4,((int)Math.floor(value.z()))>>4));sender.sendMessage("Fantasy Armorer removal failed; registration and entity are unchanged.");}else sender.sendMessage("Fantasy Armorer removal rollback failed; inspect diagnostics.");});});}});}
|
||
|
||
private void rareShop(CommandSender sender,String[] args){if(rareMerchants==null||rareMerchantController==null||rareMarket==null||args.length<2){rareShopUsage(sender);return;}if(args[1].equals("restock")&&args.length==2){rareMarket.restock().whenComplete((catalog,failure)->{if(failure!=null)report(null,"rare-shop-restock",failure);if(closed)return;nextTick.accept(()->{if(closed||!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;sender.sendMessage(failure==null?"Restocked Rare Items catalog "+catalog.revision()+"; next automatic restock remains 00:00 UTC.":"Rare Items restock failed; prior catalog is unchanged.");});});return;}if(args[1].equals("list")&&args.length==2){var values=rareMerchants.all();if(values.isEmpty())sender.sendMessage("No Rare Items merchants are registered.");else for(var value:values)sender.sendMessage(value.id()+" "+(value.name().isBlank()?"Rare Items":value.name())+" @ "+value.world()+" "+value.x()+" "+value.y()+" "+value.z());return;}if(args[1].equals("place")&&sender instanceof org.bukkit.entity.Player player){String name=args.length<3?"":String.join(" ",java.util.Arrays.copyOfRange(args,2,args.length));var location=player.getLocation().clone();try{rareMerchants.place(name,location.getWorld().getUID(),location.getX(),location.getY(),location.getZ(),location.getYaw(),location.getPitch()).whenComplete((saved,failure)->{if(failure!=null)report(player.getUniqueId(),"rare-shop-place",failure);if(closed)return;nextTick.accept(()->{if(closed||!player.hasPermission(PERMISSION)||!player.isOnline())return;if(failure!=null){player.sendMessage("Rare Items placement failed; prior state is unchanged.");return;}try{int x=location.getBlockX()>>4,z=location.getBlockZ()>>4;if(location.getWorld().isChunkLoaded(x,z))rareMerchantController.reconcile(location.getWorld().getChunkAt(x,z));player.sendMessage("Placed Rare Items merchant "+saved.id()+".");}catch(RuntimeException entityFailure){report(player.getUniqueId(),"rare-shop-entity",entityFailure);rareMerchants.remove(saved.id());rareMerchantController.removeLoaded(saved.id());player.sendMessage("Rare Items placement failed; registration rollback was requested.");}});});}catch(IllegalArgumentException invalid){sender.sendMessage("Rare Items merchant name is invalid.");}return;}if(args[1].equals("remove")&&args.length==3){UUID id;try{id=UUID.fromString(args[2]);if(!id.toString().equals(args[2]))throw new IllegalArgumentException();}catch(IllegalArgumentException invalid){sender.sendMessage("Rare Items merchant UUID is invalid.");return;}rareMerchants.remove(id).whenComplete((removed,failure)->{if(failure!=null)report(null,"rare-shop-remove",failure);if(closed)return;nextTick.accept(()->{if(closed||!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Rare Items removal failed; registration is unchanged.");else if(removed.isEmpty())sender.sendMessage("Rare Items merchant not found.");else{rareMerchantController.removeLoaded(id);sender.sendMessage("Removed Rare Items merchant "+id+".");}});});return;}rareShopUsage(sender);}
|
||
private static void rareShopUsage(CommandSender sender){sender.sendMessage("Usage: /fstickadmin rare-shop <place [name...]|remove <shop-uuid>|list|restock>");}
|
||
|
||
private void trainingDummy(CommandSender sender, String[] args) {
|
||
if (trainingDummies == null || trainingDummyController == null || args.length < 2) {
|
||
trainingDummyUsage(sender); return;
|
||
}
|
||
if (args[1].equals("list") && args.length == 2) {
|
||
var values = trainingDummies.all();
|
||
if (values.isEmpty()) sender.sendMessage("No training dummies are registered.");
|
||
else for (var value : values) sender.sendMessage(value.id() + " " + value.displayName() + " @ "
|
||
+ value.world() + " " + value.x() + " " + value.y() + " " + value.z());
|
||
return;
|
||
}
|
||
if (args[1].equals("place") && sender instanceof org.bukkit.entity.Player player) {
|
||
String name = args.length < 3 ? "" : String.join(" ", java.util.Arrays.copyOfRange(args, 2, args.length));
|
||
var location = player.getLocation().clone();
|
||
try {
|
||
trainingDummies.place(name, location.getWorld().getUID(), location.getX(), location.getY(),
|
||
location.getZ(), location.getYaw(), location.getPitch())
|
||
.whenComplete((saved, failure) -> placeDummyResponse(player, location, saved, failure));
|
||
} catch (IllegalArgumentException invalid) { sender.sendMessage("Training dummy name is invalid."); }
|
||
return;
|
||
}
|
||
if (args[1].equals("remove") && args.length == 3) {
|
||
UUID id;
|
||
try { id = UUID.fromString(args[2]); }
|
||
catch (IllegalArgumentException invalid) { sender.sendMessage("Training dummy UUID is invalid."); return; }
|
||
trainingDummies.remove(id).whenComplete((removed, failure) -> removeDummyResponse(sender, id, removed, failure));
|
||
return;
|
||
}
|
||
trainingDummyUsage(sender);
|
||
}
|
||
|
||
private static void trainingDummyUsage(CommandSender sender) {
|
||
sender.sendMessage("Usage: /fstickadmin training-dummy <place [name...]|remove <dummy-uuid>|list>");
|
||
}
|
||
|
||
private void placeDummyResponse(org.bukkit.entity.Player player, org.bukkit.Location location,
|
||
games.dmg.fantasystick.training.TrainingDummy saved, Throwable failure) {
|
||
if (failure != null) report(player.getUniqueId(), "training-dummy-place", failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure != null) {
|
||
if (player.isOnline()) player.sendMessage("Training dummy placement failed; no record or entity changed.");
|
||
return;
|
||
}
|
||
if (!player.isOnline() || !player.hasPermission(PERMISSION)) {
|
||
trainingDummies.remove(saved.id()).whenComplete((ignored, rollbackFailure) -> {
|
||
if (rollbackFailure != null) report(player.getUniqueId(), "training-dummy-permission-rollback", rollbackFailure);
|
||
if (!closed) nextTick.accept(() -> {
|
||
trainingDummyController.removeLoaded(saved.id());
|
||
if (player.isOnline()) player.sendMessage("Training dummy placement was cancelled because permission changed.");
|
||
});
|
||
});
|
||
return;
|
||
}
|
||
try {
|
||
int chunkX = location.getBlockX() >> 4, chunkZ = location.getBlockZ() >> 4;
|
||
if (location.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
||
trainingDummyController.reconcile(location.getWorld().getChunkAt(chunkX, chunkZ));
|
||
}
|
||
player.sendMessage("Placed training dummy " + saved.id() + ".");
|
||
} catch (RuntimeException entityFailure) {
|
||
report(player.getUniqueId(), "training-dummy-entity", entityFailure);
|
||
trainingDummies.remove(saved.id()).whenComplete((ignored, rollbackFailure) -> {
|
||
if (rollbackFailure != null) report(player.getUniqueId(), "training-dummy-rollback", rollbackFailure);
|
||
if (!closed) nextTick.accept(() -> {
|
||
trainingDummyController.removeLoaded(saved.id());
|
||
if (player.isOnline()) player.sendMessage("Training dummy placement failed; no record or entity changed.");
|
||
});
|
||
});
|
||
}
|
||
}); } catch (RuntimeException rejected) { report(player.getUniqueId(), "training-dummy-response", rejected); }
|
||
}
|
||
|
||
private void removeDummyResponse(CommandSender sender, UUID id,
|
||
java.util.Optional<games.dmg.fantasystick.training.TrainingDummy> removed, Throwable failure) {
|
||
if (failure != null) report(null, "training-dummy-remove", failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure != null) { sender.sendMessage("Training dummy removal failed; record and entity are unchanged."); return; }
|
||
if (removed.isEmpty()) { sender.sendMessage("Training dummy not found."); return; }
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) {
|
||
restoreDummy(sender, removed.orElseThrow(), "Training dummy removal was cancelled because permission changed.");
|
||
return;
|
||
}
|
||
try { trainingDummyController.removeLoaded(id); sender.sendMessage("Removed training dummy " + id + "."); }
|
||
catch (RuntimeException entityFailure) {
|
||
report(null, "training-dummy-entity", entityFailure);
|
||
restoreDummy(sender, removed.orElseThrow(), "Training dummy removal failed; record and entity are unchanged.");
|
||
}
|
||
}); } catch (RuntimeException rejected) { report(null, "training-dummy-response", rejected); }
|
||
}
|
||
|
||
private void restoreDummy(CommandSender sender, games.dmg.fantasystick.training.TrainingDummy removed, String message) {
|
||
trainingDummies.restore(removed).whenComplete((restored, rollbackFailure) -> {
|
||
if (rollbackFailure != null) report(null, "training-dummy-rollback", rollbackFailure);
|
||
if (closed) return;
|
||
nextTick.accept(() -> {
|
||
if (rollbackFailure == null) {
|
||
var world = server.getWorld(restored.world());
|
||
int chunkX = ((int) Math.floor(restored.x())) >> 4, chunkZ = ((int) Math.floor(restored.z())) >> 4;
|
||
if (world != null && world.isChunkLoaded(chunkX, chunkZ)) trainingDummyController.reconcile(world.getChunkAt(chunkX, chunkZ));
|
||
}
|
||
sender.sendMessage(message);
|
||
});
|
||
});
|
||
}
|
||
|
||
private void placeRegistrarResponse(org.bukkit.entity.Player player,org.bukkit.Location location,games.dmg.fantasystick.party.PartyRegistrar saved,Throwable failure){if(failure!=null)report(player.getUniqueId(),"party-registrar-place",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure!=null){if(player.isOnline())player.sendMessage("Party Registrar placement failed; no registration or entity changed.");return;}try{int chunkX=location.getBlockX()>>4,chunkZ=location.getBlockZ()>>4;if(location.getWorld().isChunkLoaded(chunkX,chunkZ))partyRegistrarController.reconcile(location.getWorld().getChunkAt(chunkX,chunkZ));if(partyEvents!=null)partyEvents.registrarPlaced("player",player.getUniqueId(),player.getName(),saved,partyRegistrarController.loadedEntity(saved.id()).orElse(null),partyRegistrarController.loadedEntity(saved.id()).isPresent());if(player.isOnline())player.sendMessage("Placed Party Registrar "+saved.id()+".");}catch(RuntimeException entityFailure){report(player.getUniqueId(),"party-registrar-entity",entityFailure);partyRegistrars.remove(saved.id()).whenComplete((ignored,rollbackFailure)->{if(rollbackFailure!=null)report(player.getUniqueId(),"party-registrar-rollback",rollbackFailure);if(closed)return;nextTick.accept(()->{partyRegistrarController.removeLoaded(saved.id());if(player.isOnline())player.sendMessage("Party Registrar placement failed; no registration or entity changed.");});});}});}catch(RuntimeException rejected){report(player.getUniqueId(),"party-registrar-response",rejected);}}
|
||
private void removeRegistrarResponse(CommandSender sender,UUID id,java.util.Optional<games.dmg.fantasystick.party.PartyRegistrar> removed,Throwable failure){if(failure!=null)report(null,"party-registrar-remove",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure!=null)sender.sendMessage("Party Registrar removal failed; registration and entity are unchanged.");else if(removed.isEmpty())sender.sendMessage("Party Registrar not found.");else try{var loaded=partyRegistrarController.loadedEntity(id);partyRegistrarController.removeLoaded(id);if(partyEvents!=null){String actorKind=sender instanceof org.bukkit.entity.Player?"player":sender instanceof org.bukkit.command.BlockCommandSender?"command_block":"console";UUID actorPlayer=sender instanceof org.bukkit.entity.Player player?player.getUniqueId():null;String actorName=sender instanceof org.bukkit.entity.Player?sender.getName():null;partyEvents.registrarRemoved(actorKind,actorPlayer,actorName,removed.orElseThrow(),loaded.orElse(null),false);}sender.sendMessage("Removed Party Registrar "+id+".");}catch(RuntimeException entityFailure){report(null,"party-registrar-entity",entityFailure);partyRegistrars.restore(removed.orElseThrow()).whenComplete((restored,rollbackFailure)->{if(rollbackFailure!=null)report(null,"party-registrar-rollback",rollbackFailure);if(closed)return;nextTick.accept(()->{if(rollbackFailure==null){var world=server.getWorld(restored.world());int chunkX=((int)Math.floor(restored.x()))>>4,chunkZ=((int)Math.floor(restored.z()))>>4;if(world!=null&&world.isChunkLoaded(chunkX,chunkZ))partyRegistrarController.reconcile(world.getChunkAt(chunkX,chunkZ));}sender.sendMessage("Party Registrar removal failed; registration and entity are unchanged.");});});}});}catch(RuntimeException rejected){report(null,"party-registrar-response",rejected);}}
|
||
private void partyRegistrar(CommandSender sender,String[] args){
|
||
if(partyRegistrars==null||partyRegistrarController==null||args.length<2){sender.sendMessage("Usage: /fstickadmin party-registrar <place [name...]|remove <registrar-uuid>|list>");return;}
|
||
if(args[1].equals("list")&&args.length==2){var values=partyRegistrars.all();if(values.isEmpty())sender.sendMessage("No Party Registrars are registered.");else for(var value:values)sender.sendMessage(value.id()+" "+(value.name().isBlank()?"Party Registrar":value.name())+" @ "+value.world()+" "+value.x()+" "+value.y()+" "+value.z());return;}
|
||
if(args[1].equals("place")&&sender instanceof org.bukkit.entity.Player player){String name=args.length<3?"":String.join(" ",java.util.Arrays.copyOfRange(args,2,args.length));var location=player.getLocation().clone();java.util.concurrent.CompletableFuture<games.dmg.fantasystick.party.PartyRegistrar> operation;try{operation=partyRegistrars.place(name,location.getWorld().getUID(),location.getX(),location.getY(),location.getZ(),location.getYaw(),location.getPitch());}catch(IllegalArgumentException invalid){sender.sendMessage("Party Registrar name is invalid.");return;}operation.whenComplete((saved,failure)->placeRegistrarResponse(player,location,saved,failure));return;}
|
||
if(args[1].equals("remove")&&args.length==3){UUID id;try{id=UUID.fromString(args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Party Registrar UUID is invalid.");return;}partyRegistrars.remove(id).whenComplete((removed,failure)->removeRegistrarResponse(sender,id,removed,failure));return;}
|
||
sender.sendMessage("Usage: /fstickadmin party-registrar <place [name...]|remove <registrar-uuid>|list>");
|
||
}
|
||
|
||
private void give(CommandSender sender, String[] args) {
|
||
if (args.length != 2 || args[1].isBlank() || characterIssuer == null) {
|
||
sender.sendMessage("Usage: /fstickadmin give <online-player>"); return;
|
||
}
|
||
var matches = server.getOnlinePlayers().stream().filter(player -> player.isOnline()
|
||
&& player.getName().equalsIgnoreCase(args[1])).toList();
|
||
if (matches.size() != 1) {
|
||
sender.sendMessage("Character issue refused: target must name one online player. No character or item was created."); return;
|
||
}
|
||
var target = matches.getFirst();
|
||
characterIssuer.issue(target, outcome -> {
|
||
if (closed || !sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(switch (outcome) {
|
||
case DELIVERED -> "Issued one new character sheet to " + target.getName() + ".";
|
||
case FULL -> "Character issue refused: " + target.getName() + " has no inventory space. No character was created.";
|
||
case BUSY -> "Character issue refused: another delivery to " + target.getName() + " is pending.";
|
||
case STALE -> "Character issue refused: target disconnected or the reserved inventory slot changed. No sheet was delivered.";
|
||
case SAVE_FAILED -> "Character issue failed before delivery; no sheet was delivered. See server diagnostics.";
|
||
case RETAINED -> "Character issue has ambiguous retained state; no retry was performed. See server diagnostics.";
|
||
});
|
||
});
|
||
}
|
||
|
||
private void configuration(CommandSender sender, String[] args) {
|
||
if (args.length < 2 || args.length > 3) { configurationUsage(sender); return; }
|
||
if (args[1].equals("adventure-mode")) { adventureConfiguration(sender, args); return; }
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.SwitchDelaySettings.KEY)) { switchDelayConfiguration(sender,args); return; }
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.RoleplaySettings.KEY)) { roleplayConfiguration(sender,args); return; }
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.PartySettings.KEY)) { partyConfiguration(sender,args); return; }
|
||
if (partyEconomySettings != null && games.dmg.fantasystick.persistence.PartyEconomySettings.keys().contains(args[1])) { partyEconomyConfiguration(sender,args); return; }
|
||
if(gearSettings!=null&&games.dmg.fantasystick.persistence.GearSettings.keys().contains(args[1])){gearConfiguration(sender,args);return;}
|
||
if(rareSettings!=null&&games.dmg.fantasystick.persistence.RareSettings.keys().contains(args[1])){rareConfiguration(sender,args);return;}
|
||
if(downedSettings!=null&&games.dmg.fantasystick.persistence.DownedSettings.keys().contains(args[1])){downedConfiguration(sender,args);return;}
|
||
if (coinSettings != null && games.dmg.fantasystick.persistence.CoinSettings.keys().contains(args[1])) { coinConfiguration(sender,args); return; }
|
||
if (hardMobXpSettings != null && args[1].equals(games.dmg.fantasystick.persistence.HardMobXpSettings.KEY)) {
|
||
hardMobXpConfiguration(sender, args); return;
|
||
}
|
||
if (adventureQuestSettings != null && games.dmg.fantasystick.persistence.AdventureQuestSettings.keys().contains(args[1])) {
|
||
adventureQuestConfiguration(sender, args); return;
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.SheetResourcePackSettings.URL_KEY)||args[1].equals(games.dmg.fantasystick.persistence.SheetResourcePackSettings.SHA1_KEY)) { sheetResourcePackConfiguration(sender,args); return; }
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.AdminReviveSettings.KEY)) { adminReviveConfiguration(sender,args); return; }
|
||
if (outOfCombatRecoverySettings != null
|
||
&& games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.keys().contains(args[1])) {
|
||
outOfCombatRecoveryConfiguration(sender, args); return;
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY)
|
||
&& quickerRegenerationSettings != null) {
|
||
quickerRegenerationConfiguration(sender, args); return;
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY)
|
||
&& quickerRegenerationIISettings != null) {
|
||
quickerRegenerationIIConfiguration(sender, args); return;
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.HealthStealSettings.KEY) && healthStealSettings != null) {
|
||
healthStealConfiguration(sender, args); return;
|
||
}
|
||
if (longbowSettings != null && games.dmg.fantasystick.persistence.LongbowSettings.keys().contains(args[1])) {
|
||
longbowConfiguration(sender, args); return;
|
||
}
|
||
if (quickstepSettings != null && games.dmg.fantasystick.persistence.QuickstepSettings.keys().contains(args[1])) {
|
||
quickstepConfiguration(sender, args); return;
|
||
}
|
||
if (secondWindSettings != null && games.dmg.fantasystick.persistence.SecondWindSettings.keys().contains(args[1])) {
|
||
secondWindConfiguration(sender, args); return;
|
||
}
|
||
if (stoneSkinSettings != null && games.dmg.fantasystick.persistence.StoneSkinSettings.keys().contains(args[1])) {
|
||
stoneSkinConfiguration(sender, args); return;
|
||
}
|
||
if (shieldBashSettings != null && games.dmg.fantasystick.persistence.ShieldBashSettings.keys().contains(args[1])) {
|
||
shieldBashConfiguration(sender, args); return;
|
||
}
|
||
if (hexSettings != null && games.dmg.fantasystick.persistence.HexSettings.keys().contains(args[1])) {
|
||
hexConfiguration(sender, args); return;
|
||
}
|
||
if (inspireSettings != null && games.dmg.fantasystick.persistence.InspireSettings.keys().contains(args[1])) {
|
||
inspireConfiguration(sender, args); return;
|
||
}
|
||
if (mendingLightSettings != null && games.dmg.fantasystick.persistence.MendingLightSettings.keys().contains(args[1])) {
|
||
mendingLightConfiguration(sender, args); return;
|
||
}
|
||
if (purifySettings != null && games.dmg.fantasystick.persistence.PurifySettings.keys().contains(args[1])) {
|
||
purifyConfiguration(sender, args); return;
|
||
}
|
||
if (guardianBondSettings != null && games.dmg.fantasystick.persistence.GuardianBondSettings.keys().contains(args[1])) {
|
||
guardianBondConfiguration(sender, args); return;
|
||
}
|
||
if (rallyingCrySettings != null && games.dmg.fantasystick.persistence.RallyingCrySettings.keys().contains(args[1])) {
|
||
rallyingCryConfiguration(sender, args); return;
|
||
}
|
||
if (frostNovaSettings != null && games.dmg.fantasystick.persistence.FrostNovaSettings.keys().contains(args[1])) {
|
||
frostNovaConfiguration(sender, args); return;
|
||
}
|
||
if (chainLightningSettings != null && games.dmg.fantasystick.persistence.ChainLightningSettings.keys().contains(args[1])) {
|
||
chainLightningConfiguration(sender, args); return;
|
||
}
|
||
if (sanctuarySettings != null && games.dmg.fantasystick.persistence.SanctuarySettings.keys().contains(args[1])) {
|
||
sanctuaryConfiguration(sender, args); return;
|
||
}
|
||
if (warBannerSettings != null && games.dmg.fantasystick.persistence.WarBannerSettings.keys().contains(args[1])) {
|
||
warBannerConfiguration(sender, args); return;
|
||
}
|
||
if (meteorSettings != null && games.dmg.fantasystick.persistence.MeteorSettings.keys().contains(args[1])) {
|
||
meteorConfiguration(sender, args); return;
|
||
}
|
||
if (fireballSettings != null && games.dmg.fantasystick.persistence.FireballSettings.keys().contains(args[1])) {
|
||
fireballConfiguration(sender, args); return;
|
||
}
|
||
if (frostSettings == null || !games.dmg.fantasystick.persistence.FrostShardSettings.keys().contains(args[1])) {
|
||
configurationUsage(sender); return;
|
||
}
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + frostSettings.value(key) + " (applies to future Frost Shard casts only)");
|
||
return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.FrostShardSettings.Update> operation;
|
||
try { operation = frostSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Frost Shard setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try {
|
||
nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
frostShard.configure(saved.settings());
|
||
abilities.replace(frostShard.definition());
|
||
frostSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Frost Shard casts; active effects and deadlines are unchanged."
|
||
: "Frost Shard configuration save failed; the effective setting is unchanged.");
|
||
});
|
||
} catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void fireballConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
var actor = abilityConfigEvents == null ? null : abilityConfigEvents.capture(sender);
|
||
String before = fireballSettings.value(key);
|
||
if (args.length == 2) {
|
||
if (abilityConfigEvents != null) abilityConfigEvents.read(actor, "fireball", key, before);
|
||
sender.sendMessage(key + "=" + before + " (applies to future Fireball casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.FireballSettings.Update> operation;
|
||
try { operation = fireballSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Fireball setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null && fireballSettings.publish(saved)) {
|
||
fireball.configure(fireballSettings.settings()); abilities.replace(fireball.definition());
|
||
if (abilityConfigEvents != null) abilityConfigEvents.changed(actor, "fireball", key, before, saved.value());
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Fireball casts; active projectiles and deadlines are unchanged."
|
||
: "Fireball configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void outOfCombatRecoveryConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + outOfCombatRecoverySettings.value(key)
|
||
+ " (applies to future recovery evaluations; the current activity timestamp is retained)");
|
||
return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.Update> operation;
|
||
try { operation = outOfCombatRecoverySettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Out-of-combat recovery setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
boolean applied = false;
|
||
if (failure == null) {
|
||
applied = outOfCombatRecoverySettings.publish(saved);
|
||
if (applied) outOfCombatRecovery.configure(saved.settings());
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) sender.sendMessage("Out-of-combat recovery configuration save failed; effective values are unchanged.");
|
||
else if (!applied) sender.sendMessage("Saved request was superseded; effective " + key + "="
|
||
+ outOfCombatRecoverySettings.value(key) + ".");
|
||
else sender.sendMessage("Saved " + key + "=" + saved.value()
|
||
+ "; future evaluations use it and current activity timestamps are retained.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void quickerRegenerationConfiguration(CommandSender sender, String[] args) {
|
||
String key=games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY;String before=quickerRegenerationSettings.value();String actorKind=sender instanceof org.bukkit.entity.Player?"player":sender instanceof org.bukkit.command.BlockCommandSender?"command_block":"console";UUID actorPlayer=sender instanceof org.bukkit.entity.Player player?player.getUniqueId():null;String actorName=sender instanceof org.bukkit.entity.Player?sender.getName():null;
|
||
if (args.length == 2) {
|
||
if(passiveEvents!=null)passiveEvents.configRead(actorKind,actorPlayer,actorName,key,before);
|
||
sender.sendMessage(key + "=" + before + " (applies to future recovery pulses only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.QuickerRegenerationSettings.Update> operation;
|
||
try { operation = quickerRegenerationSettings.set(args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Quicker Regeneration I setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-quicker-regeneration-i", failure); if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return; boolean applied = false;
|
||
if (failure == null) {
|
||
applied = quickerRegenerationSettings.publish(saved);
|
||
if (applied) { quickerRegeneration.configure(saved.settings()); passiveRegistry.replace(quickerRegeneration.definition());if(passiveEvents!=null)passiveEvents.configChanged(actorKind,actorPlayer,actorName,key,before,saved.value()); }
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) sender.sendMessage("Quicker Regeneration I configuration save failed; effective value is unchanged.");
|
||
else if (!applied) sender.sendMessage("Saved request was superseded; effective "
|
||
+ games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY + "=" + quickerRegenerationSettings.value() + ".");
|
||
else sender.sendMessage("Saved " + games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY
|
||
+ "=" + saved.value() + " for future recovery pulses.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void quickerRegenerationIIConfiguration(CommandSender sender, String[] args) {
|
||
if (args.length == 2) {
|
||
sender.sendMessage(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY + "="
|
||
+ quickerRegenerationIISettings.value() + " (applies to future recovery pulses only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.Update> operation;
|
||
try { operation = quickerRegenerationIISettings.set(args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Quicker Regeneration II setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-quicker-regeneration-ii", failure); if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return; boolean applied = false;
|
||
if (failure == null) {
|
||
applied = quickerRegenerationIISettings.publish(saved);
|
||
if (applied) { quickerRegenerationII.configure(saved.settings()); passiveRegistry.replace(quickerRegenerationII.definition()); }
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) sender.sendMessage("Quicker Regeneration II configuration save failed; effective value is unchanged.");
|
||
else if (!applied) sender.sendMessage("Saved request was superseded; effective "
|
||
+ games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY + "=" + quickerRegenerationIISettings.value() + ".");
|
||
else sender.sendMessage("Saved " + games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY
|
||
+ "=" + saved.value() + " for future recovery pulses.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void healthStealConfiguration(CommandSender sender, String[] args) {
|
||
if (args.length == 2) {
|
||
sender.sendMessage(games.dmg.fantasystick.persistence.HealthStealSettings.KEY + "="
|
||
+ healthStealSettings.value() + " (applies to later qualifying final blows only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.HealthStealSettings.Update> operation;
|
||
try { operation = healthStealSettings.set(args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Health Steal setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-health-steal", failure); if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return; boolean applied = false;
|
||
if (failure == null) {
|
||
applied = healthStealSettings.publish(saved);
|
||
if (applied) { healthSteal.configure(saved.settings()); passiveRegistry.replace(healthSteal.definition()); }
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) sender.sendMessage("Health Steal configuration save failed; effective value is unchanged.");
|
||
else if (!applied) sender.sendMessage("Saved request was superseded; effective "
|
||
+ games.dmg.fantasystick.persistence.HealthStealSettings.KEY + "=" + healthStealSettings.value() + ".");
|
||
else sender.sendMessage("Saved " + games.dmg.fantasystick.persistence.HealthStealSettings.KEY
|
||
+ "=" + saved.value() + " for later qualifying final blows.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void longbowConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + longbowSettings.value(key) + " (applies to future Longbow shots only)");
|
||
return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.LongbowSettings.Update> operation;
|
||
try { operation = longbowSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Longbow setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try {
|
||
nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
longbow.configure(saved.settings());
|
||
abilities.replace(longbow.definition());
|
||
longbowSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Longbow shots; active shots and deadlines are unchanged."
|
||
: "Longbow configuration save failed; the effective setting is unchanged.");
|
||
});
|
||
} catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void quickstepConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + quickstepSettings.value(key) + " (applies to future Quickstep dashes only)");
|
||
return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.QuickstepSettings.Update> operation;
|
||
try { operation = quickstepSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Quickstep setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try {
|
||
nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
quickstep.configure(saved.settings()); abilities.replace(quickstep.definition());
|
||
quickstepSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Quickstep dashes; active movement and deadlines are unchanged."
|
||
: "Quickstep configuration save failed; the effective setting is unchanged.");
|
||
});
|
||
} catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void inspireConfiguration(CommandSender sender,String[] args){String key=args[1];if(args.length==2){sender.sendMessage(key+"="+inspireSettings.value(key)+" (applies to future Inspire casts only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.InspireSettings.Update> operation;try{operation=inspireSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Inspire setting is invalid; the effective value is unchanged.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure==null){inspire.configure(saved.settings());abilities.replace(inspire.definition());inspireSettings.publish(saved);}if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;sender.sendMessage(failure==null?"Saved "+key+"="+saved.value()+" for future Inspire casts; active effects and deadlines are unchanged.":"Inspire configuration save failed; the effective setting is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void mendingLightConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
var actor = abilityConfigEvents == null ? null : abilityConfigEvents.capture(sender);
|
||
String before = mendingLightSettings.value(key);
|
||
if (args.length == 2) {
|
||
if (abilityConfigEvents != null) abilityConfigEvents.read(actor, "mending_light", key, before);
|
||
sender.sendMessage(key + "=" + before + " (applies to future Mending Light casts only)");
|
||
return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.MendingLightSettings.Update> operation;
|
||
try { operation = mendingLightSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Mending Light setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null && mendingLightSettings.publish(saved)) {
|
||
mendingLight.configure(saved.settings()); abilities.replace(mendingLight.definition());
|
||
if (abilityConfigEvents != null) abilityConfigEvents.changed(actor, "mending_light", key, before, saved.value());
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Mending Light casts; active work and deadlines are unchanged."
|
||
: "Mending Light configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void purifyConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + purifySettings.value(key) + " (applies to future Purify casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.PurifySettings.Update> operation;
|
||
try { operation = purifySettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Purify setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
purify.configure(saved.settings()); abilities.replace(purify.definition()); purifySettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Purify casts; active work and deadlines are unchanged."
|
||
: "Purify configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void guardianBondConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + guardianBondSettings.value(key) + " (applies to future Guardian Bond casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.GuardianBondSettings.Update> operation;
|
||
try { operation = guardianBondSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Guardian Bond setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
guardianBond.configure(saved.settings()); abilities.replace(guardianBond.definition()); guardianBondSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Guardian Bond casts; active bonds and deadlines are unchanged."
|
||
: "Guardian Bond configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void rallyingCryConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + rallyingCrySettings.value(key) + " (applies to future Rallying Cry casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.RallyingCrySettings.Update> operation;
|
||
try { operation = rallyingCrySettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Rallying Cry setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
rallyingCry.configure(saved.settings()); abilities.replace(rallyingCry.definition()); rallyingCrySettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Rallying Cry casts; active cries and deadlines are unchanged."
|
||
: "Rallying Cry configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void frostNovaConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + frostNovaSettings.value(key) + " (applies to future Frost Nova casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.FrostNovaSettings.Update> operation;
|
||
try { operation = frostNovaSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Frost Nova setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
frostNova.configure(saved.settings()); abilities.replace(frostNova.definition()); frostNovaSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Frost Nova casts; active slows and deadlines are unchanged."
|
||
: "Frost Nova configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void chainLightningConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + chainLightningSettings.value(key) + " (applies to future Chain Lightning casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.ChainLightningSettings.Update> operation;
|
||
try { operation = chainLightningSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Chain Lightning setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
chainLightning.configure(saved.settings()); abilities.replace(chainLightning.definition()); chainLightningSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Chain Lightning casts; active chains and deadlines are unchanged."
|
||
: "Chain Lightning configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void sanctuaryConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + sanctuarySettings.value(key) + " (applies to future Sanctuary casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.SanctuarySettings.Update> operation;
|
||
try { operation = sanctuarySettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Sanctuary setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
sanctuary.configure(saved.settings()); abilities.replace(sanctuary.definition()); sanctuarySettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Sanctuary casts; active areas and deadlines are unchanged."
|
||
: "Sanctuary configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void warBannerConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) { sender.sendMessage(key + "=" + warBannerSettings.value(key) + " (applies to future War Banner casts only)"); return; }
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.WarBannerSettings.Update> operation;
|
||
try { operation = warBannerSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) { sender.sendMessage("War Banner setting is invalid; the effective value is unchanged."); return; }
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure); if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) { warBanner.configure(saved.settings()); abilities.replace(warBanner.definition()); warBannerSettings.publish(saved); }
|
||
if (!sender.hasPermission(PERMISSION) || sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future War Banner casts; active areas and deadlines are unchanged."
|
||
: "War Banner configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void meteorConfiguration(CommandSender sender, String[] args) {
|
||
String key=args[1];if(args.length==2){sender.sendMessage(key+"="+meteorSettings.value(key)+" (applies to future Meteor casts only)");return;}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.MeteorSettings.Update> operation;
|
||
try{operation=meteorSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Meteor setting is invalid; the effective value is unchanged.");return;}
|
||
operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure==null){meteor.configure(saved.settings());abilities.replace(meteor.definition());meteorSettings.publish(saved);}if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;sender.sendMessage(failure==null?"Saved "+key+"="+saved.value()+" for future Meteor casts; active warnings and deadlines are unchanged.":"Meteor configuration save failed; the effective setting is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});
|
||
}
|
||
|
||
private void hexConfiguration(CommandSender sender, String[] args) {
|
||
String key=args[1];if(args.length==2){sender.sendMessage(key+"="+hexSettings.value(key)+" (applies to future Hex casts only)");return;}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.HexSettings.Update> operation;
|
||
try{operation=hexSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Hex setting is invalid; the effective value is unchanged.");return;}
|
||
operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;
|
||
try{nextTick.accept(()->{if(closed)return;if(failure==null){hex.configure(saved.settings());abilities.replace(hex.definition());hexSettings.publish(saved);}
|
||
if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;
|
||
sender.sendMessage(failure==null?"Saved "+key+"="+saved.value()+" for future Hex casts; active effects and deadlines are unchanged."
|
||
:"Hex configuration save failed; the effective setting is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});
|
||
}
|
||
|
||
private void shieldBashConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) { sender.sendMessage(key + "=" + shieldBashSettings.value(key) + " (applies to future Shield Bash strikes only)"); return; }
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.ShieldBashSettings.Update> operation;
|
||
try { operation = shieldBashSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) { sender.sendMessage("Shield Bash setting is invalid; the effective value is unchanged."); return; }
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
shieldBash.configure(saved.settings()); abilities.replace(shieldBash.definition()); shieldBashSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Shield Bash strikes; active work and deadlines are unchanged."
|
||
: "Shield Bash configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void stoneSkinConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + stoneSkinSettings.value(key) + " (applies to future Stone Skin casts only)"); return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.StoneSkinSettings.Update> operation;
|
||
try { operation = stoneSkinSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) { sender.sendMessage("Stone Skin setting is invalid; the effective value is unchanged."); return; }
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
stoneSkin.configure(saved.settings()); abilities.replace(stoneSkin.definition()); stoneSkinSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Stone Skin casts; active effects and deadlines are unchanged."
|
||
: "Stone Skin configuration save failed; the effective setting is unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void secondWindConfiguration(CommandSender sender, String[] args) {
|
||
String key = args[1];
|
||
if (args.length == 2) {
|
||
sender.sendMessage(key + "=" + secondWindSettings.value(key) + " (applies to future Second Wind casts only)");
|
||
return;
|
||
}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.SecondWindSettings.Update> operation;
|
||
try { operation = secondWindSettings.set(key, args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Second Wind setting is invalid; the effective value is unchanged."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try {
|
||
nextTick.accept(() -> {
|
||
if (closed) return;
|
||
if (failure == null) {
|
||
secondWind.configure(saved.settings()); abilities.replace(secondWind.definition());
|
||
secondWindSettings.publish(saved);
|
||
}
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved " + key + "=" + saved.value() + " for future Second Wind casts; active work and deadlines are unchanged."
|
||
: "Second Wind configuration save failed; the effective setting is unchanged.");
|
||
});
|
||
} catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void sheetResourcePackConfiguration(CommandSender sender,String[] args){if(sheetResourcePackSettings==null){configurationUsage(sender);return;}String key=args[1];if(args.length==2){sender.sendMessage(key+"="+sheetResourcePackSettings.value(key));return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.SheetResourcePackSettings.Update> operation;try{operation=sheetResourcePackSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Sheet resource-pack value is invalid; use an absolute HTTPS URL or 40 hexadecimal SHA-1 characters.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-sheet-resource-pack",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;boolean applied=false;if(failure==null){applied=sheetResourcePackSettings.publish(saved);if(applied)sheetResourcePack.deliverAll(server.getOnlinePlayers());}if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Sheet resource-pack configuration save failed; effective values are unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+sheetResourcePackSettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+sheetResourcePackSettings.value(key)+"; optional delivery was requested for online players.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void partyEconomyConfiguration(CommandSender sender,String[] args){String key=args[1],before=partyEconomySettings.value(key),actorKind=sender instanceof org.bukkit.entity.Player?"player":sender instanceof org.bukkit.command.BlockCommandSender?"command_block":"console";UUID actorPlayer=sender instanceof org.bukkit.entity.Player player?player.getUniqueId():null;String actorName=sender instanceof org.bukkit.entity.Player?sender.getName():null;if(args.length==2){if(partyEvents!=null)partyEvents.configRead(actorKind,actorPlayer,actorName,key,before);sender.sendMessage(key+"="+before+" (applies to future party transactions only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.PartyEconomySettings.Update> operation;try{operation=partyEconomySettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Party price is invalid; enter a whole number from 0 through 2147483647.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;boolean applied=failure==null&&partyEconomySettings.publish(saved);if(applied&&partyEvents!=null)partyEvents.configChanged(actorKind,actorPlayer,actorName,key,before,saved.value());if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Party price save failed; the effective price is unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+partyEconomySettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+saved.value()+" for future party transactions.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void gearConfiguration(CommandSender sender,String[] args){String key=args[1];if(args.length==2){sender.sendMessage(key+"="+gearSettings.value(key)+" (applies to the next armor restock only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.GearSettings.Update> operation;try{operation=gearSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Armor market setting is invalid; variance is 0–100, prices are nonnegative, and positive stock minima cannot exceed maxima.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;nextTick.accept(()->{boolean applied=failure==null&&gearSettings.publish(saved);if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Armor market setting save failed; effective settings and the current catalog are unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+gearSettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+saved.value()+" for the next automatic or administrative restock; the current catalog is unchanged.");});});}
|
||
private void rareConfiguration(CommandSender sender,String[] args){String key=args[1],before=rareSettings.value(key),actorKind=sender instanceof org.bukkit.entity.Player?"player":sender instanceof org.bukkit.command.BlockCommandSender?"command_block":"console";UUID actorPlayer=sender instanceof org.bukkit.entity.Player player?player.getUniqueId():null;String actorName=sender instanceof org.bukkit.entity.Player?sender.getName():null;boolean phoenix=key.contains("phoenix-down");if(args.length==2){if(phoenix&&downedEvents!=null)downedEvents.configRead(actorKind,actorPlayer,actorName,key,before);sender.sendMessage(key+"="+before+(key.endsWith("-healing-percent")||key.equals(games.dmg.fantasystick.persistence.RareSettings.PHOENIX_PROTECTION)?" (applies to future accepted uses)":" (applies to the next rare restock only)"));return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.RareSettings.Update> operation;try{operation=rareSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Rare setting is invalid; percentages are 0–100, values are nonnegative, and stock minima cannot exceed maxima.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;nextTick.accept(()->{boolean applied=failure==null&&rareSettings.publish(saved);if(applied&&phoenix&&downedEvents!=null)downedEvents.configChanged(actorKind,actorPlayer,actorName,key,before,saved.value());if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Rare setting save failed; prior effective state is unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+rareSettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+saved.value()+"; current catalog and accepted uses are unchanged.");});});}
|
||
private void downedConfiguration(CommandSender sender,String[] args){String key=args[1],before=downedSettings.value(key),actorKind=sender instanceof org.bukkit.entity.Player?"player":sender instanceof org.bukkit.command.BlockCommandSender?"command_block":"console";UUID actorPlayer=sender instanceof org.bukkit.entity.Player player?player.getUniqueId():null;String actorName=sender instanceof org.bukkit.entity.Player?sender.getName():null;if(args.length==2){if(downedEvents!=null)downedEvents.configRead(actorKind,actorPlayer,actorName,key,before);sender.sendMessage(key+"="+before+" (applies to future downed outcomes only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.DownedSettings.Update> operation;try{operation=downedSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Downed setting is invalid; timeout must be positive and protection may be zero, both at most 365 days.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;nextTick.accept(()->{boolean applied=failure==null&&downedSettings.publish(saved);if(applied&&downedEvents!=null)downedEvents.configChanged(actorKind,actorPlayer,actorName,key,before,saved.value());if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Downed setting save failed; prior effective state is unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+downedSettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+saved.value()+"; existing deadlines are unchanged.");});});}
|
||
|
||
private void coinConfiguration(CommandSender sender,String[] args){String key=args[1],before=coinSettings.value(key),actorKind=sender instanceof org.bukkit.entity.Player?"player":sender instanceof org.bukkit.command.BlockCommandSender?"command_block":"console";UUID actorPlayer=sender instanceof org.bukkit.entity.Player player?player.getUniqueId():null;String actorName=sender instanceof org.bukkit.entity.Player?sender.getName():null;if(args.length==2){if(coinEvents!=null)coinEvents.configRead(actorKind,actorPlayer,actorName,key,before);sender.sendMessage(key+"="+before+" (applies to future creation or defeats only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.CoinSettings.Update> operation;try{operation=coinSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Coin setting is invalid; ranges must be ordered whole numbers from 0 through 2147483647.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;boolean applied=failure==null&&coinSettings.publish(saved);if(applied&&coinEvents!=null)coinEvents.configChanged(actorKind,actorPlayer,actorName,key,before,saved.value());if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Coin configuration save failed; effective ranges are unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+coinSettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+saved.value()+" for future creation or defeats; existing balances and captured rewards are unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void hardMobXpConfiguration(CommandSender sender, String[] args) {
|
||
String key = games.dmg.fantasystick.persistence.HardMobXpSettings.KEY;
|
||
if (args.length == 2) { sender.sendMessage(key + "=" + hardMobXpSettings.value()
|
||
+ " (applies to future uncaptured Witch defeats only)"); return; }
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.HardMobXpSettings.Update> operation;
|
||
try { operation = hardMobXpSettings.set(args[2]); }
|
||
catch (IllegalArgumentException invalid) {
|
||
sender.sendMessage("Hard-mob XP is invalid; enter a whole number from 0 through 2147483647."); return;
|
||
}
|
||
operation.whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-" + key, failure);
|
||
if (closed) return;
|
||
try { nextTick.accept(() -> {
|
||
if (closed) return;
|
||
boolean applied = failure == null && hardMobXpSettings.publish(saved);
|
||
if (applied) combatExperience.configure(combatExperience.rules().withHardPool(saved.pool()));
|
||
if (!sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
if (failure != null) sender.sendMessage("Hard-mob XP save failed; the effective pool is unchanged.");
|
||
else if (!applied) sender.sendMessage("Saved request was superseded; effective " + key + "="
|
||
+ hardMobXpSettings.value() + ".");
|
||
else sender.sendMessage("Saved " + key + "=" + saved.value()
|
||
+ " for future uncaptured Witch defeats; existing progress and captured rewards are unchanged.");
|
||
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private void adventureQuestConfiguration(CommandSender sender, String[] args) {
|
||
String key=args[1]; if(args.length==2){sender.sendMessage(key+"="+adventureQuestSettings.value(key)+" (applies to the owning later catalog, acceptance or encounter attempt)");return;}
|
||
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.AdventureQuestSettings.Update> operation;
|
||
try{operation=adventureQuestSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Adventure quest setting is invalid; the effective value is unchanged.");return;}
|
||
operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;boolean applied=failure==null&&adventureQuestSettings.publish(saved);if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Adventure quest configuration save failed; effective values are unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+key+"="+adventureQuestSettings.value(key)+".");else sender.sendMessage("Saved "+key+"="+saved.value()+" for later catalogs, acceptances or attempts; active state is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});
|
||
}
|
||
|
||
private void partyConfiguration(CommandSender sender,String[] args){if(partySettings==null){configurationUsage(sender);return;}if(args.length==2){sender.sendMessage(games.dmg.fantasystick.persistence.PartySettings.KEY+"="+partySettings.value()+" (existing parties are retained)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.PartySettings.Update> operation;try{operation=partySettings.set(args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Party maximum is invalid; enter a positive whole number.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-party",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;boolean applied=false;if(failure==null)applied=partySettings.publish(saved);if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Party configuration save failed; the effective limit and rosters are unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+games.dmg.fantasystick.persistence.PartySettings.KEY+"="+partySettings.value()+".");else sender.sendMessage("Saved "+games.dmg.fantasystick.persistence.PartySettings.KEY+"="+saved.value()+"; existing members are retained.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void roleplayConfiguration(CommandSender sender,String[] args){if(roleplaySettings==null){configurationUsage(sender);return;}if(args.length==2){sender.sendMessage(games.dmg.fantasystick.persistence.RoleplaySettings.KEY+"="+roleplaySettings.value());return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.RoleplaySettings.Update> operation;try{operation=roleplaySettings.set(args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Usage: /fstickadmin config roleplay-disabled [true|false]");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-roleplay",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;boolean applied=false;if(failure==null){applied=roleplaySettings.publish(saved);if(applied&&saved.disabled())sessions.disableRoleplay();}if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;if(failure!=null)sender.sendMessage("Roleplay configuration save failed; policy and sessions are unchanged.");else if(!applied)sender.sendMessage("Saved request was superseded; effective "+games.dmg.fantasystick.persistence.RoleplaySettings.KEY+"="+roleplaySettings.value()+".");else sender.sendMessage("Saved "+games.dmg.fantasystick.persistence.RoleplaySettings.KEY+"="+saved.disabled()+(saved.disabled()?"; ordinary exits were requested for active sessions.":"; normal sheet activation is available."));});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void switchDelayConfiguration(CommandSender sender,String[] args){if(switchDelaySettings==null){configurationUsage(sender);return;}if(args.length==2){sender.sendMessage(games.dmg.fantasystick.persistence.SwitchDelaySettings.KEY+"="+switchDelaySettings.value()+" (new exits use this delay; existing deadlines are unchanged)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.SwitchDelaySettings.Update> operation;try{operation=switchDelaySettings.set(args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Character switch delay is invalid; the effective value is unchanged.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-switch-delay",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure==null)switchDelaySettings.publish(saved);if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;sender.sendMessage(failure==null?"Saved "+games.dmg.fantasystick.persistence.SwitchDelaySettings.KEY+"="+saved.value()+"; new exits use it and existing deadlines are unchanged.":"Character switch delay save failed; the effective value is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void adminReviveConfiguration(CommandSender sender,String[] args){if(adminReviveSettings==null){configurationUsage(sender);return;}if(args.length==2){sender.sendMessage(games.dmg.fantasystick.persistence.AdminReviveSettings.KEY+"="+adminReviveSettings.value()+" (applies to later admin revival selections only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.AdminReviveSettings.Update> operation;try{operation=adminReviveSettings.set(args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Admin revival timeout is invalid; the effective value is unchanged.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-admin-revive",failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure==null)adminReviveSettings.publish(saved);if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;sender.sendMessage(failure==null?"Saved "+games.dmg.fantasystick.persistence.AdminReviveSettings.KEY+"="+saved.value()+" for later selections; open selections retain their deadline.":"Admin revival configuration save failed; the effective setting is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
|
||
|
||
private void adventureConfiguration(CommandSender sender, String[] args) {
|
||
if (args.length == 3 && !args[2].equals("true") && !args[2].equals("false")) {
|
||
sender.sendMessage("Usage: /fstickadmin config adventure-mode [true|false]"); return;
|
||
}
|
||
if (settings == null) { sender.sendMessage("Adventure configuration is unavailable."); return; }
|
||
if (args.length == 2) {
|
||
sender.sendMessage("adventure-mode=" + settings.enabled() + " (applies to new sessions only)"); return;
|
||
}
|
||
settings.set(Boolean.parseBoolean(args[2])).whenComplete((saved, failure) -> {
|
||
if (failure != null) report(null, "config-adventure-mode", failure);
|
||
if (closed) return;
|
||
try {
|
||
nextTick.accept(() -> {
|
||
if (closed || !sender.hasPermission(PERMISSION)
|
||
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
|
||
sender.sendMessage(failure == null
|
||
? "Saved adventure-mode=" + saved + " for new sessions only; active sessions are unchanged."
|
||
: "Adventure configuration save failed; the effective setting is unchanged.");
|
||
});
|
||
} catch (RuntimeException rejected) { report(null, "config-response", rejected); }
|
||
});
|
||
}
|
||
|
||
private static void configurationUsage(CommandSender sender) {
|
||
sender.sendMessage("Usage: /fstickadmin config <setting> [value]");
|
||
}
|
||
|
||
private void report(UUID owner, String operation, Throwable cause) {
|
||
try { diagnostics.accept(new Failure(owner, operation, cause)); }
|
||
catch (RuntimeException ignored) { /* Diagnostics cannot authorize recovery. */ }
|
||
}
|
||
|
||
// Return only explicit implemented routes; never fall back to Bukkit's broad default suggestions.
|
||
@Override public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||
if (closed) return List.of();
|
||
if (!sender.hasPermission(PERMISSION)) return List.of();
|
||
if (adventureQuestCommands != null && args.length > 1) {
|
||
if (args[0].equals("adventure")) {
|
||
if (args.length == 2) return matching(List.of("reroll"), args[1]);
|
||
if (args.length == 3 && args[1].equals("reroll")) return matching(List.of("confirm"), args[2]);
|
||
return List.of();
|
||
}
|
||
var adventure = adventureQuestCommands.complete(sender,args); if(!adventure.isEmpty()) return adventure;
|
||
if(args[0].equals("adventure-site")||args[0].equals("quest-giver"))return List.of();
|
||
}
|
||
if(dungeonCommands!=null&&args.length>1){var dungeon=dungeonCommands.complete(sender,args);if(!dungeon.isEmpty())return dungeon;if(args[0].equals("dungeon"))return List.of();}
|
||
if (args.length == 1) return matching(sender instanceof org.bukkit.entity.Player
|
||
? List.of("adventure", "adventure-site", "character", "config", "dungeon", "experience", "give", "inspect", "party-registrar", "quest-giver", "rare-shop", "recover", "revive", "shop", "training-dummy")
|
||
: List.of("adventure-site", "config", "dungeon", "experience", "give", "inspect", "party-registrar", "quest-giver", "rare-shop", "recover", "shop", "training-dummy"), args[0]);
|
||
if (args.length == 2 && args[0].equals("character")) {
|
||
var routes = new java.util.ArrayList<>(List.of("find"));
|
||
if (sender instanceof org.bukkit.entity.Player) routes.addAll(List.of("recover", "show", "view"));
|
||
return matching(routes, args[1]);
|
||
}
|
||
if (args.length >= 3 && args[0].equals("character") && args[1].equals("find")) {
|
||
String prefix = String.join(" ", java.util.Arrays.copyOfRange(args, 2, args.length));
|
||
return matchingIgnoreCase(savedCharacterSuggestions().values(), prefix);
|
||
}
|
||
if (args.length == 3 && args[0].equals("character")
|
||
&& (args[1].equals("show") || args[1].equals("recover"))
|
||
&& sender instanceof org.bukkit.entity.Player)
|
||
return matching(savedCharacterSuggestions().keySet().stream().map(UUID::toString).toList(), args[2]);
|
||
if (args.length == 4 && args[0].equals("character") && args[1].equals("recover")
|
||
&& sender instanceof org.bukkit.entity.Player)
|
||
return matching(server.getOnlinePlayers().stream().filter(org.bukkit.entity.Player::isOnline)
|
||
.map(org.bukkit.entity.Player::getName).toList(), args[3]);
|
||
if (args.length == 3 && args[0].equals("character") && args[1].equals("view")
|
||
&& sender instanceof org.bukkit.entity.Player)
|
||
return matching(server.getOnlinePlayers().stream().filter(org.bukkit.entity.Player::isOnline)
|
||
.filter(player -> sessions.active(player.getUniqueId()).filter(sessions::current).isPresent())
|
||
.map(org.bukkit.entity.Player::getName).toList(), args[2]);
|
||
if(args.length==2&&args[0].equals("shop"))return matching(sender instanceof org.bukkit.entity.Player?List.of("list","place","remove","restock"):List.of("list","remove","restock"),args[1]);
|
||
if(args.length==3&&args[0].equals("shop")&&args[1].equals("remove")&&armorers!=null)return matching(armorers.all().stream().map(value->value.id().toString()).toList(),args[2]);
|
||
if(args.length==2&&args[0].equals("rare-shop"))return matching(sender instanceof org.bukkit.entity.Player?List.of("list","place","remove","restock"):List.of("list","remove","restock"),args[1]);
|
||
if(args.length==3&&args[0].equals("rare-shop")&&args[1].equals("remove")&&rareMerchants!=null)return matching(rareMerchants.all().stream().map(value->value.id().toString()).toList(),args[2]);
|
||
if (args.length == 2 && args[0].equals("training-dummy")) return matching(
|
||
sender instanceof org.bukkit.entity.Player ? List.of("list", "place", "remove") : List.of("list", "remove"), args[1]);
|
||
if (args.length == 3 && args[0].equals("training-dummy") && args[1].equals("remove") && trainingDummies != null)
|
||
return matching(trainingDummies.all().stream().map(value -> value.id().toString()).toList(), args[2]);
|
||
if (args.length == 2 && args[0].equals("party-registrar")) return matching(
|
||
sender instanceof org.bukkit.entity.Player ? List.of("list","place","remove") : List.of("list","remove"),args[1]);
|
||
if (args.length == 3 && args[0].equals("party-registrar") && args[1].equals("remove") && partyRegistrars!=null)
|
||
return matching(partyRegistrars.all().stream().map(value->value.id().toString()).toList(),args[2]);
|
||
if (args.length == 2 && args[0].equals("experience")) return matching(List.of("give"), args[1]);
|
||
if (args.length >= 3 && args[0].equals("experience") && args[1].equals("give")) return experienceNames(args);
|
||
if (args.length == 2 && (args[0].equals("inspect") || args[0].equals("recover"))) return matching(
|
||
server.getOnlinePlayers().stream().filter(org.bukkit.entity.Player::isOnline)
|
||
.map(player -> player.getUniqueId().toString()).toList(), args[1]);
|
||
if (args.length == 2 && (args[0].equals("give") || args[0].equals("revive") && sender instanceof org.bukkit.entity.Player)) return matching(server.getOnlinePlayers().stream()
|
||
.filter(org.bukkit.entity.Player::isOnline).map(org.bukkit.entity.Player::getName).toList(), args[1]);
|
||
if (args.length == 2 && args[0].equals("config")) {
|
||
var keys = new java.util.ArrayList<String>(); keys.add("adventure-mode");keys.add(games.dmg.fantasystick.persistence.AdminReviveSettings.KEY);keys.add(games.dmg.fantasystick.persistence.SwitchDelaySettings.KEY);keys.add(games.dmg.fantasystick.persistence.RoleplaySettings.KEY);keys.add(games.dmg.fantasystick.persistence.PartySettings.KEY);keys.add(games.dmg.fantasystick.persistence.SheetResourcePackSettings.URL_KEY);keys.add(games.dmg.fantasystick.persistence.SheetResourcePackSettings.SHA1_KEY);
|
||
keys.addAll(games.dmg.fantasystick.persistence.PartyEconomySettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.GearSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.RareSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.DownedSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.CoinSettings.keys());
|
||
keys.add(games.dmg.fantasystick.persistence.HardMobXpSettings.KEY);
|
||
keys.addAll(games.dmg.fantasystick.persistence.AdventureQuestSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.keys());
|
||
keys.add(games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY);
|
||
keys.add(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY);
|
||
keys.add(games.dmg.fantasystick.persistence.HealthStealSettings.KEY);
|
||
keys.addAll(games.dmg.fantasystick.persistence.FireballSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.FrostShardSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.LongbowSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.QuickstepSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.SecondWindSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.StoneSkinSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.ShieldBashSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.HexSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.InspireSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.MendingLightSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.PurifySettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.GuardianBondSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.RallyingCrySettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.FrostNovaSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.ChainLightningSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.SanctuarySettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.WarBannerSettings.keys());
|
||
keys.addAll(games.dmg.fantasystick.persistence.MeteorSettings.keys());
|
||
return matching(keys, args[1]);
|
||
}
|
||
if (args.length == 3 && args[0].equals("config")) {
|
||
if (args[1].equals("adventure-mode")) return matching(List.of("false", "true"), args[2]);
|
||
if(args[1].equals(games.dmg.fantasystick.persistence.AdminReviveSettings.KEY)&&adminReviveSettings!=null){String current=adminReviveSettings.value();return matching(current.equals(games.dmg.fantasystick.persistence.AdminReviveSettings.DEFAULT)?List.of(current):List.of(current,games.dmg.fantasystick.persistence.AdminReviveSettings.DEFAULT),args[2]);}
|
||
if(args[1].equals(games.dmg.fantasystick.persistence.SwitchDelaySettings.KEY)&&switchDelaySettings!=null){String current=switchDelaySettings.value();return matching(current.equals(games.dmg.fantasystick.persistence.SwitchDelaySettings.DEFAULT)?List.of(current):List.of(current,games.dmg.fantasystick.persistence.SwitchDelaySettings.DEFAULT),args[2]);}
|
||
if(args[1].equals(games.dmg.fantasystick.persistence.RoleplaySettings.KEY)&&roleplaySettings!=null)return matching(List.of("false","true"),args[2]);
|
||
if(args[1].equals(games.dmg.fantasystick.persistence.PartySettings.KEY)&&partySettings!=null){String current=partySettings.value();return matching(current.equals(games.dmg.fantasystick.persistence.PartySettings.DEFAULT)?List.of(current):List.of(current,games.dmg.fantasystick.persistence.PartySettings.DEFAULT),args[2]);}
|
||
if(partyEconomySettings!=null&&games.dmg.fantasystick.persistence.PartyEconomySettings.keys().contains(args[1])){String current=partyEconomySettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.PartyEconomySettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if(gearSettings!=null&&games.dmg.fantasystick.persistence.GearSettings.keys().contains(args[1])){String current=gearSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.GearSettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if(rareSettings!=null&&games.dmg.fantasystick.persistence.RareSettings.keys().contains(args[1])){String current=rareSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.RareSettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if(downedSettings!=null&&games.dmg.fantasystick.persistence.DownedSettings.keys().contains(args[1])){String current=downedSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.DownedSettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if(coinSettings!=null&&games.dmg.fantasystick.persistence.CoinSettings.keys().contains(args[1])){String current=coinSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.CoinSettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if (hardMobXpSettings != null && args[1].equals(games.dmg.fantasystick.persistence.HardMobXpSettings.KEY)) {
|
||
String current = hardMobXpSettings.value(); String defaults = games.dmg.fantasystick.persistence.HardMobXpSettings.DEFAULT;
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if(adventureQuestSettings!=null&&games.dmg.fantasystick.persistence.AdventureQuestSettings.keys().contains(args[1])){String current=adventureQuestSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.AdventureQuestSettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if(sheetResourcePackSettings!=null&&(args[1].equals(games.dmg.fantasystick.persistence.SheetResourcePackSettings.URL_KEY)||args[1].equals(games.dmg.fantasystick.persistence.SheetResourcePackSettings.SHA1_KEY)))return matching(List.of(sheetResourcePackSettings.value(args[1])),args[2]);
|
||
if (outOfCombatRecoverySettings != null
|
||
&& games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.keys().contains(args[1])) {
|
||
String current = outOfCombatRecoverySettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.OutOfCombatRecoverySettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.QuickerRegenerationSettings.KEY)
|
||
&& quickerRegenerationSettings != null) {
|
||
String current = quickerRegenerationSettings.value();
|
||
return matching(current.equals(games.dmg.fantasystick.persistence.QuickerRegenerationSettings.DEFAULT)
|
||
? List.of(current) : List.of(current, games.dmg.fantasystick.persistence.QuickerRegenerationSettings.DEFAULT), args[2]);
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.KEY)
|
||
&& quickerRegenerationIISettings != null) {
|
||
String current = quickerRegenerationIISettings.value();
|
||
return matching(current.equals(games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.DEFAULT)
|
||
? List.of(current) : List.of(current, games.dmg.fantasystick.persistence.QuickerRegenerationIISettings.DEFAULT), args[2]);
|
||
}
|
||
if (args[1].equals(games.dmg.fantasystick.persistence.HealthStealSettings.KEY) && healthStealSettings != null) {
|
||
String current = healthStealSettings.value();
|
||
return matching(current.equals(games.dmg.fantasystick.persistence.HealthStealSettings.DEFAULT)
|
||
? List.of(current) : List.of(current, games.dmg.fantasystick.persistence.HealthStealSettings.DEFAULT), args[2]);
|
||
}
|
||
if (fireballSettings != null && games.dmg.fantasystick.persistence.FireballSettings.keys().contains(args[1])) {
|
||
String current = fireballSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.FireballSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (frostSettings != null && games.dmg.fantasystick.persistence.FrostShardSettings.keys().contains(args[1])) {
|
||
String current = frostSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.FrostShardSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (longbowSettings != null && games.dmg.fantasystick.persistence.LongbowSettings.keys().contains(args[1])) {
|
||
String current = longbowSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.LongbowSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (quickstepSettings != null && games.dmg.fantasystick.persistence.QuickstepSettings.keys().contains(args[1])) {
|
||
String current = quickstepSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.QuickstepSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (secondWindSettings != null && games.dmg.fantasystick.persistence.SecondWindSettings.keys().contains(args[1])) {
|
||
String current = secondWindSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.SecondWindSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (stoneSkinSettings != null && games.dmg.fantasystick.persistence.StoneSkinSettings.keys().contains(args[1])) {
|
||
String current = stoneSkinSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.StoneSkinSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (shieldBashSettings != null && games.dmg.fantasystick.persistence.ShieldBashSettings.keys().contains(args[1])) {
|
||
String current = shieldBashSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.ShieldBashSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (hexSettings != null && games.dmg.fantasystick.persistence.HexSettings.keys().contains(args[1])) {
|
||
String current = hexSettings.value(args[1]); String defaults = games.dmg.fantasystick.persistence.HexSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if(inspireSettings!=null&&games.dmg.fantasystick.persistence.InspireSettings.keys().contains(args[1])){String current=inspireSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.InspireSettings.defaultValue(args[1]);return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);}
|
||
if (mendingLightSettings != null && games.dmg.fantasystick.persistence.MendingLightSettings.keys().contains(args[1])) {
|
||
String current = mendingLightSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.MendingLightSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (purifySettings != null && games.dmg.fantasystick.persistence.PurifySettings.keys().contains(args[1])) {
|
||
String current = purifySettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.PurifySettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (guardianBondSettings != null
|
||
&& games.dmg.fantasystick.persistence.GuardianBondSettings.keys().contains(args[1])) {
|
||
String current = guardianBondSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.GuardianBondSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (rallyingCrySettings != null
|
||
&& games.dmg.fantasystick.persistence.RallyingCrySettings.keys().contains(args[1])) {
|
||
String current = rallyingCrySettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.RallyingCrySettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (frostNovaSettings != null
|
||
&& games.dmg.fantasystick.persistence.FrostNovaSettings.keys().contains(args[1])) {
|
||
String current = frostNovaSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.FrostNovaSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (chainLightningSettings != null
|
||
&& games.dmg.fantasystick.persistence.ChainLightningSettings.keys().contains(args[1])) {
|
||
String current = chainLightningSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.ChainLightningSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (sanctuarySettings != null
|
||
&& games.dmg.fantasystick.persistence.SanctuarySettings.keys().contains(args[1])) {
|
||
String current = sanctuarySettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.SanctuarySettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (warBannerSettings != null
|
||
&& games.dmg.fantasystick.persistence.WarBannerSettings.keys().contains(args[1])) {
|
||
String current = warBannerSettings.value(args[1]);
|
||
String defaults = games.dmg.fantasystick.persistence.WarBannerSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults) ? List.of(current) : List.of(current, defaults), args[2]);
|
||
}
|
||
if (meteorSettings != null && games.dmg.fantasystick.persistence.MeteorSettings.keys().contains(args[1])) {
|
||
String current=meteorSettings.value(args[1]);String defaults=games.dmg.fantasystick.persistence.MeteorSettings.defaultValue(args[1]);
|
||
return matching(current.equals(defaults)?List.of(current):List.of(current,defaults),args[2]);
|
||
}
|
||
}
|
||
return List.of();
|
||
}
|
||
|
||
private List<String> experienceNames(String[] args) {
|
||
int priorTokens = args.length - 3;
|
||
String prefix = args[args.length - 1];
|
||
return matching(sessions.activeCharacters().stream().map(active -> active.record().name())
|
||
.map(name -> name.split(" ")).filter(tokens -> tokens.length > priorTokens)
|
||
.filter(tokens -> java.util.stream.IntStream.range(0, priorTokens)
|
||
.allMatch(index -> tokens[index].equals(args[index + 2])))
|
||
.map(tokens -> tokens[priorTokens]).toList(), prefix);
|
||
}
|
||
|
||
private static List<String> matching(java.util.Collection<String> values, String prefix) {
|
||
return values.stream().filter(value -> value.startsWith(prefix)).distinct().sorted().toList();
|
||
}
|
||
|
||
private static List<String> matchingIgnoreCase(java.util.Collection<String> values, String prefix) {
|
||
String folded = prefix.toLowerCase(java.util.Locale.ROOT);
|
||
return values.stream().filter(value -> value.toLowerCase(java.util.Locale.ROOT).startsWith(folded))
|
||
.distinct().sorted(java.util.Comparator.comparing((String value) -> value.toLowerCase(java.util.Locale.ROOT))
|
||
.thenComparing(java.util.Comparator.naturalOrder())).toList();
|
||
}
|
||
@Override public void close() { closed = true; savedSearches.clear(); if (characterIssuer != null) characterIssuer.close(); if(adminRevival!=null)adminRevival.close(); if(characterRecovery!=null)characterRecovery.close(); if(experienceGrant!=null)experienceGrant.close(); }
|
||
}
|