8.4 update

This commit is contained in:
mfnalex 2020-05-21 13:43:18 +02:00
parent dd95dfe3ef
commit c17fd9dc5a
8 changed files with 29 additions and 14 deletions

View File

@ -1,4 +1,7 @@
# Changelog
## 8.4
- Fixes InventoryPages support for the new hotkeys
## 8.3
- This should fix a problem where the player was able to sort inventories belonging to 3rd party plugins' GUIs using hotkeys

View File

@ -6,7 +6,7 @@
<groupId>de.jeffclan</groupId>
<artifactId>JeffChestSort</artifactId>
<version>8.3</version>
<version>8.4</version>
<packaging>jar</packaging>
<name>JeffChestSort</name>

View File

@ -47,11 +47,11 @@ public class JeffChestSortAdditionalHotkeyListener implements Listener {
JeffChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if(e.isLeftClick() && setting.leftClick) {
de.jeffclan.utils.InventoryHelper.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory());
plugin.invhelper.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory());
plugin.sortInventory(e.getInventory());
de.jeffclan.utils.InventoryHelper.updateInventoryView(e.getInventory());
plugin.invhelper.updateInventoryView(e.getInventory());
} else if(e.isRightClick() && setting.rightClick) {
de.jeffclan.utils.InventoryHelper.stuffInventoryIntoAnother(e.getInventory(), p.getInventory(),e.getInventory());
plugin.invhelper.stuffInventoryIntoAnother(e.getInventory(), p.getInventory(),e.getInventory());
}
}

View File

@ -348,7 +348,7 @@ public class JeffChestSortListener implements Listener {
}
plugin.organizer.sortInventory(event.getClickedInventory());
de.jeffclan.utils.InventoryHelper.updateInventoryView(event);
plugin.invhelper.updateInventoryView(event);
return;
} else if(holder instanceof Player) {
@ -358,12 +358,12 @@ public class JeffChestSortListener implements Listener {
if(event.getSlotType() == SlotType.QUICKBAR) {
plugin.organizer.sortInventory(p.getInventory(),0,8);
de.jeffclan.utils.InventoryHelper.updateInventoryView(event);
plugin.invhelper.updateInventoryView(event);
return;
}
else if(event.getSlotType() == SlotType.CONTAINER) {
plugin.organizer.sortInventory(p.getInventory(),9,35);
de.jeffclan.utils.InventoryHelper.updateInventoryView(event);
plugin.invhelper.updateInventoryView(event);
return;
}
return;

View File

@ -39,7 +39,7 @@ public class JeffChestSortOrganizer {
JeffChestSortPlugin plugin;
CrackShotHook crackShotHook;
InventoryPagesHook inventoryPagesHook;
public InventoryPagesHook inventoryPagesHook; // public for InventoryHelper
// All available colors in the game. We will strip this from the item names and
// keep the color in a separate variable

View File

@ -50,13 +50,15 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import de.jeffclan.utils.InventoryHelper;
import de.jeffclan.utils.Utils;
public class JeffChestSortPlugin extends JavaPlugin {
Map<String, JeffChestSortPlayerSetting> perPlayerSettings = new HashMap<String, JeffChestSortPlayerSetting>();
JeffChestSortMessages messages;
JeffChestSortOrganizer organizer;
public JeffChestSortOrganizer organizer;
InventoryHelper invhelper;
JeffChestSortUpdateChecker updateChecker;
JeffChestSortListener listener;
JeffChestSortAdditionalHotkeyListener additionalHotkeys;
@ -243,6 +245,7 @@ public class JeffChestSortPlugin extends JavaPlugin {
// Organizer will load all category files and will be ready to sort stuff
organizer = new JeffChestSortOrganizer(this);
invhelper = new InventoryHelper(this);
settingsGUI = new JeffChestSortSettingsGUI(this);

View File

@ -12,13 +12,21 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import de.jeffclan.JeffChestSort.JeffChestSortPlugin;
public class InventoryHelper {
private JeffChestSortPlugin plugin;
private static final int maxInventorySize=54;
private static final int playerInvStartSlot=9; // Inclusive
private static final int playerInvEndSlot=35; // Inclusive
public static void updateInventoryView(InventoryClickEvent event) {
public InventoryHelper(JeffChestSortPlugin jeffChestSortPlugin) {
this.plugin = jeffChestSortPlugin;
}
public void updateInventoryView(InventoryClickEvent event) {
for(HumanEntity viewer : event.getViewers()) {
if(viewer instanceof Player) {
Player playerViewer = (Player) viewer;
@ -27,7 +35,7 @@ public class InventoryHelper {
}
}
public static void updateInventoryView(Inventory inventory) {
public void updateInventoryView(Inventory inventory) {
for(HumanEntity viewer : inventory.getViewers()) {
if(viewer instanceof Player) {
Player playerViewer = (Player) viewer;
@ -36,7 +44,7 @@ public class InventoryHelper {
}
}
public static void stuffInventoryIntoAnother(Inventory source, Inventory destination,Inventory origSource) {
public void stuffInventoryIntoAnother(Inventory source, Inventory destination,Inventory origSource) {
ArrayList<ItemStack> leftovers = new ArrayList<ItemStack>();
@ -60,12 +68,13 @@ public class InventoryHelper {
}
public static void stuffPlayerInventoryIntoAnother(PlayerInventory source,
public void stuffPlayerInventoryIntoAnother(PlayerInventory source,
Inventory destination) {
boolean destinationIsShulkerBox = destination.getType() == InventoryType.SHULKER_BOX;
Inventory temp = Bukkit.createInventory(null, maxInventorySize);
for(int i = playerInvStartSlot;i<=playerInvEndSlot;i++) {
if(source.getItem(i)==null) continue;
if(plugin.hookInventoryPages && plugin.organizer.inventoryPagesHook.isButton(source.getItem(i), i, source)) continue;
if(destinationIsShulkerBox && source.getItem(i).getType().name().endsWith("SHULKER_BOX")) continue;
temp.addItem(source.getItem(i));
source.clear(i);

View File

@ -1,6 +1,6 @@
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
name: ChestSort
version: 8.3
version: 8.4
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex