8.17.1 release

This commit is contained in:
mfnalex 2020-07-24 16:33:52 +02:00
parent 3ee0da41cd
commit 9dd6dc3a32
8 changed files with 179 additions and 18 deletions

View File

@ -2,6 +2,8 @@
## 8.17.1-SNAPSHOT
- Added possibility to sort a player's inventory from console using /invsort <player> [toggle|on|off|hotbar|inv|all]
- Added placeholders (see new config.yml)
- Added "use permissions" metric
## 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.

12
pom.xml
View File

@ -9,7 +9,7 @@
<name>ChestSort</name>
<url>https://www.chestsort.de</url>
<description>Automatically sorts your chests!</description>
<version>8.17.1-SNAPSHOT</version>
<version>8.17.1</version>
<packaging>jar</packaging>
<properties>
@ -85,6 +85,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
@ -104,6 +108,12 @@
</repositories>
<dependencies>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>

View File

@ -20,11 +20,6 @@ public class ChestSortInvSortCommand implements CommandExecutor {
Player p = null;
// This command toggles automatic chest sorting for the player that runs the command
if (!command.getName().equalsIgnoreCase("invsort")) {
return false;
}
if(args.length>0 && args[0].equalsIgnoreCase("help")) {
return false;
}
@ -45,6 +40,8 @@ public class ChestSortInvSortCommand implements CommandExecutor {
if(args.length>1) {
args = new String[] { args[1] };
} else {
args = new String[0];
}
//sender.sendMessage(plugin.messages.MSG_PLAYERSONLY);

View File

@ -11,10 +11,10 @@ public class ChestSortPlayerSetting {
// - Did this player see the message on how to use ChestSort (message-when-using-chest in config.yml)
// Sorting enabled for this player?
boolean sortingEnabled;
public boolean sortingEnabled;
// Inventory sorting enabled for this player?
boolean invSortingEnabled;
public boolean invSortingEnabled;
// Hotkey settings
boolean middleClick, shiftClick, doubleClick, shiftRightClick, leftClick, rightClick;

View File

@ -42,6 +42,7 @@ import java.util.Map;
import java.util.UUID;
import de.jeff_media.ChestSort.hooks.GenericGUIHook;
import de.jeff_media.ChestSort.placeholders.ChestSortPlaceholders;
import de.jeff_media.PluginUpdateChecker.PluginUpdateChecker;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
@ -69,7 +70,7 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
String sortingMethod;
ArrayList<String> disabledWorlds;
ChestSortAPIHandler api;
final int currentConfigVersion = 41;
final int currentConfigVersion = 42;
boolean usingMatchingConfig = true;
protected boolean debug = false;
boolean verbose = true;
@ -250,6 +251,11 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
}
}
public ChestSortPlayerSetting getPlayerSetting(Player p) {
registerPlayerIfNeeded(p);
return perPlayerSettings.get(p.getUniqueId().toString());
}
@Override
public void onEnable() {
@ -259,6 +265,10 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
mcMinorVersion = Integer.parseInt(tmpVersion.substring(0,tmpVersion.indexOf("_")));
load(false);
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null){
new ChestSortPlaceholders(this).register();
}
}
private String getCategoryList() {
@ -322,6 +332,8 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
() -> Boolean.toString(getConfig().getBoolean("additional-hotkeys.left-click"))));
bStats.addCustomChart(new Metrics.SimplePie("hotkey_right_click",
() -> Boolean.toString(getConfig().getBoolean("additional-hotkeys.right-click"))));
bStats.addCustomChart(new Metrics.SimplePie("use_permissions",
() -> Boolean.toString(getConfig().getBoolean("use-permissions"))));
}

View File

@ -0,0 +1,108 @@
package de.jeff_media.ChestSort.placeholders;
import de.jeff_media.ChestSort.ChestSortPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
public class ChestSortPlaceholders extends PlaceholderExpansion {
private ChestSortPlugin main;
public ChestSortPlaceholders(ChestSortPlugin main){
this.main = main;
}
/**
* Because this is an internal class,
* you must override this method to let PlaceholderAPI know to not unregister your expansion class when
* PlaceholderAPI is reloaded
*
* @return true to persist through reloads
*/
@Override
public boolean persist(){
return true;
}
/**
* Because this is a internal class, this check is not needed
* and we can simply return {@code true}
*
* @return Always true since it's an internal class.
*/
@Override
public boolean canRegister(){
return true;
}
/**
* The name of the person who created this expansion should go here.
* <br>For convienience do we return the author from the plugin.yml
*
* @return The name of the author as a String.
*/
@Override
public String getAuthor(){
return main.getDescription().getAuthors().toString();
}
/**
* The placeholder identifier should go here.
* <br>This is what tells PlaceholderAPI to call our onRequest
* method to obtain a value if a placeholder starts with our
* identifier.
* <br>This must be unique and can not contain % or _
*
* @return The identifier in {@code %<identifier>_<value>%} as String.
*/
@Override
public String getIdentifier(){
return "chestsort";
}
/**
* This is the version of the expansion.
* <br>You don't have to use numbers, since it is set as a String.
*
* For convienience do we return the version from the plugin.yml
*
* @return The version as a String.
*/
@Override
public String getVersion(){
return main.getDescription().getVersion();
}
/**
* This is the method called when a placeholder with our identifier
* is found and needs a value.
* <br>We specify the value identifier in this method.
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
*
* @param player
* A {@link org.bukkit.Player Player}.
* @param identifier
* A String containing the identifier/value.
*
* @return possibly-null String of the requested identifier.
*/
@Override
public String onPlaceholderRequest(Player player, String identifier){
if(player == null){
return "";
}
if(identifier.equals("sortingenabled")){
return Boolean.toString(main.getPlayerSetting(player).sortingEnabled);
}
if(identifier.equals("invsortingenabled")){
return Boolean.toString(main.getPlayerSetting(player).invSortingEnabled);
}
// We return null if an invalid placeholder (f.e. %someplugin_placeholder3%)
// was provided
return null;
}
}

View File

@ -10,11 +10,43 @@
# Don't worry! Your changes will be kept after every update.
#
#
# Please note that players will need the chestsort.use permission
# or have to be OP to be able to use automatic chest sorting.
# To use /invsort, the permission chestsort.use.inventory is required.
#
###############################
####### Commands #######
###############################
# /sort (or /chestsort) Toggle automatic sorting for containers (chests, barrels, enderchests, llamas, etc.)
# /sort on Enable automatic sorting for containers
# /sort off Disable automatic sorting for containers
# /sort hotkeys Open a GUI to change the sorting hotkeys
# /sort help Display help about the /sort (or /chestsort) command
# /isort (or /invsort) Sort the player's inventory
# /isort hotbar Sort the player's hotbar
# /isort all Sort the player's inventory and hotbar
# /isort toggle Toggle automatic sorting for the player's inventory
# /isort on Enable automatic sorting for the player's inventory
# /isort off Disable automatic sorting for the player's inventory
# /isort help Display help about the /isort (or /invsort) command
###############################
####### 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
###############################
####### Placeholders #######
###############################
# When using PlaceholderAPI, you can use the following placeholders:
# %chestsort_sortingenabled% - true if this player has automatic sorting enabled for containers
# %chestsort_invsortingenabled% - true if this player has automatic sorting enabled for the player's inventory
############################
##### Default settings #####
@ -588,4 +620,4 @@ log: false
# Please DO NOT change the following line manually!
# It is used by the automatic config updater.
config-version: 41
config-version: 42

View File

@ -1,6 +1,6 @@
main: de.jeff_media.ChestSort.ChestSortPlugin
name: ChestSort
version: 8.17.1-SNAPSHOT
version: 8.17.1
api-version: "1.13"
description: Allows automatic chest sorting
author: mfnalex
@ -21,7 +21,7 @@ commands:
/<command> help -- Shows help about this command
aliases: chestsort
permission: chestsort.use
invsort:
isort:
description: Toggle automatic inventory sorting or sorts the player's inventory.
usage: |
/<command> -- Sort your inventory
@ -31,7 +31,7 @@ commands:
/<command> hotbar -- Sort your hotbar
/<command> all -- Sort your inventory and hotbar
/<command> help -- Shows help about this command
aliases: [isort,inventorysort]
aliases: [invsort,inventorysort]
permission: chestsort.use.inventory
permissions:
chestsort.use: