Add support for MC 1.14

This commit is contained in:
GeorgH93 2019-04-22 20:13:01 +02:00
parent 273117e1e6
commit 20708f45b6
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 8 additions and 8 deletions

View File

@ -58,7 +58,7 @@
<dependency>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>PluginLib</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.0.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2018 GeorgH93
* Copyright (C) 2014-2019 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
@ -39,7 +39,7 @@ public class Backpack implements InventoryHolder
{
private final static Method METHOD_GET_INVENTORY = NMSReflection.getOBCMethod("inventory.CraftInventory", "getInventory");
private final static Field FIELD_TITLE = NMSReflection.getOBCField("inventory.CraftInventoryCustom$MinecraftInventory", "title");
private final static Method METHOD_CRAFT_CHAT_MESSAGE_FROM_STRING_OR_NULL = MCVersion.isNewerOrEqualThan(MCVersion.MC_1_13) ? NMSReflection.getOBCMethod("util.CraftChatMessage", "fromStringOrNull", String.class) : null;
private final static Method METHOD_CRAFT_CHAT_MESSAGE_FROM_STRING_OR_NULL = MCVersion.isAny(MCVersion.MC_1_13) ? NMSReflection.getOBCMethod("util.CraftChatMessage", "fromStringOrNull", String.class) : null;
private OfflinePlayer owner;
private HashMap<Player, Boolean> opened = new HashMap<>();
@ -120,15 +120,15 @@ public void open(Player p, boolean editable)
try
{
String title = p.equals(owner) ? MinePacks.backpackTitle : titleOther;
if(MCVersion.isOlderThan(MCVersion.MC_NMS_1_13_R1))
if(MCVersion.isAny(MCVersion.MC_1_13))
{
//noinspection ConstantConditions
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), title);
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), METHOD_CRAFT_CHAT_MESSAGE_FROM_STRING_OR_NULL.invoke(null, title));
}
else
{
//noinspection ConstantConditions
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), METHOD_CRAFT_CHAT_MESSAGE_FROM_STRING_OR_NULL.invoke(null, title));
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), title);
}
}
catch(Exception e)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2018 GeorgH93
* Copyright (C) 2014-2019 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
@ -69,7 +69,7 @@ public void onEnable()
//region Check compatibility with used minecraft version
String name = Bukkit.getServer().getClass().getPackage().getName();
String[] version = name.substring(name.lastIndexOf('.') + 2).split("_");
if((version[0].equals("1") && Integer.valueOf(version[1]) > 13) || Integer.valueOf(version[0]) > 1)
if((version[0].equals("1") && Integer.valueOf(version[1]) > 14) || Integer.valueOf(version[0]) > 1)
{
MinePacks.getInstance().warnOnVersionIncompatibility(version[0] + "." + version[1]);
this.setEnabled(false);