Skip to content

Conversation

@Valjean42
Copy link

API Update, a few DB-related fixes, change %pokemon% and %item% to %pokemonItem% in locale cus they use the same locale option.

Valjean42 added 2 commits July 3, 2025 14:34
… might need more looking at when we delete), change %pokemon% and %item% to %pokemonItem% in locale cus they use the same locale option.
@danorris709 danorris709 changed the title Val fixes fix(database): prevent dupe, and add new placeholders Jul 4, 2025
GTSAttribute attribute = ((ForgeEnvyPlayer) envyPlayer).getAttributeNow(GTSAttribute.class);
GTSAttribute attribute = envyPlayer.getAttributeNow(GTSAttribute.class);
attribute.getOwnedTrades().remove(this);
UtilConcurrency.runAsync(this::delete);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be here. We should only delete the trade once we are certain that the entire stack has been added to their inventory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if the trade is removed from getOwnedTrades the db should reflect the same changes no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this is the pokemon trade, there is no stack.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I didn't look at the class name there. However, I think this is still applicable as what if their PC is full?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current code actually doesn't handle that at all?

TimeUnit.SECONDS.toMillis(EnvyGTSForge.getConfig().getMinTradeDuration())
))
.replace("%pokemon%", pokemon.getDisplayName().getString())))
.replace("%pokemonItem%", pokemon.getDisplayName().getString())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both types of DurationUIs use the same locale string, so I changed these two (this one and the question below) to be the same replacement string. Maybe I should change it to be something like "tradableName" to be a little more generic...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see.

Yeah perhaps an underscore inbetween the words too to match the format of the other placeholders?

TimeUnit.SECONDS.toMillis(EnvyGTSForge.getConfig().getMinTradeDuration())
))
.replace("%item%", itemInHand.getHoverName().getString())))
.replace("%pokemonItem%", itemInHand.getHoverName().getString())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here, regarding what was the reasoning for changing this?


group = 'com.envyful.gts'
version = '5.1.0'
version = '5.2.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important for now but in the future you shouldn't include these changes in a PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk :3

} else {
returnGui.accept(player);
}
UtilConcurrency.runAsync(this::delete);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete call should not be here. The stack was not fully returned to the player's inventory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It saves immediately afterwards. This deletion is for when the item partially got added, but some still couldn't be, which causes the item's count to be different, so we have to reflect that in the DB

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so we shouldn't be deleting it, we should just be updating the value in the database which is what the save call should be doing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this might just be me being SQL stupid, but does INSERT INTO update existing values? I thought it just creates a new one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are correct it is not updating. Perhaps this is the root cause of the issue? I have been assuming the save call was an INSERT INTO .... ON DUPLICATE KEY UPDATE etc etc

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly the cause of the issue. hmm.

attribute.setCurrentMinPrice(0);
attribute.setCurrentPrice(0);
attribute.setSelectedSlot(-1);
PlatformProxy.runSync(player.getParent()::closeContainer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this here? Clicking the button should already close the UI

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that was me trying to prevent the error that pops up with dialogues (which didn't work), I guess I didn't notice and committed it too.

}

UtilPlayer.runCommand(player.getParent(), "gts sell " + itemInHand.getCount() + " " + time + " " + submitted.getInput());
PlatformProxy.runSync(player.getParent()::closeContainer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again here, clicking the button should be closing the UI so why is this here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants