10.3.0 release TEST release

This commit is contained in:
mfnalex 2021-06-21 00:22:47 +02:00
parent ffe5025569
commit ad86881964
7 changed files with 53 additions and 12 deletions

View File

@ -1,5 +1,15 @@
# Changelog
## 10.3.0
- Added permissions for each hotkey.
- Given to all players by default
- Permission: chestsort.hotkey.\<hotkey\>
- Available hotkeys are:
- shiftclick, middleclick, doubleclick, shiftrightclick, leftclickoutside, rightclickoutside
## 10.2.1
- Fixed config updater breaking the config.yml file because "sorting-method" value wasn't put inside double quotes
## 10.2.0
- Added config option "allow-commands"

View File

@ -9,7 +9,7 @@
<name>ChestSort</name>
<url>https://www.chestsort.de</url>
<description>Allows automatic chest sorting!</description>
<version>10.2.0</version>
<version>10.3.0</version>
<packaging>jar</packaging>
<properties>

View File

@ -25,7 +25,7 @@ public final class ConfigUpdater {
// Lines STARTING WITH these names will get no quotes although they would match one of the lists below
private static final String[] CONFLICTING_NODES_NEEDING_NO_QUOTES = {};
// Lines STARTING WITH these names will get their values wrapped in double quotes
private static final String[] NODES_NEEDING_DOUBLE_QUOTES = {"message-"};
private static final String[] NODES_NEEDING_DOUBLE_QUOTES = {"message-","sorting-method"};
// Lines STARTING WITH these names will get their values wrapped in single quotes
private static final String[] NODES_NEEDING_SINGLE_QUOTES = {};

View File

@ -0,0 +1,14 @@
package de.jeff_media.chestsort.enums;
import java.util.Locale;
public enum Hotkey {
SHIFT_CLICK,
MIDDLE_CLICK, DOUBLE_CLICK, SHIFT_RIGHT_CLICK,
LEFT_CLICK_OUTSIDE, RIGHT_CLICK_OUTSIDE;
public static String getPermission(Hotkey hotkey) {
return hotkey.name().toLowerCase(Locale.ROOT).replace("_", "");
}
}

View File

@ -2,6 +2,7 @@ package de.jeff_media.chestsort.listeners;
import de.jeff_media.chestsort.ChestSortEvent;
import de.jeff_media.chestsort.config.Messages;
import de.jeff_media.chestsort.enums.Hotkey;
import de.jeff_media.chestsort.handlers.Logger;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.ISortable;
@ -455,7 +456,7 @@ public class Listener implements org.bukkit.event.Listener {
case MIDDLE:
cause = Logger.SortCause.H_MIDDLE;
//if(plugin.getConfig().getBoolean("hotkeys.middle-click")) {
if (setting.middleClick) {
if (setting.middleClick && p.hasPermission(Hotkey.getPermission(Hotkey.MIDDLE_CLICK))) {
if (event.getWhoClicked().getGameMode() != GameMode.CREATIVE) {
sort = true;
} else {
@ -469,7 +470,7 @@ public class Listener implements org.bukkit.event.Listener {
if(event.isShiftClick()) return;
cause = Logger.SortCause.H_DOUBLE;
//if(plugin.getConfig().getBoolean("hotkeys.double-click")) {
if (setting.doubleClick) {
if (setting.doubleClick && p.hasPermission(Hotkey.getPermission(Hotkey.DOUBLE_CLICK))) {
// We need getCursor() instead of getCurrentItem(), because after picking up the item, it is gone into the cursor
if (event.getCursor() == null || (event.getCursor() != null && event.getCursor().getType() == Material.AIR)) {
sort = true;
@ -479,7 +480,7 @@ public class Listener implements org.bukkit.event.Listener {
case SHIFT_LEFT:
cause = Logger.SortCause.H_SHIFT;
//if(plugin.getConfig().getBoolean("hotkeys.shift-click")) {
if (setting.shiftClick) {
if (setting.shiftClick && p.hasPermission(Hotkey.getPermission(Hotkey.SHIFT_CLICK))) {
if (event.getCurrentItem() == null || (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.AIR)) {
sort = true;
}
@ -488,7 +489,7 @@ public class Listener implements org.bukkit.event.Listener {
case SHIFT_RIGHT:
cause = Logger.SortCause.H_SHIFTRIGHT;
//if(plugin.getConfig().getBoolean("hotkeys.shift-right-click")) {
if (setting.shiftRightClick) {
if (setting.shiftRightClick && p.hasPermission(Hotkey.getPermission(Hotkey.SHIFT_RIGHT_CLICK))) {
if (event.getCurrentItem() == null || (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.AIR)) {
sort = true;
}
@ -648,7 +649,7 @@ public class Listener implements org.bukkit.event.Listener {
return;
}
if (e.isLeftClick() && setting.leftClick) {
if (e.isLeftClick() && setting.leftClick && p.hasPermission(Hotkey.getPermission(Hotkey.LEFT_CLICK_OUTSIDE))) {
plugin.getLgr().logSort(p, Logger.SortCause.H_LEFT);
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.LEFT_CLICK)
== PlayerSetting.DoubleClickType.LEFT_CLICK) {
@ -660,7 +661,7 @@ public class Listener implements org.bukkit.event.Listener {
plugin.getOrganizer().stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), true, chestSortEvent);
}
} else if (e.isRightClick() && setting.rightClick) {
} else if (e.isRightClick() && setting.rightClick && p.hasPermission(Hotkey.getPermission(Hotkey.RIGHT_CLICK_OUTSIDE))) {
plugin.getLgr().logSort(p, Logger.SortCause.H_RIGHT);
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.RIGHT_CLICK)
== PlayerSetting.DoubleClickType.RIGHT_CLICK) {

View File

@ -33,9 +33,13 @@
####### Permissions #######
###############################
# chestsort.use Allows to sort containers using automatic sorting (/sort) or via hotkeys
# chestsort.use.inventory Allows to sort the player's inventory using automatic sorting (/isort) or via hotkeys
# chestsort.reload Allows to reload the config using /sort reload
# chestsort.use Allows to sort containers using automatic sorting (/sort) or via hotkeys
# chestsort.use.inventory Allows to sort the player's inventory using automatic sorting (/isort) or via hotkeys
# chestsort.reload Allows to reload the config using /sort reload
# chestsort.hotkey.<hotkey> Allows to use a specific hotkey. Given to all players by default. Players still need
# to have the chestsort.use permission.
# Available hotkeys are: shiftclick, middleclick, doubleclick, shiftrightclick,
# leftclickoutside, rightclickoutside
###############################

View File

@ -46,4 +46,16 @@ permissions:
chestsort.use.inventory:
description: Allows inventory sorting
chestsort.reload:
description: Allows to reload the config via /chestsort reload
description: Allows to reload the config via /chestsort reload
chestsort.hotkey.shiftclick:
default: true
chestsort.hotkey.middleclick:
default: true
chestsort.hotkey.doubleclick:
default: true
chestsort.hotkey.shiftrightclick:
default: true
chestsort.hotkey.leftclickoutside:
default: true
chestsort.hotkey.rightclickoutside:
default: true