13.3.0 release

This commit is contained in:
mfnalex 2022-07-19 11:08:08 +02:00
parent bf5906b4ec
commit fd47607f69
5 changed files with 82 additions and 52 deletions

View File

@ -1,5 +1,8 @@
# Changelog
## 13.2.1
- Fixed exceptions when using the latest version of AdvancedChests
## 13.0.5
Sorry for 3 updates within 10 minutes!

View File

@ -9,7 +9,7 @@
<name>ChestSort</name>
<url>https://www.chestsort.de</url>
<description>Allows automatic chest sorting!</description>
<version>13.2.0</version>
<version>13.3.0</version>
<packaging>jar</packaging>
<properties>
@ -171,6 +171,11 @@
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>jeff-media-public</id>
<url>https://hub.jeff-media.com/nexus/repository/jeff-media-public/</url>
</repository>
<repository>
<id>pcgf-repo</id>
<url>https://repo.pcgamingfreaks.at/repository/maven-everything</url>
@ -202,7 +207,7 @@
<dependency>
<groupId>de.jeff_media</groupId>
<artifactId>JeffLib</artifactId>
<version>8.0.0-SNAPSHOT</version>
<version>9.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

View File

@ -29,7 +29,6 @@ package de.jeff_media.chestsort;
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksPlugin;
import com.jeff_media.updatechecker.UpdateChecker;
import de.jeff_media.chestsort.commands.AdminCommand;
import de.jeff_media.chestsort.commands.ChestSortCommand;
import de.jeff_media.chestsort.commands.InvSortCommand;
import de.jeff_media.chestsort.commands.TabCompleter;
@ -48,7 +47,7 @@ import de.jeff_media.chestsort.handlers.Logger;
import de.jeff_media.chestsort.hooks.EnderContainersHook;
import de.jeff_media.chestsort.hooks.GenericGUIHook;
import de.jeff_media.chestsort.hooks.PlayerVaultsHook;
import de.jeff_media.chestsort.listeners.Listener;
import de.jeff_media.chestsort.listeners.ChestSortListener;
import de.jeff_media.chestsort.placeholders.Placeholders;
import de.jeff_media.chestsort.utils.Utils;
import de.jeff_media.jefflib.JeffLib;
@ -62,9 +61,7 @@ import org.bukkit.NamespacedKey;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.yaml.snakeyaml.Yaml;
import java.io.*;
import java.util.*;
@ -86,7 +83,7 @@ public class ChestSortPlugin extends JavaPlugin {
private ArrayList<String> disabledWorlds;
private HashMap<UUID, Long> hotkeyCooldown;
private Logger lgr;
private Listener listener;
private ChestSortListener chestSortListener;
// 1.14.4 = 1_14_R1
// 1.8.0 = 1_8_R1
private int mcMinorVersion; // 14 for 1.14, 13 for 1.13, ...
@ -252,12 +249,12 @@ public class ChestSortPlugin extends JavaPlugin {
this.lgr = lgr;
}
public Listener getListener() {
return listener;
public ChestSortListener getListener() {
return chestSortListener;
}
public void setListener(Listener listener) {
this.listener = listener;
public void setListener(ChestSortListener chestSortListener) {
this.chestSortListener = chestSortListener;
}
public int getMcMinorVersion() {
@ -492,7 +489,7 @@ public class ChestSortPlugin extends JavaPlugin {
getLogger().severe("The Update Checker will NOT work when using CraftBukkit instead of Spigot/Paper!");
PaperLib.suggestPaper(this);
}
setListener(new Listener(this));
setListener(new ChestSortListener(this));
setHotkeyCooldown(new HashMap<>());
setPermissionsHandler(new ChestSortPermissionsHandler(this));
setUpdateCheckInterval(getConfig().getDouble("check-interval"));
@ -699,7 +696,7 @@ public class ChestSortPlugin extends JavaPlugin {
boolean changed;
boolean hasSeenMessage;
if (playerFile.exists() || !McVersion.isAtLeast(1,14,4)) {
if (playerFile.exists() || !McVersion.current().isAtLeast(1,14,4)) {
// If the player settings file does not exist for this player, set it to the
// default value
activeForThisPlayer = playerConfig.getBoolean("sortingEnabled");
@ -715,7 +712,7 @@ public class ChestSortPlugin extends JavaPlugin {
changed = true;
if (McVersion.isAtLeast(1,14,4)) {
if (McVersion.current().isAtLeast(1,14,4)) {
if (playerFile.delete()) {
this.getLogger().info("Converted old .yml playerdata file to NBT tags for player " + p.getName());
} else {
@ -752,7 +749,7 @@ public class ChestSortPlugin extends JavaPlugin {
// when "show-message-again-after-logout" is enabled, we don't care if the
// player already saw the message
if (!getConfig().getBoolean("show-message-again-after-logout")) {
if (McVersion.isAtLeast(1,14,4) && !playerFile.exists()) {
if (McVersion.current().isAtLeast(1,14,4) && !playerFile.exists()) {
NBTAPI.getNBT(p, "hasSeenMessage", String.valueOf(false));
} else {
newSettings.hasSeenMessage = playerConfig.getBoolean("hasSeenMessage");
@ -926,7 +923,7 @@ public class ChestSortPlugin extends JavaPlugin {
if (getPerPlayerSettings().containsKey(uniqueId.toString())) {
PlayerSetting setting = getPerPlayerSettings().get(p.getUniqueId().toString());
if (McVersion.isAtLeast(1,14,4)) {
if (McVersion.current().isAtLeast(1,14,4)) {
for(NamespacedKey key : p.getPersistentDataContainer().getKeys()) {
if(key.getKey().equals(new NamespacedKey(this,"test").getKey())) {

View File

@ -14,45 +14,62 @@ public class AdvancedChestsHook {
public AdvancedChestsHook(ChestSortPlugin plugin) {
this.plugin = plugin;
if(plugin.isHookAdvancedChests()){
double version = Double.parseDouble(plugin.getServer().getPluginManager()
.getPlugin("AdvancedChests")
.getDescription().getVersion());
if(version >= 20.3) {
plugin.getLogger().info("Successfully hooked into AdvancedChests");
}else plugin.setHookAdvancedChests(false);
}
try {
if (plugin.isHookAdvancedChests()) {
double version = Double.parseDouble(plugin.getServer().getPluginManager()
.getPlugin("AdvancedChests")
.getDescription().getVersion());
if (version >= 20.3) {
plugin.getLogger().info("Successfully hooked into AdvancedChests");
} else plugin.setHookAdvancedChests(false);
}
} catch (Throwable t) {
plugin.setHookAdvancedChests(false);
}
}
public boolean isAnAdvancedChest(Inventory inventory){
return plugin.isHookAdvancedChests()
&& inventory != null
&& AdvancedChestsAPI.getInventoryManager().getAdvancedChest(inventory) != null;
try {
return plugin.isHookAdvancedChests()
&& inventory != null
&& AdvancedChestsAPI.getInventoryManager().getAdvancedChest(inventory) != null;
} catch (Throwable ignored) {
return false; // TODO: Remove once everyone updated AC
}
}
public boolean handleAChestSortingIfPresent(Inventory inventory){
if(!plugin.isHookAdvancedChests())return false;
InteractiveInventory interactiveInventory = AdvancedChestsAPI.getInventoryManager().getInteractiveByBukkit(inventory);
if(interactiveInventory != null) {
if (interactiveInventory instanceof ChestPage) {
plugin.getOrganizer().sortInventory(inventory, 0, inventory.getSize() - 10);
}
return true;
}else {
return false;
}
if(!plugin.isHookAdvancedChests()) return false;
try {
InteractiveInventory interactiveInventory = AdvancedChestsAPI.getInventoryManager().getInteractiveByBukkit(inventory);
if (interactiveInventory != null) {
if (interactiveInventory instanceof ChestPage) {
plugin.getOrganizer().sortInventory(inventory, 0, inventory.getSize() - 10);
}
return true;
} else {
return false;
}
} catch (Throwable ignored) {
return false; // TODO: Remove once everyone updated AC
}
}
public boolean handleAChestSortingIfPresent(Location location){
if(!plugin.isHookAdvancedChests())return false;
AdvancedChest<?,?> chest = AdvancedChestsAPI.getChestManager().getAdvancedChest(location);
if(chest != null){
for (ChestPage<?> page : chest.getPages()) {
Inventory inventory = page.getBukkitInventory();
plugin.getOrganizer().sortInventory(inventory,0,inventory.getSize()-10);
}
return true;
}
return false;
try {
AdvancedChest<?, ?> chest = AdvancedChestsAPI.getChestManager().getAdvancedChest(location);
if (chest != null) {
for (ChestPage<?> page : chest.getPages()) {
Inventory inventory = page.getBukkitInventory();
plugin.getOrganizer().sortInventory(inventory, 0, inventory.getSize() - 10);
}
return true;
}
return false;
} catch (Throwable ignored) {
return false; // TODO: Remove once everyone updated AC
}
}
}

View File

@ -11,7 +11,6 @@ import de.jeff_media.chestsort.data.PlayerSetting;
import de.jeff_media.chestsort.hooks.*;
import de.jeff_media.chestsort.utils.LlamaUtils;
import de.jeff_media.jefflib.ProtectionUtils;
import de.jeff_media.jefflib.data.ShadowPlayer;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -39,7 +38,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public class Listener implements org.bukkit.event.Listener {
public class ChestSortListener implements org.bukkit.event.Listener {
final ChestSortPlugin plugin;
public final MinepacksHook minepacksHook;
@ -49,7 +48,7 @@ public class Listener implements org.bukkit.event.Listener {
private static Event ignoredEvent;
public Listener(ChestSortPlugin plugin) {
public ChestSortListener(ChestSortPlugin plugin) {
this.plugin = plugin;
this.minepacksHook = new MinepacksHook(plugin);
this.headDatabaseHook = new HeadDatabaseHook(plugin);
@ -97,9 +96,14 @@ public class Listener implements org.bukkit.event.Listener {
Container containerState = (Container) clickedBlock.getState();
Inventory inventory = containerState.getInventory();
if(!advancedChestsHook.handleAChestSortingIfPresent(clickedBlock.getLocation())) {
plugin.getOrganizer().sortInventory(inventory);
}
try {
if (!advancedChestsHook.handleAChestSortingIfPresent(clickedBlock.getLocation())) {
plugin.getOrganizer().sortInventory(inventory);
}
} catch (Throwable ignored) {
// TODO: Remove when everyone updated AdvancedChests
}
event.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(Messages.MSG_CONTAINER_SORTED));
}
@ -316,6 +320,10 @@ public class Listener implements org.bukkit.event.Listener {
return true;
}
if (inventory.getHolder() != null && inventory.getHolder().getClass().getName().toLowerCase().contains("boat")) {
return true;
}
// Possible Fix for https://github.com/JEFF-Media-GbR/Spigot-ChestSort/issues/13
if (inventory.getHolder() == null) {
return false;