-
Notifications
You must be signed in to change notification settings - Fork 0
Using the ResouceAPI
ancap-kun edited this page Feb 17, 2023
·
1 revision
ResouceAPI - a way to work with resources of different versions. ResourceAPI allows you to load and transfer values in config. With ResourceAPI your plugin users will never have to recreate configs and manually re-fill everything again!
The ResourceAPI is already integrated into the AncapPluginAPI, and when you get a config via this.getConfiguration from the AncapPlugin descendant, you are given a ResourceAPI-processed config. All you have to do is fill in the value-transfer-map.yml:
main-domain:
test-config.yml:
2: # version to which the transfer is made
- "test-relocated:test.relocated" # old path : new path
- "test-empty-relocated:test.empty-relocated"
- "test-incorrect.relocation:test-incorrect-relocation"
custom:
LanguageAPI: # Locales are populated here, one transfer mapping for all locales at once
2:
- "ru.ancap.framework.messages.not-enough-args:ru.ancap.framework.messages.not-enough-arguments"And add the version field to your config. For normal config this field is config-version, for locales from LanguageAPI this field is version:
config-version: 1This is how you can create your own domain/resource preparer yourself:
private final Cache<FileConfiguration> configCache = new Cache<>(1_000_000_000);
protected ConfigurationSection getConfiguration(String fileName) {
return this.configCache.get(() -> this.newResourceSource(FileConfigurationPreparator.resolveConflicts(
(version) -> this.valueTransferMap() /* from AncapPlugin heir */ != null ?
BuiltTransferMap.makeFor(this.valueTransferMap().getConfigurationSection("main-domain. "+fileName), version) :
BuiltTransferMap.EMPTY,
"config-version"
))).getResource(fileName));
}-
Создание плагина
- Создание main-класса
- Настройка ancapplugin.yml
- Использование AncapPluginAPI
- Использование LanguageAPI
- Использование CommunicatorAPI
- Использование ConfigurationAPI
- Использование CommandAPI
- Использование DatabaseAPI
- Использование EventAPI
- Использование MaterialAPI
- Использование WorldIteratorAPI
- Использование BukkitUtil
- Использование ResourceAPI
-
- Creating main class
- Setting up the ancapplugin.yml
- Using the AncapPluginAPI
- Using the LanguageAPI
- Using the CommunicatorAPI
- Using the ConfigurationAPI
- Using the CommandAPI
- Using the DatabaseAPI
- Using the EventAPI
- Using the MaterialAPI
- Using the WorldIteratorAPI
- Using the BukkitUtil
- Using the ResouceAPI