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

v2.1.4 Updated for 1.10

Dieser Commit ist enthalten in:
Steven 2016-06-12 13:54:45 +08:00
Ursprung f13d121919
Commit 148065dbdc
9 geänderte Dateien mit 60 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -9,7 +9,7 @@ I wanted to create an armor stand for each kit in my mini-game that acts out its
Compatibility Compatibility
------------- -------------
- Spigot/CraftBukkit 1.8 - 1.9.x - Spigot/CraftBukkit 1.8.x, 1.9.x, 1.10
Features Features
-------- --------

Datei anzeigen

@ -42,7 +42,7 @@ class ArmorStandGUI implements Listener {
im.setDisplayName(" "); im.setDisplayName(" ");
filler.setItemMeta(im); filler.setItemMeta(im);
invSlots.add(10); invSlots.add(10);
if(Main.oneNine) { if(!Main.oneEight) {
invSlots.add(12); invSlots.add(12);
} }
invSlots.add(2); invSlots.add(2);
@ -68,11 +68,11 @@ class ArmorStandGUI implements Listener {
i.setItem(tool.getSlot(), updateLore(tool)); i.setItem(tool.getSlot(), updateLore(tool));
} }
} }
if(Main.oneNine) { if(Main.oneEight) {
i.setItem(10, as.getItemInHand());
} else {
i.setItem(10, as.getEquipment().getItemInMainHand()); i.setItem(10, as.getEquipment().getItemInMainHand());
i.setItem(12, as.getEquipment().getItemInOffHand()); i.setItem(12, as.getEquipment().getItemInOffHand());
} else {
i.setItem(10, as.getItemInHand());
} }
i.setItem(2, as.getHelmet()); i.setItem(2, as.getHelmet());
i.setItem(11, as.getChestplate()); i.setItem(11, as.getChestplate());
@ -253,11 +253,11 @@ class ArmorStandGUI implements Listener {
@Override @Override
public void run() { public void run() {
if(as == null || i == null) return; if(as == null || i == null) return;
if(Main.oneNine) { if(Main.oneEight) {
as.setItemInHand(i.getItem(10));
} else {
as.getEquipment().setItemInMainHand(i.getItem(10)); as.getEquipment().setItemInMainHand(i.getItem(10));
as.getEquipment().setItemInOffHand(i.getItem(12)); as.getEquipment().setItemInOffHand(i.getItem(12));
} else {
as.setItemInHand(i.getItem(10));
} }
as.setHelmet(i.getItem(2)); as.setHelmet(i.getItem(2));
as.setChestplate(i.getItem(11)); as.setChestplate(i.getItem(11));

Datei anzeigen

@ -125,7 +125,7 @@ public enum ArmorStandTool {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
static ArmorStandTool get(Player p) { static ArmorStandTool get(Player p) {
return get(Main.oneNine ? p.getInventory().getItemInMainHand() : p.getItemInHand()); return get(Main.oneEight ? p.getItemInHand() : p.getInventory().getItemInMainHand());
} }
static boolean isTool(ItemStack is) { static boolean isTool(ItemStack is) {
@ -134,6 +134,6 @@ public enum ArmorStandTool {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
static boolean isHoldingTool(Player p) { static boolean isHoldingTool(Player p) {
return isTool(Main.oneNine ? p.getInventory().getItemInMainHand() : p.getItemInHand()); return isTool(Main.oneEight ? p.getItemInHand() : p.getInventory().getItemInMainHand());
} }
} }

Datei anzeigen

@ -26,13 +26,14 @@ public class Main extends JavaPlugin {
public final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<UUID, ItemStack[]>(); public final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<UUID, ItemStack[]>();
private final EulerAngle zero = new EulerAngle(0D, 0D, 0D); private final EulerAngle zero = new EulerAngle(0D, 0D, 0D);
static String NMS_VERSION; static String NMS_VERSION;
static boolean oneNine, oneNineFour; static boolean oneEight, oneNineFour, oneTen;
@Override @Override
public void onEnable() { public void onEnable() {
NMS_VERSION = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; NMS_VERSION = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
oneNine = NMS_VERSION.startsWith("v1_9"); oneEight = NMS_VERSION.startsWith("v1_8");
oneNineFour = NMS_VERSION.startsWith("v1_9_R2"); oneNineFour = NMS_VERSION.startsWith("v1_9_R2");
oneTen = NMS_VERSION.startsWith("v1_10");
getServer().getPluginManager().registerEvents(new MainListener(this), this); getServer().getPluginManager().registerEvents(new MainListener(this), this);
CommandExecutor ce = new Commands(this); CommandExecutor ce = new Commands(this);
getCommand("astools").setExecutor(ce); getCommand("astools").setExecutor(ce);
@ -81,8 +82,15 @@ public class Main extends JavaPlugin {
int dSlots = NBT.getDisabledSlots(as); int dSlots = NBT.getDisabledSlots(as);
String hand, boots, legs, chest, helm, offHand = "0"; String hand, boots, legs, chest, helm, offHand = "0";
int handDmg, offHandDmg = 0; int handDmg, offHandDmg = 0;
if(oneEight) {
hand = as.getItemInHand() == null ? "0" : String.valueOf(as.getItemInHand().getTypeId());
boots = as.getBoots() == null ? "0" : String.valueOf(as.getBoots().getTypeId());
legs = as.getLeggings() == null ? "0" : String.valueOf(as.getLeggings().getTypeId());
chest = as.getChestplate() == null ? "0" : String.valueOf(as.getChestplate().getTypeId());
helm = as.getHelmet() == null ? "0" : String.valueOf(as.getHelmet().getTypeId());
handDmg = as.getItemInHand() == null ? 0 : as.getItemInHand().getDurability();
if(oneNine) { } else {
hand = as.getEquipment().getItemInMainHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInMainHand().getType()); hand = as.getEquipment().getItemInMainHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInMainHand().getType());
offHand = as.getEquipment().getItemInOffHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInOffHand().getType()); offHand = as.getEquipment().getItemInOffHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInOffHand().getType());
boots = as.getBoots() == null ? "air" : Utils.getNmsName(as.getBoots().getType()); boots = as.getBoots() == null ? "air" : Utils.getNmsName(as.getBoots().getType());
@ -91,13 +99,6 @@ public class Main extends JavaPlugin {
helm = as.getHelmet() == null ? "air" : Utils.getNmsName(as.getHelmet().getType()); helm = as.getHelmet() == null ? "air" : Utils.getNmsName(as.getHelmet().getType());
handDmg = as.getEquipment().getItemInMainHand() == null ? 0 : as.getEquipment().getItemInMainHand().getDurability(); handDmg = as.getEquipment().getItemInMainHand() == null ? 0 : as.getEquipment().getItemInMainHand().getDurability();
offHandDmg = as.getEquipment().getItemInOffHand() == null ? 0 : as.getEquipment().getItemInOffHand().getDurability(); offHandDmg = as.getEquipment().getItemInOffHand() == null ? 0 : as.getEquipment().getItemInOffHand().getDurability();
} else {
hand = as.getItemInHand() == null ? "0" : String.valueOf(as.getItemInHand().getTypeId());
boots = as.getBoots() == null ? "0" : String.valueOf(as.getBoots().getTypeId());
legs = as.getLeggings() == null ? "0" : String.valueOf(as.getLeggings().getTypeId());
chest = as.getChestplate() == null ? "0" : String.valueOf(as.getChestplate().getTypeId());
helm = as.getHelmet() == null ? "0" : String.valueOf(as.getHelmet().getTypeId());
handDmg = as.getItemInHand() == null ? 0 : as.getItemInHand().getDurability();
} }
int bootsDmg = as.getBoots() == null ? 0 : as.getBoots().getDurability(); int bootsDmg = as.getBoots() == null ? 0 : as.getBoots().getDurability();
@ -111,7 +112,7 @@ public class Main extends JavaPlugin {
EulerAngle ra = as.getRightArmPose(); EulerAngle ra = as.getRightArmPose();
EulerAngle bo = as.getBodyPose(); EulerAngle bo = as.getBodyPose();
String cmd; String cmd;
if(oneNine) { if(!oneEight) {
cmd = "summon ArmorStand " + Utils.twoDec(loc.getX()) + " " + Utils.twoDec(loc.getY()) + " " + Utils.twoDec(loc.getZ()) + " {" cmd = "summon ArmorStand " + Utils.twoDec(loc.getX()) + " " + Utils.twoDec(loc.getY()) + " " + Utils.twoDec(loc.getZ()) + " {"
+ (as.getMaxHealth() != 20 ? "Attributes:[{Name:\"generic.maxHealth\", Base:" + as.getMaxHealth() + "}]," : "") + (as.getMaxHealth() != 20 ? "Attributes:[{Name:\"generic.maxHealth\", Base:" + as.getMaxHealth() + "}]," : "")
+ (as.isVisible() ? "" : "Invisible:1,") + (as.isVisible() ? "" : "Invisible:1,")
@ -184,11 +185,11 @@ public class Main extends JavaPlugin {
clone.setChestplate(as.getChestplate()); clone.setChestplate(as.getChestplate());
clone.setLeggings(as.getLeggings()); clone.setLeggings(as.getLeggings());
clone.setBoots(as.getBoots()); clone.setBoots(as.getBoots());
if(oneNine) { if(oneEight) {
clone.setItemInHand(as.getItemInHand());
} else {
clone.getEquipment().setItemInMainHand(as.getEquipment().getItemInMainHand()); clone.getEquipment().setItemInMainHand(as.getEquipment().getItemInMainHand());
clone.getEquipment().setItemInOffHand(as.getEquipment().getItemInOffHand()); clone.getEquipment().setItemInOffHand(as.getEquipment().getItemInOffHand());
} else {
clone.setItemInHand(as.getItemInHand());
} }
clone.setHeadPose(as.getHeadPose()); clone.setHeadPose(as.getHeadPose());
clone.setBodyPose(as.getBodyPose()); clone.setBodyPose(as.getBodyPose());

Datei anzeigen

@ -360,11 +360,11 @@ public class MainListener implements Listener {
as.setChestplate(Config.chest); as.setChestplate(Config.chest);
as.setLeggings(Config.pants); as.setLeggings(Config.pants);
as.setBoots(Config.boots); as.setBoots(Config.boots);
if(Main.oneNine) { if(Main.oneEight) {
as.setItemInHand(Config.itemInHand);
} else {
as.getEquipment().setItemInMainHand(Config.itemInHand); as.getEquipment().setItemInMainHand(Config.itemInHand);
as.getEquipment().setItemInOffHand(Config.itemInOffHand); as.getEquipment().setItemInOffHand(Config.itemInOffHand);
} else {
as.setItemInHand(Config.itemInHand);
} }
as.setVisible(Config.isVisible); as.setVisible(Config.isVisible);
as.setSmall(Config.isSmall); as.setSmall(Config.isSmall);

Datei anzeigen

@ -21,10 +21,14 @@ class NBT {
static int getDisabledSlots(ArmorStand as) { static int getDisabledSlots(ArmorStand as) {
Object nmsEntity = getNmsEntity(as); Object nmsEntity = getNmsEntity(as);
if(nmsEntity == null) return 0; if(nmsEntity == null) return 0;
if(Main.oneNine) { if(Main.oneEight) {
Object tag = getTag(nmsEntity);
if (tag == null) return 0;
return getInt(tag, "DisabledSlots");
} else {
Field f; Field f;
try { try {
f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz"); f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : (Main.oneTen ? "bB" : "bz"));
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
return 0; return 0;
@ -36,20 +40,21 @@ class NBT {
e.printStackTrace(); e.printStackTrace();
return 0; return 0;
} }
} else {
Object tag = getTag(nmsEntity);
if (tag == null) return 0;
return getInt(tag, "DisabledSlots");
} }
} }
static void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) { static void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) {
Object nmsEntity = getNmsEntity(as); Object nmsEntity = getNmsEntity(as);
if (nmsEntity == null) return; if (nmsEntity == null) return;
if(Main.oneNine) { if(Main.oneEight) {
Object tag = getTag(nmsEntity);
if (tag == null) return;
setInt(tag, "DisabledSlots", slotsDisabled ? 2039583 : 0);
saveTagA(nmsEntity, tag);
} else {
Field f; Field f;
try { try {
f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz"); f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : (Main.oneTen ? "bB" : "bz"));
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
return; return;
@ -60,11 +65,6 @@ class NBT {
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else {
Object tag = getTag(nmsEntity);
if (tag == null) return;
setInt(tag, "DisabledSlots", slotsDisabled ? 2039583 : 0);
saveTagA(nmsEntity, tag);
} }
} }
@ -75,9 +75,15 @@ class NBT {
} }
static boolean isInvulnerable(ArmorStand as) { static boolean isInvulnerable(ArmorStand as) {
if(Main.oneNineFour || Main.oneTen) {
return as.isInvulnerable();
}
Object nmsEntity = getNmsEntity(as); Object nmsEntity = getNmsEntity(as);
if (nmsEntity == null) return false; if (nmsEntity == null) return false;
if(Main.oneNine) { if(Main.oneEight) {
Object tag = getTag(nmsEntity);
return tag != null && getBoolean(tag, "Invulnerable");
} else {
Field f; Field f;
try { try {
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable"); f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
@ -92,16 +98,21 @@ class NBT {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} else {
Object tag = getTag(nmsEntity);
return tag != null && getBoolean(tag, "Invulnerable");
} }
} }
static void setInvulnerable(ArmorStand as, boolean invulnerable) { static void setInvulnerable(ArmorStand as, boolean invulnerable) {
if(Main.oneNineFour || Main.oneTen) {
as.setInvulnerable(invulnerable);
}
Object nmsEntity = getNmsEntity(as); Object nmsEntity = getNmsEntity(as);
if (nmsEntity == null) return; if (nmsEntity == null) return;
if(Main.oneNine) { if(Main.oneEight) {
Object tag = getTag(nmsEntity);
if(tag == null) return;
setBoolean(tag, "Invulnerable", invulnerable);
saveTagF(nmsEntity, tag);
} else {
Field f; Field f;
try { try {
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable"); f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
@ -115,11 +126,6 @@ class NBT {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else {
Object tag = getTag(nmsEntity);
if(tag == null) return;
setBoolean(tag, "Invulnerable", invulnerable);
saveTagF(nmsEntity, tag);
} }
} }

Datei anzeigen

@ -4,7 +4,7 @@
# #
# Main Config # Main Config
# #
# File generated by: v2.1.3 # File generated by: v2.1.4
# (If this is not the version you are running, consider deleting this # (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) # config to allow it to be re-created. There may be new config options)
# #

Datei anzeigen

@ -4,7 +4,7 @@
# #
# Language Config # Language Config
# #
# File generated by: v2.1.3 # File generated by: v2.1.4
# (If this is not the version you are running, consider deleting this # (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) # 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 main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
name: ArmorStandTools name: ArmorStandTools
version: 2.1.3 version: 2.1.4
author: St3venAU author: St3venAU
description: Armor stand manipulation tools description: Armor stand manipulation tools
softdepend: [WorldGuard, PlotSquared] softdepend: [WorldGuard, PlotSquared]