mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
fix
This commit is contained in:
parent
757d7613ac
commit
61ff68d34a
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -28,6 +29,7 @@ public class GuideHistory {
|
||||
|
||||
private final PlayerProfile profile;
|
||||
private final Deque<GuideEntry<?>> queue = new LinkedList<>();
|
||||
private int mainMenuPage = 1;
|
||||
|
||||
/**
|
||||
* This creates a new {@link GuideHistory} for the given {@link PlayerProfile}
|
||||
@ -47,6 +49,27 @@ public class GuideHistory {
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the page of the main menu of this {@link GuideHistory}
|
||||
*
|
||||
* @param page
|
||||
* The current page of the main menu that should be stored
|
||||
*/
|
||||
public void setMainMenuPage(int page) {
|
||||
Validate.isTrue(page >= 1, "page must be greater than 0!");
|
||||
|
||||
mainMenuPage = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the current main menu page of this {@link GuideHistory}
|
||||
*
|
||||
* @return The main menu page of this {@link GuideHistory}
|
||||
*/
|
||||
public int getMainMenuPage() {
|
||||
return mainMenuPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a {@link Category} to this {@link GuideHistory}.
|
||||
* Should the {@link Category} already be the last element in this {@link GuideHistory},
|
||||
@ -165,7 +188,7 @@ public class GuideHistory {
|
||||
|
||||
private <T> void open(@Nonnull SlimefunGuideImplementation guide, @Nullable GuideEntry<T> entry) {
|
||||
if (entry == null) {
|
||||
guide.openMainMenu(profile, 1);
|
||||
guide.openMainMenu(profile, mainMenuPage);
|
||||
} else if (entry.getIndexedObject() instanceof Category) {
|
||||
guide.openCategory(profile, (Category) entry.getIndexedObject(), entry.getPage());
|
||||
} else if (entry.getIndexedObject() instanceof SlimefunItem) {
|
||||
|
@ -146,6 +146,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
||||
if (isSurvivalMode()) {
|
||||
profile.getGuideHistory().clear();
|
||||
}
|
||||
profile.getGuideHistory().setMainMenuPage(page);
|
||||
|
||||
ChestMenu menu = create(p);
|
||||
List<Category> categories = getVisibleCategories(p, profile);
|
||||
@ -602,7 +603,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
||||
|
||||
menu.addMenuClickHandler(slot, (pl, s, is, action) -> {
|
||||
if (action.isShiftClicked()) {
|
||||
openMainMenu(profile, 1);
|
||||
openMainMenu(profile, profile.getGuideHistory().getMainMenuPage());
|
||||
} else {
|
||||
history.goBack(this);
|
||||
}
|
||||
@ -612,7 +613,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
||||
} else {
|
||||
menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide"))));
|
||||
menu.addMenuClickHandler(slot, (pl, s, is, action) -> {
|
||||
openMainMenu(profile, 1);
|
||||
openMainMenu(profile, profile.getGuideHistory().getMainMenuPage());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user