This commit is contained in:
mfnalex 2021-10-16 10:25:07 +02:00
parent ed9e921628
commit 219b7e3a6b
5 changed files with 52 additions and 6 deletions

View File

@ -1,5 +1,12 @@
# Changelog
## 12.0.2
- Replaced PlayerInteractEvent with ChestSortLeftClickHotkeyEvent (fixes problems with other plugins opening GUIs on PlayerInteractEvent)
## 12.0.1
- Fixed mistake in gui.yml: The default head for the "enabled rightclick" hotkey was set to show the "disabled" head
- Important: When upgrading from 12.0.0, change the "*base64-disabled" to "*base64-enabled" in your "rightclick-enabled" part in your gui.yml (should be line 207 if you havent changed anything)
## 12.0.0
- GUI is now 100% customizable!
- Supports Custom Model Data to create vanilla-looking GUIs

View File

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

View File

@ -0,0 +1,21 @@
package de.jeff_media.chestsort.events;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ChestSortLeftClickHotkeyEvent extends PlayerInteractEvent {
public ChestSortLeftClickHotkeyEvent(@NotNull Player who, @NotNull Action action, @Nullable ItemStack item, @Nullable Block clickedBlock, @NotNull BlockFace clickedFace) {
super(who, action, item, clickedBlock, clickedFace);
}
public ChestSortLeftClickHotkeyEvent(@NotNull Player who, @NotNull Action action, @Nullable ItemStack item, @Nullable Block clickedBlock, @NotNull BlockFace clickedFace, @Nullable EquipmentSlot hand) {
super(who, action, item, clickedBlock, clickedFace, hand);
}
}

View File

@ -3,6 +3,7 @@ package de.jeff_media.chestsort.listeners;
import de.jeff_media.chestsort.api.ChestSortEvent;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.enums.Hotkey;
import de.jeff_media.chestsort.events.ChestSortLeftClickHotkeyEvent;
import de.jeff_media.chestsort.handlers.Logger;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.api.*;
@ -10,6 +11,7 @@ import de.jeff_media.chestsort.data.PlayerSetting;
import de.jeff_media.chestsort.hooks.*;
import de.jeff_media.chestsort.utils.LlamaUtils;
import de.jeff_media.jefflib.ProtectionUtils;
import de.jeff_media.jefflib.data.ShadowPlayer;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -18,6 +20,7 @@ import org.bukkit.Material;
import org.bukkit.block.*;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
@ -44,6 +47,8 @@ public class Listener implements org.bukkit.event.Listener {
final GoldenCratesHook goldenCratesHook;
final AdvancedChestsHook advancedChestsHook;
private static Event ignoredEvent;
public Listener(ChestSortPlugin plugin) {
this.plugin = plugin;
this.minepacksHook = new MinepacksHook(plugin);
@ -54,6 +59,9 @@ public class Listener implements org.bukkit.event.Listener {
@EventHandler
public void onLeftClickChest(PlayerInteractEvent event) {
if(event instanceof ChestSortLeftClickHotkeyEvent) {
return;
}
// checking in lower case for lazy admins
if (plugin.getDisabledWorlds().contains(event.getPlayer().getWorld().getName().toLowerCase())) {
return;
@ -69,14 +77,24 @@ public class Listener implements org.bukkit.event.Listener {
if(CrateReloadedHook.isCrate(clickedBlock)) {
return;
}
if (!ProtectionUtils.canInteract(event.getPlayer(), clickedBlock, plugin.getConfig().getBoolean("mute-protection-plugins"))) {
//System.out.println("ChestSort: cannot interact!");
return;
}
plugin.registerPlayerIfNeeded(event.getPlayer());
PlayerSetting playerSetting = plugin.getPlayerSetting(event.getPlayer());
if(!playerSetting.leftClickOutside) return;
if(plugin.getConfig().getBoolean("mute-protection-plugins")) {
if (!ProtectionUtils.canInteract(event.getPlayer(), clickedBlock, plugin.getConfig().getBoolean("mute-protection-plugins"))) {
//System.out.println("ChestSort: cannot interact!");
return;
}
} else {
ChestSortLeftClickHotkeyEvent testEvent = new ChestSortLeftClickHotkeyEvent(event.getPlayer(), Action.RIGHT_CLICK_BLOCK, event.getPlayer().getInventory().getItemInMainHand(), clickedBlock, BlockFace.UP, EquipmentSlot.HAND);
Bukkit.getPluginManager().callEvent(testEvent);
if(testEvent.isCancelled() || testEvent.useInteractedBlock() == Event.Result.DENY) {
return;
}
}
Container containerState = (Container) clickedBlock.getState();
Inventory inventory = containerState.getInventory();
if(!advancedChestsHook.handleAChestSortingIfPresent(clickedBlock.getLocation())) {

View File

@ -204,7 +204,7 @@ items:
rightclick-enabled:
display-name: &rightclick-name "<#2e86c1>Empty Chest<#/85c1e9>"
material: PLAYER_HEAD
base64: *base64-disabled
base64: *base64-enabled
lore:
- *lore-enabled
- &rightclick-lore-1 "<#d5dbdb>Take matching items from a chest by"