mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2025-02-18 13:21:29 +01:00
8.8.3-pre1 ChestSortEvent
This commit is contained in:
parent
65726c4f6c
commit
9a948b6103
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>de.jeffclan</groupId>
|
<groupId>de.jeffclan</groupId>
|
||||||
<artifactId>JeffChestSort</artifactId>
|
<artifactId>JeffChestSort</artifactId>
|
||||||
<version>8.8.2</version>
|
<version>8.8.3-pre1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>JeffChestSort</name>
|
<name>JeffChestSort</name>
|
||||||
|
42
src/main/java/de/jeff_media/ChestSort/ChestSortEvent.java
Normal file
42
src/main/java/de/jeff_media/ChestSort/ChestSortEvent.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package de.jeff_media.ChestSort;
|
package de.jeff_media.ChestSort;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
@ -397,6 +398,15 @@ public class ChestSortListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onAdditionalHotkeys(InventoryClickEvent e) {
|
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")) {
|
if(!plugin.getConfig().getBoolean("allow-hotkeys")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -386,6 +386,14 @@ public class ChestSortOrganizer {
|
|||||||
|
|
||||||
// Sort an inventory only between startSlot and endSlot
|
// Sort an inventory only between startSlot and endSlot
|
||||||
void sortInventory(Inventory inv, int startSlot, int 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) {
|
if (plugin.debug) {
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
main: de.jeff_media.ChestSort.ChestSortPlugin
|
main: de.jeff_media.ChestSort.ChestSortPlugin
|
||||||
name: ChestSort
|
name: ChestSort
|
||||||
version: 8.8.2
|
version: 8.8.3-pre1
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: Allows automatic chest sorting
|
description: Allows automatic chest sorting
|
||||||
author: mfnalex
|
author: mfnalex
|
||||||
|
Loading…
Reference in New Issue
Block a user