Fix duplicate sorting trigger
This commit is contained in:
parent
7a0fd842c9
commit
fe53481afd
@ -6,6 +6,7 @@ import org.bukkit.block.ShulkerBox;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -27,12 +28,14 @@ public class SortListener implements Listener {
|
|||||||
* 2. Player must be attempting to interact with a Chest or Shulker Box
|
* 2. Player must be attempting to interact with a Chest or Shulker Box
|
||||||
* 3. Player must be sneaking
|
* 3. Player must be sneaking
|
||||||
* 4. Player must be holding a sword in their main hand
|
* 4. Player must be holding a sword in their main hand
|
||||||
|
* 5. Event is not triggered for players off-hand
|
||||||
*/
|
*/
|
||||||
if (event.hasBlock() &&
|
if (event.hasBlock() &&
|
||||||
(Objects.requireNonNull(event.getClickedBlock()).getState() instanceof Chest ||
|
(Objects.requireNonNull(event.getClickedBlock()).getState() instanceof Chest ||
|
||||||
event.getClickedBlock().getState() instanceof ShulkerBox) &&
|
event.getClickedBlock().getState() instanceof ShulkerBox) &&
|
||||||
event.getPlayer().isSneaking() &&
|
event.getPlayer().isSneaking() &&
|
||||||
playerInventory.getItemInMainHand().getType().name().endsWith("_SWORD")
|
playerInventory.getItemInMainHand().getType().name().endsWith("_SWORD") &&
|
||||||
|
event.getHand() != EquipmentSlot.OFF_HAND
|
||||||
) {
|
) {
|
||||||
logger.fine(LOG_PLUGIN_NAME + " Triggering /sort for player " + event.getPlayer().getName());
|
logger.fine(LOG_PLUGIN_NAME + " Triggering /sort for player " + event.getPlayer().getName());
|
||||||
event.getPlayer().performCommand("sort");
|
event.getPlayer().performCommand("sort");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user