From 3ee0da41cd4fe6fa2aaf8885ce60a7dbb7ce4641 Mon Sep 17 00:00:00 2001 From: mfnalex <1122571+mfnalex@users.noreply.github.com> Date: Sat, 18 Jul 2020 16:19:40 +0200 Subject: [PATCH] 8.17.1-SNAPSHOT --- CHANGELOG.md | 3 +++ pom.xml | 2 +- .../ChestSort/ChestSortInvSortCommand.java | 26 ++++++++++++++++--- src/main/resources/plugin.yml | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd2a606..97f29d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 8.17.1-SNAPSHOT +- Added possibility to sort a player's inventory from console using /invsort [toggle|on|off|hotbar|inv|all] + ## 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. diff --git a/pom.xml b/pom.xml index c2bd96a..8f60085 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ ChestSort https://www.chestsort.de Automatically sorts your chests! - 8.17.0 + 8.17.1-SNAPSHOT jar diff --git a/src/main/java/de/jeff_media/ChestSort/ChestSortInvSortCommand.java b/src/main/java/de/jeff_media/ChestSort/ChestSortInvSortCommand.java index fe48a9a..dd8cb07 100644 --- a/src/main/java/de/jeff_media/ChestSort/ChestSortInvSortCommand.java +++ b/src/main/java/de/jeff_media/ChestSort/ChestSortInvSortCommand.java @@ -1,5 +1,6 @@ package de.jeff_media.ChestSort; +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -17,6 +18,8 @@ public class ChestSortInvSortCommand implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNull String label, String[] args) { + Player p = null; + // This command toggles automatic chest sorting for the player that runs the command if (!command.getName().equalsIgnoreCase("invsort")) { return false; @@ -27,11 +30,28 @@ public class ChestSortInvSortCommand implements CommandExecutor { } if (!(sender instanceof Player)) { - sender.sendMessage(plugin.messages.MSG_PLAYERSONLY); - return true; + + if(args.length==0) { + sender.sendMessage(plugin.messages.MSG_PLAYERSONLY); + return true; + } + // Console can sort player's inventories + if(Bukkit.getPlayer(args[0]) == null) { + sender.sendMessage("Could not find player "+args[0]); + return true; + } + + p = Bukkit.getPlayer(args[0]); + + if(args.length>1) { + args = new String[] { args[1] }; + } + + //sender.sendMessage(plugin.messages.MSG_PLAYERSONLY); + //return true; } - Player p = (Player) sender; + if(p == null) p = (Player) sender; int start = 9; int end = 35; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 32973ad..50d4748 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ main: de.jeff_media.ChestSort.ChestSortPlugin name: ChestSort -version: 8.17.0 +version: 8.17.1-SNAPSHOT api-version: "1.13" description: Allows automatic chest sorting author: mfnalex