mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-14 10:45:23 +01:00
Fix error when backpack is opened by more than one player on MC 1.14, 1.15 and 1.16
Add support for RGB colors in all messages
This commit is contained in:
parent
5891a7da7c
commit
05de6aebbb
@ -38,7 +38,7 @@
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>PluginLib</artifactId>
|
||||
<version>1.0.27-SNAPSHOT</version>
|
||||
<version>1.0.28-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- BadRabbit -->
|
||||
<dependency>
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import at.pcgamingfreaks.Bukkit.MCVersion;
|
||||
import at.pcgamingfreaks.Bukkit.NMSReflection;
|
||||
import at.pcgamingfreaks.Bukkit.Utils;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.InventoryCompressor;
|
||||
import at.pcgamingfreaks.StringUtils;
|
||||
|
||||
@ -48,7 +49,7 @@ public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
|
||||
private final static Field FIELD_TITLE = NMSReflection.getOBCField("inventory.CraftInventoryCustom$MinecraftInventory", "title");
|
||||
@Setter(AccessLevel.PACKAGE) private static ShrinkApproach shrinkApproach = ShrinkApproach.COMPRESS;
|
||||
private static Object titleOwn;
|
||||
private static String titleOtherFormat, titleOther;
|
||||
private static String titleOtherFormat, titleOther, titleOwnString;
|
||||
private final OfflinePlayer owner;
|
||||
private final Object titleOtherOBC;
|
||||
private final Map<Player, Boolean> opened = new ConcurrentHashMap<>(); //Thanks Minecraft 1.14
|
||||
@ -58,6 +59,7 @@ public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
|
||||
|
||||
public static void setTitle(final @NotNull String title, final @NotNull String titleOther)
|
||||
{
|
||||
titleOwnString = title;
|
||||
titleOwn = prepareTitle(title);
|
||||
titleOtherFormat = titleOther;
|
||||
}
|
||||
@ -194,6 +196,8 @@ public void open(@NotNull Player player, boolean editable, final @Nullable Strin
|
||||
opened.put(player, editable);
|
||||
|
||||
//region Set backpack title
|
||||
if(MCVersion.isOlderThan(MCVersion.MC_1_14))
|
||||
{
|
||||
// It's not perfect, but it is the only way of doing this.
|
||||
// This sets the title of the inventory based on the person who is opening it.
|
||||
// The owner will see an other title, then everyone else.
|
||||
@ -210,9 +214,15 @@ public void open(@NotNull Player player, boolean editable, final @Nullable Strin
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
player.openInventory(bp);
|
||||
if(MCVersion.isNewerOrEqualThan(MCVersion.MC_1_14))
|
||||
{
|
||||
final String usedTitle = (title == null) ? (player.equals(owner) ? titleOwnString : titleOther) : title;
|
||||
Bukkit.getScheduler().runTaskLater(Minepacks.getInstance(), () -> Utils.updateInventoryTitle(player, usedTitle), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void close(Player p)
|
||||
|
@ -19,5 +19,5 @@
|
||||
|
||||
public class MagicValues
|
||||
{
|
||||
public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.27-SNAPSHOT";
|
||||
public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.28-SNAPSHOT";
|
||||
}
|
@ -105,6 +105,7 @@ public void onEnable()
|
||||
updater = new ManagedUpdater(this);
|
||||
instance = this;
|
||||
config = new Config(this);
|
||||
updater.setChannel(config.getUpdateChannel());
|
||||
if(config.useUpdater()) updater.update();
|
||||
|
||||
if(!checkMcVersion()) return;
|
||||
|
Loading…
Reference in New Issue
Block a user