mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-02-27 03:32:22 +01:00
Update to V1.17.12
- Fix missing lastupdate column for sqlite when auto cleanup is not used - Fix backpack title switching on MC 1.13
This commit is contained in:
parent
e0f32d6982
commit
d2975ac796
4
pom.xml
4
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>MinePacks</artifactId>
|
||||
<version>1.17.12-SNAPSHOT</version>
|
||||
<version>1.17.12</version>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>
|
||||
@ -52,7 +52,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.13-pre7-R0.1-SNAPSHOT</version>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -39,6 +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 OfflinePlayer owner;
|
||||
private HashMap<Player, Boolean> opened = new HashMap<>();
|
||||
@ -118,16 +119,16 @@ public void open(Player p, boolean editable)
|
||||
// This way we can add owner name to the tile for everyone else.
|
||||
try
|
||||
{
|
||||
//noinspection ConstantConditions
|
||||
FIELD_TITLE.setAccessible(true);
|
||||
String title = p.equals(owner) ? MinePacks.backpackTitle : titleOther;
|
||||
if(MCVersion.isOlderThan(MCVersion.MC_NMS_1_13_R1))
|
||||
{
|
||||
//noinspection ConstantConditions
|
||||
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), p.equals(owner) ? MinePacks.backpackTitle : titleOther);
|
||||
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), title);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO convert title to IChatBaseComponent
|
||||
//noinspection ConstantConditions
|
||||
FIELD_TITLE.set(METHOD_GET_INVENTORY.invoke(bp), METHOD_CRAFT_CHAT_MESSAGE_FROM_STRING_OR_NULL.invoke(null, title));
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
|
@ -112,16 +112,13 @@ protected void checkDB()
|
||||
stmt.execute("ALTER TABLE `backpacks` ADD COLUMN `version` INT DEFAULT 0;");
|
||||
}
|
||||
catch(SQLException ignored) {}
|
||||
if(maxAge > 0)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultSet rs = stmt.executeQuery("SELECT DATE('now');");
|
||||
rs.next();
|
||||
stmt.execute("ALTER TABLE `backpacks` ADD COLUMN `lastupdate` DATE DEFAULT '" + rs.getString(1) + "';");
|
||||
}
|
||||
catch(SQLException ignored) {}
|
||||
ResultSet rs = stmt.executeQuery("SELECT DATE('now');");
|
||||
rs.next();
|
||||
stmt.execute("ALTER TABLE `backpacks` ADD COLUMN `lastupdate` DATE DEFAULT '" + rs.getString(1) + "';");
|
||||
}
|
||||
catch(SQLException ignored) {}
|
||||
}
|
||||
catch(SQLException e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user