mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-23 21:51:31 +01:00
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:
parent
e091b182b3
commit
dce86eb79d
@ -17,32 +17,36 @@
|
|||||||
|
|
||||||
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
||||||
|
|
||||||
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.BukkitItemStackSerializer;
|
|
||||||
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.ItemStackSerializer;
|
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.ItemStackSerializer;
|
||||||
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.NBTItemStackSerializerGen2;
|
|
||||||
import at.pcgamingfreaks.Bukkit.MCVersion;
|
import at.pcgamingfreaks.Bukkit.MCVersion;
|
||||||
import at.pcgamingfreaks.ConsoleColor;
|
import at.pcgamingfreaks.ConsoleColor;
|
||||||
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class InventorySerializer
|
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 final Logger logger;
|
||||||
private ItemStackSerializer serializer;
|
private final ItemStackSerializer serializer;
|
||||||
private int usedSerializer = 2;
|
@Getter private final int usedSerializer;
|
||||||
|
|
||||||
public InventorySerializer(Logger logger)
|
public InventorySerializer(Logger logger)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
ItemStackSerializer serializer = null;
|
||||||
|
int usedSerializer = 2;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(NBTItemStackSerializerGen2.isMCVersionCompatible())
|
if(ItemStackSerializer.isNBTItemStackSerializerAvailable())
|
||||||
{
|
{
|
||||||
serializer = new NBTItemStackSerializerGen2(logger);
|
serializer = ItemStackSerializer.makeNBTItemStackSerializer(logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@ -54,6 +58,8 @@ public InventorySerializer(Logger logger)
|
|||||||
usedSerializer = 0;
|
usedSerializer = 0;
|
||||||
serializer = BUKKIT_ITEM_STACK_SERIALIZER;
|
serializer = BUKKIT_ITEM_STACK_SERIALIZER;
|
||||||
}
|
}
|
||||||
|
this.serializer = serializer;
|
||||||
|
this.usedSerializer = usedSerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] serialize(Inventory inv)
|
public byte[] serialize(Inventory inv)
|
||||||
@ -67,15 +73,10 @@ public ItemStack[] deserialize(byte[] data, int usedSerializer)
|
|||||||
switch(usedSerializer)
|
switch(usedSerializer)
|
||||||
{
|
{
|
||||||
case 0: return BUKKIT_ITEM_STACK_SERIALIZER.deserialize(data);
|
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);
|
case 2: return serializer.deserialize(data);
|
||||||
default: logger.warning(ConsoleColor.RED + "No compatible deserializer for backpack format available!" + ConsoleColor.RESET);
|
default: logger.warning(ConsoleColor.RED + "No compatible deserializer for backpack format available!" + ConsoleColor.RESET);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUsedSerializer()
|
|
||||||
{
|
|
||||||
return usedSerializer;
|
|
||||||
}
|
|
||||||
}
|
}
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.3.18</revision>
|
<revision>2.3.19</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user