mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-11-13 06:05:36 +01:00
cleanup
This commit is contained in:
parent
202fdebd3f
commit
6b0d3d46f1
@ -1,4 +1,8 @@
|
||||
# Changelog
|
||||
## 8.11.1
|
||||
- Improved help messages
|
||||
- Huge code cleanup
|
||||
|
||||
## 8.11.0
|
||||
- Adjustet Left-Click / Right-Click hotkeys:
|
||||
- Left-Click outside of inventories will put matching items from your inventory into the chest
|
||||
@ -8,6 +12,7 @@
|
||||
- Using new universal Update checker (https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
|
||||
|
||||
Note: The last two messages in the config.yml have changed, so please retranslate them. I am also always happy to integrate your translations into the default config.yml if you send them to me.
|
||||
|
||||
## 8.10.5
|
||||
- Added reload command (/chestsort reload) with permission chestsort.reload
|
||||
- ChestSort checks if Minepacks version is recent enough and, if not, disable the Minepacks hook.
|
||||
|
4
pom.xml
4
pom.xml
@ -9,7 +9,7 @@
|
||||
<name>JeffChestSort</name>
|
||||
<url>https://www.chestsort.de</url>
|
||||
<description>Automatically sorts your chests!</description>
|
||||
<version>8.11.0</version>
|
||||
<version>8.11.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@ -132,7 +132,7 @@
|
||||
<dependency>
|
||||
<groupId>de.jeff_media</groupId>
|
||||
<artifactId>PluginUpdateChecker</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>[1.2,</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class ChestSortAPI {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
ChestSortAPI(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -12,9 +12,9 @@ public class ChestSortCategory implements Comparable<ChestSortCategory>{
|
||||
// "COARSE_DIRT" will not match the typeMatch "dirt"
|
||||
// "COARSE_DIRT" will match the typeMatch "*dirt"
|
||||
|
||||
String name;
|
||||
final String name;
|
||||
boolean sticky = false;
|
||||
TypeMatchPositionPair[] typeMatches;
|
||||
final TypeMatchPositionPair[] typeMatches;
|
||||
|
||||
ChestSortCategory(String name, TypeMatchPositionPair[] typeMatchPositionPairs) {
|
||||
this.name = name;
|
||||
@ -48,15 +48,15 @@ public class ChestSortCategory implements Comparable<ChestSortCategory>{
|
||||
typeMatch = typeMatch.substring(0, typeMatch.length() - 1);
|
||||
}
|
||||
|
||||
if (asteriskBefore == false && asteriskAfter == false) {
|
||||
if (!asteriskBefore && !asteriskAfter) {
|
||||
if (itemname.equalsIgnoreCase(typeMatch)) {
|
||||
return typeMatchPositionPair.getPosition();
|
||||
}
|
||||
} else if (asteriskBefore == true && asteriskAfter == true) {
|
||||
} else if (asteriskBefore && asteriskAfter) {
|
||||
if (itemname.contains(typeMatch)) {
|
||||
return typeMatchPositionPair.getPosition();
|
||||
}
|
||||
} else if (asteriskBefore == true && asteriskAfter == false) {
|
||||
} else if (asteriskBefore && !asteriskAfter) {
|
||||
if (itemname.endsWith(typeMatch)) {
|
||||
return typeMatchPositionPair.getPosition();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class ChestSortChestSortCommand implements CommandExecutor {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
ChestSortChestSortCommand(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -58,7 +58,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
|
||||
if(args.length>0) {
|
||||
if(args[0].equalsIgnoreCase("hotkey") || args[0].equalsIgnoreCase("hotkeys")) {
|
||||
|
||||
if(plugin.hotkeyGUI==false) {
|
||||
if(!plugin.hotkeyGUI) {
|
||||
p.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
|
||||
return true;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import de.jeff_media.ChestSort.utils.Utils;
|
||||
|
||||
public class ChestSortConfigUpdater {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
public ChestSortConfigUpdater(ChestSortPlugin jeffChestSortPlugin) {
|
||||
this.plugin = jeffChestSortPlugin;
|
||||
@ -55,7 +55,7 @@ public class ChestSortConfigUpdater {
|
||||
Map<String, Object> oldValues = oldConfig.getValues(false);
|
||||
|
||||
// Read default config to keep comments
|
||||
ArrayList<String> linesInDefaultConfig = new ArrayList<String>();
|
||||
ArrayList<String> linesInDefaultConfig = new ArrayList<>();
|
||||
try {
|
||||
|
||||
Scanner scanner = new Scanner(
|
||||
@ -68,7 +68,7 @@ public class ChestSortConfigUpdater {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ArrayList<String> newLines = new ArrayList<String>();
|
||||
ArrayList<String> newLines = new ArrayList<>();
|
||||
for (String line : linesInDefaultConfig) {
|
||||
String newline = line;
|
||||
if (line.startsWith("config-version:")) {
|
||||
@ -121,8 +121,8 @@ public class ChestSortConfigUpdater {
|
||||
String[] linesArray = newLines.toArray(new String[linesInDefaultConfig.size()]);
|
||||
try {
|
||||
fw = new FileWriter(plugin.getDataFolder().getAbsolutePath() + File.separator + "config.yml");
|
||||
for (int i = 0; i < linesArray.length; i++) {
|
||||
fw.write(linesArray[i] + "\n");
|
||||
for (String s : linesArray) {
|
||||
fw.write(s + "\n");
|
||||
}
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
|
@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChestSortDebugger implements @NotNull Listener {
|
||||
|
||||
private ChestSortPlugin plugin;
|
||||
private final ChestSortPlugin plugin;
|
||||
|
||||
ChestSortDebugger(ChestSortPlugin plugin) {
|
||||
plugin.getLogger().warning("=======================================");
|
||||
|
@ -12,7 +12,7 @@ public class ChestSortEvent extends Event implements Cancellable {
|
||||
|
||||
boolean cancelled = false;
|
||||
Location loc;
|
||||
Inventory inv;
|
||||
final Inventory inv;
|
||||
Player p;
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class ChestSortInvSortCommand implements CommandExecutor {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
ChestSortInvSortCommand(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -24,8 +24,8 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class ChestSortListener implements Listener {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
MinepacksHook minepacksHook;
|
||||
final ChestSortPlugin plugin;
|
||||
final MinepacksHook minepacksHook;
|
||||
|
||||
ChestSortListener(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -207,13 +207,10 @@ public class ChestSortListener implements Listener {
|
||||
// WARNING: The names are inconsistent! A chest will return
|
||||
// org.bukkit.craftbukkit.v1_14_R1.block.CraftChest
|
||||
// in Spigot 1.14 while a double chest returns org.bukkit.block.DoubleChest
|
||||
if (!(inventory.getHolder() instanceof Chest) && !(inventory.getHolder() instanceof DoubleChest)
|
||||
&& !(inventory.getHolder().getClass().toString().endsWith(".CraftMinecartChest"))
|
||||
&& !(inventory.getHolder().getClass().toString().endsWith(".CraftShulkerBox")) //Obsolete, is checked above by InventoryType
|
||||
&& !(inventory.getHolder().getClass().toString().endsWith(".CraftBarrel"))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return inventory.getHolder() instanceof Chest || inventory.getHolder() instanceof DoubleChest
|
||||
|| inventory.getHolder().getClass().toString().endsWith(".CraftMinecartChest")
|
||||
|| inventory.getHolder().getClass().toString().endsWith(".CraftShulkerBox") //Obsolete, is checked above by InventoryType
|
||||
|| inventory.getHolder().getClass().toString().endsWith(".CraftBarrel");
|
||||
}
|
||||
|
||||
private boolean isReadyToSort(Player p) {
|
||||
@ -408,7 +405,6 @@ public class ChestSortListener implements Listener {
|
||||
|
||||
plugin.organizer.sortInventory(event.getClickedInventory());
|
||||
plugin.organizer.updateInventoryView(event);
|
||||
return;
|
||||
} else if (holder instanceof Player) {
|
||||
if (!p.hasPermission("chestsort.use.inventory")) {
|
||||
return;
|
||||
@ -423,7 +419,6 @@ public class ChestSortListener implements Listener {
|
||||
plugin.organizer.updateInventoryView(event);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class ChestSortMessages {
|
||||
// When creating pull requests that feature a message to the player, please
|
||||
// stick to this scheme
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
final String MSG_ACTIVATED, MSG_DEACTIVATED, MSG_INVACTIVATED, MSG_INVDEACTIVATED, MSG_COMMANDMESSAGE, MSG_COMMANDMESSAGE2, MSG_PLAYERSONLY,
|
||||
MSG_PLAYERINVSORTED, MSG_INVALIDOPTIONS;
|
||||
|
@ -44,9 +44,9 @@ public class ChestSortOrganizer {
|
||||
* they are already alphabetically in the right order
|
||||
*/
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
CrackShotHook crackShotHook;
|
||||
InventoryPagesHook inventoryPagesHook;
|
||||
final ChestSortPlugin plugin;
|
||||
final CrackShotHook crackShotHook;
|
||||
final InventoryPagesHook inventoryPagesHook;
|
||||
|
||||
private static final int maxInventorySize=54;
|
||||
private static final int playerInvStartSlot=9; // Inclusive
|
||||
@ -64,8 +64,8 @@ public class ChestSortOrganizer {
|
||||
private static final String emptyPlaceholderString = "~";
|
||||
|
||||
// We store a list of all Category objects
|
||||
ArrayList<ChestSortCategory> categories = new ArrayList<ChestSortCategory>();
|
||||
ArrayList<String> stickyCategoryNames = new ArrayList<String>();
|
||||
final ArrayList<ChestSortCategory> categories = new ArrayList<>();
|
||||
final ArrayList<String> stickyCategoryNames = new ArrayList<>();
|
||||
|
||||
ChestSortOrganizer(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -73,18 +73,13 @@ public class ChestSortOrganizer {
|
||||
// Load Categories
|
||||
File categoriesFolder = new File(
|
||||
plugin.getDataFolder().getAbsolutePath() + File.separator + "categories" + File.separator);
|
||||
File[] listOfCategoryFiles = categoriesFolder.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File directory, String fileName) {
|
||||
if (!fileName.endsWith(".txt")) {
|
||||
return false;
|
||||
}
|
||||
if (fileName.matches("(?i)^\\d\\d\\d.*\\.txt$")) // Category between 900 and 999-... are default
|
||||
// categories
|
||||
{
|
||||
return true;
|
||||
}
|
||||
File[] listOfCategoryFiles = categoriesFolder.listFiles((directory, fileName) -> {
|
||||
if (!fileName.endsWith(".txt")) {
|
||||
return false;
|
||||
}
|
||||
// Category between 900 and 999-... are default
|
||||
// categories
|
||||
return fileName.matches("(?i)^\\d\\d\\d.*\\.txt$");
|
||||
});
|
||||
for (File file : listOfCategoryFiles) {
|
||||
if (file.isFile()) {
|
||||
@ -129,7 +124,7 @@ public class ChestSortOrganizer {
|
||||
// you can set it per category
|
||||
boolean appendLineNumber = false;
|
||||
Scanner sc = new Scanner(file);
|
||||
List<TypeMatchPositionPair> lines = new ArrayList<TypeMatchPositionPair>();
|
||||
List<TypeMatchPositionPair> lines = new ArrayList<>();
|
||||
short currentLineNumber = 1;
|
||||
while (sc.hasNextLine()) {
|
||||
String currentLine = sc.nextLine();
|
||||
@ -323,7 +318,7 @@ public class ChestSortOrganizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NoSuchMethodException | SecurityException e) { }
|
||||
} catch (NoSuchMethodException | SecurityException ignored) { }
|
||||
|
||||
// potionEffects = potionEffects.substring(0, potionEffects.length()-1);
|
||||
}
|
||||
@ -410,7 +405,7 @@ public class ChestSortOrganizer {
|
||||
System.out.println(" ");
|
||||
}
|
||||
|
||||
ArrayList<Integer> unsortableSlots = new ArrayList<Integer>();
|
||||
ArrayList<Integer> unsortableSlots = new ArrayList<>();
|
||||
|
||||
// We copy the complete inventory into an array
|
||||
ItemStack[] items = inv.getContents();
|
||||
@ -469,7 +464,7 @@ public class ChestSortOrganizer {
|
||||
|
||||
// We don't want to have stacks of null, so we create a new ArrayList and put in
|
||||
// everything != null
|
||||
ArrayList<ItemStack> nonNullItemsList = new ArrayList<ItemStack>();
|
||||
ArrayList<ItemStack> nonNullItemsList = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
nonNullItemsList.add(item);
|
||||
@ -484,15 +479,10 @@ public class ChestSortOrganizer {
|
||||
// Because I did not bother to count the number of non-null items beforehand.
|
||||
// TODO: Feel free to make a Pull request if you want to save your server a few
|
||||
// nanoseconds :)
|
||||
ItemStack[] nonNullItems = nonNullItemsList.toArray(new ItemStack[nonNullItemsList.size()]);
|
||||
ItemStack[] nonNullItems = nonNullItemsList.toArray(new ItemStack[0]);
|
||||
|
||||
// Sort the array with ItemStacks according to each ItemStacks' sortable String
|
||||
Arrays.sort(nonNullItems, new Comparator<ItemStack>() {
|
||||
@Override
|
||||
public int compare(ItemStack s1, ItemStack s2) {
|
||||
return (getSortableString(s1).compareTo(getSortableString(s2)));
|
||||
}
|
||||
});
|
||||
Arrays.sort(nonNullItems, (s1, s2) -> (getSortableString(s1).compareTo(getSortableString(s2))));
|
||||
|
||||
// Now, we put everything back in a temporary inventory to combine ItemStacks
|
||||
// even when using strict slot sorting
|
||||
@ -579,8 +569,7 @@ public class ChestSortOrganizer {
|
||||
}
|
||||
|
||||
public boolean isOversizedStack(ItemStack item) {
|
||||
if(item!=null && item.getAmount()>64) return true;
|
||||
return false;
|
||||
return item != null && item.getAmount() > 64;
|
||||
}
|
||||
|
||||
public void stuffInventoryIntoAnother(Inventory source, Inventory destination,Inventory origSource, boolean onlyMatchingStuff) {
|
||||
@ -601,7 +590,7 @@ public class ChestSortOrganizer {
|
||||
}
|
||||
|
||||
|
||||
ArrayList<ItemStack> leftovers = new ArrayList<ItemStack>();
|
||||
ArrayList<ItemStack> leftovers = new ArrayList<>();
|
||||
|
||||
for(int i = 0;i<source.getSize();i++) {
|
||||
|
||||
@ -613,14 +602,12 @@ public class ChestSortOrganizer {
|
||||
if(isOversizedStack(current)) continue;
|
||||
source.clear(i);
|
||||
HashMap<Integer,ItemStack> currentLeftovers = destination.addItem(current);
|
||||
|
||||
|
||||
for(ItemStack currentLeftover : currentLeftovers.values()) {
|
||||
leftovers.add(currentLeftover);
|
||||
}
|
||||
|
||||
|
||||
leftovers.addAll(currentLeftovers.values());
|
||||
}
|
||||
|
||||
origSource.addItem(leftovers.toArray(new ItemStack[leftovers.size()]));
|
||||
origSource.addItem(leftovers.toArray(new ItemStack[0]));
|
||||
|
||||
// Restore hotbar
|
||||
if(destinationIsPlayerInventory) {
|
||||
|
@ -8,12 +8,12 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
public class ChestSortPermissionsHandler {
|
||||
|
||||
HashMap<UUID,PermissionAttachment> permissions;
|
||||
ChestSortPlugin plugin;
|
||||
final HashMap<UUID,PermissionAttachment> permissions;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
ChestSortPermissionsHandler(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.permissions = new HashMap<UUID,PermissionAttachment>();
|
||||
this.permissions = new HashMap<>();
|
||||
}
|
||||
|
||||
void addPermissions(Player p) {
|
||||
|
@ -30,7 +30,7 @@ public class ChestSortPlayerSetting {
|
||||
DoubleClickType currentDoubleClick = DoubleClickType.NONE;
|
||||
|
||||
enum DoubleClickType {
|
||||
NONE, RIGHT_CLICK, LEFT_CLICK;
|
||||
NONE, RIGHT_CLICK, LEFT_CLICK
|
||||
}
|
||||
|
||||
ChestSortPlayerSetting(boolean sortingEnabled, boolean invSortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick, boolean leftClick, boolean rightClick, boolean changed) {
|
||||
@ -53,12 +53,7 @@ public class ChestSortPlayerSetting {
|
||||
}
|
||||
if(currentDoubleClick != click) {
|
||||
currentDoubleClick = click;
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentDoubleClick = DoubleClickType.NONE;
|
||||
}
|
||||
}, 10);
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> currentDoubleClick = DoubleClickType.NONE, 10);
|
||||
return DoubleClickType.NONE;
|
||||
}
|
||||
return DoubleClickType.NONE;
|
||||
|
@ -58,7 +58,7 @@ import de.jeff_media.ChestSort.utils.Utils;
|
||||
|
||||
public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<String, ChestSortPlayerSetting>();
|
||||
Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<>();
|
||||
ChestSortMessages messages;
|
||||
ChestSortOrganizer organizer;
|
||||
PluginUpdateChecker updateChecker;
|
||||
@ -68,11 +68,11 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
String sortingMethod;
|
||||
ArrayList<String> disabledWorlds;
|
||||
ChestSortAPI api;
|
||||
int currentConfigVersion = 33;
|
||||
final int currentConfigVersion = 33;
|
||||
boolean usingMatchingConfig = true;
|
||||
protected boolean debug = false;
|
||||
boolean verbose = true;
|
||||
boolean hotkeyGUI = true;
|
||||
final boolean hotkeyGUI = true;
|
||||
|
||||
public boolean hookCrackShot = false;
|
||||
public boolean hookInventoryPages = false;
|
||||
@ -109,7 +109,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
boolean isSortingEnabled(Player p) {
|
||||
if (perPlayerSettings == null) {
|
||||
perPlayerSettings = new HashMap<String, ChestSortPlayerSetting>();
|
||||
perPlayerSettings = new HashMap<>();
|
||||
}
|
||||
listener.plugin.registerPlayerIfNeeded(p);
|
||||
return perPlayerSettings.get(p.getUniqueId().toString()).sortingEnabled;
|
||||
@ -238,7 +238,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
private String getCategoryList() {
|
||||
String list = "";
|
||||
ChestSortCategory[] categories = organizer.categories.toArray(new ChestSortCategory[organizer.categories.size()]);
|
||||
ChestSortCategory[] categories = organizer.categories.toArray(new ChestSortCategory[0]);
|
||||
Arrays.sort(categories);
|
||||
for(ChestSortCategory category : categories) {
|
||||
list = list + category.name + " (";
|
||||
@ -296,7 +296,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
private void saveDefaultCategories() {
|
||||
|
||||
// Abort when auto-generate-category-files is set to false in config.yml
|
||||
if (getConfig().getBoolean("auto-generate-category-files", true) != true) {
|
||||
if (!getConfig().getBoolean("auto-generate-category-files", true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -306,18 +306,13 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
|
||||
// Delete all files starting with 9..
|
||||
for (File file : new File(getDataFolder().getAbsolutePath() + File.separator + "categories" + File.separator)
|
||||
.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File directory, String fileName) {
|
||||
if (!fileName.endsWith(".txt")) {
|
||||
return false;
|
||||
}
|
||||
if (fileName.matches("(?i)9\\d\\d.*\\.txt$")) // Category between 900 and 999-... are default
|
||||
// categories
|
||||
{
|
||||
return true;
|
||||
}
|
||||
.listFiles((directory, fileName) -> {
|
||||
if (!fileName.endsWith(".txt")) {
|
||||
return false;
|
||||
}
|
||||
// Category between 900 and 999-... are default
|
||||
// categories
|
||||
return fileName.matches("(?i)9\\d\\d.*\\.txt$");
|
||||
})) {
|
||||
|
||||
boolean delete = true;
|
||||
@ -433,13 +428,13 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
hookCrackShot = getConfig().getBoolean("hook-crackshot")
|
||||
&& Bukkit.getPluginManager().getPlugin("CrackShot") instanceof Plugin ? true : false;
|
||||
&& Bukkit.getPluginManager().getPlugin("CrackShot") instanceof Plugin;
|
||||
|
||||
hookInventoryPages = getConfig().getBoolean("hook-inventorypages")
|
||||
&& Bukkit.getPluginManager().getPlugin("InventoryPages") instanceof Plugin ? true : false;
|
||||
&& Bukkit.getPluginManager().getPlugin("InventoryPages") instanceof Plugin;
|
||||
|
||||
hookMinepacks = getConfig().getBoolean("hook-minepacks")
|
||||
&& Bukkit.getPluginManager().getPlugin("Minepacks") instanceof MinepacksPlugin ? true : false;
|
||||
&& Bukkit.getPluginManager().getPlugin("Minepacks") instanceof MinepacksPlugin;
|
||||
|
||||
saveDefaultCategories();
|
||||
|
||||
@ -521,7 +516,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
perPlayerSettings = new HashMap<String,ChestSortPlayerSetting>();
|
||||
perPlayerSettings = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,20 +15,20 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class ChestSortSettingsGUI implements Listener {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
|
||||
public static int slotMiddleClick = 1;
|
||||
public static int slotShiftClick = 3 ;
|
||||
public static int slotDoubleClick = 5 ;
|
||||
public static int slotShiftRightClick = 7 ;
|
||||
public static int slotLeftClick = 2+18;
|
||||
public static int slotRightClick = 6+18;
|
||||
public static final int slotMiddleClick = 1;
|
||||
public static final int slotShiftClick = 3 ;
|
||||
public static final int slotDoubleClick = 5 ;
|
||||
public static final int slotShiftRightClick = 7 ;
|
||||
public static final int slotLeftClick = 2+18;
|
||||
public static final int slotRightClick = 6+18;
|
||||
|
||||
final static Material red = Material.REDSTONE_BLOCK;
|
||||
final static Material green = Material.EMERALD_BLOCK;
|
||||
|
||||
enum Hotkey {
|
||||
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick, LeftClick, RightClick;
|
||||
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick, LeftClick, RightClick
|
||||
}
|
||||
|
||||
ChestSortSettingsGUI(ChestSortPlugin plugin) {
|
||||
@ -95,13 +95,12 @@ public class ChestSortSettingsGUI implements Listener {
|
||||
}
|
||||
|
||||
Inventory createGUI(String name, Player inventoryHolder) {
|
||||
Inventory inventory = Bukkit.createInventory(inventoryHolder, InventoryType.CHEST, name);
|
||||
return inventory;
|
||||
return Bukkit.createInventory(inventoryHolder, InventoryType.CHEST, name);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onGUIInteract(InventoryClickEvent event) {
|
||||
if(plugin.hotkeyGUI==false) {
|
||||
if(!plugin.hotkeyGUI) {
|
||||
return;
|
||||
}
|
||||
if(!(event.getWhoClicked() instanceof Player)) {
|
||||
@ -131,28 +130,22 @@ public class ChestSortSettingsGUI implements Listener {
|
||||
if(event.getSlot() == ChestSortSettingsGUI.slotMiddleClick) {
|
||||
setting.toggleMiddleClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
}
|
||||
else if(event.getSlot() == ChestSortSettingsGUI.slotShiftClick) {
|
||||
setting.toggleShiftClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
} else if(event.getSlot() == ChestSortSettingsGUI.slotDoubleClick) {
|
||||
setting.toggleDoubleClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
} else if(event.getSlot() == ChestSortSettingsGUI.slotShiftRightClick) {
|
||||
setting.toggleShiftRightClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
} else if(event.getSlot() == ChestSortSettingsGUI.slotLeftClick) {
|
||||
setting.toggleLeftClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
} else if(event.getSlot() == ChestSortSettingsGUI.slotRightClick) {
|
||||
setting.toggleRightClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class ChestSortTabCompleter implements TabCompleter {
|
||||
static final String[] invsortOptions = { "toggle","on","off","all", "hotbar", "inv" };
|
||||
|
||||
private List<String> getMatchingOptions(String entered, String[] options) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
for(String option : options) {
|
||||
if(option.toLowerCase().startsWith(entered.toLowerCase())) {
|
||||
@ -36,7 +36,7 @@ public class ChestSortTabCompleter implements TabCompleter {
|
||||
if(command.getName().equalsIgnoreCase("invsort")) {
|
||||
return getMatchingOptions(entered,invsortOptions);
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import de.jeff_media.ChestSort.ChestSortPlugin;
|
||||
|
||||
public class CrackShotHook {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
CSUtility crackShotUtility = null;
|
||||
|
||||
public CrackShotHook(ChestSortPlugin plugin) {
|
||||
@ -22,7 +22,7 @@ public class CrackShotHook {
|
||||
|
||||
// Will return when not a weapon
|
||||
public String getCrackShotWeaponName(ItemStack item) {
|
||||
if(crackShotUtility == null || plugin.hookCrackShot==false) {
|
||||
if(crackShotUtility == null || !plugin.hookCrackShot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class InventoryPagesHook {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
YamlConfiguration inventoryPagesConfig;
|
||||
|
||||
int prevSlot, nextSlot;
|
||||
@ -63,26 +63,20 @@ public class InventoryPagesHook {
|
||||
//System.out.println("Checking if slot " + slot + " "+ item.toString() + " is button");
|
||||
|
||||
// When using &f as color, we manually have to add this to the string because it gets removed by InventoryPages
|
||||
if(prevName.startsWith("§f")) prevName = prevName.substring(2,prevName.length());
|
||||
if(nextName.startsWith("§f")) nextName = nextName.substring(2,nextName.length());
|
||||
if(noPageName.startsWith("§f")) noPageName = noPageName.substring(2,noPageName.length());
|
||||
if(prevName.startsWith("§f")) prevName = prevName.substring(2);
|
||||
if(nextName.startsWith("§f")) nextName = nextName.substring(2);
|
||||
if(noPageName.startsWith("§f")) noPageName = noPageName.substring(2);
|
||||
|
||||
if(slot == prevSlot ) {
|
||||
if(item.getType() == prevMat && (item.getItemMeta().getDisplayName().equals(prevName))) {
|
||||
return true;
|
||||
} else if(item.getType() == noPageMat && item.getItemMeta().getDisplayName().equals(noPageName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else return item.getType() == noPageMat && item.getItemMeta().getDisplayName().equals(noPageName);
|
||||
}
|
||||
|
||||
if(slot == nextSlot ) {
|
||||
if(item.getType() == nextMat && item.getItemMeta().getDisplayName().equals(nextName)) {
|
||||
return true;
|
||||
} else if(item.getType() == noPageMat && item.getItemMeta().getDisplayName().equals(noPageName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else return item.getType() == noPageMat && item.getItemMeta().getDisplayName().equals(noPageName);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -11,7 +11,7 @@ import de.jeff_media.ChestSort.ChestSortPlugin;
|
||||
|
||||
public class MinepacksHook {
|
||||
|
||||
ChestSortPlugin plugin;
|
||||
final ChestSortPlugin plugin;
|
||||
MinepacksPlugin minepacks = null;
|
||||
|
||||
public MinepacksHook(ChestSortPlugin plugin) {
|
||||
@ -44,13 +44,9 @@ public class MinepacksHook {
|
||||
if(minepacks == null) return false;
|
||||
|
||||
if( inv.getHolder() == null) return false;
|
||||
|
||||
if(inv.getHolder() instanceof Backpack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
return inv.getHolder() instanceof Backpack;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package de.jeff_media.ChestSort.utils;
|
||||
|
||||
|
||||
public class CategoryLinePair {
|
||||
String categoryName;
|
||||
String formattedPosition;
|
||||
final String categoryName;
|
||||
final String formattedPosition;
|
||||
boolean sticky = false;
|
||||
short position;
|
||||
final short position;
|
||||
|
||||
public CategoryLinePair(String categoryName,short position) {
|
||||
this(categoryName,position,false);
|
||||
|
@ -21,10 +21,7 @@ public class LlamaUtils {
|
||||
}
|
||||
|
||||
public static boolean belongsToLlama(Inventory inv) {
|
||||
if(inv != null && inv.getHolder() != null && inv.getHolder().getClass().getName().endsWith("CraftLlama")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return inv != null && inv.getHolder() != null && inv.getHolder().getClass().getName().endsWith("CraftLlama");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package de.jeff_media.ChestSort.utils;
|
||||
|
||||
public class TypeMatchPositionPair {
|
||||
|
||||
String typeMatch;
|
||||
String formattedPosition;
|
||||
final String typeMatch;
|
||||
final String formattedPosition;
|
||||
boolean sticky=false;
|
||||
|
||||
public String getTypeMatch() {
|
||||
@ -23,7 +23,7 @@ public class TypeMatchPositionPair {
|
||||
return formattedPosition;
|
||||
}
|
||||
|
||||
short position;
|
||||
final short position;
|
||||
|
||||
public TypeMatchPositionPair(String typeMatch,short position) {
|
||||
this(typeMatch,position,false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
main: de.jeff_media.ChestSort.ChestSortPlugin
|
||||
name: ChestSort
|
||||
version: 8.11.0
|
||||
api-version: 1.13
|
||||
version: 8.11.1
|
||||
api-version: "1.13"
|
||||
description: Allows automatic chest sorting
|
||||
author: mfnalex
|
||||
website: https://www.chestsort.de
|
||||
@ -12,12 +12,21 @@ softdepend: [CrackShot,InventoryPages,Minepacks]
|
||||
commands:
|
||||
chestsort:
|
||||
description: Toggle automatic chest sorting.
|
||||
usage: /<command> [on|off|toggle]
|
||||
usage: |
|
||||
/<command> -- Toggles automatic chest sorting
|
||||
/<command> on|off -- Enables/disabled automatic chest sorting
|
||||
/<command> hotkeys -- Opens hotkeys GUI to enable/disable hotkeys
|
||||
/<command> reload -- Reloads config
|
||||
aliases: sort
|
||||
permission: chestsort.use
|
||||
invsort:
|
||||
description: Toggle automatic inventory sorting or sorts the player's inventory. When no option is specified, only the regular inventory (excluding the hotbar) is sorted.
|
||||
usage: /<command> [on|off|toggle|inv|hotbar|all]
|
||||
usage: |
|
||||
/<command> toggle -- Toggles automatic inventory sorting
|
||||
/<command> on|off -- Enables/disables automatic inventory sorting
|
||||
/<command> inv -- Sorts your inventory
|
||||
/<command> hotbar -- Sorts your hotbar
|
||||
/<command> all -- Sorts your inventory and hotbar
|
||||
aliases: [isort,inventorysort]
|
||||
permission: chestsort.use.inventory
|
||||
permissions:
|
||||
|
Loading…
Reference in New Issue
Block a user