mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-02 15:43:22 +01:00
12.1.1
This commit is contained in:
parent
7be76e2343
commit
3563a827f7
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
## 12.1.1
|
||||
- ChestSort will no longer move any shulkerboxes in the inventory around if this shulkerbox is currently open in ShulkerPacks
|
||||
|
||||
## 12.0.6
|
||||
- Fixed "additional-hotkeys" not working for ender chests
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -9,7 +9,7 @@
|
||||
<name>ChestSort</name>
|
||||
<url>https://www.chestsort.de</url>
|
||||
<description>Allows automatic chest sorting!</description>
|
||||
<version>12.1.0</version>
|
||||
<version>12.1.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -5,6 +5,7 @@ import de.jeff_media.chestsort.ChestSortPlugin;
|
||||
import de.jeff_media.chestsort.data.Category;
|
||||
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;
|
||||
@ -552,6 +553,7 @@ public class ChestSortOrganizer {
|
||||
if ((plugin.isHookMinepacks() && plugin.getListener().minepacksHook.isMinepacksBackpack(items[i]))
|
||||
|| (plugin.isHookInventoryPages() && inventoryPagesHook.isButton(items[i], i, inv))
|
||||
|| (plugin.getConfig().getBoolean("dont-move-slimefun-backpacks") && SlimeFunHook.isSlimefunBackpack(items[i]))
|
||||
|| ShulkerPacksHook.isOpenShulkerPack(items[i])
|
||||
|| isOversizedStack(items[i])
|
||||
|| chestSortEvent.isUnmovable(i)
|
||||
|| chestSortEvent.isUnmovable(items[i])) {
|
||||
@ -718,6 +720,8 @@ public class ChestSortOrganizer {
|
||||
if (plugin.isHookInventoryPages()
|
||||
&& plugin.getOrganizer().inventoryPagesHook.isButton(currentItem, i, source)) continue;
|
||||
|
||||
if(ShulkerPacksHook.isOpenShulkerPack(currentItem)) continue;
|
||||
|
||||
if (destinationIsShulkerBox && currentItem.getType().name().endsWith("SHULKER_BOX")) continue;
|
||||
|
||||
if (isOversizedStack(currentItem)) continue;
|
||||
|
@ -0,0 +1,59 @@
|
||||
package de.jeff_media.chestsort.hooks;
|
||||
|
||||
import de.jeff_media.chestsort.ChestSortPlugin;
|
||||
import de.jeff_media.chestsort.api.ChestSortEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.w3c.dom.ls.LSOutput;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ShulkerPacksHook {
|
||||
|
||||
private static Method checkIfOpenMethod;
|
||||
private static Boolean installed = null;
|
||||
|
||||
public static boolean isOpenShulkerPack(ItemStack item) {
|
||||
if(installed == null) {
|
||||
if (Bukkit.getPluginManager().getPlugin("ShulkerPacks") == null) {
|
||||
installed = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
checkIfOpenMethod = Class.forName("me.darkolythe.shulkerpacks.ShulkerListener").getDeclaredMethod("checkIfOpen",ItemStack.class);
|
||||
//System.out.println("Found ShulkerPacks method: " + checkIfOpenMethod);
|
||||
if(checkIfOpenMethod != null) checkIfOpenMethod.setAccessible(true);
|
||||
installed = checkIfOpenMethod != null;
|
||||
} catch (Throwable t) {
|
||||
installed = false;
|
||||
ChestSortPlugin.getInstance().getLogger().severe("Error while hooking into ShulkerPacks. Try updating ShulkerPacks to the newest version.");
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(installed) {
|
||||
try {
|
||||
return (boolean) checkIfOpenMethod.invoke(null, item);
|
||||
} catch (IllegalAccessException | InvocationTargetException ignored) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsOpenShulkerPack(Inventory inventory) {
|
||||
for(ItemStack item : inventory.getContents()) {
|
||||
if(item == null) continue;
|
||||
if(!item.getType().name().endsWith("SHULKER_BOX")) continue;
|
||||
if(isOpenShulkerPack(item)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -502,7 +502,6 @@ public class Listener implements org.bukkit.event.Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (event.getClick()) {
|
||||
case MIDDLE:
|
||||
cause = Logger.SortCause.H_MIDDLE;
|
||||
|
@ -10,7 +10,7 @@ website: ${project.url}
|
||||
prefix: ${spigot.prefix}
|
||||
database: false
|
||||
loadbefore: [InvUnload]
|
||||
softdepend: [CrackShot,InventoryPages,Minepacks,PlaceholderAPI,AdvancedChests]
|
||||
softdepend: [CrackShot,InventoryPages,Minepacks,PlaceholderAPI,AdvancedChests,ShulkerPacks]
|
||||
commands:
|
||||
sort:
|
||||
description: Toggle automatic chest sorting or change your hotkey settings
|
||||
|
Loading…
Reference in New Issue
Block a user