14.0.4 - fixes #192

This commit is contained in:
mfnalex 2024-05-25 10:15:22 +02:00
parent 7a11054b56
commit bc58a23cbb
No known key found for this signature in database
GPG Key ID: 4A5852356225BAE1
2 changed files with 36 additions and 30 deletions

View File

@ -9,7 +9,7 @@
<name>ChestSort</name>
<url>https://www.chestsort.de</url>
<description>Allows automatic chest sorting!</description>
<version>14.0.3</version>
<version>14.0.4</version>
<packaging>jar</packaging>
<properties>

View File

@ -1,20 +1,19 @@
package de.jeff_media.chestsort.handlers;
import de.jeff_media.chestsort.api.ChestSortEvent;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.api.ChestSortEvent;
import de.jeff_media.chestsort.api.ChestSortPostSortEvent;
import de.jeff_media.chestsort.data.Category;
import de.jeff_media.chestsort.data.CategoryLinePair;
import de.jeff_media.chestsort.hooks.CrackShotHook;
import de.jeff_media.chestsort.hooks.InventoryPagesHook;
import de.jeff_media.chestsort.hooks.ShulkerPacksHook;
import de.jeff_media.chestsort.hooks.SlimeFunHook;
import de.jeff_media.chestsort.data.CategoryLinePair;
import de.jeff_media.chestsort.utils.EnchantmentUtils;
import de.jeff_media.chestsort.utils.TypeMatchPositionPair;
import de.jeff_media.chestsort.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -28,7 +27,14 @@ import org.bukkit.potion.PotionData;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class ChestSortOrganizer {
@ -54,11 +60,11 @@ public class ChestSortOrganizer {
private static final int playerInvStartSlot = 9; // Inclusive
private static final int playerInvEndSlot = 35; // Inclusive
private static final String emptyPlaceholderString = "~";
// We store a list of all Category objects
public final ArrayList<Category> categories = new ArrayList<>();
final ChestSortPlugin plugin;
final CrackShotHook crackShotHook;
final InventoryPagesHook inventoryPagesHook;
// We store a list of all Category objects
public final ArrayList<Category> categories = new ArrayList<>();
final ArrayList<String> stickyCategoryNames = new ArrayList<>();
private final HashSet<Inventory> sortableInventories = new HashSet<>();
private final HashSet<Inventory> unsortableInventories = new HashSet<>();
@ -393,15 +399,13 @@ public class ChestSortOrganizer {
// Only continue if Method "getBasePotionData" exists
Class<? extends PotionMeta> potionMetaClass = potionMeta.getClass();
try {
if (potionMetaClass.getDeclaredMethod("getBasePotionData", (Class<?>) null) != null) {
if (potionMeta.getBasePotionData() != null) {
PotionData pdata = potionMeta.getBasePotionData();
if (pdata != null && pdata.getType() != null && pdata.getType().getEffectType() != null) {
potionEffect = "|" + pdata.getType().getEffectType().getName();
}
}
}
} catch (NoSuchMethodException | SecurityException ignored) {
} catch (Throwable ignored) {
}
// potionEffects = potionEffects.substring(0, potionEffects.length()-1);
@ -586,7 +590,8 @@ public class ChestSortOrganizer {
// Sort the array with ItemStacks according to each ItemStacks' sortable String
Arrays.sort(nonNullItems, Comparator.comparing((ItemStack item) -> {
// lambda expression used to pass extra parameter
return this.getSortableString(item, chestSortEvent.getSortableMaps().get(item));}));
return this.getSortableString(item, chestSortEvent.getSortableMaps().get(item));
}));
// Now, we put everything back in a temporary inventory to combine ItemStacks
// even when using strict slot sorting
@ -717,7 +722,8 @@ public class ChestSortOrganizer {
/*if(plugin.hookMinepacks && plugin.listener.minepacksHook.isMinepacksBackpack(destination)
&& plugin.listener.minepacksHook.isMinepacksBackpack(currentItem)) continue;*/
// This prevents Minepacks from being moved at all
if (plugin.isHookMinepacks() && plugin.getListener().minepacksHook.isMinepacksBackpack(currentItem)) continue;
if (plugin.isHookMinepacks() && plugin.getListener().minepacksHook.isMinepacksBackpack(currentItem))
continue;
if (plugin.isHookInventoryPages()
&& plugin.getOrganizer().inventoryPagesHook.isButton(currentItem, i, source)) continue;