8.17.7 release

This commit is contained in:
mfnalex 2020-09-29 21:33:40 +02:00
parent 127cbb2e1c
commit 0f85944e06
5 changed files with 46 additions and 17 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
## 8.17.7-SNAPSHOT
- Fixed InventoryPages hook when using colored item names
## 8.17.6 ## 8.17.6
- Fixed exception and hotbar being filled up with barrier blocks when using the addition right-click-hotkey on MC 1.8 - Fixed exception and hotbar being filled up with barrier blocks when using the addition right-click-hotkey on MC 1.8

View File

@ -9,7 +9,7 @@
<name>ChestSort</name> <name>ChestSort</name>
<url>https://www.chestsort.de</url> <url>https://www.chestsort.de</url>
<description>Automatically sorts your chests!</description> <description>Automatically sorts your chests!</description>
<version>8.17.6</version> <version>8.17.7</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>

View File

@ -86,22 +86,46 @@ public class ChestSortListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInventoryClose(InventoryCloseEvent event) { public void onPlayerInventoryClose(InventoryCloseEvent event) {
if(!plugin.getConfig().getBoolean("allow-automatic-inventory-sorting")) return; plugin.debug("Attempt to automatically sort a player inventory");
if (event.getInventory().getHolder() == null) return; if (event.getInventory().getHolder() == null) {
plugin.debug("Abort: holder == null");
return;
}
// Might be obsolete, because its @NotNull in 1.15, but who knows if thats for 1.8 // Might be obsolete, because its @NotNull in 1.15, but who knows if thats for 1.8
if (event.getInventory().getType() == null) return; if (event.getInventory().getType() == null) {
if (event.getInventory().getType() != InventoryType.CRAFTING) plugin.debug("Abort: type == null");
return;
}
if (event.getInventory().getType() != InventoryType.CRAFTING) {
plugin.debug("Abort: type != CRAFTING, but "+event.getInventory().getType().name());
return; // Weird! Returns CRAFTING instead of PLAYER return; // Weird! Returns CRAFTING instead of PLAYER
if (!(event.getInventory().getHolder() instanceof Player)) return; }
if (!(event.getInventory().getHolder() instanceof Player)) {
plugin.debug("Abort: holder ! instanceof Player");
return;
}
if(!plugin.getConfig().getBoolean("allow-automatic-inventory-sorting")) {
plugin.debug("allow-automatic-inventory-sorting is false");
return;
}
Player p = (Player) event.getInventory().getHolder(); Player p = (Player) event.getInventory().getHolder();
if (!p.hasPermission("chestsort.use.inventory")) return; if (!p.hasPermission("chestsort.use.inventory")) {
plugin.debug("Missing permission chestsort.use.inventory");
return;
}
plugin.registerPlayerIfNeeded(p); plugin.registerPlayerIfNeeded(p);
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString()); ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
if (!setting.invSortingEnabled) return; if (!setting.invSortingEnabled) {
plugin.debug("auto inv sorting not enabled for player "+p.getName());
return;
}
plugin.lgr.logSort(p, ChestSortLogger.SortCause.INV_CLOSE); plugin.lgr.logSort(p, ChestSortLogger.SortCause.INV_CLOSE);
@ -157,6 +181,8 @@ public class ChestSortListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onChestOpen(InventoryOpenEvent event) { public void onChestOpen(InventoryOpenEvent event) {
plugin.debug("onChestOpen (InventoryOpenEvent");
if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) return; if(!plugin.getConfig().getBoolean("allow-automatic-sorting")) return;
if (!(plugin.getConfig().getString("sort-time").equalsIgnoreCase("open") if (!(plugin.getConfig().getString("sort-time").equalsIgnoreCase("open")

View File

@ -2,6 +2,7 @@ package de.jeff_media.ChestSort.hooks;
import java.io.File; import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -9,7 +10,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import de.jeff_media.ChestSort.ChestSortPlugin; import de.jeff_media.ChestSort.ChestSortPlugin;
import net.md_5.bungee.api.ChatColor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class InventoryPagesHook { public class InventoryPagesHook {
@ -60,20 +60,20 @@ public class InventoryPagesHook {
} }
// When using &f as color, we manually have to add this to the string because it gets removed by InventoryPages // 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); //if(prevName.startsWith("§f")) prevName = prevName.substring(2);
if(nextName.startsWith("§f")) nextName = nextName.substring(2); //if(nextName.startsWith("§f")) nextName = nextName.substring(2);
if(noPageName.startsWith("§f")) noPageName = noPageName.substring(2); //if(noPageName.startsWith("§f")) noPageName = noPageName.substring(2);
if(slot == prevSlot ) { if(slot == prevSlot ) {
if(item.getType() == prevMat && (item.getItemMeta().getDisplayName().equals(prevName))) { if(item.getType() == prevMat && (ChatColor.stripColor(item.getItemMeta().getDisplayName()).equals(ChatColor.stripColor(prevName)))) {
return true; return true;
} else return item.getType() == noPageMat && item.getItemMeta().getDisplayName().equals(noPageName); } else return item.getType() == noPageMat && ChatColor.stripColor(item.getItemMeta().getDisplayName()).equals(ChatColor.stripColor(noPageName));
} }
if(slot == nextSlot ) { if(slot == nextSlot ) {
if(item.getType() == nextMat && item.getItemMeta().getDisplayName().equals(nextName)) { if(item.getType() == nextMat && ChatColor.stripColor(item.getItemMeta().getDisplayName()).equals(ChatColor.stripColor(nextName))) {
return true; return true;
} else return item.getType() == noPageMat && item.getItemMeta().getDisplayName().equals(noPageName); } else return item.getType() == noPageMat && ChatColor.stripColor(item.getItemMeta().getDisplayName()).equals(ChatColor.stripColor(noPageName));
} }
return false; return false;

View File

@ -1,6 +1,6 @@
main: de.jeff_media.ChestSort.ChestSortPlugin main: de.jeff_media.ChestSort.ChestSortPlugin
name: ChestSort name: ChestSort
version: 8.17.6 version: 8.17.7
api-version: "1.13" api-version: "1.13"
description: Allows automatic chest sorting description: Allows automatic chest sorting
author: mfnalex author: mfnalex