Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate instanceof ManaKey #36

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/appbot/ae2/ManaExternalStorageStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ private record ManaStorageAdapter(ManaReceiver receiver, Runnable injectOrExtrac

@Override
public long insert(AEKey what, long amount, Actionable mode, IActionSource source) {
if (!(what instanceof ManaKey)) {
return 0;
}

var inserted = (int) Math.min(amount,
ManaHelper.getCapacity(receiver) - receiver.getCurrentMana());

Expand All @@ -60,6 +64,10 @@ public long insert(AEKey what, long amount, Actionable mode, IActionSource sourc

@Override
public long extract(AEKey what, long amount, Actionable mode, IActionSource source) {
if (!(what instanceof ManaKey)) {
return 0;
}

var extracted = (int) Math.min(amount, receiver.getCurrentMana());

if (extracted > 0 && mode == Actionable.MODULATE) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/appbot/ae2/ManaStorageExportStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public ManaStorageExportStrategy(ServerLevel level,

@Override
public long transfer(StackTransferContext context, AEKey what, long amount) {
if (!(what instanceof ManaKey)) {
return 0;
}

var receiver = apiCache.find(fromSide);

if (receiver == null) {
Expand All @@ -50,6 +54,10 @@ public long transfer(StackTransferContext context, AEKey what, long amount) {

@Override
public long push(AEKey what, long amount, Actionable mode) {
if (!(what instanceof ManaKey)) {
return 0;
}

var receiver = apiCache.find(fromSide);

if (receiver == null) {
Expand Down