diff --git a/pom.xml b/pom.xml
index 0c9d0d5..bb85c74 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
at.pcgamingfreaks
Minepacks
- 2.1.3
+ 2.1.4-SNAPSHOT
scm:git:git@github.com:GeorgH93/Minepacks.git
diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java
index bb114e3..77455be 100644
--- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java
+++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 GeorgH93
+ * Copyright (C) 2020 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
+import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@@ -90,6 +91,11 @@ public Backpack(OfflinePlayer owner, int size)
public Backpack(OfflinePlayer owner, int size, int ID)
{
+ if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_14))
+ {
+ size = Math.min(size, 54);
+ Minepacks.getInstance().getLogger().warning("Backpacks with more than 6 rows are no longer supported on Minecraft 1.14 and up!");
+ }
this.owner = owner;
titleOther = StringUtils.limitLength(String.format(titleOtherFormat, owner.getName()), 32);
bp = Bukkit.createInventory(this, size, titleOther);
@@ -110,6 +116,30 @@ public Backpack(OfflinePlayer owner, int size, int ID)
public Backpack(OfflinePlayer owner, ItemStack[] backpack, int ID)
{
this(owner, backpack.length, ID);
+ if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_14) && backpack.length > 54)
+ { // Try to optimize space usage to compress items into only 6 rows
+ ItemStack[] dbStack = backpack;
+ backpack = new ItemStack[54];
+ int filled = 0;
+ for(ItemStack stack : dbStack)
+ {
+ if(stack == null || stack.getType() == Material.AIR) continue;
+ if(filled == 54)
+ {
+ Minepacks.getInstance().getLogger().warning(owner.getName() + "'s backpack has to many items.");
+ if(owner.isOnline())
+ {
+ owner.getPlayer().getWorld().dropItemNaturally(owner.getPlayer().getLocation(), stack);
+ //Owner is online!
+ }
+ else throw new RuntimeException("Backpack to big for MC 1.14 and up!");
+ }
+ else
+ {
+ backpack[filled++] = stack;
+ }
+ }
+ }
bp.setContents(backpack);
}
diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java
index f0520d9..450d86c 100644
--- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java
+++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java
@@ -167,6 +167,7 @@ public int getBackpackMaxSize()
{
int size = getConfigE().getInt("MaxSize", 6);
if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_14)) size = Math.min(6, size);
+ if(size > 6) logger.warning("Backpacks with more than 6 rows will not work on MC 1.14");
return Math.max(1, size);
}