8.8.3-pre1 ChestSortEvent

This commit is contained in:
mfnalex 2020-06-02 02:02:24 +02:00
parent 65726c4f6c
commit 9a948b6103
5 changed files with 62 additions and 2 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.jeffclan</groupId>
<artifactId>JeffChestSort</artifactId>
<version>8.8.2</version>
<version>8.8.3-pre1</version>
<packaging>jar</packaging>
<name>JeffChestSort</name>

View File

@ -0,0 +1,42 @@
package de.jeff_media.ChestSort;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ChestSortEvent extends Event implements Cancellable {
boolean cancelled = false;
Location loc;
private static final HandlerList HANDLERS = new HandlerList();
public ChestSortEvent(Location loc) {
this.loc=loc;
}
public Location getLocation() {
return loc;
}
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
}

View File

@ -1,5 +1,6 @@
package de.jeff_media.ChestSort;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Chest;
@ -397,6 +398,15 @@ public class ChestSortListener implements Listener {
@EventHandler
public void onAdditionalHotkeys(InventoryClickEvent e) {
if(e.getClickedInventory() != null && e.getClickedInventory().getLocation()!=null) {
ChestSortEvent chestSortEvent = new ChestSortEvent(e.getClickedInventory().getLocation());
Bukkit.getPluginManager().callEvent(chestSortEvent);
if (chestSortEvent.isCancelled()) {
return;
}
}
if(!plugin.getConfig().getBoolean("allow-hotkeys")) {
return;
}

View File

@ -386,6 +386,14 @@ public class ChestSortOrganizer {
// Sort an inventory only between startSlot and endSlot
void sortInventory(Inventory inv, int startSlot, int endSlot) {
if(inv.getLocation() != null) {
ChestSortEvent chestSortEvent = new ChestSortEvent(inv.getLocation());
Bukkit.getPluginManager().callEvent(chestSortEvent);
if (chestSortEvent.isCancelled()) {
return;
}
}
if (plugin.debug) {
System.out.println(" ");

View File

@ -1,6 +1,6 @@
main: de.jeff_media.ChestSort.ChestSortPlugin
name: ChestSort
version: 8.8.2
version: 8.8.3-pre1
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex