mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-02 07:33:23 +01:00
CoreProtect integration when using Fill/Empty chest hotkeys
This commit is contained in:
parent
fc616c973d
commit
1daf8aa960
14
pom.xml
14
pom.xml
@ -9,7 +9,7 @@
|
|||||||
<name>ChestSort</name>
|
<name>ChestSort</name>
|
||||||
<url>https://www.chestsort.de</url>
|
<url>https://www.chestsort.de</url>
|
||||||
<description>Allows automatic chest sorting!</description>
|
<description>Allows automatic chest sorting!</description>
|
||||||
<version>13.5.1</version>
|
<version>13.5.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -186,6 +186,11 @@
|
|||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>CoreProtect</id>
|
||||||
|
<url>https://maven.playpro.com/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -273,6 +278,13 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.coreprotect</groupId>
|
||||||
|
<artifactId>coreprotect</artifactId>
|
||||||
|
<version>21.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package de.jeff_media.chestsort.hooks;
|
||||||
|
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class CoreProtectHook {
|
||||||
|
|
||||||
|
public static void logContainerTransaction(String user, Location location) {
|
||||||
|
CoreProtectAPI api = getCoreProtect();
|
||||||
|
if (api == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
api.logContainerTransaction(user, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CoreProtectAPI getCoreProtect() {
|
||||||
|
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||||
|
|
||||||
|
// Check that CoreProtect is loaded
|
||||||
|
if (!(plugin instanceof CoreProtect)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the API is enabled
|
||||||
|
CoreProtectAPI api = ((CoreProtect) plugin).getAPI();
|
||||||
|
if (!api.isEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that a compatible version of the API is loaded
|
||||||
|
if (api.APIVersion() < 9) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -31,10 +31,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.*;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -734,6 +731,12 @@ public class ChestSortListener implements org.bukkit.event.Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CoreProtect hook
|
||||||
|
if (e.getInventory().getHolder() instanceof BlockInventoryHolder) {
|
||||||
|
Block block = ((BlockInventoryHolder) e.getInventory().getHolder()).getBlock();
|
||||||
|
CoreProtectHook.logContainerTransaction(p.getName(), block.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
if (e.isLeftClick() && setting.leftClick && p.hasPermission(Hotkey.getPermission(Hotkey.LEFT_CLICK))) {
|
if (e.isLeftClick() && setting.leftClick && p.hasPermission(Hotkey.getPermission(Hotkey.LEFT_CLICK))) {
|
||||||
plugin.getLgr().logSort(p, Logger.SortCause.H_LEFT);
|
plugin.getLgr().logSort(p, Logger.SortCause.H_LEFT);
|
||||||
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.LEFT_CLICK)
|
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.LEFT_CLICK)
|
||||||
|
@ -10,7 +10,7 @@ website: ${project.url}
|
|||||||
prefix: ${spigot.prefix}
|
prefix: ${spigot.prefix}
|
||||||
database: false
|
database: false
|
||||||
loadbefore: [InvUnload]
|
loadbefore: [InvUnload]
|
||||||
softdepend: [CrackShot,InventoryPages,Minepacks,PlaceholderAPI,AdvancedChests,ShulkerPacks]
|
softdepend: [CrackShot,InventoryPages,Minepacks,PlaceholderAPI,AdvancedChests,ShulkerPacks,CoreProtect]
|
||||||
commands:
|
commands:
|
||||||
sort:
|
sort:
|
||||||
description: Toggle automatic chest sorting or change your hotkey settings
|
description: Toggle automatic chest sorting or change your hotkey settings
|
||||||
|
Loading…
Reference in New Issue
Block a user