8.8.2 Fixes exception in ancient versions

This commit is contained in:
mfnalex 2020-05-31 23:15:28 +02:00
parent 89c4d9e827
commit 65726c4f6c
6 changed files with 26 additions and 13 deletions

View File

@ -1,4 +1,10 @@
# Changelog
## 8.8.2
- Fixes exception when sorting inventories containing potions in ancient Minecraft versions like 1.8
## 8.8.1
- Changed config-version, because I forgot that in 8.8. You can now use the new config option and translations.
## 8.8
- Improved Minepacks hook and prevents backpacks from being put into itself
- Prevent ItemStacks > 64 slots from being sorted at all

View File

@ -6,7 +6,7 @@
<groupId>de.jeffclan</groupId>
<artifactId>JeffChestSort</artifactId>
<version>8.8</version>
<version>8.8.2</version>
<packaging>jar</packaging>
<name>JeffChestSort</name>

View File

@ -308,20 +308,27 @@ public class ChestSortOrganizer {
String potionEffect = ",";
// Potions
if(item.getItemMeta()!=null) {
if (item.getItemMeta() != null) {
ItemMeta meta = item.getItemMeta();
if(meta instanceof PotionMeta) {
if (meta instanceof PotionMeta) {
PotionMeta potionMeta = (PotionMeta) meta;
if(potionMeta.getBasePotionData()!=null) {
PotionData pdata = potionMeta.getBasePotionData();
if(pdata != null && pdata.getType()!=null && pdata.getType().getEffectType()!=null) {
potionEffect = "|"+pdata.getType().getEffectType().getName();
// Only continue if Method "getBasePotionData" exists
Class<? extends PotionMeta> potionMetaClass = potionMeta.getClass();
try {
if (potionMetaClass.getDeclaredMethod("getBasePotionData", null) != null) {
if (potionMeta.getBasePotionData() != null) {
PotionData pdata = potionMeta.getBasePotionData();
if (pdata != null && pdata.getType() != null && pdata.getType().getEffectType() != null) {
potionEffect = "|" + pdata.getType().getEffectType().getName();
}
}
}
}
//potionEffects = potionEffects.substring(0, potionEffects.length()-1);
} catch (NoSuchMethodException | SecurityException e) { }
// potionEffects = potionEffects.substring(0, potionEffects.length()-1);
}
}
String hookChangedName = item.getType().name();
// CrackShot Support Start

View File

@ -65,7 +65,7 @@ public class ChestSortPlugin extends JavaPlugin {
String sortingMethod;
ArrayList<String> disabledWorlds;
ChestSortAPI api;
int currentConfigVersion = 31;
int currentConfigVersion = 32;
boolean usingMatchingConfig = true;
protected boolean debug = false;
boolean verbose = true;

View File

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

View File

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