Mirror von
https://github.com/St3venAU/ArmorStandTools.git
synchronisiert 2024-12-28 04:20:08 +01:00
v2.1.4 Updated for 1.10
Dieser Commit ist enthalten in:
Ursprung
f13d121919
Commit
148065dbdc
@ -9,7 +9,7 @@ I wanted to create an armor stand for each kit in my mini-game that acts out its
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
- Spigot/CraftBukkit 1.8 - 1.9.x
|
||||
- Spigot/CraftBukkit 1.8.x, 1.9.x, 1.10
|
||||
|
||||
Features
|
||||
--------
|
||||
|
@ -42,7 +42,7 @@ class ArmorStandGUI implements Listener {
|
||||
im.setDisplayName(" ");
|
||||
filler.setItemMeta(im);
|
||||
invSlots.add(10);
|
||||
if(Main.oneNine) {
|
||||
if(!Main.oneEight) {
|
||||
invSlots.add(12);
|
||||
}
|
||||
invSlots.add(2);
|
||||
@ -68,11 +68,11 @@ class ArmorStandGUI implements Listener {
|
||||
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(12, as.getEquipment().getItemInOffHand());
|
||||
} else {
|
||||
i.setItem(10, as.getItemInHand());
|
||||
}
|
||||
i.setItem(2, as.getHelmet());
|
||||
i.setItem(11, as.getChestplate());
|
||||
@ -253,11 +253,11 @@ class ArmorStandGUI implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
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().setItemInOffHand(i.getItem(12));
|
||||
} else {
|
||||
as.setItemInHand(i.getItem(10));
|
||||
}
|
||||
as.setHelmet(i.getItem(2));
|
||||
as.setChestplate(i.getItem(11));
|
||||
|
@ -125,7 +125,7 @@ public enum ArmorStandTool {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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) {
|
||||
@ -134,6 +134,6 @@ public enum ArmorStandTool {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static boolean isHoldingTool(Player p) {
|
||||
return isTool(Main.oneNine ? p.getInventory().getItemInMainHand() : p.getItemInHand());
|
||||
return isTool(Main.oneEight ? p.getItemInHand() : p.getInventory().getItemInMainHand());
|
||||
}
|
||||
}
|
@ -26,13 +26,14 @@ public class Main extends JavaPlugin {
|
||||
public final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<UUID, ItemStack[]>();
|
||||
private final EulerAngle zero = new EulerAngle(0D, 0D, 0D);
|
||||
static String NMS_VERSION;
|
||||
static boolean oneNine, oneNineFour;
|
||||
static boolean oneEight, oneNineFour, oneTen;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
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");
|
||||
oneTen = NMS_VERSION.startsWith("v1_10");
|
||||
getServer().getPluginManager().registerEvents(new MainListener(this), this);
|
||||
CommandExecutor ce = new Commands(this);
|
||||
getCommand("astools").setExecutor(ce);
|
||||
@ -81,8 +82,15 @@ public class Main extends JavaPlugin {
|
||||
int dSlots = NBT.getDisabledSlots(as);
|
||||
String hand, boots, legs, chest, helm, offHand = "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());
|
||||
offHand = as.getEquipment().getItemInOffHand() == null ? "air" : Utils.getNmsName(as.getEquipment().getItemInOffHand().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());
|
||||
handDmg = as.getEquipment().getItemInMainHand() == null ? 0 : as.getEquipment().getItemInMainHand().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();
|
||||
@ -111,7 +112,7 @@ public class Main extends JavaPlugin {
|
||||
EulerAngle ra = as.getRightArmPose();
|
||||
EulerAngle bo = as.getBodyPose();
|
||||
String cmd;
|
||||
if(oneNine) {
|
||||
if(!oneEight) {
|
||||
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.isVisible() ? "" : "Invisible:1,")
|
||||
@ -184,11 +185,11 @@ public class Main extends JavaPlugin {
|
||||
clone.setChestplate(as.getChestplate());
|
||||
clone.setLeggings(as.getLeggings());
|
||||
clone.setBoots(as.getBoots());
|
||||
if(oneNine) {
|
||||
if(oneEight) {
|
||||
clone.setItemInHand(as.getItemInHand());
|
||||
} else {
|
||||
clone.getEquipment().setItemInMainHand(as.getEquipment().getItemInMainHand());
|
||||
clone.getEquipment().setItemInOffHand(as.getEquipment().getItemInOffHand());
|
||||
} else {
|
||||
clone.setItemInHand(as.getItemInHand());
|
||||
}
|
||||
clone.setHeadPose(as.getHeadPose());
|
||||
clone.setBodyPose(as.getBodyPose());
|
||||
|
@ -360,11 +360,11 @@ public class MainListener implements Listener {
|
||||
as.setChestplate(Config.chest);
|
||||
as.setLeggings(Config.pants);
|
||||
as.setBoots(Config.boots);
|
||||
if(Main.oneNine) {
|
||||
if(Main.oneEight) {
|
||||
as.setItemInHand(Config.itemInHand);
|
||||
} else {
|
||||
as.getEquipment().setItemInMainHand(Config.itemInHand);
|
||||
as.getEquipment().setItemInOffHand(Config.itemInOffHand);
|
||||
} else {
|
||||
as.setItemInHand(Config.itemInHand);
|
||||
}
|
||||
as.setVisible(Config.isVisible);
|
||||
as.setSmall(Config.isSmall);
|
||||
|
@ -21,10 +21,14 @@ class NBT {
|
||||
static int getDisabledSlots(ArmorStand as) {
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
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;
|
||||
try {
|
||||
f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz");
|
||||
f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : (Main.oneTen ? "bB" : "bz"));
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
@ -36,20 +40,21 @@ class NBT {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
Object tag = getTag(nmsEntity);
|
||||
if (tag == null) return 0;
|
||||
return getInt(tag, "DisabledSlots");
|
||||
}
|
||||
}
|
||||
|
||||
static void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) {
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
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;
|
||||
try {
|
||||
f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz");
|
||||
f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : (Main.oneTen ? "bB" : "bz"));
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
@ -60,11 +65,6 @@ class NBT {
|
||||
} catch (IllegalAccessException e) {
|
||||
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) {
|
||||
if(Main.oneNineFour || Main.oneTen) {
|
||||
return as.isInvulnerable();
|
||||
}
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
if (nmsEntity == null) return false;
|
||||
if(Main.oneNine) {
|
||||
if(Main.oneEight) {
|
||||
Object tag = getTag(nmsEntity);
|
||||
return tag != null && getBoolean(tag, "Invulnerable");
|
||||
} else {
|
||||
Field f;
|
||||
try {
|
||||
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
|
||||
@ -92,16 +98,21 @@ class NBT {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Object tag = getTag(nmsEntity);
|
||||
return tag != null && getBoolean(tag, "Invulnerable");
|
||||
}
|
||||
}
|
||||
|
||||
static void setInvulnerable(ArmorStand as, boolean invulnerable) {
|
||||
if(Main.oneNineFour || Main.oneTen) {
|
||||
as.setInvulnerable(invulnerable);
|
||||
}
|
||||
Object nmsEntity = getNmsEntity(as);
|
||||
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;
|
||||
try {
|
||||
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
|
||||
@ -115,11 +126,6 @@ class NBT {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Object tag = getTag(nmsEntity);
|
||||
if(tag == null) return;
|
||||
setBoolean(tag, "Invulnerable", invulnerable);
|
||||
saveTagF(nmsEntity, tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# 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
|
||||
# config to allow it to be re-created. There may be new config options)
|
||||
#
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# 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
|
||||
# config to allow it to be re-created. There may be new config options)
|
||||
#
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
|
||||
name: ArmorStandTools
|
||||
version: 2.1.3
|
||||
version: 2.1.4
|
||||
author: St3venAU
|
||||
description: Armor stand manipulation tools
|
||||
softdepend: [WorldGuard, PlotSquared]
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren