This commit is contained in:
mfnalex 2020-07-17 22:19:48 +02:00
parent f0d7c9ed1e
commit a6f0b72ba5
8 changed files with 37 additions and 4 deletions

View File

@ -1,5 +1,8 @@
# Changelog
## 8.17.0
- Added option to disable automatic sorting and/or automatic inventory sorting. Hotkeys will still work if enabled. When running /chestsort while automatic sorting is disabled, it will display the hotkeys gui instead.
## 8.16.1
- Allow middle-click hotkey in creative mode when clicked slot is empty

View File

@ -9,7 +9,7 @@
<name>ChestSort</name>
<url>https://www.chestsort.de</url>
<description>Automatically sorts your chests!</description>
<version>8.16.0</version>
<version>8.17.0</version>
<packaging>jar</packaging>
<properties>

View File

@ -71,6 +71,8 @@ public class ChestSortChestSortCommand implements CommandExecutor {
// fix for Spigot's stupid /reload function
plugin.registerPlayerIfNeeded(p);
if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) args=new String[] {"hotkeys"};
// Settings GUI
if(args.length>0) {

View File

@ -37,6 +37,8 @@ public class ChestSortInvSortCommand implements CommandExecutor {
int end = 35;
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if(!plugin.getConfig().getBoolean("allow-automatic-inventory-sorting")) args=new String[]{"inv"};
if(args.length>0) {
if(args[0].equalsIgnoreCase("all")) {

View File

@ -74,6 +74,7 @@ public class ChestSortListener implements Listener {
}
void onBackPackUse(Inventory inv, Player p) {
if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) return; //TODO: Maybe change to allow-automatic-inventory-sorting ?
if (!minepacksHook.isMinepacksBackpack(inv)) return;
if (!p.hasPermission("chestsort.use")) return;
plugin.registerPlayerIfNeeded(p);
@ -84,6 +85,9 @@ public class ChestSortListener implements Listener {
@EventHandler
public void onPlayerInventoryClose(InventoryCloseEvent event) {
if(!plugin.getConfig().getBoolean("allow-automatic-inventory-sorting")) return;
if (event.getInventory().getHolder() == null) return;
// Might be obsolete, because its @NotNull in 1.15, but who knows if thats for 1.8
if (event.getInventory().getType() == null) return;
@ -112,6 +116,8 @@ public class ChestSortListener implements Listener {
@EventHandler
public void onChestClose(InventoryCloseEvent event) {
if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) return;
if (!(plugin.getConfig().getString("sort-time").equalsIgnoreCase("close")
|| plugin.getConfig().getString("sort-time").equalsIgnoreCase("both"))) {
return;
@ -151,6 +157,8 @@ public class ChestSortListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onChestOpen(InventoryOpenEvent event) {
if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) return;
if (!(plugin.getConfig().getString("sort-time").equalsIgnoreCase("open")
|| plugin.getConfig().getString("sort-time").equalsIgnoreCase("both"))) {
return;
@ -287,6 +295,8 @@ public class ChestSortListener implements Listener {
@EventHandler
public void onEnderChestOpen(InventoryOpenEvent event) {
if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) return;
if (!(event.getPlayer() instanceof Player)) {
return;
}

View File

@ -69,7 +69,7 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
String sortingMethod;
ArrayList<String> disabledWorlds;
ChestSortAPIHandler api;
final int currentConfigVersion = 40;
final int currentConfigVersion = 41;
boolean usingMatchingConfig = true;
protected boolean debug = false;
boolean verbose = true;
@ -184,6 +184,8 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
// for every missing option.
// By default, sorting is disabled. Every player has to run /chestsort once
getConfig().addDefault("use-permissions", true);
getConfig().addDefault("allow-automatic-sorting",true);
getConfig().addDefault("allow-automatic-inventory-sorting",true);
getConfig().addDefault("sorting-enabled-by-default", false);
getConfig().addDefault("inv-sorting-enabled-by-default", false);
getConfig().addDefault("show-message-when-using-chest", true);
@ -283,6 +285,12 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
new Metrics.SimplePie("check_for_updates", () -> getConfig().getString("check-for-updates", "true")));
bStats.addCustomChart(
new Metrics.SimplePie("update_interval", () -> Long.toString(updateCheckInterval)));
bStats.addCustomChart(new Metrics.SimplePie("allow_automatic_sorting",
() -> Boolean.toString(getConfig().getBoolean("allow-automatic-sorting"))));
bStats.addCustomChart(new Metrics.SimplePie("allow_automatic_inv_sorting",
() -> Boolean.toString(getConfig().getBoolean("allow-automatic-inventory-sorting"))));
bStats.addCustomChart(new Metrics.SimplePie("show_message_when_using_chest",
() -> Boolean.toString(getConfig().getBoolean("show-message-when-using-chest"))));
bStats.addCustomChart(new Metrics.SimplePie("show_message_when_using_chest_and_sorting_is_enabl", () -> Boolean

View File

@ -28,6 +28,14 @@
# - chestsort.use.inventory (allow inventory sorting by hotkeys and via /invsort)
use-permissions: true
# when set to false, no player is allowed to enable automatic chest sorting
# hotkeys will still work if enabled
allow-automatic-sorting: true
# when set to false, no player is allowed to enable automatic inventory sorting
# hotkeys will still work if enabled
allow-automatic-inventory-sorting: true
# when set to false, new players will have to run /chestsort
# once to enable automatic chest sorting.
sorting-enabled-by-default: false
@ -580,4 +588,4 @@ log: false
# Please DO NOT change the following line manually!
# It is used by the automatic config updater.
config-version: 40
config-version: 41

View File

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