mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-14 22:56:27 +01:00
Start of Inventory Sort Implementation.
This commit is contained in:
parent
cba7fd7b5f
commit
c4fa121c7e
@ -45,6 +45,7 @@ public class HopperListener implements Listener {
|
||||
public void run() {
|
||||
Utils.moveToOtherInventory(event.getSource(), 1, storage.getInventory());
|
||||
event.getDestination().getHolder().getInventory().clear();
|
||||
storage.sort();
|
||||
}
|
||||
}.runTaskLater(ChestsPlusPlus.PLUGIN, 1);
|
||||
}
|
||||
|
@ -1,24 +1,26 @@
|
||||
package com.jamesdpeters.minecraft.chests.listeners;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Config;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Messages;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Permissions;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryPlayerUpdate(InventoryClickEvent event){
|
||||
if(event.getInventory().getHolder() instanceof VirtualInventoryHolder){
|
||||
inventoryUpdate(event);
|
||||
Config.save();
|
||||
}
|
||||
}
|
||||
@ -55,4 +57,18 @@ public class InventoryListener implements Listener {
|
||||
} catch (NullPointerException ignore){} //Essentials does something weird with enderchests - shit fix but works :)
|
||||
}
|
||||
|
||||
public void inventoryUpdate(InventoryInteractEvent event){
|
||||
if(event.getInventory().getHolder() instanceof VirtualInventoryHolder){
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, () -> ((VirtualInventoryHolder) event.getInventory().getHolder()).getStorage().sort(),1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryPlayerUpdate(InventoryDragEvent event){
|
||||
if(event.getInventory().getHolder() instanceof VirtualInventoryHolder){
|
||||
inventoryUpdate(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public class VirtualChestToHopper extends BukkitRunnable {
|
||||
continue;
|
||||
}
|
||||
Utils.moveToOtherInventory(storage.getInventory(), 1, hopper.getInventory(), Utils.getHopperFilters(below.getBlock()));
|
||||
storage.sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user