mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-10-01 08:27:26 +02:00
CrackShot support
This commit is contained in:
parent
6977deaa99
commit
22eb9fe7d9
9
pom.xml
9
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>de.jeffclan</groupId>
|
<groupId>de.jeffclan</groupId>
|
||||||
<artifactId>JeffChestSort</artifactId>
|
<artifactId>JeffChestSort</artifactId>
|
||||||
<version>6.2</version>
|
<version>6.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>JeffChestSort</name>
|
<name>JeffChestSort</name>
|
||||||
@ -92,6 +92,13 @@
|
|||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.shampaggon.crackshot</groupId>
|
||||||
|
<artifactId>CSUtility</artifactId>
|
||||||
|
<version>0.98.9</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/lib/CrackShot.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<description>Automatically sorts your chests!</description>
|
<description>Automatically sorts your chests!</description>
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import de.jeffclan.hooks.CrackShotHook;
|
||||||
import de.jeffclan.utils.CategoryLinePair;
|
import de.jeffclan.utils.CategoryLinePair;
|
||||||
import de.jeffclan.utils.TypeMatchPositionPair;
|
import de.jeffclan.utils.TypeMatchPositionPair;
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ public class JeffChestSortOrganizer {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
JeffChestSortPlugin plugin;
|
JeffChestSortPlugin plugin;
|
||||||
|
CrackShotHook crackShotHook;
|
||||||
|
|
||||||
// All available colors in the game. We will strip this from the item names and
|
// All available colors in the game. We will strip this from the item names and
|
||||||
// keep the color in a separate variable
|
// keep the color in a separate variable
|
||||||
@ -96,6 +98,8 @@ public class JeffChestSortOrganizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crackShotHook = new CrackShotHook(plugin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an array with all typematches listed in the category file
|
// Returns an array with all typematches listed in the category file
|
||||||
@ -276,10 +280,23 @@ public class JeffChestSortOrganizer {
|
|||||||
String[] typeAndColor = getTypeAndColor(item.getType().name());
|
String[] typeAndColor = getTypeAndColor(item.getType().name());
|
||||||
String typeName = typeAndColor[0];
|
String typeName = typeAndColor[0];
|
||||||
String color = typeAndColor[1];
|
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 categoryName = categoryLinePair.getCategoryName();
|
||||||
String categorySticky = categoryName;
|
String categorySticky = categoryName;
|
||||||
String lineNumber = getCategoryLinePair(item.getType().name()).getFormattedPosition();
|
String lineNumber = getCategoryLinePair(hookChangedName).getFormattedPosition();
|
||||||
if(stickyCategoryNames.contains(categoryName)) {
|
if(stickyCategoryNames.contains(categoryName)) {
|
||||||
categorySticky = categoryName+"~"+lineNumber;
|
categorySticky = categoryName+"~"+lineNumber;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import de.jeffclan.utils.Utils;
|
import de.jeffclan.utils.Utils;
|
||||||
@ -61,10 +62,13 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
JeffChestSortListener listener;
|
JeffChestSortListener listener;
|
||||||
String sortingMethod;
|
String sortingMethod;
|
||||||
ArrayList<String> disabledWorlds;
|
ArrayList<String> disabledWorlds;
|
||||||
int currentConfigVersion = 15;
|
int currentConfigVersion = 16;
|
||||||
boolean usingMatchingConfig = true;
|
boolean usingMatchingConfig = true;
|
||||||
boolean debug = false;
|
boolean debug = false;
|
||||||
boolean verbose = true;
|
boolean verbose = true;
|
||||||
|
|
||||||
|
public boolean hookCrackShot = false;
|
||||||
|
|
||||||
private long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours (if you never
|
private long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours (if you never
|
||||||
// restart your server)
|
// restart your server)
|
||||||
|
|
||||||
@ -140,6 +144,10 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
getConfig().addDefault("hotkeys.shift-click", true);
|
getConfig().addDefault("hotkeys.shift-click", true);
|
||||||
getConfig().addDefault("hotkeys.double-click", true);
|
getConfig().addDefault("hotkeys.double-click", true);
|
||||||
getConfig().addDefault("hotkeys.shift-right-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()
|
getConfig().addDefault("verbose", true); // Prints some information in onEnable()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +214,12 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
// the default values for unset options
|
// the default values for unset options
|
||||||
createConfig();
|
createConfig();
|
||||||
|
|
||||||
|
if(getConfig().getBoolean("hook-crackshot")) {
|
||||||
|
if(Bukkit.getPluginManager().getPlugin("CrackShot") instanceof Plugin) {
|
||||||
|
hookCrackShot=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
debug = getConfig().getBoolean("debug");
|
debug = getConfig().getBoolean("debug");
|
||||||
|
|
||||||
// Save default sorting category files when enabled in the config (default=true)
|
// Save default sorting category files when enabled in the config (default=true)
|
||||||
|
33
src/main/java/de/jeffclan/hooks/CrackShotHook.java
Normal file
33
src/main/java/de/jeffclan/hooks/CrackShotHook.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,6 +13,8 @@
|
|||||||
# in your sorting-method
|
# in your sorting-method
|
||||||
sticky=true
|
sticky=true
|
||||||
|
|
||||||
|
crackshot_weapon_*
|
||||||
|
crossbow
|
||||||
bow
|
bow
|
||||||
*_sword
|
*_sword
|
||||||
trident
|
trident
|
||||||
|
@ -106,6 +106,26 @@ verbose: true
|
|||||||
|
|
||||||
disabled-worlds:
|
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 #####
|
##### 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!
|
# please do not change the following line manually!
|
||||||
config-version: 15
|
config-version: 16
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
|
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
|
||||||
name: ChestSort
|
name: ChestSort
|
||||||
version: 6.2
|
version: 6.3
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: Allows automatic chest sorting
|
description: Allows automatic chest sorting
|
||||||
author: mfnalex
|
author: mfnalex
|
||||||
website: https://www.chestsort.de
|
website: https://www.chestsort.de
|
||||||
prefix: ChestSort
|
prefix: ChestSort
|
||||||
database: false
|
database: false
|
||||||
loadbefore:
|
loadbefore: [InvUnload]
|
||||||
- InvUnload
|
softdepend: [CrackShot]
|
||||||
commands:
|
commands:
|
||||||
chestsort:
|
chestsort:
|
||||||
description: Toggle automatic chest sorting
|
description: Toggle automatic chest sorting
|
||||||
|
Loading…
Reference in New Issue
Block a user