mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-02 23:53:21 +01:00
9.3.0
This commit is contained in:
parent
150a237ec1
commit
19c2c727bf
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 9.3.0
|
||||||
|
- Added CraftBukkit compatibility (although I don't unterstand why anyone would prefer CraftBukkit over Spigot)
|
||||||
|
|
||||||
|
## 9.2.0
|
||||||
|
- Added support for PlayerVaultsX
|
||||||
|
|
||||||
## 9.1.1
|
## 9.1.1
|
||||||
- Fixed category files being "too wildcardy" lol
|
- Fixed category files being "too wildcardy" lol
|
||||||
|
|
||||||
|
16
pom.xml
16
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>Automatically sorts your chests!</description>
|
<description>Automatically sorts your chests!</description>
|
||||||
<version>9.1.1</version>
|
<version>9.3.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -51,6 +51,10 @@
|
|||||||
<pattern>org.bstats</pattern>
|
<pattern>org.bstats</pattern>
|
||||||
<shadedPattern>de.jeff_media.ChestSort</shadedPattern>
|
<shadedPattern>de.jeff_media.ChestSort</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>io.papermc.lib</pattern>
|
||||||
|
<shadedPattern>de.jeff_media.ChestSort.paperlib</shadedPattern> <!-- Replace this -->
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<excludes>
|
<excludes>
|
||||||
@ -85,6 +89,10 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>placeholderapi</id>
|
<id>placeholderapi</id>
|
||||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
@ -179,6 +187,12 @@
|
|||||||
<version>RC-15</version>
|
<version>RC-15</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.jeff_media.ChestSort;
|
package de.jeff_media.ChestSort;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -17,22 +18,23 @@ public class ChestSortDebugger implements @NotNull Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onInventoryClickEvent(InventoryClickEvent e) {
|
public void onInventoryClickEvent(InventoryClickEvent e) {
|
||||||
// Debug
|
|
||||||
if(plugin.debug) {
|
if(plugin.debug) {
|
||||||
System.out.println(" ");
|
// Debug
|
||||||
System.out.println("InventoryClickEvent:");
|
plugin.debug(" ");
|
||||||
System.out.println("- Holder: " + e.getInventory().getHolder());
|
plugin.debug("InventoryClickEvent:");
|
||||||
|
plugin.debug("- Holder: " + e.getInventory().getHolder());
|
||||||
if (e.getInventory().getHolder() != null) {
|
if (e.getInventory().getHolder() != null) {
|
||||||
System.out.println("- Holder class: "+e.getInventory().getHolder().getClass());
|
plugin.debug("- Holder class: " + e.getInventory().getHolder().getClass());
|
||||||
}
|
|
||||||
System.out.println("- Slot: "+e.getRawSlot());
|
|
||||||
System.out.println("- Left-Click: "+e.isLeftClick());
|
|
||||||
System.out.println("- Right-Click: "+e.isRightClick());
|
|
||||||
System.out.println("- Shift-Click: "+e.isShiftClick());
|
|
||||||
System.out.println(" ");
|
|
||||||
}
|
}
|
||||||
|
plugin.debug("- Slot: " + e.getRawSlot());
|
||||||
|
plugin.debug("- Left-Click: " + e.isLeftClick());
|
||||||
|
plugin.debug("- Right-Click: " + e.isRightClick());
|
||||||
|
plugin.debug("- Shift-Click: " + e.isShiftClick());
|
||||||
|
plugin.debug(" ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package de.jeff_media.ChestSort;
|
package de.jeff_media.ChestSort;
|
||||||
|
|
||||||
import de.jeff_media.ChestSort.hooks.CrateReloadedHook;
|
import de.jeff_media.ChestSort.hooks.*;
|
||||||
import de.jeff_media.ChestSort.hooks.GoldenCratesHook;
|
|
||||||
import de.jeff_media.ChestSort.hooks.HeadDatabaseHook;
|
|
||||||
import de.jeff_media.ChestSort.hooks.MinepacksHook;
|
|
||||||
import de.jeff_media.ChestSort.utils.LlamaUtils;
|
import de.jeff_media.ChestSort.utils.LlamaUtils;
|
||||||
import de.jeff_media.ChestSortAPI.ChestSortEvent;
|
import de.jeff_media.ChestSortAPI.ChestSortEvent;
|
||||||
import de.jeff_media.ChestSortAPI.ISortable;
|
import de.jeff_media.ChestSortAPI.ISortable;
|
||||||
@ -354,36 +351,48 @@ public class ChestSortListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onHotkey(InventoryClickEvent event) {
|
public void onHotkey(InventoryClickEvent event) {
|
||||||
|
|
||||||
|
plugin.debug2("Hotkey?");
|
||||||
|
|
||||||
if (!(event.getWhoClicked() instanceof Player)) {
|
if (!(event.getWhoClicked() instanceof Player)) {
|
||||||
|
plugin.debug2("exit: 0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Player p = (Player) event.getWhoClicked();
|
Player p = (Player) event.getWhoClicked();
|
||||||
|
|
||||||
plugin.registerPlayerIfNeeded(p);
|
plugin.registerPlayerIfNeeded(p);
|
||||||
|
|
||||||
if (!plugin.getConfig().getBoolean("allow-sorting-hotkeys")) {
|
if (!plugin.getConfig().getBoolean("allow-sorting-hotkeys")) {
|
||||||
|
plugin.debug2("exit: 1");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!p.hasPermission("chestsort.use") && !p.hasPermission("chestsort.use.inventory")) {
|
if (!p.hasPermission("chestsort.use") && !p.hasPermission("chestsort.use.inventory")) {
|
||||||
|
plugin.debug2("exit: 2");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//InventoryHolder holder = event.getInventory().getHolder();
|
//InventoryHolder holder = event.getInventory().getHolder();
|
||||||
if (event.getClickedInventory() == null) {
|
if (event.getClickedInventory() == null) {
|
||||||
|
plugin.debug2("exit: 3");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean isAPICall = isAPICall(event.getClickedInventory());
|
boolean isAPICall = isAPICall(event.getClickedInventory());
|
||||||
|
|
||||||
// Detect generic GUIs
|
// Detect generic GUIs
|
||||||
if(!isAPICall &&
|
if(!isAPICall &&
|
||||||
(plugin.genericHook.isPluginGUI(event.getInventory())
|
(plugin.genericHook.isPluginGUI(event.getInventory())
|
||||||
|| plugin.genericHook.isPluginGUI(event.getInventory()))) {
|
|| plugin.genericHook.isPluginGUI(event.getInventory()))) {
|
||||||
|
plugin.debug("Aborting hotkey sorting: no API call & generic GUI detected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Possible fix for #57
|
// Possible fix for #57
|
||||||
if (!isAPICall && (event.getClickedInventory().getHolder() != null
|
if (!isAPICall && (event.getClickedInventory().getHolder() != null
|
||||||
&& event.getClickedInventory().getHolder() == p
|
&& event.getClickedInventory().getHolder() == p
|
||||||
@ -392,6 +401,7 @@ public class ChestSortListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// End Possible fix for #57
|
// End Possible fix for #57
|
||||||
InventoryHolder holder = event.getClickedInventory().getHolder();
|
InventoryHolder holder = event.getClickedInventory().getHolder();
|
||||||
|
|
||||||
@ -405,12 +415,14 @@ public class ChestSortListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prevent player from putting items into GUI inventory
|
// Prevent player from putting items into GUI inventory
|
||||||
if (event.getInventory() == setting.guiInventory) {
|
if (event.getInventory() == setting.guiInventory) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (event.getClick()) {
|
switch (event.getClick()) {
|
||||||
case MIDDLE:
|
case MIDDLE:
|
||||||
cause = ChestSortLogger.SortCause.H_MIDDLE;
|
cause = ChestSortLogger.SortCause.H_MIDDLE;
|
||||||
@ -426,6 +438,7 @@ public class ChestSortListener implements Listener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK:
|
case DOUBLE_CLICK:
|
||||||
|
if(event.isShiftClick()) return;
|
||||||
cause = ChestSortLogger.SortCause.H_DOUBLE;
|
cause = ChestSortLogger.SortCause.H_DOUBLE;
|
||||||
//if(plugin.getConfig().getBoolean("hotkeys.double-click")) {
|
//if(plugin.getConfig().getBoolean("hotkeys.double-click")) {
|
||||||
if (setting.doubleClick) {
|
if (setting.doubleClick) {
|
||||||
@ -461,23 +474,40 @@ public class ChestSortListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAPICall || belongsToChestLikeBlock(event.getClickedInventory()) || LlamaUtils.belongsToLlama(event.getClickedInventory()) || minepacksHook.isMinepacksBackpack(event.getClickedInventory())) {
|
|
||||||
|
if(plugin.isInHotkeyCooldown(p.getUniqueId())) {
|
||||||
|
plugin.debug("Skipping: hotkey cooldown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
plugin.debug("Hotkey triggered: " + event.getClick().name());
|
||||||
|
|
||||||
|
if (isAPICall
|
||||||
|
|| belongsToChestLikeBlock(event.getClickedInventory())
|
||||||
|
|| LlamaUtils.belongsToLlama(event.getClickedInventory())
|
||||||
|
|| minepacksHook.isMinepacksBackpack(event.getClickedInventory())
|
||||||
|
|| plugin.playerVaultsHook.isPlayerVault(event.getClickedInventory())) {
|
||||||
|
|
||||||
|
|
||||||
if (!p.hasPermission("chestsort.use")) {
|
if (!p.hasPermission("chestsort.use")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LlamaUtils.belongsToLlama(event.getClickedInventory())) {
|
if (LlamaUtils.belongsToLlama(event.getClickedInventory())) {
|
||||||
|
|
||||||
plugin.lgr.logSort(p,cause);
|
plugin.lgr.logSort(p,cause);
|
||||||
ChestedHorse llama = (ChestedHorse) event.getInventory().getHolder();
|
ChestedHorse llama = (ChestedHorse) event.getInventory().getHolder();
|
||||||
plugin.organizer.sortInventory(event.getClickedInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
plugin.organizer.sortInventory(event.getClickedInventory(), 2, LlamaUtils.getLlamaChestSize(llama) + 1);
|
||||||
plugin.organizer.updateInventoryView(event);
|
plugin.organizer.updateInventoryView(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.lgr.logSort(p,cause);
|
plugin.lgr.logSort(p,cause);
|
||||||
plugin.organizer.sortInventory(event.getClickedInventory());
|
plugin.organizer.sortInventory(event.getClickedInventory());
|
||||||
plugin.organizer.updateInventoryView(event);
|
plugin.organizer.updateInventoryView(event);
|
||||||
} else if (holder instanceof Player) {
|
} else if (holder instanceof Player) {
|
||||||
|
|
||||||
if (!p.hasPermission("chestsort.use.inventory")) {
|
if (!p.hasPermission("chestsort.use.inventory")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -486,10 +516,12 @@ public class ChestSortListener implements Listener {
|
|||||||
plugin.lgr.logSort(p,cause);
|
plugin.lgr.logSort(p,cause);
|
||||||
plugin.organizer.sortInventory(p.getInventory(), 0, 8);
|
plugin.organizer.sortInventory(p.getInventory(), 0, 8);
|
||||||
plugin.organizer.updateInventoryView(event);
|
plugin.organizer.updateInventoryView(event);
|
||||||
|
|
||||||
} else if (event.getSlotType() == SlotType.CONTAINER) {
|
} else if (event.getSlotType() == SlotType.CONTAINER) {
|
||||||
plugin.lgr.logSort(p,cause);
|
plugin.lgr.logSort(p,cause);
|
||||||
plugin.organizer.sortInventory(p.getInventory(), 9, 35);
|
plugin.organizer.sortInventory(p.getInventory(), 9, 35);
|
||||||
plugin.organizer.updateInventoryView(event);
|
plugin.organizer.updateInventoryView(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,8 +460,10 @@ public class ChestSortOrganizer {
|
|||||||
// Sort an inventory only between startSlot and endSlot
|
// Sort an inventory only between startSlot and endSlot
|
||||||
void sortInventory(@NotNull Inventory inv, int startSlot, int endSlot) {
|
void sortInventory(@NotNull Inventory inv, int startSlot, int endSlot) {
|
||||||
if(inv==null) return;
|
if(inv==null) return;
|
||||||
|
plugin.debug("Attempting to sort an Inventory and calling ChestSortEvent.");
|
||||||
Class<? extends Inventory> invClass = inv.getClass();
|
Class<? extends Inventory> invClass = inv.getClass();
|
||||||
de.jeff_media.ChestSortAPI.ChestSortEvent chestSortEvent = new de.jeff_media.ChestSortAPI.ChestSortEvent(inv);
|
de.jeff_media.ChestSortAPI.ChestSortEvent chestSortEvent = new de.jeff_media.ChestSortAPI.ChestSortEvent(inv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (invClass.getMethod("getLocation", null) != null) {
|
if (invClass.getMethod("getLocation", null) != null) {
|
||||||
// This whole try/catch fixes MethodNotFoundException when using inv.getLocation in Spigot 1.8.
|
// This whole try/catch fixes MethodNotFoundException when using inv.getLocation in Spigot 1.8.
|
||||||
@ -490,6 +492,7 @@ public class ChestSortOrganizer {
|
|||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(chestSortEvent);
|
Bukkit.getPluginManager().callEvent(chestSortEvent);
|
||||||
if (chestSortEvent.isCancelled()) {
|
if (chestSortEvent.isCancelled()) {
|
||||||
|
plugin.debug("ChestSortEvent cancelled, I'll stay in bed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,6 +600,7 @@ public class ChestSortOrganizer {
|
|||||||
inv.setItem(currentSlot, item);
|
inv.setItem(currentSlot, item);
|
||||||
currentSlot++;
|
currentSlot++;
|
||||||
}
|
}
|
||||||
|
plugin.debug("Sorting successful. I'll go back to bed now.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInventoryView(InventoryClickEvent event) {
|
public void updateInventoryView(InventoryClickEvent event) {
|
||||||
|
@ -41,9 +41,12 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import de.jeff_media.ChestSort.config.Config;
|
||||||
import de.jeff_media.ChestSort.hooks.GenericGUIHook;
|
import de.jeff_media.ChestSort.hooks.GenericGUIHook;
|
||||||
|
import de.jeff_media.ChestSort.hooks.PlayerVaultsHook;
|
||||||
import de.jeff_media.ChestSort.placeholders.ChestSortPlaceholders;
|
import de.jeff_media.ChestSort.placeholders.ChestSortPlaceholders;
|
||||||
import de.jeff_media.PluginUpdateChecker.PluginUpdateChecker;
|
import de.jeff_media.PluginUpdateChecker.PluginUpdateChecker;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -61,6 +64,7 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
|
|
||||||
ChestSortLogger lgr;
|
ChestSortLogger lgr;
|
||||||
Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<>();
|
Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<>();
|
||||||
|
HashMap<UUID,Long> hotkeyCooldown;
|
||||||
ChestSortMessages messages;
|
ChestSortMessages messages;
|
||||||
ChestSortOrganizer organizer;
|
ChestSortOrganizer organizer;
|
||||||
PluginUpdateChecker updateChecker;
|
PluginUpdateChecker updateChecker;
|
||||||
@ -70,7 +74,7 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
String sortingMethod;
|
String sortingMethod;
|
||||||
ArrayList<String> disabledWorlds;
|
ArrayList<String> disabledWorlds;
|
||||||
ChestSortAPIHandler api;
|
ChestSortAPIHandler api;
|
||||||
final int currentConfigVersion = 44;
|
final int currentConfigVersion = 45;
|
||||||
boolean usingMatchingConfig = true;
|
boolean usingMatchingConfig = true;
|
||||||
protected boolean debug = false;
|
protected boolean debug = false;
|
||||||
boolean verbose = true;
|
boolean verbose = true;
|
||||||
@ -81,6 +85,7 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
public boolean hookMinepacks = false;
|
public boolean hookMinepacks = false;
|
||||||
|
|
||||||
public GenericGUIHook genericHook;
|
public GenericGUIHook genericHook;
|
||||||
|
public PlayerVaultsHook playerVaultsHook;
|
||||||
|
|
||||||
private static long updateCheckInterval = 4*60*60; // in seconds. We check on startup and every 4 hours
|
private static long updateCheckInterval = 4*60*60; // in seconds. We check on startup and every 4 hours
|
||||||
|
|
||||||
@ -133,6 +138,10 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
if(debug) getLogger().warning("[DEBUG] "+t);
|
if(debug) getLogger().warning("[DEBUG] "+t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void debug2(String t) {
|
||||||
|
if(getConfig().getBoolean(Config.DEBUG2)) getLogger().warning("[DEBUG2] "+t);
|
||||||
|
}
|
||||||
|
|
||||||
// Creates the default configuration file
|
// Creates the default configuration file
|
||||||
// Also checks the config-version of an already existing file. If the existing
|
// Also checks the config-version of an already existing file. If the existing
|
||||||
// config is too
|
// config is too
|
||||||
@ -490,12 +499,26 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
messages = new ChestSortMessages(this);
|
messages = new ChestSortMessages(this);
|
||||||
organizer = new ChestSortOrganizer(this);
|
organizer = new ChestSortOrganizer(this);
|
||||||
settingsGUI = new ChestSortSettingsGUI(this);
|
settingsGUI = new ChestSortSettingsGUI(this);
|
||||||
|
try {
|
||||||
|
if(Class.forName("net.md_5.bungee.api.chat.BaseComponent") != null) {
|
||||||
updateChecker = new PluginUpdateChecker(this, "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt", "https://chestsort.de", "https://chestsort.de/changelog", "https://chestsort.de/donate");
|
updateChecker = new PluginUpdateChecker(this, "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt", "https://chestsort.de", "https://chestsort.de/changelog", "https://chestsort.de/donate");
|
||||||
|
} else {
|
||||||
|
getLogger().severe("You are using an unsupported server software! Consider switching to Spigot or Paper!");
|
||||||
|
getLogger().severe("The Update Checker will NOT work when using CraftBukkit instead of Spigot/Paper!");
|
||||||
|
PaperLib.suggestPaper(this);
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
getLogger().severe("You are using an unsupported server software! Consider switching to Spigot or Paper!");
|
||||||
|
getLogger().severe("The Update Checker will NOT work when using CraftBukkit instead of Spigot/Paper!");
|
||||||
|
PaperLib.suggestPaper(this);
|
||||||
|
}
|
||||||
listener = new ChestSortListener(this);
|
listener = new ChestSortListener(this);
|
||||||
api = new ChestSortAPIHandler(this);
|
api = new ChestSortAPIHandler(this);
|
||||||
|
hotkeyCooldown = new HashMap<>();
|
||||||
permissionsHandler = new ChestSortPermissionsHandler(this);
|
permissionsHandler = new ChestSortPermissionsHandler(this);
|
||||||
updateCheckInterval = (int) (getConfig().getDouble("check-interval")*60*60);
|
updateCheckInterval = (int) (getConfig().getDouble("check-interval")*60*60);
|
||||||
sortingMethod = getConfig().getString("sorting-method");
|
sortingMethod = getConfig().getString("sorting-method");
|
||||||
|
playerVaultsHook = new PlayerVaultsHook(this);
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
getServer().getPluginManager().registerEvents(settingsGUI, this);
|
getServer().getPluginManager().registerEvents(settingsGUI, this);
|
||||||
ChestSortChestSortCommand chestsortCommandExecutor = new ChestSortChestSortCommand(this);
|
ChestSortChestSortCommand chestsortCommandExecutor = new ChestSortChestSortCommand(this);
|
||||||
@ -536,12 +559,14 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
getLogger().info("Categories: " + getCategoryList());
|
getLogger().info("Categories: " + getCategoryList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(updateChecker!=null) {
|
||||||
if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("true")) {
|
if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("true")) {
|
||||||
updateChecker.check(updateCheckInterval);
|
updateChecker.check(updateCheckInterval);
|
||||||
} // When set to on-startup, we check right now (delay 0)
|
} // When set to on-startup, we check right now (delay 0)
|
||||||
else if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("on-startup")) {
|
else if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("on-startup")) {
|
||||||
updateChecker.check();
|
updateChecker.check();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
registerMetrics();
|
registerMetrics();
|
||||||
|
|
||||||
@ -590,6 +615,17 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInHotkeyCooldown(UUID uuid) {
|
||||||
|
double cooldown = getConfig().getDouble(Config.HOTKEY_COOLDOWN)*1000;
|
||||||
|
if(cooldown==0) return false;
|
||||||
|
long lastUsage = hotkeyCooldown.containsKey(uuid) ? hotkeyCooldown.get(uuid) : 0;
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
long difference = currentTime-lastUsage;
|
||||||
|
hotkeyCooldown.put(uuid,currentTime);
|
||||||
|
debug("Difference: "+difference);
|
||||||
|
return difference <= cooldown;
|
||||||
|
}
|
||||||
|
|
||||||
void registerPlayerIfNeeded(Player p) {
|
void registerPlayerIfNeeded(Player p) {
|
||||||
// Players are stored by their UUID, so that name changes don't break player's
|
// Players are stored by their UUID, so that name changes don't break player's
|
||||||
// settings
|
// settings
|
||||||
|
17
src/main/java/de/jeff_media/ChestSort/config/Config.java
Normal file
17
src/main/java/de/jeff_media/ChestSort/config/Config.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package de.jeff_media.ChestSort.config;
|
||||||
|
|
||||||
|
import de.jeff_media.ChestSort.ChestSortPlugin;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
public static final String HOTKEY_COOLDOWN = "hotkey-cooldown";
|
||||||
|
public static final String DEBUG2 = "debug2";
|
||||||
|
|
||||||
|
private final ChestSortPlugin main;
|
||||||
|
|
||||||
|
public Config(ChestSortPlugin main) {
|
||||||
|
this.main=main;
|
||||||
|
|
||||||
|
main.getConfig().addDefault(HOTKEY_COOLDOWN,0.0);
|
||||||
|
main.getConfig().addDefault(DEBUG2,false);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package de.jeff_media.ChestSort.hooks;
|
||||||
|
|
||||||
|
import de.jeff_media.ChestSort.ChestSortPlugin;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
public class PlayerVaultsHook {
|
||||||
|
|
||||||
|
private final ChestSortPlugin main;
|
||||||
|
|
||||||
|
public PlayerVaultsHook(ChestSortPlugin main) {
|
||||||
|
this.main=main;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayerVault(Inventory inv) {
|
||||||
|
if(inv==null) return false;
|
||||||
|
if(inv.getHolder()==null) return false;
|
||||||
|
if(!main.getConfig().getBoolean("hook-playervaultsx",true)) return false;
|
||||||
|
return inv.getHolder().getClass().getName().equals("com.drtshock.playervaults.vaultmanagement.VaultHolder");
|
||||||
|
}
|
||||||
|
}
|
@ -145,6 +145,10 @@ sorting-hotkeys:
|
|||||||
# Use shift + right-click on any EMPTY inventory slot as hotkey
|
# Use shift + right-click on any EMPTY inventory slot as hotkey
|
||||||
shift-right-click: true
|
shift-right-click: true
|
||||||
|
|
||||||
|
# Amount in seconds that players have to wait between using hotkeys to prevent them from spamming the
|
||||||
|
# sorting mechanism
|
||||||
|
hotkey-cooldown: 0.2
|
||||||
|
|
||||||
# Additionally to sorting hotkeys, you can quickly unload your inventory into a chest and vice versa
|
# Additionally to sorting hotkeys, you can quickly unload your inventory into a chest and vice versa
|
||||||
# using left-click or right-click outside of a chest's inventory.
|
# using left-click or right-click outside of a chest's inventory.
|
||||||
# A single click will only affect matching items (items that are already present in the other inventory)
|
# A single click will only affect matching items (items that are already present in the other inventory)
|
||||||
@ -225,6 +229,11 @@ hook-inventorypages: true
|
|||||||
# backpacks and sort them like a regular chest.
|
# backpacks and sort them like a regular chest.
|
||||||
hook-minepacks: true
|
hook-minepacks: true
|
||||||
|
|
||||||
|
##### PlayerVaultsX #####
|
||||||
|
# When PlayerVaultsX is installed, ChestSort can sort your
|
||||||
|
# player vaults just like regular chests.
|
||||||
|
hook-playervaultsx: true
|
||||||
|
|
||||||
##### CrateReloaded #####
|
##### CrateReloaded #####
|
||||||
# Prevents the player from using hotkeys on a crate
|
# Prevents the player from using hotkeys on a crate
|
||||||
hook-cratereloaded: true
|
hook-cratereloaded: true
|
||||||
@ -642,10 +651,11 @@ dump: false
|
|||||||
|
|
||||||
# Debug mode - you probably do not want this.
|
# Debug mode - you probably do not want this.
|
||||||
debug: false
|
debug: false
|
||||||
|
debug2: false
|
||||||
|
|
||||||
# Enable log - you probably do not want this.
|
# Enable log - you probably do not want this.
|
||||||
log: false
|
log: false
|
||||||
|
|
||||||
# Please DO NOT change the following line manually!
|
# Please DO NOT change the following line manually!
|
||||||
# It is used by the automatic config updater.
|
# It is used by the automatic config updater.
|
||||||
config-version: 44
|
config-version: 45
|
@ -1,6 +1,6 @@
|
|||||||
main: de.jeff_media.ChestSort.ChestSortPlugin
|
main: de.jeff_media.ChestSort.ChestSortPlugin
|
||||||
name: ChestSort
|
name: ChestSort
|
||||||
version: 9.1.1
|
version: 9.3.0
|
||||||
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