1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Little bit of refactoring

This commit is contained in:
TheBusyBiscuit 2021-01-11 12:45:11 +01:00
parent 7a4712f930
commit f6a9150296
3 changed files with 8 additions and 20 deletions

View File

@ -82,10 +82,6 @@ public final class SlimefunGuide {
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode layout, int selectedPage) { public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode layout, int selectedPage) {
if (category == null) {
return;
}
SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage); SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage);
} }
@ -110,8 +106,12 @@ public final class SlimefunGuide {
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory); SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
} }
public static boolean isGuideItem(@Nonnull ItemStack item) { public static boolean isGuideItem(@Nullable ItemStack item) {
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true); if (item == null) {
return false;
} else {
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true);
}
} }
/** /**

View File

@ -393,19 +393,6 @@ final class CargoUtils {
} }
} }
/**
* Get the whitelist/blacklist slots in a Cargo Input Node. If you wish to access the items
* in the cargo (without hardcoding the slots in case of change) then you can use this method.
*
* @deprecated Renamed to {@link #getFilteringSlots()}
*
* @return The slot indexes for the whitelist/blacklist section.
*/
@Deprecated
public static int[] getWhitelistBlacklistSlots() {
return getFilteringSlots();
}
/** /**
* Gets the {@link ItemFilter} slots for a Cargo Node. If you wish to access the items * Gets the {@link ItemFilter} slots for a Cargo Node. If you wish to access the items
* in the cargo (without hardcoding the slots in case of change) then you can use this method. * in the cargo (without hardcoding the slots in case of change) then you can use this method.

View File

@ -136,7 +136,6 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor")); ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor"));
menu.setEmptySlotsClickable(false); menu.setEmptySlotsClickable(false);
int pages = 1 + (floors.size() / GUI_SIZE);
int index = GUI_SIZE * (page - 1); int index = GUI_SIZE * (page - 1);
for (int i = 0; i < Math.min(GUI_SIZE, floors.size() - index); i++) { for (int i = 0; i < Math.min(GUI_SIZE, floors.size() - index); i++) {
@ -162,6 +161,8 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
// @formatter:on // @formatter:on
} }
int pages = 1 + (floors.size() / GUI_SIZE);
// 0 index so size is the first slot of the last row. // 0 index so size is the first slot of the last row.
for (int i = GUI_SIZE; i < GUI_SIZE + 9; i++) { for (int i = GUI_SIZE; i < GUI_SIZE + 9; i++) {
if (i == GUI_SIZE + 2 && pages > 1 && page != 1) { if (i == GUI_SIZE + 2 && pages > 1 && page != 1) {