-
Notifications
You must be signed in to change notification settings - Fork 12
fix(database): prevent dupe, and add new placeholders #47
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
Changes from all commits
a84ffb7
edad0ba
e0e9006
db1733a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,18 +69,20 @@ public CompletableFuture<Void> collect(EnvyPlayer<?> player, Consumer<EnvyPlayer | |
| if (!parent.getInventory().add(copy)) { | ||
| player.message(UtilChatColour.colour(EnvyGTSForge.getLocale().getMessages().getInventoryFull())); | ||
|
|
||
| if (returnGui == null) { | ||
| parent.closeContainer(); | ||
| } else { | ||
| returnGui.accept(player); | ||
| } | ||
| UtilConcurrency.runAsync(this::delete); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possibly the cause of the issue. hmm. |
||
|
|
||
| this.item.setCount(copy.getCount()); | ||
|
|
||
| var attribute = player.getAttributeNow(GTSAttribute.class); | ||
| attribute.getOwnedTrades().add(this); | ||
| this.save(); | ||
|
|
||
| if (returnGui == null) { | ||
| parent.closeContainer(); | ||
| } else { | ||
| returnGui.accept(player); | ||
| } | ||
|
|
||
| return CompletableFuture.completedFuture(null); | ||
| } | ||
|
|
||
|
|
@@ -95,8 +97,6 @@ public CompletableFuture<Void> collect(EnvyPlayer<?> player, Consumer<EnvyPlayer | |
| returnGui.accept(player); | ||
| } | ||
|
|
||
| UtilConcurrency.runAsync(this::save); | ||
|
|
||
| return UtilConcurrency.runAsync(this::delete); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,8 +172,9 @@ public void displayClaimable(int pos, Consumer<EnvyPlayer<?>> returnGui, Pane pa | |
| .asyncClick(false) | ||
| .singleClick() | ||
| .clickHandler((envyPlayer, clickType) -> { | ||
| GTSAttribute attribute = ((ForgeEnvyPlayer) envyPlayer).getAttributeNow(GTSAttribute.class); | ||
| GTSAttribute attribute = envyPlayer.getAttributeNow(GTSAttribute.class); | ||
| attribute.getOwnedTrades().remove(this); | ||
| UtilConcurrency.runAsync(this::delete); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this is the pokemon trade, there is no stack.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the current code actually doesn't handle that at all? |
||
| this.collect(envyPlayer, returnGui); | ||
| }) | ||
| .build()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ public static void openUI(ForgeEnvyPlayer player, int page, int position, boolea | |
| .replace("%max_duration%", UtilTimeFormat.getFormattedDuration( | ||
| TimeUnit.SECONDS.toMillis(EnvyGTSForge.getConfig().getMinTradeDuration()) | ||
| )) | ||
| .replace("%pokemon%", pokemon.getDisplayName().getString()))) | ||
| .replace("%pokemonItem%", pokemon.getDisplayName().getString()))) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why have you changed this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| .defaultText(TimeUnit.SECONDS.toMinutes(EnvyGTSForge.getConfig().getMinTradeDuration()) + "m") | ||
| .maxInputLength(10) | ||
| .closeOnEscape() | ||
|
|
@@ -96,6 +96,7 @@ public static void openUI(ForgeEnvyPlayer player, int page, int position, boolea | |
| attribute.setCurrentMinPrice(0); | ||
| attribute.setCurrentPrice(0); | ||
| attribute.setSelectedSlot(-1); | ||
| PlatformProxy.runSync(player.getParent()::closeContainer); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| }); | ||
| }) | ||
| .build() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import com.envyful.api.neoforge.concurrency.UtilForgeConcurrency; | ||
| import com.envyful.api.neoforge.player.ForgeEnvyPlayer; | ||
| import com.envyful.api.neoforge.player.util.UtilPlayer; | ||
| import com.envyful.api.platform.PlatformProxy; | ||
| import com.envyful.api.time.UtilTime; | ||
| import com.envyful.api.time.UtilTimeFormat; | ||
| import com.envyful.gts.forge.EnvyGTSForge; | ||
|
|
@@ -34,11 +35,10 @@ public static void openUI(ForgeEnvyPlayer player, double time, boolean error) { | |
| .replace("%max_duration%", UtilTimeFormat.getFormattedDuration( | ||
| TimeUnit.SECONDS.toMillis(EnvyGTSForge.getConfig().getMinTradeDuration()) | ||
| )) | ||
| .replace("%item%", itemInHand.getHoverName().getString()))) | ||
| .replace("%pokemonItem%", itemInHand.getHoverName().getString()))) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here, regarding what was the reasoning for changing this? |
||
| .showInput() | ||
| .defaultText(TimeUnit.SECONDS.toMinutes(EnvyGTSForge.getConfig().getMinTradeDuration()) + "m") | ||
| .closeOnEscape() | ||
| .onClose(closedScreen -> SellHandOrParty.open(player)) | ||
| .buttons(DialogueButton.builder() | ||
| .text("Submit") | ||
| .onClick(submitted -> { | ||
|
|
@@ -55,6 +55,7 @@ public static void openUI(ForgeEnvyPlayer player, double time, boolean error) { | |
| } | ||
|
|
||
| UtilPlayer.runCommand(player.getParent(), "gts sell " + itemInHand.getCount() + " " + time + " " + submitted.getInput()); | ||
| PlatformProxy.runSync(player.getParent()::closeContainer); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| }) | ||
| .build()) | ||
| .sendTo(player.getParent()), 5); | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kk :3