Skip to content

Commit

Permalink
Conversation menu reopening bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubix327 committed Nov 20, 2022
1 parent cc07425 commit 121737a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,12 @@ public final void conversationAbandoned(final ConversationAbandonedEvent event)
(event.gracefulExit() ? CompSound.SUCCESSFUL_HIT : CompSound.NOTE_BASS).play(player, 1F, 1F);

if (this.menuToReturnTo != null && this.reopenMenu()) {
final AdvancedMenu menu = AdvancedMenu.newInstanceOf(menuToReturnTo.getClass(), player);

menu.display();
menuToReturnTo.newInstance().display();

final String title = this.getMenuAnimatedTitle();

if (title != null)
Common.runLater(2, () -> menu.animateTitle(title));
Common.runLater(2, () -> menuToReturnTo.animateTitle(title));
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/mineacademy/fo/menu/AdvancedMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected final Button getMenuButton(Class<? extends AdvancedMenu> to, ItemStack
return new Button() {
@Override
public void onClickedInMenu(Player player, AdvancedMenu menu, ClickType click) {
newInstanceOf(to, player).display();
menu.newInstance().display();
}

@Override
Expand Down Expand Up @@ -452,7 +452,7 @@ public ItemStack getItemAt(int slot) {
}

@Override
public final AdvancedMenu newInstance() {
public AdvancedMenu newInstance() {
return newInstanceOf(this.getClass(), this.player);
}

Expand All @@ -461,8 +461,7 @@ public final AdvancedMenu newInstance() {
*/
public static AdvancedMenu newInstanceOf(Class<? extends AdvancedMenu> menu, Player player){
try{
AdvancedMenu am = menu.getDeclaredConstructor(Player.class).newInstance(player);
return am;
return menu.getDeclaredConstructor(Player.class).newInstance(player);
}
catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e){
e.printStackTrace();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/mineacademy/fo/remain/Remain.java
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,6 @@ else if (inventorySize == 6)
final int inventorySize = player.getOpenInventory().getTopInventory().getSize() / 9;

if (inventorySize < 1 || inventorySize > 6) {
Common.log("Cannot update title for " + player.getName() + " as their inventory has non typical size: " + inventorySize + " rows");

return;
}

Expand Down

0 comments on commit 121737a

Please sign in to comment.