Update to v2.3.19

* Prepare for PCGF_PluginLib v1.0.31-SNAPSHOT
* Fix RGB colors in legacy formatted messages
* Fix empty messages causing errors when attempting to send them (they now set the send method to disabled)
This commit is contained in:
GeorgH93 2020-09-20 22:33:21 +02:00
parent e091b182b3
commit dce86eb79d
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
2 changed files with 15 additions and 14 deletions

View File

@ -17,32 +17,36 @@
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.BukkitItemStackSerializer;
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.ItemStackSerializer;
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.NBTItemStackSerializerGen2;
import at.pcgamingfreaks.Bukkit.MCVersion;
import at.pcgamingfreaks.ConsoleColor;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import lombok.Getter;
import java.util.logging.Logger;
public class InventorySerializer
{
private static final ItemStackSerializer BUKKIT_ITEM_STACK_SERIALIZER = new BukkitItemStackSerializer();
@SuppressWarnings("deprecation")
private static final ItemStackSerializer BUKKIT_ITEM_STACK_SERIALIZER = ItemStackSerializer.makeBukkitItemStackSerializer();
private final Logger logger;
private ItemStackSerializer serializer;
private int usedSerializer = 2;
private final ItemStackSerializer serializer;
@Getter private final int usedSerializer;
public InventorySerializer(Logger logger)
{
this.logger = logger;
ItemStackSerializer serializer = null;
int usedSerializer = 2;
try
{
if(NBTItemStackSerializerGen2.isMCVersionCompatible())
if(ItemStackSerializer.isNBTItemStackSerializerAvailable())
{
serializer = new NBTItemStackSerializerGen2(logger);
serializer = ItemStackSerializer.makeNBTItemStackSerializer(logger);
}
}
catch(Exception e)
@ -54,6 +58,8 @@ public InventorySerializer(Logger logger)
usedSerializer = 0;
serializer = BUKKIT_ITEM_STACK_SERIALIZER;
}
this.serializer = serializer;
this.usedSerializer = usedSerializer;
}
public byte[] serialize(Inventory inv)
@ -67,15 +73,10 @@ public ItemStack[] deserialize(byte[] data, int usedSerializer)
switch(usedSerializer)
{
case 0: return BUKKIT_ITEM_STACK_SERIALIZER.deserialize(data);
case 1: if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_13)) logger.warning(ConsoleColor.YELLOW + "Backpack was created with an old version of minecraft. There is the chance that some items will disappear from it.");
case 1: if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_13)) logger.warning(ConsoleColor.YELLOW + "Backpack was created with an old version of minepacks and minecraft. There is the chance that some items will disappear from it." + ConsoleColor.RESET);
case 2: return serializer.deserialize(data);
default: logger.warning(ConsoleColor.RED + "No compatible deserializer for backpack format available!" + ConsoleColor.RESET);
}
return null;
}
public int getUsedSerializer()
{
return usedSerializer;
}
}

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging>
<properties>
<revision>2.3.18</revision>
<revision>2.3.19</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>