-
Notifications
You must be signed in to change notification settings - Fork 9
Developer Section: Plugin
AStagesPlugin is an interface used to extend the functionality of AStages. It allows plugin developers to:
- Register new managers for custom logic.
- Modify existing restriction attributes.
- Create new paths and folders for both internal use within AStages and for the plugin itself.
- Handle restriction updates, including removing or resetting them when necessary during reloads.
This interface provides hooks for synchronizing data with clients, executing code before and after scripts are reloaded, and managing plugin-specific resources, while ensuring proper integration with the core AStages system.
AStagesPlugin#reloadBeforeScripts: clear restriction caches.
Called before JS scripts are reloaded. Useful for preparing or clearing data before scripts are processed, managers highly use this method. AStages will call this method when necessary, no additional logic is required unless you want custom reloading.
public class YourPlugin implements AStagesPlugin {
public static final CustomManager CUSTOM_INSTANCE = ...;
@Override
public void reloadBeforeScripts() {
CUSTOM_INSTANCE.reloadBeforeScripts();
}
}AStagesPlugin#clientSynchronization: synchronize restrictions to client.
Called to synchronize plugin data with a player's client. This is useful when restrictions need to be updated on the client side, for example to hide item names in tooltips or above the hotbar. AStages will call this method when necessary, no additional logic is required unless you want custom synchronization.
public class YourPlugin implements AStagesPlugin {
public static final CustomManager CUSTOM_INSTANCE = ...;
@Override
public void clientSynchronization(@Nullable ServerPlayer player) {
CUSTOM_INSTANCE.clientSynchronization(player);
}
} AStagesPlugin#reloadAfterScripts: build caches and support client-side command autocompletion.
Called after JS scripts and restrictions have been reloaded.
This method is commonly used to build or rebuild caches based on the restriction values previously added or modified.
AStages automatically invokes this method when reload operations complete.
public class YourPlugin implements AStagesPlugin {
public static final CustomManager CUSTOM_INSTANCE = ...;
@Override
public void reloadAfterScripts() {
CUSTOM_INSTANCE.reloadAfterScripts();
}
}This overload is called when the server instance is available. AStages uses it specifically to update networking-dependent features, such as:
- Client-side command autocompletion for stage IDs
- Autocompletion for simple restriction IDs
- Any feature requiring server data to be sent to the client
The server is required because without a valid server reference the plugin cannot safely send packets—doing so would cause a networking error.
public class YourPlugin implements AStagesPlugin {
public static final CustomManager CUSTOM_INSTANCE = ...;
@Override
public void reloadAfterScripts(MinecraftServer server) {
// Build server-dependent caches and send updated autocomplete data
CUSTOM_INSTANCE.someSynchronization(server);
}
}AStagesPlugin#clearClientOnLogin: clear leftover client-side synchronized data.
Called when a player logs into a server.
This method is used to clear any client-side leftover data from previous synchronizations, such as restriction states or attribute values that were cached while connected to a different server.
Without cleaning these values, the client might display outdated or incorrect information after switching servers.
AStages will call this method automatically when needed; plugins only need to implement the cleanup logic.
public class YourPlugin implements AStagesPlugin {
@Override
public void clearClientOnLogin() {
// Some clearing operations
}
}AStagesPlugin#registerManagers: register custom managers for specific restriction types.
Called during plugin initialization to allow the mod to register new managers and associate them with their corresponding restriction types or handling logic.
Managers are responsible for processing, validating, updating, or caching restrictions of a specific category.
Registering a manager here ensures that AStages recognizes it.
public class YourPlugin implements AStagesPlugin {
// This line is required because restriction types are registries
// Remember to register it in your mod main class, under mod event bus
public static final DeferredRegister<ARestrictionType> RESTRICTION_TYPES = ARestrictionType.setCurrentDeferredRegister(DeferredRegister.create(AStagesRegistries.Keys.RESTRICTION_TYPES, YourMod.MODID));
public static final ARestrictionType YOUR_TYPE = ARestrictionType.create("your_type");
public static final CustomManager CUSTOM_INSTANCE = ...;
@Override
public void registerManagers(ManagerContainer container) {
container.register(YOUR_TYPE, CUSTOM_INSTANCE);
}
}Documentation:
-
Restrictions
- Overview
- Crop
- Dimension
- Effect
- Enchant
- Item (Old)
- Loot
- Mob
- Ore
- Pet
- Recipe
- Region
- Screen
- Structure -
Addons
- Curios API
- FTB Quests
- Pufferfish Skill's -
Simple Restrictions (via commands)
Brand new and intuitive way to add restriction! -
Developers
- Plugin
- Restrictions
- Simple Restrictions
- Stage System
- Utils -
Q&A
A place where questions are on the agenda! -
Changelogs
Changelogs since 0.6.0 version! -
What's Happened? (FLOP!)
New code formatting is coming!