3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-27 12:00:07 +01:00

v3.0.2 Workaround for spigot bug

Dieser Commit ist enthalten in:
Steven 2018-08-07 18:46:33 +08:00
Ursprung edf2e3aed4
Commit 076fdfd829
7 geänderte Dateien mit 30 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -9,7 +9,7 @@ I wanted to create an armor stand for each kit in my mini-game, and I quickly be
Compatibility
-------------
- Armor Stand Tools v3.0.0 - Spigot/CraftBukkit 1.13 only
- Armor Stand Tools v3.0.2 - Spigot/CraftBukkit 1.13 only
- Armor Stand Tools v2.4.3 - Spigot/CraftBukkit 1.8, 1.9, 1.10, 1.11, 1.12
Features

Datei anzeigen

@ -79,7 +79,7 @@ public class Main extends JavaPlugin {
getLogger().warning("Support for " + nmsVersion + " not found, trying " + usingVersion + ". Please check for possible updates to the plugin.");
}
try {
nms = (NMS) Class.forName("com.gmail.St3venAU.plugins.ArmorStandTools.NMS_" + usingVersion).getConstructor(String.class).newInstance(nmsVersion);
nms = (NMS) Class.forName("com.gmail.St3venAU.plugins.ArmorStandTools.NMS_" + usingVersion).getConstructor(Main.class, String.class).newInstance(this, nmsVersion);
} catch (Exception e) {
e.printStackTrace();
getLogger().warning("An error occurred while attempting to load support for this version of Craftbukkit/Spigot. Loading plugin failed.");

Datei anzeigen

@ -11,17 +11,21 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.Field;
import java.util.Map;
abstract class NMS {
private Main plugin;
private final String
nmsVersion,
disabledSlotsFieldName;
NMS(String nmsVersion, String disabledSlotsFieldName) {
NMS(Main plugin, String nmsVersion, String disabledSlotsFieldName) {
this.plugin = plugin;
this.nmsVersion = nmsVersion;
this.disabledSlotsFieldName = disabledSlotsFieldName;
}
@ -39,16 +43,21 @@ abstract class NMS {
}
}
void openSign(Player p, Block b) {
try {
Object world = b.getWorld().getClass().getMethod("getHandle").invoke(b.getWorld());
Object blockPos = getNMSClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(b.getX(), b.getY(), b.getZ());
Object sign = world.getClass().getMethod("getTileEntity", getNMSClass("BlockPosition")).invoke(world, blockPos);
Object player = p.getClass().getMethod("getHandle").invoke(p);
player.getClass().getMethod("openSign", getNMSClass("TileEntitySign")).invoke(player, sign);
} catch (Exception e) {
e.printStackTrace();
}
void openSign(final Player p, final Block b) {
new BukkitRunnable() {
@Override
public void run() {
try {
Object world = b.getWorld().getClass().getMethod("getHandle").invoke(b.getWorld());
Object blockPos = getNMSClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(b.getX(), b.getY(), b.getZ());
Object sign = world.getClass().getMethod("getTileEntity", getNMSClass("BlockPosition")).invoke(world, blockPos);
Object player = p.getClass().getMethod("getHandle").invoke(p);
player.getClass().getMethod("openSign", getNMSClass("TileEntitySign")).invoke(player, sign);
} catch (Exception e) {
e.printStackTrace();
}
}
}.runTaskLater(plugin, 2L);
}
boolean toggleSlotsDisabled(ArmorStand as) {
@ -102,7 +111,7 @@ abstract class NMS {
if(is == null) {
return "";
}
StringBuilder tags = new StringBuilder("");
StringBuilder tags = new StringBuilder();
if(is.getItemMeta() != null && is.getItemMeta() instanceof LeatherArmorMeta) {
LeatherArmorMeta armorMeta = (LeatherArmorMeta) is.getItemMeta();
tags.append("display:{color:");

Datei anzeigen

@ -3,10 +3,11 @@ package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_13_R1 extends NMS {
public NMS_v1_13_R1(String nmsVersion) {
public NMS_v1_13_R1(Main plugin, String nmsVersion) {
super(
nmsVersion, // NMS Version
"bH" // Disabled slots field name
plugin,
nmsVersion,
"bH"
);
}

Datei anzeigen

@ -4,7 +4,7 @@
#
# Main Config
#
# File generated by: v3.0.0
# File generated by: v3.0.2
# (If this is not the version you are running, consider deleting this
# config to allow it to be re-created. There may be new config options)
#

Datei anzeigen

@ -4,7 +4,7 @@
#
# Language Config
#
# File generated by: v3.0.0
# File generated by: v3.0.2
# (If this is not the version you are running, consider deleting this
# config to allow it to be re-created. There may be new config options)
#

Datei anzeigen

@ -1,6 +1,6 @@
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
name: ArmorStandTools
version: 3.0.0
version: 3.0.2
api-version: 1.13
author: St3venAU
description: Armor stand manipulation tools