mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2025-01-06 00:17:52 +01:00
8.0-pre1 update
This commit is contained in:
parent
fe9fca02ea
commit
df15d83a1a
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 8.0
|
||||
- Added two new hotkeys (disabled by default): Left-Click outside of chest's inventory will load all your stuff except hotbar into the chest, Right-Click outside of the chest's inventory will unload the chest into your inventory. The hotkeys can be enabled using /chestsort hotkeys and need the chestsort.use permission
|
||||
- Added debug and dump option to config (you will probably not need those)
|
||||
- Note: This version includes two new messages, so please send me your new translations :)
|
||||
|
||||
## 7.7-pre1
|
||||
- Moved /invsort command to separate class
|
||||
- Moved registerPlayerIfNeeded from Listener to main class
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.jeffclan</groupId>
|
||||
<artifactId>JeffChestSort</artifactId>
|
||||
<version>7.7-pre1</version>
|
||||
<version>8.0-pre1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>JeffChestSort</name>
|
||||
|
@ -0,0 +1,43 @@
|
||||
package de.jeffclan.JeffChestSort;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
public class JeffChestSortAdditionalHotkeyListener implements Listener {
|
||||
|
||||
JeffChestSortPlugin plugin;
|
||||
|
||||
public JeffChestSortAdditionalHotkeyListener(JeffChestSortPlugin jeffChestSortPlugin) {
|
||||
this.plugin = jeffChestSortPlugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClickEvent(InventoryClickEvent e) {
|
||||
if(!(e.getWhoClicked() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
// Only continue if clicked outside of the chest
|
||||
if(e.getClickedInventory()!=null) {
|
||||
return;
|
||||
}
|
||||
if(e.getInventory().getType() != InventoryType.CHEST) {
|
||||
return;
|
||||
}
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
|
||||
if(!p.hasPermission("chestsort.use")) return;
|
||||
|
||||
plugin.registerPlayerIfNeeded(p);
|
||||
JeffChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
|
||||
if(e.isLeftClick() && setting.leftClick) {
|
||||
de.jeffclan.utils.InventoryHelper.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory());
|
||||
} else if(e.isRightClick() && setting.rightClick) {
|
||||
de.jeffclan.utils.InventoryHelper.stuffInventoryIntoAnother(e.getInventory(), p.getInventory());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,14 @@ public class JeffChestSortConfigUpdater {
|
||||
// Don't worry! Your changes will be kept
|
||||
|
||||
void updateConfig() {
|
||||
|
||||
// hotkeys has been renamed to sorting-hotkeys
|
||||
if(plugin.getConfig().isSet("hotkeys.middle-click")) {
|
||||
plugin.getConfig().set("sorting-hotkeys.middle-click", plugin.getConfig().getBoolean("hotkeys.middle-click"));
|
||||
plugin.getConfig().set("sorting-hotkeys.shift-click", plugin.getConfig().getBoolean("hotkeys.shift-click"));
|
||||
plugin.getConfig().set("sorting-hotkeys.double-click", plugin.getConfig().getBoolean("hotkeys.double-click"));
|
||||
plugin.getConfig().set("sorting-hotkeys.shift-right-click", plugin.getConfig().getBoolean("hotkeys.shift-right-click"));
|
||||
}
|
||||
|
||||
if (plugin.debug)
|
||||
plugin.getLogger().info("rename config.yml -> config.old.yml");
|
||||
@ -73,14 +81,20 @@ public class JeffChestSortConfigUpdater {
|
||||
newLines.add("- " + disabledWorld);
|
||||
}
|
||||
}
|
||||
} else if (line.startsWith("hotkeys:")) {
|
||||
} else if (line.startsWith("sorting-hotkeys:") || line.startsWith("additional-hotkeys:")) {
|
||||
// dont replace hotkeys root part
|
||||
} else if (line.startsWith(" middle-click:")) {
|
||||
newline = " middle-click: " + plugin.getConfig().getBoolean("hotkeys.middle-click");
|
||||
newline = " middle-click: " + plugin.getConfig().getBoolean("sorting-hotkeys.middle-click");
|
||||
} else if (line.startsWith(" shift-click:")) {
|
||||
newline = " shift-click: " + plugin.getConfig().getBoolean("hotkeys.shift-click");
|
||||
newline = " shift-click: " + plugin.getConfig().getBoolean("sorting-hotkeys.shift-click");
|
||||
} else if (line.startsWith(" double-click:")) {
|
||||
newline = " double-click: " + plugin.getConfig().getBoolean("hotkeys.double-click");
|
||||
newline = " double-click: " + plugin.getConfig().getBoolean("sorting-hotkeys.double-click");
|
||||
} else if (line.startsWith(" shift-right-click:")) {
|
||||
newline = " shift-right-click: " + plugin.getConfig().getBoolean("sorting-hotkeys.shift-right-click");
|
||||
} else if (line.startsWith(" left-click:")) {
|
||||
newline = " left-click: " + plugin.getConfig().getBoolean("additional-hotkeys.left-click");
|
||||
} else if (line.startsWith(" right-click:")) {
|
||||
newline = " right-click: " + plugin.getConfig().getBoolean("additional-hotkeys.right-click");
|
||||
} else {
|
||||
for (String node : oldValues.keySet()) {
|
||||
if (line.startsWith(node + ":")) {
|
||||
|
@ -343,7 +343,7 @@ public class JeffChestSortListener implements Listener {
|
||||
}
|
||||
|
||||
plugin.organizer.sortInventory(event.getClickedInventory());
|
||||
updateInventoryView(event);
|
||||
de.jeffclan.utils.InventoryHelper.updateInventoryView(event);
|
||||
return;
|
||||
} else if(holder instanceof Player) {
|
||||
|
||||
@ -353,25 +353,18 @@ public class JeffChestSortListener implements Listener {
|
||||
|
||||
if(event.getSlotType() == SlotType.QUICKBAR) {
|
||||
plugin.organizer.sortInventory(p.getInventory(),0,8);
|
||||
updateInventoryView(event);
|
||||
de.jeffclan.utils.InventoryHelper.updateInventoryView(event);
|
||||
return;
|
||||
}
|
||||
else if(event.getSlotType() == SlotType.CONTAINER) {
|
||||
plugin.organizer.sortInventory(p.getInventory(),9,35);
|
||||
updateInventoryView(event);
|
||||
de.jeffclan.utils.InventoryHelper.updateInventoryView(event);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void updateInventoryView(InventoryClickEvent event) {
|
||||
for(HumanEntity viewer : event.getViewers()) {
|
||||
if(viewer instanceof Player) {
|
||||
Player playerViewer = (Player) viewer;
|
||||
playerViewer.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class JeffChestSortMessages {
|
||||
|
||||
final String MSG_GUI_ENABLED, MSG_GUI_DISABLED;
|
||||
|
||||
final String MSG_GUI_MIDDLECLICK, MSG_GUI_SHIFTCLICK, MSG_GUI_DOUBLECLICK, MSG_GUI_SHIFTRIGHTCLICK;
|
||||
final String MSG_GUI_MIDDLECLICK, MSG_GUI_SHIFTCLICK, MSG_GUI_DOUBLECLICK, MSG_GUI_SHIFTRIGHTCLICK, MSG_GUI_LEFTCLICK, MSG_GUI_RIGHTCLICK;
|
||||
|
||||
JeffChestSortMessages(JeffChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -68,6 +68,10 @@ public class JeffChestSortMessages {
|
||||
MSG_GUI_SHIFTRIGHTCLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
|
||||
.getString("message-gui-shift-right-click","Shift + Right-Click"));
|
||||
|
||||
MSG_GUI_LEFTCLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("message-gui-left-click","Fill Chest (Left-Click)"));
|
||||
|
||||
MSG_GUI_RIGHTCLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("message-gui-right-click","Unload Chest (Right-Click)"));
|
||||
|
||||
//MSG_ERR_HOTKEYSDISABLED = ChatColor.RED + "[ChestSort] Hotkeys are only available for Minecraft 1.9 and later.";
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class JeffChestSortPlayerSetting {
|
||||
boolean invSortingEnabled;
|
||||
|
||||
// Hotkey settings
|
||||
boolean middleClick, shiftClick, doubleClick, shiftRightClick;
|
||||
boolean middleClick, shiftClick, doubleClick, shiftRightClick, leftClick, rightClick;
|
||||
|
||||
Inventory guiInventory = null;
|
||||
|
||||
@ -26,13 +26,15 @@ public class JeffChestSortPlayerSetting {
|
||||
// Do we have to save these settings?
|
||||
boolean changed = false;
|
||||
|
||||
JeffChestSortPlayerSetting(boolean sortingEnabled, boolean invSortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick, boolean changed) {
|
||||
JeffChestSortPlayerSetting(boolean sortingEnabled, boolean invSortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick, boolean leftClick, boolean rightClick, boolean changed) {
|
||||
this.sortingEnabled = sortingEnabled;
|
||||
this.middleClick = middleClick;
|
||||
this.shiftClick = shiftClick;
|
||||
this.doubleClick = doubleClick;
|
||||
this.shiftRightClick = shiftRightClick;
|
||||
this.invSortingEnabled = invSortingEnabled;
|
||||
this.leftClick = leftClick;
|
||||
this.rightClick = rightClick;
|
||||
this.changed = changed;
|
||||
}
|
||||
|
||||
@ -52,6 +54,14 @@ public class JeffChestSortPlayerSetting {
|
||||
shiftRightClick = !shiftRightClick;
|
||||
changed = true;
|
||||
}
|
||||
void toggleLeftClick() {
|
||||
leftClick = !leftClick;
|
||||
changed = true;
|
||||
}
|
||||
void toggleRightClick() {
|
||||
rightClick = !rightClick;
|
||||
changed = true;
|
||||
}
|
||||
void enableChestSorting() {
|
||||
sortingEnabled = true;
|
||||
changed = true;
|
||||
|
@ -54,16 +54,16 @@ import de.jeffclan.utils.Utils;
|
||||
|
||||
public class JeffChestSortPlugin extends JavaPlugin {
|
||||
|
||||
// We need a map to store each player's settings
|
||||
Map<String, JeffChestSortPlayerSetting> perPlayerSettings = new HashMap<String, JeffChestSortPlayerSetting>();
|
||||
JeffChestSortMessages messages;
|
||||
JeffChestSortOrganizer organizer;
|
||||
JeffChestSortUpdateChecker updateChecker;
|
||||
JeffChestSortListener listener;
|
||||
JeffChestSortAdditionalHotkeyListener additionalHotkeys;
|
||||
JeffChestSortSettingsGUI settingsGUI;
|
||||
String sortingMethod;
|
||||
ArrayList<String> disabledWorlds;
|
||||
int currentConfigVersion = 22;
|
||||
int currentConfigVersion = 26;
|
||||
boolean usingMatchingConfig = true;
|
||||
protected boolean debug = false;
|
||||
boolean verbose = true;
|
||||
@ -72,16 +72,13 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
public boolean hookCrackShot = false;
|
||||
public boolean hookInventoryPages = false;
|
||||
|
||||
private long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours (if you never
|
||||
// restart your server)
|
||||
private long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours
|
||||
|
||||
String mcVersion; // 1.13.2 = 1_13_R2
|
||||
// 1.14.4 = 1_14_R1
|
||||
// 1.8.0 = 1_8_R1
|
||||
int mcMinorVersion; // 14 for 1.14, 13 for 1.13, ...
|
||||
|
||||
|
||||
|
||||
// Public API method to sort any given inventory
|
||||
public void sortInventory(Inventory inv) {
|
||||
this.organizer.sortInventory(inv);
|
||||
@ -91,6 +88,16 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
public void sortInventory(Inventory inv, int startSlot, int endSlot) {
|
||||
this.organizer.sortInventory(inv, startSlot, endSlot);
|
||||
}
|
||||
|
||||
// Check whether sorting is enabled for a player. Public because it can be
|
||||
// accessed as part of the API
|
||||
public boolean sortingEnabled(Player p) {
|
||||
if (perPlayerSettings == null) {
|
||||
perPlayerSettings = new HashMap<String, JeffChestSortPlayerSetting>();
|
||||
}
|
||||
listener.plugin.registerPlayerIfNeeded(p);
|
||||
return perPlayerSettings.get(p.getUniqueId().toString()).sortingEnabled;
|
||||
}
|
||||
|
||||
// Creates the default configuration file
|
||||
// Also checks the config-version of an already existing file. If the existing
|
||||
@ -151,10 +158,12 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
getConfig().addDefault("auto-generate-category-files", true);
|
||||
getConfig().addDefault("sort-time", "close");
|
||||
getConfig().addDefault("allow-hotkeys", true);
|
||||
getConfig().addDefault("hotkeys.middle-click", true);
|
||||
getConfig().addDefault("hotkeys.shift-click", true);
|
||||
getConfig().addDefault("hotkeys.double-click", true);
|
||||
getConfig().addDefault("hotkeys.shift-right-click", true);
|
||||
getConfig().addDefault("sorting-hotkeys.middle-click", true);
|
||||
getConfig().addDefault("sorting-hotkeys.shift-click", true);
|
||||
getConfig().addDefault("sorting-hotkeys.double-click", true);
|
||||
getConfig().addDefault("sorting-hotkeys.shift-right-click", true);
|
||||
getConfig().addDefault("additional-hotkeys.left-click", false);
|
||||
getConfig().addDefault("additional-hotkeys.right-click", false);
|
||||
getConfig().addDefault("dump", false);
|
||||
|
||||
getConfig().addDefault("hook-crackshot", true);
|
||||
@ -245,14 +254,14 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
// the Organizer to sort inventories when a player closes a chest, shulkerbox or
|
||||
// barrel inventory
|
||||
listener = new JeffChestSortListener(this);
|
||||
|
||||
//hotbarRefiller = new JeffChestSortHotbarRefiller(this);
|
||||
additionalHotkeys = new JeffChestSortAdditionalHotkeyListener(this);
|
||||
|
||||
// The sorting method will determine how stuff is sorted
|
||||
sortingMethod = getConfig().getString("sorting-method");
|
||||
|
||||
// Register the events for our Listener
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
getServer().getPluginManager().registerEvents(additionalHotkeys, this);
|
||||
|
||||
// Register events for the GUI interaction
|
||||
getServer().getPluginManager().registerEvents(settingsGUI, this);
|
||||
@ -275,10 +284,15 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
getLogger().info("Sort time: " + getConfig().getString("sort-time"));
|
||||
getLogger().info("Allow hotkeys: " + getConfig().getBoolean("allow-hotkeys"));
|
||||
if(getConfig().getBoolean("allow-hotkeys")) {
|
||||
getLogger().info("|- Middle-Click: " + getConfig().getBoolean("hotkeys.middle-click"));
|
||||
getLogger().info("|- Shift-Click: " + getConfig().getBoolean("hotkeys.shift-click"));
|
||||
getLogger().info("|- Double-Click: " + getConfig().getBoolean("hotkeys.double-click"));
|
||||
getLogger().info("|- Shift-Right-Click: " + getConfig().getBoolean("hotkeys.shift-right-click"));
|
||||
getLogger().info("Hotkeys enabled by default:");
|
||||
getLogger().info("- Sorting hotkeys:");
|
||||
getLogger().info(" |- Middle-Click: " + getConfig().getBoolean("sorting-hotkeys.middle-click"));
|
||||
getLogger().info(" |- Shift-Click: " + getConfig().getBoolean("sorting-hotkeys.shift-click"));
|
||||
getLogger().info(" |- Double-Click: " + getConfig().getBoolean("sorting-hotkeys.double-click"));
|
||||
getLogger().info(" |- Shift-Right-Click: " + getConfig().getBoolean("sorting-hotkeys.shift-right-click"));
|
||||
getLogger().info("- Additional hotkeys:");
|
||||
getLogger().info(" |- Left-Click: " + getConfig().getBoolean("additional-hotkeys.left-click"));
|
||||
getLogger().info(" |- Right-Click: " + getConfig().getBoolean("additional-hotkeys.right-click"));
|
||||
}
|
||||
getLogger().info("Check for updates: " + getConfig().getString("check-for-updates"));
|
||||
getLogger().info("Categories: " + getCategoryList());
|
||||
@ -354,13 +368,17 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
bStats.addCustomChart(new Metrics.SimplePie("allow_hotkeys",
|
||||
() -> Boolean.toString(getConfig().getBoolean("allow-hotkeys"))));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("hotkey_middle_click",
|
||||
() -> Boolean.toString(getConfig().getBoolean("hotkeys.middle-click"))));
|
||||
() -> Boolean.toString(getConfig().getBoolean("sorting-hotkeys.middle-click"))));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("hotkey_shift_click",
|
||||
() -> Boolean.toString(getConfig().getBoolean("hotkeys.shift-click"))));
|
||||
() -> Boolean.toString(getConfig().getBoolean("sorting-hotkeys.shift-click"))));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("hotkey_double_click",
|
||||
() -> Boolean.toString(getConfig().getBoolean("hotkeys.double-click"))));
|
||||
() -> Boolean.toString(getConfig().getBoolean("sorting-hotkeys.double-click"))));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("hotkey_shift_right_click",
|
||||
() -> Boolean.toString(getConfig().getBoolean("hotkeys.shift-right-click"))));
|
||||
() -> Boolean.toString(getConfig().getBoolean("sorting-hotkeys.shift-right-click"))));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("hotkey_left_click",
|
||||
() -> Boolean.toString(getConfig().getBoolean("additional-hotkeys.left-click"))));
|
||||
bStats.addCustomChart(new Metrics.SimplePie("hotkey_right_click",
|
||||
() -> Boolean.toString(getConfig().getBoolean("additional-hotkeys.right-click"))));
|
||||
|
||||
}
|
||||
|
||||
@ -444,24 +462,6 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether sorting is enabled for a player. Public because it can be
|
||||
// accessed as part of the API
|
||||
public boolean sortingEnabled(Player p) {
|
||||
|
||||
// The following is for all the lazy server admins who use /reload instead of
|
||||
// properly restarting their
|
||||
// server ;) I am sometimes getting stacktraces although it is clearly stated
|
||||
// that /reload is NOT
|
||||
// supported. So, here is a quick fix
|
||||
if (perPlayerSettings == null) {
|
||||
perPlayerSettings = new HashMap<String, JeffChestSortPlayerSetting>();
|
||||
}
|
||||
listener.plugin.registerPlayerIfNeeded(p);
|
||||
// End of quick fix
|
||||
|
||||
return perPlayerSettings.get(p.getUniqueId().toString()).sortingEnabled;
|
||||
}
|
||||
|
||||
// Unregister a player and save their settings in the playerdata folder
|
||||
void unregisterPlayer(Player p) {
|
||||
// File will be named by the player's uuid. This will prevent problems on player
|
||||
@ -484,6 +484,8 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
playerConfig.set("shiftClick",setting.shiftClick);
|
||||
playerConfig.set("doubleClick",setting.doubleClick);
|
||||
playerConfig.set("shiftRightClick",setting.shiftRightClick);
|
||||
playerConfig.set("leftClick",setting.leftClick);
|
||||
playerConfig.set("rightClick",setting.rightClick);
|
||||
try {
|
||||
// Only saved if the config has been changed
|
||||
if(setting.changed) {
|
||||
@ -526,14 +528,16 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
YamlConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile);
|
||||
|
||||
playerConfig.addDefault("invSortingEnabled", getConfig().getBoolean("inv-sorting-enabled-by-default"));
|
||||
playerConfig.addDefault("middleClick", getConfig().getBoolean("hotkeys.middle-click"));
|
||||
playerConfig.addDefault("shiftClick", getConfig().getBoolean("hotkeys.shift-click"));
|
||||
playerConfig.addDefault("doubleClick", getConfig().getBoolean("hotkeys.double-click"));
|
||||
playerConfig.addDefault("shiftRightClick", getConfig().getBoolean("hotkeys.shift-right-click"));
|
||||
playerConfig.addDefault("middleClick", getConfig().getBoolean("sorting-hotkeys.middle-click"));
|
||||
playerConfig.addDefault("shiftClick", getConfig().getBoolean("sorting-hotkeys.shift-click"));
|
||||
playerConfig.addDefault("doubleClick", getConfig().getBoolean("sorting-hotkeys.double-click"));
|
||||
playerConfig.addDefault("shiftRightClick", getConfig().getBoolean("sorting-hotkeys.shift-right-click"));
|
||||
playerConfig.addDefault("leftClick", getConfig().getBoolean("additional-hotkeys.left-click"));
|
||||
playerConfig.addDefault("rightClick", getConfig().getBoolean("additional-hotkeys.right-click"));
|
||||
|
||||
boolean activeForThisPlayer = false;
|
||||
boolean invActiveForThisPlayer = false;
|
||||
boolean middleClick, shiftClick, doubleClick, shiftRightClick;
|
||||
boolean middleClick, shiftClick, doubleClick, shiftRightClick, leftClick, rightClick;
|
||||
boolean changed = false;
|
||||
|
||||
if (!playerFile.exists()) {
|
||||
@ -541,10 +545,12 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
// default value
|
||||
activeForThisPlayer = getConfig().getBoolean("sorting-enabled-by-default");
|
||||
invActiveForThisPlayer = getConfig().getBoolean("inv-sorting-enabled-by-default");
|
||||
middleClick = getConfig().getBoolean("hotkeys.middle-click");
|
||||
shiftClick = getConfig().getBoolean("hotkeys.shift-click");
|
||||
doubleClick = getConfig().getBoolean("hotkeys.double-click");
|
||||
shiftRightClick = getConfig().getBoolean("hotkeys.shift-right-click");
|
||||
middleClick = getConfig().getBoolean("sorting-hotkeys.middle-click");
|
||||
shiftClick = getConfig().getBoolean("sorting-hotkeys.shift-click");
|
||||
doubleClick = getConfig().getBoolean("sorting-hotkeys.double-click");
|
||||
shiftRightClick = getConfig().getBoolean("sorting-hotkeys.shift-right-click");
|
||||
leftClick = getConfig().getBoolean("additional-hotkeys.left-click");
|
||||
rightClick = getConfig().getBoolean("additional-hotkeys.right-click");
|
||||
|
||||
if(debug) {
|
||||
getLogger().info("Player "+p.getName()+" does not have player settings yet, using default values.");
|
||||
@ -555,14 +561,16 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
} else {
|
||||
// If the file exists, check if the player has sorting enabled
|
||||
activeForThisPlayer = playerConfig.getBoolean("sortingEnabled");
|
||||
invActiveForThisPlayer = playerConfig.getBoolean("invSortingEnabled");
|
||||
invActiveForThisPlayer = playerConfig.getBoolean("invSortingEnabled",getConfig().getBoolean("inv-sorting-enabled-by-default"));
|
||||
middleClick = playerConfig.getBoolean("middleClick");
|
||||
shiftClick = playerConfig.getBoolean("shiftClick");
|
||||
doubleClick = playerConfig.getBoolean("doubleClick");
|
||||
shiftRightClick = playerConfig.getBoolean("shiftRightClick");
|
||||
leftClick = playerConfig.getBoolean("leftClick",getConfig().getBoolean("additional-hotkeys.left-click"));
|
||||
rightClick = playerConfig.getBoolean("rightClick",getConfig().getBoolean("additional-hotkeys.right-click"));
|
||||
}
|
||||
|
||||
JeffChestSortPlayerSetting newSettings = new JeffChestSortPlayerSetting(activeForThisPlayer,invActiveForThisPlayer,middleClick,shiftClick,doubleClick,shiftRightClick,changed);
|
||||
JeffChestSortPlayerSetting newSettings = new JeffChestSortPlayerSetting(activeForThisPlayer,invActiveForThisPlayer,middleClick,shiftClick,doubleClick,shiftRightClick,leftClick,rightClick,changed);
|
||||
|
||||
// when "show-message-again-after-logout" is enabled, we don't care if the
|
||||
// player already saw the message
|
||||
|
@ -17,16 +17,18 @@ public class JeffChestSortSettingsGUI implements Listener {
|
||||
|
||||
JeffChestSortPlugin plugin;
|
||||
|
||||
public static int slotMiddleClick = 1 + 9;
|
||||
public static int slotShiftClick = 3 + 9;
|
||||
public static int slotDoubleClick = 5 + 9;
|
||||
public static int slotShiftRightClick = 7 + 9;
|
||||
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;
|
||||
|
||||
final static Material red = Material.REDSTONE_BLOCK;
|
||||
final static Material green = Material.EMERALD_BLOCK;
|
||||
|
||||
enum Hotkey {
|
||||
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick;
|
||||
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick, LeftClick, RightClick;
|
||||
}
|
||||
|
||||
JeffChestSortSettingsGUI(JeffChestSortPlugin plugin) {
|
||||
@ -61,6 +63,12 @@ public class JeffChestSortSettingsGUI implements Listener {
|
||||
case ShiftRightClick:
|
||||
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_SHIFTRIGHTCLICK + ": " + suffix);
|
||||
break;
|
||||
case LeftClick:
|
||||
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_LEFTCLICK + ": "+ suffix);
|
||||
break;
|
||||
case RightClick:
|
||||
meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_RIGHTCLICK + ": "+ suffix);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -79,6 +87,8 @@ public class JeffChestSortSettingsGUI implements Listener {
|
||||
inventory.setItem(slotShiftClick, getItem(setting.shiftClick,Hotkey.ShiftClick));
|
||||
inventory.setItem(slotDoubleClick, getItem(setting.doubleClick,Hotkey.DoubleClick));
|
||||
inventory.setItem(slotShiftRightClick, getItem(setting.shiftRightClick,Hotkey.ShiftRightClick));
|
||||
inventory.setItem(slotLeftClick, getItem(setting.leftClick,Hotkey.LeftClick));
|
||||
inventory.setItem(slotRightClick, getItem(setting.rightClick,Hotkey.RightClick));
|
||||
|
||||
setting.guiInventory = inventory;
|
||||
player.openInventory(inventory);
|
||||
@ -135,6 +145,14 @@ public class JeffChestSortSettingsGUI implements Listener {
|
||||
setting.toggleShiftRightClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
} else if(event.getSlot() == JeffChestSortSettingsGUI.slotLeftClick) {
|
||||
setting.toggleLeftClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
} else if(event.getSlot() == JeffChestSortSettingsGUI.slotRightClick) {
|
||||
setting.toggleRightClick();
|
||||
plugin.settingsGUI.openGUI(p);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
74
src/main/java/de/jeffclan/utils/InventoryHelper.java
Normal file
74
src/main/java/de/jeffclan/utils/InventoryHelper.java
Normal file
@ -0,0 +1,74 @@
|
||||
package de.jeffclan.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class InventoryHelper {
|
||||
|
||||
private static final int maxInventorySize=54;
|
||||
private static final int playerInvStartSlot=9; // Inclusive
|
||||
private static final int playerInvEndSlot=35; // Inclusive
|
||||
|
||||
public static void updateInventoryView(InventoryClickEvent event) {
|
||||
for(HumanEntity viewer : event.getViewers()) {
|
||||
if(viewer instanceof Player) {
|
||||
Player playerViewer = (Player) viewer;
|
||||
playerViewer.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateInventoryView(Inventory inventory) {
|
||||
for(HumanEntity viewer : inventory.getViewers()) {
|
||||
if(viewer instanceof Player) {
|
||||
Player playerViewer = (Player) viewer;
|
||||
playerViewer.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void stuffInventoryIntoAnother(Inventory source, Inventory destination) {
|
||||
|
||||
ArrayList<ItemStack> leftovers = new ArrayList<ItemStack>();
|
||||
|
||||
for(int i = 0;i<source.getSize();i++) {
|
||||
|
||||
ItemStack current = source.getItem(i);
|
||||
|
||||
if(current == null) continue;
|
||||
|
||||
source.clear(i);
|
||||
HashMap<Integer,ItemStack> currentLeftovers = destination.addItem(current);
|
||||
|
||||
for(ItemStack currentLeftover : currentLeftovers.values()) {
|
||||
leftovers.add(currentLeftover);
|
||||
}
|
||||
}
|
||||
|
||||
source.addItem(leftovers.toArray(new ItemStack[leftovers.size()]));
|
||||
updateInventoryView(destination);
|
||||
updateInventoryView(source);
|
||||
|
||||
}
|
||||
|
||||
public static void stuffPlayerInventoryIntoAnother(PlayerInventory source,
|
||||
Inventory destination) {
|
||||
Inventory temp = Bukkit.createInventory(null, maxInventorySize);
|
||||
for(int i = playerInvStartSlot;i<=playerInvEndSlot;i++) {
|
||||
if(source.getItem(i)==null) continue;
|
||||
temp.addItem(source.getItem(i));
|
||||
source.clear(i);
|
||||
}
|
||||
stuffInventoryIntoAnother(temp,destination);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -67,16 +67,20 @@ auto-generate-category-files: true
|
||||
# Available options: open, close, both
|
||||
sort-time: close
|
||||
|
||||
###################
|
||||
##### Hotkeys #####
|
||||
###################
|
||||
|
||||
# Instead of automatic sorting, you can also use hotkeys (see below)
|
||||
# when using an inventory to have it sorted immediately.
|
||||
# You can disable this by setting this to false.
|
||||
allow-hotkeys: true
|
||||
|
||||
# You can define which hotkeys are enabled by default.
|
||||
# You can define which sorting hotkeys are enabled by default.
|
||||
# Hotkeys that could interfere with Minecraft's normal behaviour (e.g.
|
||||
# shift+left-click) only work on empty slots, so don't worry about them.
|
||||
# Players can also enable/disable all shortcuts individually via /chestsort hotkeys
|
||||
hotkeys:
|
||||
# Players can also enable/disable these shortcuts individually via /chestsort hotkeys
|
||||
sorting-hotkeys:
|
||||
# Use middle click (mousewheel) on ANY inventory slot as hotkey
|
||||
middle-click: true
|
||||
# Use shift + left-click on any EMPTY inventory slot as hotkey
|
||||
@ -86,6 +90,15 @@ hotkeys:
|
||||
# Use shift + right-click on any EMPTY inventory slot as hotkey
|
||||
shift-right-click: true
|
||||
|
||||
# Additionally to sorting hotkeys, you can quickly unload your inventory into a chest and vice versa
|
||||
# using left-click or richt-click outside of a chest's inventory.
|
||||
# Players can also enable/disable these shortcuts individually via /chestsort hotkeys
|
||||
additional-hotkeys:
|
||||
# Use left-click outside inventory to quickly put your inventory (except hotbar) into the chest
|
||||
left-click: false
|
||||
# Use right-click outside inventory to quickly take all items out of the chest and into your inventory
|
||||
right-click: false
|
||||
|
||||
# should we check for updates?
|
||||
# when enabled, a message is printed in the console if a new
|
||||
# version has been found, and OPs will be notified when they join the server
|
||||
@ -174,7 +187,7 @@ hook-inventorypages: true
|
||||
# sort by category, but keep exactly the same order as defined in each category file, then sort any undefined items by name and color
|
||||
# '{category},{keepCategoryOrder},{name},{color}
|
||||
#
|
||||
sorting-method: '{category},{itemsFirst},{name},{color}'
|
||||
sorting-method: '{category},{itemsFirst},{name},{color},{customName}'
|
||||
|
||||
#########################
|
||||
##### localization ######
|
||||
@ -212,6 +225,8 @@ message-gui-middle-click: "Middle-Click"
|
||||
message-gui-shift-click: "Shift + Click"
|
||||
message-gui-double-click: "Double-Click"
|
||||
message-gui-shift-right-click: "Shift + Right-Click"
|
||||
message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### English
|
||||
#message-when-using-chest: "&7Hint: Type &6/chestsort&7 to enable automatic chest sorting."
|
||||
@ -229,6 +244,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Chinese - Thanks to qsefthuopq and Aira-Sakuranomiya for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -247,8 +264,11 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + 单击"
|
||||
#message-gui-double-click: "双击"
|
||||
#message-gui-shift-right-click: "Shift + 双击"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Chinese (Traditional) 繁體中文 - Thanks to Command1264 for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
#message-when-using-chest: "&7小提醒: 輸入 &6/chestsort&7 來開啟自動整理箱子"
|
||||
#message-when-using-chest2: "&7小提醒: 輸入 &6/chestsort&7 來關閉自動整理箱子"
|
||||
#message-sorting-disabled: "&7自動整理箱子已 &c關閉&7"
|
||||
@ -264,6 +284,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + 左鍵"
|
||||
#message-gui-double-click: "雙擊左鍵"
|
||||
#message-gui-shift-right-click: "Shift + 右鍵"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Dutch - Thanks to Xeyame for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -282,8 +304,11 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### French / Français - Thanks to automatizer, demon57730 and FichdlMaa for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
#message-when-using-chest: "&7Remarque: Tape &6/chestsort&7 pour activer le classement automatique."
|
||||
#message-when-using-chest2: "&7Remarque: Tape &6/chestsort&7 pour désactiver le classement automatique."
|
||||
#message-sorting-disabled: "&7Le classement automatique a été &cdésactivé&7."
|
||||
@ -298,7 +323,9 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-middle-click: "Clic du milieu"
|
||||
#message-gui-shift-click: "Maj. + Clic"
|
||||
#message-gui-double-click: "Double-Clic"
|
||||
#message-gui-shift-right-click: "Shift + Clic droit"
|
||||
#message-gui-shift-right-click: "Shift + Clic droit"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### German
|
||||
#message-when-using-chest: "&7Hinweis: Benutze &6/chestsort&7 um die automatische Kistensortierung zu aktivieren."
|
||||
@ -316,6 +343,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Klick"
|
||||
#message-gui-double-click: "Doppelklick"
|
||||
#message-gui-shift-right-click: "Shift + Rechtsklick"
|
||||
#message-gui-left-click: "Kiste füllen (Linksklick)"
|
||||
#message-gui-right-click: "Kiste leeren (Rechtsklick)"
|
||||
|
||||
##### Hungarian - Thanks to Letter for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -334,6 +363,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Italian
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -352,6 +383,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Japanese
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -370,6 +403,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Korean (한국어) - Thanks to kf12 for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -388,6 +423,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "쉬프트 + 클릭"
|
||||
#message-gui-double-click: "더블 클릭"
|
||||
#message-gui-shift-right-click: "쉬프트 + 우클릭"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Portuguese - Thanks to wildastral for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -406,6 +443,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Russian - Thanks to Gandon for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -424,6 +463,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Spanish - Thanks to Bers_ for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -442,6 +483,8 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
##### Turkish - Thanks to bertek41 for translating!
|
||||
##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
|
||||
@ -460,10 +503,22 @@ message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-shift-click: "Shift + Click"
|
||||
#message-gui-double-click: "Double-Click"
|
||||
#message-gui-shift-right-click: "Shift + Right-Click"
|
||||
#message-gui-left-click: "Fill Chest (Left-Click)"
|
||||
#message-gui-right-click: "Load Chest (Right-Click)"
|
||||
|
||||
#########################
|
||||
##### Done! #####
|
||||
#########################
|
||||
############################
|
||||
##### Technical stuff! #####
|
||||
############################
|
||||
|
||||
# please do not change the following line manually!
|
||||
config-version: 22
|
||||
# If you want to reorganize your category files, you can temporarily enable
|
||||
# the dump option to get a .txt file that includes EVERY available material
|
||||
# with its associated category. This way, you can easily find items that
|
||||
# have not yet been assigned to a category.
|
||||
dump: false
|
||||
|
||||
# You should not use this unless for debugging purposes
|
||||
debug: false
|
||||
|
||||
# Please DO NOT change the following line manually!
|
||||
# It is used by the automatic config updater.
|
||||
config-version: 26
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
|
||||
name: ChestSort
|
||||
version: 7.7-pre1
|
||||
version: 8.0-pre1
|
||||
api-version: 1.13
|
||||
description: Allows automatic chest sorting
|
||||
author: mfnalex
|
||||
|
Loading…
Reference in New Issue
Block a user