8.12.0 release

This commit is contained in:
mfnalex 2020-06-25 01:48:11 +02:00
parent 5b16c3870d
commit d478be13ea
9 changed files with 33 additions and 25 deletions

View File

@ -1,5 +1,7 @@
# Changelog
## 8.11.1-SNAPSHOT
## 8.12.0
- Changed name of command /chestsort to /sort. You can still use /chestsort though.
- Fixed weird config updater problem on systems that don't properly support UTF-8 (like Windows)
- Improved help messages
- Huge code cleanup
- Improved performance by caching Reflection checks in the Minepacks hook

View File

@ -9,7 +9,7 @@
<name>JeffChestSort</name>
<url>https://www.chestsort.de</url>
<description>Automatically sorts your chests!</description>
<version>8.11.1-SNAPSHOT</version>
<version>8.12.0</version>
<packaging>jar</packaging>
<properties>
@ -132,7 +132,7 @@
<dependency>
<groupId>de.jeff_media</groupId>
<artifactId>PluginUpdateChecker</artifactId>
<version>[1.2,</version>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -20,7 +20,7 @@ public class ChestSortChestSortCommand implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNull String label, String[] args) {
// This command toggles automatic chest sorting for the player that runs the command
if (!command.getName().equalsIgnoreCase("chestsort")) {
if (!command.getName().equalsIgnoreCase("sort")) {
return false;
}

View File

@ -1,9 +1,8 @@
package de.jeff_media.ChestSort;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
@ -36,6 +35,12 @@ public class ChestSortConfigUpdater {
plugin.getConfig().set("sorting-hotkeys.shift-right-click", plugin.getConfig().getBoolean("hotkeys.shift-right-click"));
}
try {
Files.deleteIfExists(new File(plugin.getDataFolder().getAbsolutePath()+File.separator+"config.old.yml").toPath());
} catch (IOException e) {
}
if (plugin.debug)
plugin.getLogger().info("rename config.yml -> config.old.yml");
Utils.renameFileInPluginDir(plugin, "config.yml", "config.old.yml");
@ -44,7 +49,7 @@ public class ChestSortConfigUpdater {
plugin.saveDefaultConfig();
File oldConfigFile = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "config.old.yml");
FileConfiguration oldConfig = new YamlConfiguration();
FileConfiguration oldConfig = YamlConfiguration.loadConfiguration(oldConfigFile);
try {
oldConfig.load(oldConfigFile);
@ -59,7 +64,7 @@ public class ChestSortConfigUpdater {
try {
Scanner scanner = new Scanner(
new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "config.yml"));
new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "config.yml"),"UTF-8");
while (scanner.hasNextLine()) {
linesInDefaultConfig.add(scanner.nextLine() + "");
}
@ -117,10 +122,10 @@ public class ChestSortConfigUpdater {
newLines.add(newline);
}
FileWriter fw;
BufferedWriter fw;
String[] linesArray = newLines.toArray(new String[linesInDefaultConfig.size()]);
try {
fw = new FileWriter(plugin.getDataFolder().getAbsolutePath() + File.separator + "config.yml");
fw = Files.newBufferedWriter(new File(plugin.getDataFolder().getAbsolutePath(),"config.yml").toPath(), StandardCharsets.UTF_8);
for (String s : linesArray) {
fw.write(s + "\n");
}

View File

@ -37,11 +37,6 @@ public class ChestSortListener implements Listener {
plugin.permissionsHandler.addPermissions(event.getPlayer());
// OPs will get an update notice if a new update is available
if (event.getPlayer().isOp()) {
plugin.updateChecker.sendUpdateMessage(event.getPlayer());
}
// Put player into our perPlayerSettings map
plugin.registerPlayerIfNeeded(event.getPlayer());
@ -479,23 +474,27 @@ public class ChestSortListener implements Listener {
== ChestSortPlayerSetting.DoubleClickType.LEFT_CLICK) {
// Left double click: put everything into destination
plugin.organizer.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), false);
plugin.organizer.sortInventory(e.getInventory());
} else {
// Left single click: put only matching items into destination
plugin.organizer.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory(), true);
}
} else if (e.isRightClick() && setting.rightClick) {
if (setting.getCurrentDoubleClick(plugin, ChestSortPlayerSetting.DoubleClickType.RIGHT_CLICK)
== ChestSortPlayerSetting.DoubleClickType.RIGHT_CLICK) {
// Right double click: put everything into player inventory
plugin.organizer.stuffInventoryIntoAnother(e.getInventory(), p.getInventory(), e.getInventory(), false);
plugin.organizer.sortInventory(p.getInventory(),9,35);
} else {
// Right single click: put only matching items into player inventory
plugin.organizer.stuffInventoryIntoAnother(e.getInventory(), p.getInventory(), e.getInventory(), true);
}
}
//plugin.organizer.sortInventory(e.getInventory());
plugin.organizer.updateInventoryView(e.getInventory());
plugin.organizer.updateInventoryView(p.getInventory());
}

View File

@ -510,6 +510,7 @@ public class ChestSortOrganizer {
// duplication
int currentSlot = startSlot;
for (ItemStack item : tempInventory.getContents()) {
if(item==null) break; // TODO: If there is item loss, change break to continue (should not happen)
while (unsortableSlots.contains(currentSlot) && currentSlot < endSlot) {
currentSlot++;
}

View File

@ -67,7 +67,7 @@ public class ChestSortPlugin extends JavaPlugin {
String sortingMethod;
ArrayList<String> disabledWorlds;
ChestSortAPI api;
final int currentConfigVersion = 33;
final int currentConfigVersion = 34;
boolean usingMatchingConfig = true;
protected boolean debug = false;
boolean verbose = true;
@ -131,6 +131,7 @@ public class ChestSortPlugin extends JavaPlugin {
// This saves the config.yml included in the .jar file, but it will not
// overwrite an existing config.yml
this.saveDefaultConfig();
reloadConfig();
// Load disabled-worlds. If it does not exist in the config, it returns null.
// That's no problem
@ -451,8 +452,8 @@ public class ChestSortPlugin extends JavaPlugin {
getServer().getPluginManager().registerEvents(settingsGUI, this);
ChestSortChestSortCommand chestsortCommandExecutor = new ChestSortChestSortCommand(this);
ChestSortTabCompleter tabCompleter = new ChestSortTabCompleter();
this.getCommand("chestsort").setExecutor(chestsortCommandExecutor);
this.getCommand("chestsort").setTabCompleter(tabCompleter);
this.getCommand("sort").setExecutor(chestsortCommandExecutor);
this.getCommand("sort").setTabCompleter(tabCompleter);
ChestSortInvSortCommand invsortCommandExecutor = new ChestSortInvSortCommand(this);
this.getCommand("invsort").setExecutor(invsortCommandExecutor);
this.getCommand("invsort").setTabCompleter(tabCompleter);

View File

@ -573,4 +573,4 @@ debug: false
# Please DO NOT change the following line manually!
# It is used by the automatic config updater.
config-version: 33
config-version: 34

View File

@ -1,6 +1,6 @@
main: de.jeff_media.ChestSort.ChestSortPlugin
name: ChestSort
version: 8.11.1-SNAPSHOT
version: 8.12.0
api-version: "1.13"
description: Allows automatic chest sorting
author: mfnalex
@ -10,14 +10,14 @@ database: false
loadbefore: [InvUnload]
softdepend: [CrackShot,InventoryPages,Minepacks]
commands:
chestsort:
sort:
description: Toggle automatic chest sorting.
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
aliases: chestsort
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.