From 22eb9fe7d91b0a453f97171f1d7ade44d555fb7c Mon Sep 17 00:00:00 2001 From: mfnalex <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:32:38 +0200 Subject: [PATCH 1/9] CrackShot support --- pom.xml | 9 ++++- .../JeffChestSort/JeffChestSortOrganizer.java | 21 ++++++++++-- .../JeffChestSort/JeffChestSortPlugin.java | 16 ++++++++- .../java/de/jeffclan/hooks/CrackShotHook.java | 33 +++++++++++++++++++ .../categories/900-weapons.default.txt | 2 ++ src/main/resources/config.yml | 22 ++++++++++++- src/main/resources/plugin.yml | 6 ++-- 7 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 src/main/java/de/jeffclan/hooks/CrackShotHook.java diff --git a/pom.xml b/pom.xml index 753070e..4d46490 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ de.jeffclan JeffChestSort - 6.2 + 6.3 jar JeffChestSort @@ -92,6 +92,13 @@ 1.4 compile + + com.shampaggon.crackshot + CSUtility + 0.98.9 + system + ${project.basedir}/lib/CrackShot.jar + Automatically sorts your chests! diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java index 143f7e7..7bf3b04 100644 --- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java +++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java @@ -13,6 +13,7 @@ import org.bukkit.Bukkit; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import de.jeffclan.hooks.CrackShotHook; import de.jeffclan.utils.CategoryLinePair; import de.jeffclan.utils.TypeMatchPositionPair; @@ -30,6 +31,7 @@ public class JeffChestSortOrganizer { */ JeffChestSortPlugin plugin; + CrackShotHook crackShotHook; // All available colors in the game. We will strip this from the item names and // keep the color in a separate variable @@ -95,6 +97,8 @@ public class JeffChestSortOrganizer { } } } + + crackShotHook = new CrackShotHook(plugin); } @@ -276,10 +280,23 @@ public class JeffChestSortOrganizer { String[] typeAndColor = getTypeAndColor(item.getType().name()); String typeName = typeAndColor[0]; String color = typeAndColor[1]; - CategoryLinePair categoryLinePair = getCategoryLinePair(item.getType().name()); + + String hookChangedName = item.getType().name(); + + // CrackShot Support Start + if(plugin.hookCrackShot) { + if(crackShotHook.getCrackShotWeaponName(item)!=null) { + typeName = plugin.getConfig().getString("hook-crackshot-prefix") + "_" + crackShotHook.getCrackShotWeaponName(item); + color=""; + hookChangedName = typeName; + } + } + // CrackShot Support End + + CategoryLinePair categoryLinePair = getCategoryLinePair(hookChangedName); String categoryName = categoryLinePair.getCategoryName(); String categorySticky = categoryName; - String lineNumber = getCategoryLinePair(item.getType().name()).getFormattedPosition(); + String lineNumber = getCategoryLinePair(hookChangedName).getFormattedPosition(); if(stickyCategoryNames.contains(categoryName)) { categorySticky = categoryName+"~"+lineNumber; } diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java index 6044ec3..6d30211 100644 --- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java +++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java @@ -47,6 +47,7 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import de.jeffclan.utils.Utils; @@ -61,10 +62,13 @@ public class JeffChestSortPlugin extends JavaPlugin { JeffChestSortListener listener; String sortingMethod; ArrayList disabledWorlds; - int currentConfigVersion = 15; + int currentConfigVersion = 16; boolean usingMatchingConfig = true; boolean debug = false; boolean verbose = true; + + public boolean hookCrackShot = false; + private long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours (if you never // restart your server) @@ -140,6 +144,10 @@ public class JeffChestSortPlugin extends JavaPlugin { getConfig().addDefault("hotkeys.shift-click", true); getConfig().addDefault("hotkeys.double-click", true); getConfig().addDefault("hotkeys.shift-right-click", true); + + getConfig().addDefault("hook-crackshot", true); + getConfig().addDefault("hook-crackshot-prefix", "crackshot_weapon"); + getConfig().addDefault("verbose", true); // Prints some information in onEnable() } @@ -205,6 +213,12 @@ public class JeffChestSortPlugin extends JavaPlugin { // Create the config file, including checks for old config versions, and load // the default values for unset options createConfig(); + + if(getConfig().getBoolean("hook-crackshot")) { + if(Bukkit.getPluginManager().getPlugin("CrackShot") instanceof Plugin) { + hookCrackShot=true; + } + } debug = getConfig().getBoolean("debug"); diff --git a/src/main/java/de/jeffclan/hooks/CrackShotHook.java b/src/main/java/de/jeffclan/hooks/CrackShotHook.java new file mode 100644 index 0000000..193ff79 --- /dev/null +++ b/src/main/java/de/jeffclan/hooks/CrackShotHook.java @@ -0,0 +1,33 @@ +package de.jeffclan.hooks; + +import org.bukkit.inventory.ItemStack; + +import com.shampaggon.crackshot.CSUtility; + +import de.jeffclan.JeffChestSort.JeffChestSortPlugin; + +public class CrackShotHook { + + JeffChestSortPlugin plugin; + CSUtility crackShotUtility = null; + + public CrackShotHook(JeffChestSortPlugin plugin) { + this.plugin=plugin; + + if(plugin.hookCrackShot) { + crackShotUtility = new CSUtility(); + plugin.getLogger().info("Succesfully hooked into CrackShot"); + } + } + + // Will return when not a weapon + public String getCrackShotWeaponName(ItemStack item) { + if(crackShotUtility == null || plugin.hookCrackShot==false) { + return null; + } + + // Will be null if not a weapon + return crackShotUtility.getWeaponTitle(item); + } + +} diff --git a/src/main/resources/categories/900-weapons.default.txt b/src/main/resources/categories/900-weapons.default.txt index b2831fd..0c38f67 100644 --- a/src/main/resources/categories/900-weapons.default.txt +++ b/src/main/resources/categories/900-weapons.default.txt @@ -13,6 +13,8 @@ # in your sorting-method sticky=true +crackshot_weapon_* +crossbow bow *_sword trident diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9d9e408..87d8f14 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -106,6 +106,26 @@ verbose: true disabled-worlds: +########################## +##### Plugin hooks ##### +########################## + +# ChestSort can hook into other plugins to allow better sorting +# for items belonging to 3rd party plugins. +# You do NOT have to disable the hooks for plugins you don't have +# installed. ChestSort will automatically check if the plugins +# are installed. + +##### CrackShot ##### +# When CrackShot is installed, all CrackShot weapons will be +# grouped together and sorted by their name +hook-crackshot: true +# You can define a custom name that will be used as prefix +# for all CrackShot weapon names. +# E.g. when you set this to "crackshot_weapon", an AK-47 +# will be called "crackshot_weapon_AK-47" +hook-crackshot-prefix: "crackshot_weapon" + ########################## ##### Sorting Method ##### ########################## @@ -289,4 +309,4 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s ######################### # please do not change the following line manually! -config-version: 15 +config-version: 16 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e7a8877..b5ccc55 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,14 +1,14 @@ main: de.jeffclan.JeffChestSort.JeffChestSortPlugin name: ChestSort -version: 6.2 +version: 6.3 api-version: 1.13 description: Allows automatic chest sorting author: mfnalex website: https://www.chestsort.de prefix: ChestSort database: false -loadbefore: -- InvUnload +loadbefore: [InvUnload] +softdepend: [CrackShot] commands: chestsort: description: Toggle automatic chest sorting From f37b05bd6aef9f68fcd4d3fd286d01b83024fc0a Mon Sep 17 00:00:00 2001 From: mfnalex <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:35:25 +0200 Subject: [PATCH 2/9] updated ReadMe for CrackShot library --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8a53a29..6989b78 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ Please see the related topic at spigotmc.org for information regarding the comma https://www.spigotmc.org/resources/1-13-chestsort.59773/ +## Building .jar file +To build the .jar file, you will need maven. Also, the CrackShot library is in no public repository, you please create a lib directory and put the latest CrackShot.jar inside it. Now you can do `mvn install` + ## Technical stuff ChestSort takes an instance of org.bukkit.inventory.Inventory and copies the contents. The resulting array is sorted by rules defined in the config.yml. This takes far less than one millisecond for a whole chest. So there should be no problems even on big servers, where hundreds of players are using chests at the same time. The plugin should cause no lag at all. From d2c13118000e96121369d647edf1d6dbf6abb324 Mon Sep 17 00:00:00 2001 From: mfnalex <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:36:26 +0200 Subject: [PATCH 3/9] update ReadMe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6989b78..98286ef 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Please see the related topic at spigotmc.org for information regarding the comma https://www.spigotmc.org/resources/1-13-chestsort.59773/ ## Building .jar file -To build the .jar file, you will need maven. Also, the CrackShot library is in no public repository, you please create a lib directory and put the latest CrackShot.jar inside it. Now you can do `mvn install` +To build the .jar file, you will need maven. Also, the CrackShot library is in no public repository, so please create a directory called `lib` and put the latest CrackShot.jar file inside it. Now you can do `mvn install` ## Technical stuff ChestSort takes an instance of org.bukkit.inventory.Inventory and copies the contents. The resulting array is sorted by rules defined in the config.yml. This takes far less than one millisecond for a whole chest. So there should be no problems even on big servers, where hundreds of players are using chests at the same time. From 35c5fd0600a38fe1e00ed3f4a55364472072708b Mon Sep 17 00:00:00 2001 From: JEFF <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:39:00 +0200 Subject: [PATCH 4/9] Update README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 98286ef..8c24c4f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,11 @@ # ChestSort -1.8 to 1.14 compatible Minecraft-/Spigot-Plugin to allow automatic chest sorting. +1.8 to 1.14 compatible Minecraft-/Spigot-Plugin to allow automatic chest and inventory sorting. ## About Tired of sorting your chests? Let's spend less time on organizing, and more on playing! ![Screenshot ChestSort](https://static.jeff-media.de/i/chestsortbeforeafter.jpg "Screenshot ChestSort") -ChestSort will automatically sort every chest after you have closed it. Every player can enable or disable this feature if desired with the simple command `/chestsort`. By default, sorting is disabled. If a player uses a chest for the first time after logging in, they will be shown a text on how to enable automatic chest sorting. Players need the "chestsort.use" permission to use the plugin. - -Sorting will work with chests and shulker boxes. - Tested Spigot versions: 1.8 to 1.14 ## Download & more information From f4eb058672f475a4bcb5b466f51830245c2ba9a9 Mon Sep 17 00:00:00 2001 From: JEFF <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:41:53 +0200 Subject: [PATCH 5/9] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c24c4f..c98da83 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ ## About Tired of sorting your chests? Let's spend less time on organizing, and more on playing! -![Screenshot ChestSort](https://static.jeff-media.de/i/chestsortbeforeafter.jpg "Screenshot ChestSort") +![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen1.jpg "Screenshot ChestSort") +![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen2.jpg "Screenshot ChestSort") Tested Spigot versions: 1.8 to 1.14 From 4b29d855f0a140a7ddef49d3ae4a679a387096aa Mon Sep 17 00:00:00 2001 From: JEFF <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:42:03 +0200 Subject: [PATCH 6/9] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c98da83..bc1187e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Tired of sorting your chests? Let's spend less time on organizing, and more on playing! ![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen1.jpg "Screenshot ChestSort") + ![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen2.jpg "Screenshot ChestSort") Tested Spigot versions: 1.8 to 1.14 From 402ac982059870956b42ba9c0a6577ef92a60f63 Mon Sep 17 00:00:00 2001 From: JEFF <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:42:56 +0200 Subject: [PATCH 7/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc1187e..8d0b5ae 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ## About Tired of sorting your chests? Let's spend less time on organizing, and more on playing! -![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen1.jpg "Screenshot ChestSort") +

![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen1.jpg "Screenshot ChestSort")

-![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen2.jpg "Screenshot ChestSort") +

![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen2.jpg "Screenshot ChestSort")

Tested Spigot versions: 1.8 to 1.14 From 4bde4434555b6179f4977f61511492b07b3a7970 Mon Sep 17 00:00:00 2001 From: JEFF <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:43:27 +0200 Subject: [PATCH 8/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d0b5ae..bda9eab 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ## About Tired of sorting your chests? Let's spend less time on organizing, and more on playing! -

![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen1.jpg "Screenshot ChestSort")

+

Screenshot ChestSort

-

![Screenshot ChestSort](https://static.jeff-media.de/chestsort/chestsort-screen2.jpg "Screenshot ChestSort")

+

Screenshot ChestSort

Tested Spigot versions: 1.8 to 1.14 From c6c32473d003297b578339dde4cbd783e7bf9853 Mon Sep 17 00:00:00 2001 From: JEFF <1122571+mfnalex@users.noreply.github.com> Date: Mon, 15 Jul 2019 14:44:13 +0200 Subject: [PATCH 9/9] Update README.md --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bda9eab..36e7f7f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,6 @@ # ChestSort 1.8 to 1.14 compatible Minecraft-/Spigot-Plugin to allow automatic chest and inventory sorting. -## About -Tired of sorting your chests? Let's spend less time on organizing, and more on playing! - -

Screenshot ChestSort

- -

Screenshot ChestSort

- -Tested Spigot versions: 1.8 to 1.14 - ## Download & more information Please see the related topic at spigotmc.org for information regarding the commands, permissions and download links: @@ -21,3 +12,8 @@ To build the .jar file, you will need maven. Also, the CrackShot library is in n ## Technical stuff ChestSort takes an instance of org.bukkit.inventory.Inventory and copies the contents. The resulting array is sorted by rules defined in the config.yml. This takes far less than one millisecond for a whole chest. So there should be no problems even on big servers, where hundreds of players are using chests at the same time. The plugin should cause no lag at all. + +## Screenshots +

Screenshot ChestSort

+ +

Screenshot ChestSort