-
Notifications
You must be signed in to change notification settings - Fork 0
Developer Integration Tutorial
This guide explains how to integrate UBS into another mod dev environment for the current Forge 1.20.1 branch.
Current UBS identity:
- Maven group:
net.austizz.ultimatebankingsystem - Artifact:
ultimatebankingsystem - Mod id:
ultimatebankingsystem - Current version in this repo:
1.2.0
Dependency coordinate format:
net.austizz.ultimatebankingsystem:ultimatebankingsystem:<ubs_version>
Yes, if your code imports UBS classes (for example UltimateBankingApiProvider), your mod must have UBS on the compile classpath.
You also need UBS present at runtime for tests/dev runs if you actually call UBS APIs.
Use one:
- Composite build (best when developing both mods locally)
-
mavenLocal()(best if UBS is built/published locally) -
libs/jar dependency (quick local setup)
pluginManagement {
repositories {
gradlePluginPortal()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
includeBuild("../Ultimate-Banking-System-UBS-")Point the path to your local UBS clone.
dependencies {
compileOnly "net.austizz.ultimatebankingsystem:ultimatebankingsystem:1.2.0"
runtimeOnly "net.austizz.ultimatebankingsystem:ultimatebankingsystem:1.2.0"
}./gradlew publishToMavenLocalWindows:
gradlew.bat publishToMavenLocalrepositories {
mavenLocal()
maven { url "https://libraries.minecraft.net" }
// other repos...
}
dependencies {
compileOnly "net.austizz.ultimatebankingsystem:ultimatebankingsystem:1.2.0"
runtimeOnly "net.austizz.ultimatebankingsystem:ultimatebankingsystem:1.2.0"
}./gradlew buildTake the produced UBS jar from build/libs/ and place it in your mod's libs/.
repositories {
flatDir {
dirs "libs"
}
}
dependencies {
compileOnly name: "ultimatebankingsystem-1.2.0"
runtimeOnly name: "ultimatebankingsystem-1.2.0"
}In your mod's src/main/resources/META-INF/mods.toml, replace <your_modid> with your mod id.
[[dependencies.<your_modid>]]
modId="ultimatebankingsystem"
type="required"
versionRange="[1.2.0,)"
ordering="AFTER"
side="BOTH"[[dependencies.<your_modid>]]
modId="ultimatebankingsystem"
type="optional"
versionRange="[1.2.0,)"
ordering="AFTER"
side="BOTH"Use required if your mod cannot function without UBS.
Use optional if UBS features are add-ons.
You can call UBS API directly during normal server lifecycle points.
UltimateBankingApi api = UltimateBankingApiProvider.get();
if (!api.isServerAvailable()) {
return;
}Guard integration so your mod does not crash when UBS is missing.
import net.neoforged.fml.ModList;
boolean hasUbs = ModList.get().isLoaded("ultimatebankingsystem");
if (!hasUbs) {
return;
}Keep UBS-specific code in classes only touched when UBS is loaded.
Do not jarJar/shade UBS into your own mod jar. UBS should load as a separate mod.
import net.austizz.ultimatebankingsystem.api.UltimateBankingApi;
import net.austizz.ultimatebankingsystem.api.UltimateBankingApiProvider;
UltimateBankingApi api = UltimateBankingApiProvider.get();
String apiVersion = api.getApiVersion();import java.math.BigDecimal;
var bal = api.getBalance(accountId);
if (bal.success()) {
// bal.balanceAfter()
}
var tx = api.transfer(senderAccountId, receiverAccountId, new BigDecimal("250.50"), "EXAMPLE_ORDER:1234");
if (!tx.success()) {
// tx.reason()
}import java.util.List;
import java.util.UUID;
if (!api.playerHasAnyAccount(playerId)) {
// Ask the player to create a UBS account before using this integration.
}
List<UUID> accountIds = api.getPlayerAccountIds(playerId);
if (api.playerHasAvailablePrimaryAccount(playerId)
&& api.primaryAccountCanSend(playerId, new BigDecimal("250.50"))) {
// The player's primary account exists and can send this payment.
}playerHasAvailablePrimaryAccount, primaryAccountCanSend, and primaryAccountCanReceive require an explicitly selected primary account. Use playerHasAvailableAccount when any usable owned account is acceptable.
import net.austizz.ultimatebankingsystem.api.ApiAlertTone;
api.sendUiAlert(
playerId,
"Auction House",
"Your bid was accepted.",
ApiAlertTone.SUCCESS,
4200
);
api.sendUiAlert(
playerId,
"Auction House",
"Raw payload-style warning.",
true,
5000,
ApiAlertTone.WARNING.id()
);var cheque = api.issueCheque(
sourceAccountId,
recipientPlayerId,
300L,
writerPlayerId,
"Cashier",
"Recipient"
);
if (cheque.success()) {
ItemStack stack = cheque.itemStack();
}var cash = api.giveDollarBills(playerId, 20, 5); // 5x $20 bills
int cashOnHand = api.getPlayerCashOnHand(playerId);var coins = api.giveCoins(playerId, 25, 8); // 8x quarters
int quarterCount = api.getPlayerCoinCount(playerId, 25);var pay = api.shopPurchase(
payerAccountId,
merchantAccountId,
45L,
"Coffee Counter",
"pos-terminal-01"
);After setup:
-
./gradlew buildsucceeds in your mod. - Game starts with both mods in dev run.
-
ModList.get().isLoaded("ultimatebankingsystem")reports true when expected. -
api.isServerAvailable()becomes true after server data init. - A test API call (for example
getPlayerAccountCount) returns expected values.
- Missing UBS on compile classpath:
- Causes compile errors for UBS imports.
- Missing UBS on runtime classpath:
- Causes
ClassNotFound/NoClassDefFoundduring dev run.
- Causes
-
optionalmods.toml but unguarded UBS class usage:- Crashes when UBS is not installed.
- Wrong version range in mods.toml:
- Dependency mismatch at load.