Mirror von
https://github.com/St3venAU/ArmorStandTools.git
synchronisiert 2024-12-29 04:50:09 +01:00
Updated for Spigot/Craftbukkit 1.9 (Backwards compatible with 1.8.x)
Added GUI slot for setting the item in the Armor Stand's left hand (1.9 only) Added config.yml option for default item in left hand (inOffHand) Workaround for setting player skulls in 1.9
Dieser Commit ist enthalten in:
Ursprung
7d8cb88876
Commit
d66c6c5e1e
@ -41,11 +41,14 @@ class ArmorStandGUI implements Listener {
|
|||||||
ItemMeta im = filler.getItemMeta();
|
ItemMeta im = filler.getItemMeta();
|
||||||
im.setDisplayName(" ");
|
im.setDisplayName(" ");
|
||||||
filler.setItemMeta(im);
|
filler.setItemMeta(im);
|
||||||
invSlots.add(0);
|
|
||||||
invSlots.add(9);
|
|
||||||
invSlots.add(10);
|
invSlots.add(10);
|
||||||
invSlots.add(18);
|
if(Main.one_nine) {
|
||||||
invSlots.add(27);
|
invSlots.add(12);
|
||||||
|
}
|
||||||
|
invSlots.add(2);
|
||||||
|
invSlots.add(11);
|
||||||
|
invSlots.add(20);
|
||||||
|
invSlots.add(29);
|
||||||
}
|
}
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
@ -65,11 +68,16 @@ class ArmorStandGUI implements Listener {
|
|||||||
i.setItem(tool.getSlot(), updateLore(tool));
|
i.setItem(tool.getSlot(), updateLore(tool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i.setItem(0, as.getHelmet());
|
if(Main.one_nine) {
|
||||||
i.setItem(9, as.getChestplate());
|
i.setItem(10, as.getEquipment().getItemInMainHand());
|
||||||
i.setItem(10, as.getItemInHand());
|
i.setItem(12, as.getEquipment().getItemInOffHand());
|
||||||
i.setItem(18, as.getLeggings());
|
} else {
|
||||||
i.setItem(27, as.getBoots());
|
i.setItem(10, as.getItemInHand());
|
||||||
|
}
|
||||||
|
i.setItem(2, as.getHelmet());
|
||||||
|
i.setItem(11, as.getChestplate());
|
||||||
|
i.setItem(20, as.getLeggings());
|
||||||
|
i.setItem(29, as.getBoots());
|
||||||
inUse.add(as.getEntityId());
|
inUse.add(as.getEntityId());
|
||||||
p.openInventory(i);
|
p.openInventory(i);
|
||||||
}
|
}
|
||||||
@ -148,32 +156,32 @@ class ArmorStandGUI implements Listener {
|
|||||||
switch (t) {
|
switch (t) {
|
||||||
case INVIS:
|
case INVIS:
|
||||||
as.setVisible(!as.isVisible());
|
as.setVisible(!as.isVisible());
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.asVisible + ": " + (as.isVisible() ? Config.isTrue : Config.isFalse));
|
Utils.actionBarMsg(p, Config.asVisible + ": " + (as.isVisible() ? Config.isTrue : Config.isFalse));
|
||||||
break;
|
break;
|
||||||
case CLONE:
|
case CLONE:
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
plugin.pickUpArmorStand(plugin.clone(as), p, true);
|
plugin.pickUpArmorStand(plugin.clone(as), p, true);
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
|
Utils.actionBarMsg(p, Config.carrying);
|
||||||
break;
|
break;
|
||||||
case SAVE:
|
case SAVE:
|
||||||
plugin.generateCmdBlock(p.getLocation(), as);
|
plugin.generateCmdBlock(p.getLocation(), as);
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.cbCreated);
|
Utils.actionBarMsg(p, Config.cbCreated);
|
||||||
break;
|
break;
|
||||||
case SIZE:
|
case SIZE:
|
||||||
as.setSmall(!as.isSmall());
|
as.setSmall(!as.isSmall());
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.size + ": " + (as.isSmall() ? Config.small : Config.normal));
|
Utils.actionBarMsg(p, Config.size + ": " + (as.isSmall() ? Config.small : Config.normal));
|
||||||
break;
|
break;
|
||||||
case BASE:
|
case BASE:
|
||||||
as.setBasePlate(!as.hasBasePlate());
|
as.setBasePlate(!as.hasBasePlate());
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.basePlate + ": " + (as.hasBasePlate() ? Config.isOn : Config.isOff));
|
Utils.actionBarMsg(p, Config.basePlate + ": " + (as.hasBasePlate() ? Config.isOn : Config.isOff));
|
||||||
break;
|
break;
|
||||||
case GRAV:
|
case GRAV:
|
||||||
as.setGravity(!as.hasGravity());
|
as.setGravity(!as.hasGravity());
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.gravity + ": " + (as.hasGravity() ? Config.isOn : Config.isOff));
|
Utils.actionBarMsg(p, Config.gravity + ": " + (as.hasGravity() ? Config.isOn : Config.isOff));
|
||||||
break;
|
break;
|
||||||
case ARMS:
|
case ARMS:
|
||||||
as.setArms(!as.hasArms());
|
as.setArms(!as.hasArms());
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.arms + ": " + (as.hasArms() ? Config.isOn : Config.isOff));
|
Utils.actionBarMsg(p, Config.arms + ": " + (as.hasArms() ? Config.isOn : Config.isOff));
|
||||||
break;
|
break;
|
||||||
case NAME:
|
case NAME:
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
@ -184,10 +192,10 @@ class ArmorStandGUI implements Listener {
|
|||||||
plugin.setPlayerSkull(p, as);
|
plugin.setPlayerSkull(p, as);
|
||||||
break;
|
break;
|
||||||
case INVUL:
|
case INVUL:
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.invul + ": " + (NBT.toggleInvulnerability(as) ? Config.isOn : Config.isOff));
|
Utils.actionBarMsg(p, Config.invul + ": " + (NBT.toggleInvulnerability(as) ? Config.isOn : Config.isOff));
|
||||||
break;
|
break;
|
||||||
case SLOTS:
|
case SLOTS:
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.equip + ": " + (NBT.toggleSlotsDisabled(as) ? Config.locked : Config.unLocked));
|
Utils.actionBarMsg(p, Config.equip + ": " + (NBT.toggleSlotsDisabled(as) ? Config.locked : Config.unLocked));
|
||||||
break;
|
break;
|
||||||
case MOVE:
|
case MOVE:
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
@ -197,16 +205,16 @@ class ArmorStandGUI implements Listener {
|
|||||||
Utils.actionBarMsg(p, Config.asDropped);
|
Utils.actionBarMsg(p, Config.asDropped);
|
||||||
} else {
|
} else {
|
||||||
plugin.pickUpArmorStand(as, p, false);
|
plugin.pickUpArmorStand(as, p, false);
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
|
Utils.actionBarMsg(p, Config.carrying);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NODEL: // Developer tool - do not use
|
case NODEL: // Developer tool - do not use
|
||||||
if(as.getMaxHealth() == 50) {
|
if(as.getMaxHealth() == 50) {
|
||||||
as.setMaxHealth(20);
|
as.setMaxHealth(20);
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + "Deletion Protection: Disabled");
|
Utils.actionBarMsg(p, "Deletion Protection: Disabled");
|
||||||
} else {
|
} else {
|
||||||
as.setMaxHealth(50);
|
as.setMaxHealth(50);
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + "Deletion Protection: Enabled");
|
Utils.actionBarMsg(p, "Deletion Protection: Enabled");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -245,11 +253,16 @@ class ArmorStandGUI implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(as == null || i == null) return;
|
if(as == null || i == null) return;
|
||||||
as.setHelmet(i.getItem(0));
|
if(Main.one_nine) {
|
||||||
as.setChestplate(i.getItem(9));
|
as.getEquipment().setItemInMainHand(i.getItem(10));
|
||||||
as.setItemInHand(i.getItem(10));
|
as.getEquipment().setItemInOffHand(i.getItem(12));
|
||||||
as.setLeggings(i.getItem(18));
|
} else {
|
||||||
as.setBoots(i.getItem(27));
|
as.setItemInHand(i.getItem(10));
|
||||||
|
}
|
||||||
|
as.setHelmet(i.getItem(2));
|
||||||
|
as.setChestplate(i.getItem(11));
|
||||||
|
as.setLeggings(i.getItem(20));
|
||||||
|
as.setBoots(i.getItem(29));
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 1L);
|
}.runTaskLater(plugin, 1L);
|
||||||
}
|
}
|
||||||
|
@ -33,18 +33,18 @@ public enum ArmorStandTool {
|
|||||||
SUMMON ("summon", Material.ARMOR_STAND, (short) 0, 0, false, true, "astools.use"),
|
SUMMON ("summon", Material.ARMOR_STAND, (short) 0, 0, false, true, "astools.use"),
|
||||||
GUI ("gui", Material.NETHER_STAR, (short) 0, 1, false, true, "astools.use"),
|
GUI ("gui", Material.NETHER_STAR, (short) 0, 1, false, true, "astools.use"),
|
||||||
ROTAT ("rotat", Material.MAGMA_CREAM, (short) 0, 2, false, true, "astools.use"),
|
ROTAT ("rotat", Material.MAGMA_CREAM, (short) 0, 2, false, true, "astools.use"),
|
||||||
CLONE ("gui_clone", Material.GLOWSTONE_DUST, (short) 0, 16, true, true, "astools.clone"),
|
CLONE ("gui_clone", Material.GLOWSTONE_DUST, (short) 0, 15, true, true, "astools.clone"),
|
||||||
SAVE ("gui_save", Material.DIAMOND, (short) 0, 17, true, true, "astools.cmdblock"),
|
SAVE ("gui_save", Material.DIAMOND, (short) 0, 16, true, true, "astools.cmdblock"),
|
||||||
INVIS ("gui_invis", Material.GOLD_NUGGET, (short) 0, 14, true, true, "astools.use"),
|
INVIS ("gui_invis", Material.GOLD_NUGGET, (short) 0, 7, true, true, "astools.use"),
|
||||||
SIZE ("gui_size", Material.EMERALD, (short) 0, 23, true, true, "astools.use"),
|
SIZE ("gui_size", Material.EMERALD, (short) 0, 25, true, true, "astools.use"),
|
||||||
BASE ("gui_base", Material.BOOK, (short) 0, 22, true, true, "astools.use"),
|
BASE ("gui_base", Material.BOOK, (short) 0, 24, true, true, "astools.use"),
|
||||||
GRAV ("gui_grav", Material.GHAST_TEAR, (short) 0, 24, true, true, "astools.use"),
|
GRAV ("gui_grav", Material.GHAST_TEAR, (short) 0, 32, true, true, "astools.use"),
|
||||||
ARMS ("gui_arms", Material.ARROW, (short) 0, 21, true, true, "astools.use"),
|
ARMS ("gui_arms", Material.ARROW, (short) 0, 23, true, true, "astools.use"),
|
||||||
NAME ("gui_name", Material.NAME_TAG, (short) 0, 12, true, true, "astools.use"),
|
NAME ("gui_name", Material.NAME_TAG, (short) 0, 5, true, true, "astools.use"),
|
||||||
SLOTS ("gui_slots", Material.IRON_HOE, (short) 0, 26, true, true, "astools.use"),
|
SLOTS ("gui_slots", Material.IRON_HOE, (short) 0, 34, true, true, "astools.use"),
|
||||||
PHEAD ("gui_pHead", Material.SKULL_ITEM, (short) 3, 13, true, true, "astools.use"),
|
PHEAD ("gui_pHead", Material.SKULL_ITEM, (short) 3, 6, true, true, "astools.use"),
|
||||||
INVUL ("gui_invul", Material.GOLDEN_CARROT, (short) 0, 25, true, true, "astools.use"),
|
INVUL ("gui_invul", Material.GOLDEN_CARROT, (short) 0, 33, true, true, "astools.use"),
|
||||||
MOVE ("gui_move", Material.FEATHER, (short) 0, 15, true, true, "astools.use"),
|
MOVE ("gui_move", Material.FEATHER, (short) 0, 14, true, true, "astools.use"),
|
||||||
NODEL ("gui_noDel", Material.WOOD_SPADE, (short) 0, 35, true, false, "astools.use"); // Developer tool, disabled by default
|
NODEL ("gui_noDel", Material.WOOD_SPADE, (short) 0, 35, true, false, "astools.use"); // Developer tool, disabled by default
|
||||||
|
|
||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
|
@ -19,7 +19,7 @@ class Config {
|
|||||||
|
|
||||||
public static WorldGuardPlugin worldGuardPlugin;
|
public static WorldGuardPlugin worldGuardPlugin;
|
||||||
|
|
||||||
public static ItemStack helmet, chest, pants, boots, itemInHand;
|
public static ItemStack helmet, chest, pants, boots, itemInHand, itemInOffHand;
|
||||||
public static boolean isVisible = true;
|
public static boolean isVisible = true;
|
||||||
public static boolean isSmall = false;
|
public static boolean isSmall = false;
|
||||||
public static boolean hasArms = true;
|
public static boolean hasArms = true;
|
||||||
@ -100,6 +100,7 @@ class Config {
|
|||||||
pants = toItemStack(config.getString("pants"));
|
pants = toItemStack(config.getString("pants"));
|
||||||
boots = toItemStack(config.getString("boots"));
|
boots = toItemStack(config.getString("boots"));
|
||||||
itemInHand = toItemStack(config.getString("inHand"));
|
itemInHand = toItemStack(config.getString("inHand"));
|
||||||
|
itemInOffHand = toItemStack(config.getString("inOffHand"));
|
||||||
isVisible = config.getBoolean("isVisible");
|
isVisible = config.getBoolean("isVisible");
|
||||||
isSmall = config.getBoolean("isSmall");
|
isSmall = config.getBoolean("isSmall");
|
||||||
hasArms = config.getBoolean("hasArms");
|
hasArms = config.getBoolean("hasArms");
|
||||||
|
@ -27,10 +27,12 @@ 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 one_nine;
|
||||||
|
|
||||||
@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];
|
||||||
|
one_nine = NMS_VERSION.startsWith("v1_9");
|
||||||
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);
|
||||||
@ -77,15 +79,30 @@ public class Main extends JavaPlugin {
|
|||||||
void generateCmdBlock(Location l, ArmorStand as) {
|
void generateCmdBlock(Location l, ArmorStand as) {
|
||||||
Location loc = as.getLocation();
|
Location loc = as.getLocation();
|
||||||
int dSlots = NBT.getDisabledSlots(as);
|
int dSlots = NBT.getDisabledSlots(as);
|
||||||
int hand = as.getItemInHand() == null ? 0 : as.getItemInHand().getTypeId();
|
String hand, boots, legs, chest, helm, offHand = "0";
|
||||||
int handDmg = as.getItemInHand() == null ? 0 : as.getItemInHand().getDurability();
|
int handDmg, offHandDmg = 0;
|
||||||
int boots = as.getBoots() == null ? 0 : as.getBoots().getTypeId();
|
|
||||||
|
if(one_nine) {
|
||||||
|
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());
|
||||||
|
legs = as.getLeggings() == null ? "air" : Utils.getNmsName(as.getLeggings().getType());
|
||||||
|
chest = as.getChestplate() == null ? "air" : Utils.getNmsName(as.getChestplate().getType());
|
||||||
|
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();
|
int bootsDmg = as.getBoots() == null ? 0 : as.getBoots().getDurability();
|
||||||
int legs = as.getLeggings() == null ? 0 : as.getLeggings().getTypeId();
|
|
||||||
int legsDmg = as.getLeggings() == null ? 0 : as.getLeggings().getDurability();
|
int legsDmg = as.getLeggings() == null ? 0 : as.getLeggings().getDurability();
|
||||||
int chest = as.getChestplate() == null ? 0 : as.getChestplate().getTypeId();
|
|
||||||
int chestDmg = as.getChestplate() == null ? 0 : as.getChestplate().getDurability();
|
int chestDmg = as.getChestplate() == null ? 0 : as.getChestplate().getDurability();
|
||||||
int helm = as.getHelmet() == null ? 0 : as.getHelmet().getTypeId();
|
|
||||||
int helmDmg = as.getHelmet() == null ? 0 : as.getHelmet().getDurability();
|
int helmDmg = as.getHelmet() == null ? 0 : as.getHelmet().getDurability();
|
||||||
EulerAngle he = as.getHeadPose();
|
EulerAngle he = as.getHeadPose();
|
||||||
EulerAngle ll = as.getLeftLegPose();
|
EulerAngle ll = as.getLeftLegPose();
|
||||||
@ -93,33 +110,65 @@ public class Main extends JavaPlugin {
|
|||||||
EulerAngle la = as.getLeftArmPose();
|
EulerAngle la = as.getLeftArmPose();
|
||||||
EulerAngle ra = as.getRightArmPose();
|
EulerAngle ra = as.getRightArmPose();
|
||||||
EulerAngle bo = as.getBodyPose();
|
EulerAngle bo = as.getBodyPose();
|
||||||
String cmd =
|
String cmd;
|
||||||
"summon ArmorStand " + Utils.twoDec(loc.getX()) + " " + Utils.twoDec(loc.getY()) + " " + Utils.twoDec(loc.getZ()) + " {"
|
if(one_nine) {
|
||||||
+ (as.getMaxHealth() != 20 ? "Attributes:[{Name:\"generic.maxHealth\", Base:" + as.getMaxHealth() + "}]," : "")
|
cmd = "summon ArmorStand " + Utils.twoDec(loc.getX()) + " " + Utils.twoDec(loc.getY()) + " " + Utils.twoDec(loc.getZ()) + " {"
|
||||||
+ (as.isVisible() ? "" : "Invisible:1,")
|
+ (as.getMaxHealth() != 20 ? "Attributes:[{Name:\"generic.maxHealth\", Base:" + as.getMaxHealth() + "}]," : "")
|
||||||
+ (as.hasBasePlate() ? "" : "NoBasePlate:1,")
|
+ (as.isVisible() ? "" : "Invisible:1,")
|
||||||
+ (as.hasGravity() ? "" : "NoGravity:1,")
|
+ (as.hasBasePlate() ? "" : "NoBasePlate:1,")
|
||||||
+ (as.hasArms() ? "ShowArms:1," : "")
|
+ (as.hasGravity() ? "" : "NoGravity:1,")
|
||||||
+ (as.isSmall() ? "Small:1," : "")
|
+ (as.hasArms() ? "ShowArms:1," : "")
|
||||||
+ (NBT.isInvulnerable(as) ? "Invulnerable:1," : "")
|
+ (as.isSmall() ? "Small:1," : "")
|
||||||
+ (dSlots == 0 ? "" : ("DisabledSlots:" + dSlots + ","))
|
+ (NBT.isInvulnerable(as) ? "Invulnerable:1," : "")
|
||||||
+ (as.isCustomNameVisible() ? "CustomNameVisible:1," : "")
|
+ (dSlots == 0 ? "" : ("DisabledSlots:" + dSlots + ","))
|
||||||
+ (as.getCustomName() == null ? "" : ("CustomName:\"" + as.getCustomName() + "\","))
|
+ (as.isCustomNameVisible() ? "CustomNameVisible:1," : "")
|
||||||
+ (loc.getYaw() == 0F ? "" : ("Rotation:[" + Utils.twoDec(loc.getYaw()) + "f],"))
|
+ (as.getCustomName() == null ? "" : ("CustomName:\"" + as.getCustomName() + "\","))
|
||||||
+ (hand == 0 && boots == 0 && legs == 0 && chest == 0 && helm == 0 ? "" : (
|
+ (loc.getYaw() == 0F ? "" : ("Rotation:[" + Utils.twoDec(loc.getYaw()) + "f],"))
|
||||||
"Equipment:["
|
+ (as.getBoots() == null && as.getLeggings() == null && as.getChestplate() == null && as.getHelmet() == null ? "" : (
|
||||||
+ "{id:" + hand + ",Count:" + as.getItemInHand().getAmount() + ",Damage:" + handDmg + NBT.getItemStackTags(as.getItemInHand()) + "},"
|
"ArmorItems:["
|
||||||
+ "{id:" + boots + ",Count:" + as.getBoots().getAmount() + ",Damage:" + bootsDmg + NBT.getItemStackTags(as.getBoots()) + "},"
|
+ "{id:" + boots + ",Count:" + as.getBoots().getAmount() + ",Damage:" + bootsDmg + NBT.getItemStackTags(as.getBoots()) + "},"
|
||||||
+ "{id:" + legs + ",Count:" + as.getLeggings().getAmount() + ",Damage:" + legsDmg + NBT.getItemStackTags(as.getLeggings()) + "},"
|
+ "{id:" + legs + ",Count:" + as.getLeggings().getAmount() + ",Damage:" + legsDmg + NBT.getItemStackTags(as.getLeggings()) + "},"
|
||||||
+ "{id:" + chest + ",Count:" + as.getChestplate().getAmount() + ",Damage:" + chestDmg + NBT.getItemStackTags(as.getChestplate()) + "},"
|
+ "{id:" + chest + ",Count:" + as.getChestplate().getAmount() + ",Damage:" + chestDmg + NBT.getItemStackTags(as.getChestplate()) + "},"
|
||||||
+ "{id:" + helm + ",Count:" + as.getHelmet().getAmount() + ",Damage:" + helmDmg + NBT.getItemStackTags(as.getHelmet()) + NBT.skullOwner(as.getHelmet()) + "}],"))
|
+ "{id:" + helm + ",Count:" + as.getHelmet().getAmount() + ",Damage:" + helmDmg + NBT.getItemStackTags(as.getHelmet()) + NBT.skullOwner(as.getHelmet()) + "}],"))
|
||||||
+ "Pose:{"
|
+ (as.getEquipment().getItemInMainHand() == null && as.getEquipment().getItemInOffHand() == null ? "" : (
|
||||||
+ (bo.equals(zero) ? "" : ("Body:[" + Utils.angle(bo.getX()) + "f," + Utils.angle(bo.getY()) + "f," + Utils.angle(bo.getZ()) + "f],"))
|
"HandItems:["
|
||||||
+ (he.equals(zero) ? "" : ("Head:[" + Utils.angle(he.getX()) + "f," + Utils.angle(he.getY()) + "f," + Utils.angle(he.getZ()) + "f],"))
|
+ "{id:" + hand + ",Count:" + as.getEquipment().getItemInMainHand().getAmount() + ",Damage:" + handDmg + NBT.getItemStackTags(as.getEquipment().getItemInMainHand()) + "},"
|
||||||
+ (ll.equals(zero) ? "" : ("LeftLeg:[" + Utils.angle(ll.getX()) + "f," + Utils.angle(ll.getY()) + "f," + Utils.angle(ll.getZ()) + "f],"))
|
+ "{id:" + offHand + ",Count:" + as.getEquipment().getItemInOffHand().getAmount() + ",Damage:" + offHandDmg + NBT.getItemStackTags(as.getEquipment().getItemInOffHand()) + "}],"))
|
||||||
+ (rl.equals(zero) ? "" : ("RightLeg:[" + Utils.angle(rl.getX()) + "f," + Utils.angle(rl.getY()) + "f," + Utils.angle(rl.getZ()) + "f],"))
|
+ "Pose:{"
|
||||||
+ (la.equals(zero) ? "" : ("LeftArm:[" + Utils.angle(la.getX()) + "f," + Utils.angle(la.getY()) + "f," + Utils.angle(la.getZ()) + "f],"))
|
+ (bo.equals(zero) ? "" : ("Body:[" + Utils.angle(bo.getX()) + "f," + Utils.angle(bo.getY()) + "f," + Utils.angle(bo.getZ()) + "f],"))
|
||||||
+ "RightArm:[" + Utils.angle(ra.getX()) + "f," + Utils.angle(ra.getY()) + "f," + Utils.angle(ra.getZ()) + "f]}}";
|
+ (he.equals(zero) ? "" : ("Head:[" + Utils.angle(he.getX()) + "f," + Utils.angle(he.getY()) + "f," + Utils.angle(he.getZ()) + "f],"))
|
||||||
|
+ (ll.equals(zero) ? "" : ("LeftLeg:[" + Utils.angle(ll.getX()) + "f," + Utils.angle(ll.getY()) + "f," + Utils.angle(ll.getZ()) + "f],"))
|
||||||
|
+ (rl.equals(zero) ? "" : ("RightLeg:[" + Utils.angle(rl.getX()) + "f," + Utils.angle(rl.getY()) + "f," + Utils.angle(rl.getZ()) + "f],"))
|
||||||
|
+ (la.equals(zero) ? "" : ("LeftArm:[" + Utils.angle(la.getX()) + "f," + Utils.angle(la.getY()) + "f," + Utils.angle(la.getZ()) + "f],"))
|
||||||
|
+ "RightArm:[" + Utils.angle(ra.getX()) + "f," + Utils.angle(ra.getY()) + "f," + Utils.angle(ra.getZ()) + "f]}}";
|
||||||
|
} else {
|
||||||
|
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,")
|
||||||
|
+ (as.hasBasePlate() ? "" : "NoBasePlate:1,")
|
||||||
|
+ (as.hasGravity() ? "" : "NoGravity:1,")
|
||||||
|
+ (as.hasArms() ? "ShowArms:1," : "")
|
||||||
|
+ (as.isSmall() ? "Small:1," : "")
|
||||||
|
+ (NBT.isInvulnerable(as) ? "Invulnerable:1," : "")
|
||||||
|
+ (dSlots == 0 ? "" : ("DisabledSlots:" + dSlots + ","))
|
||||||
|
+ (as.isCustomNameVisible() ? "CustomNameVisible:1," : "")
|
||||||
|
+ (as.getCustomName() == null ? "" : ("CustomName:\"" + as.getCustomName() + "\","))
|
||||||
|
+ (loc.getYaw() == 0F ? "" : ("Rotation:[" + Utils.twoDec(loc.getYaw()) + "f],"))
|
||||||
|
+ (as.getItemInHand() == null && as.getBoots() == null && as.getLeggings() == null && as.getChestplate() == null && as.getHelmet() == null ? "" : (
|
||||||
|
"Equipment:["
|
||||||
|
+ "{id:" + hand + ",Count:" + as.getItemInHand().getAmount() + ",Damage:" + handDmg + NBT.getItemStackTags(as.getItemInHand()) + "},"
|
||||||
|
+ "{id:" + boots + ",Count:" + as.getBoots().getAmount() + ",Damage:" + bootsDmg + NBT.getItemStackTags(as.getBoots()) + "},"
|
||||||
|
+ "{id:" + legs + ",Count:" + as.getLeggings().getAmount() + ",Damage:" + legsDmg + NBT.getItemStackTags(as.getLeggings()) + "},"
|
||||||
|
+ "{id:" + chest + ",Count:" + as.getChestplate().getAmount() + ",Damage:" + chestDmg + NBT.getItemStackTags(as.getChestplate()) + "},"
|
||||||
|
+ "{id:" + helm + ",Count:" + as.getHelmet().getAmount() + ",Damage:" + helmDmg + NBT.getItemStackTags(as.getHelmet()) + NBT.skullOwner(as.getHelmet()) + "}],"))
|
||||||
|
+ "Pose:{"
|
||||||
|
+ (bo.equals(zero) ? "" : ("Body:[" + Utils.angle(bo.getX()) + "f," + Utils.angle(bo.getY()) + "f," + Utils.angle(bo.getZ()) + "f],"))
|
||||||
|
+ (he.equals(zero) ? "" : ("Head:[" + Utils.angle(he.getX()) + "f," + Utils.angle(he.getY()) + "f," + Utils.angle(he.getZ()) + "f],"))
|
||||||
|
+ (ll.equals(zero) ? "" : ("LeftLeg:[" + Utils.angle(ll.getX()) + "f," + Utils.angle(ll.getY()) + "f," + Utils.angle(ll.getZ()) + "f],"))
|
||||||
|
+ (rl.equals(zero) ? "" : ("RightLeg:[" + Utils.angle(rl.getX()) + "f," + Utils.angle(rl.getY()) + "f," + Utils.angle(rl.getZ()) + "f],"))
|
||||||
|
+ (la.equals(zero) ? "" : ("LeftArm:[" + Utils.angle(la.getX()) + "f," + Utils.angle(la.getY()) + "f," + Utils.angle(la.getZ()) + "f],"))
|
||||||
|
+ "RightArm:[" + Utils.angle(ra.getX()) + "f," + Utils.angle(ra.getY()) + "f," + Utils.angle(ra.getZ()) + "f]}}";
|
||||||
|
}
|
||||||
Block b = l.getBlock();
|
Block b = l.getBlock();
|
||||||
b.setType(Material.COMMAND);
|
b.setType(Material.COMMAND);
|
||||||
b.setData((byte) 0);
|
b.setData((byte) 0);
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.gmail.St3venAU.plugins.ArmorStandTools;
|
package com.gmail.St3venAU.plugins.ArmorStandTools;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.SkullType;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Skull;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -64,7 +63,7 @@ public class MainListener implements Listener {
|
|||||||
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
|
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArmorStandTool tool = ArmorStandTool.get(p.getItemInHand());
|
ArmorStandTool tool = ArmorStandTool.get(p.getInventory().getItemInMainHand());
|
||||||
if(tool == null) return;
|
if(tool == null) return;
|
||||||
ArmorStand as = (ArmorStand) event.getRightClicked();
|
ArmorStand as = (ArmorStand) event.getRightClicked();
|
||||||
if (!plugin.playerHasPermission(p, event.getRightClicked().getLocation().getBlock(), tool)) {
|
if (!plugin.playerHasPermission(p, event.getRightClicked().getLocation().getBlock(), tool)) {
|
||||||
@ -190,7 +189,7 @@ public class MainListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
as.teleport(Utils.getLocationFacing(event.getTo()));
|
as.teleport(Utils.getLocationFacing(event.getTo()));
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
|
Utils.actionBarMsg(p, Config.carrying);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +209,7 @@ public class MainListener implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
as.teleport(Utils.getLocationFacing(p.getLocation()));
|
as.teleport(Utils.getLocationFacing(p.getLocation()));
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
|
Utils.actionBarMsg(p, Config.carrying);
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 1L);
|
}.runTaskLater(plugin, 1L);
|
||||||
} else {
|
} else {
|
||||||
@ -315,7 +314,7 @@ public class MainListener implements Listener {
|
|||||||
}
|
}
|
||||||
Location l = Utils.getLocationFacing(p.getLocation());
|
Location l = Utils.getLocationFacing(p.getLocation());
|
||||||
plugin.pickUpArmorStand(spawnArmorStand(l), p, true);
|
plugin.pickUpArmorStand(spawnArmorStand(l), p, true);
|
||||||
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
|
Utils.actionBarMsg(p, Config.carrying);
|
||||||
}
|
}
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -327,7 +326,7 @@ public class MainListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
if(event.getEntity() instanceof ArmorStand && event.getDamager() instanceof Player && ArmorStandTool.isTool(((Player) event.getDamager()).getItemInHand())) {
|
if(event.getEntity() instanceof ArmorStand && event.getDamager() instanceof Player && ArmorStandTool.isTool(((Player) event.getDamager()).getInventory().getItemInMainHand())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(noCooldown(event.getDamager())) {
|
if(noCooldown(event.getDamager())) {
|
||||||
Utils.cycleInventory((Player) event.getDamager());
|
Utils.cycleInventory((Player) event.getDamager());
|
||||||
@ -350,7 +349,12 @@ 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);
|
||||||
as.setItemInHand(Config.itemInHand);
|
if(Main.one_nine) {
|
||||||
|
as.getEquipment().setItemInMainHand(Config.itemInHand);
|
||||||
|
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);
|
||||||
as.setArms(Config.hasArms);
|
as.setArms(Config.hasArms);
|
||||||
@ -379,7 +383,6 @@ public class MainListener implements Listener {
|
|||||||
if(event.getBlock().hasMetadata("armorStand")) {
|
if(event.getBlock().hasMetadata("armorStand")) {
|
||||||
final Block b = event.getBlock();
|
final Block b = event.getBlock();
|
||||||
final ArmorStand as = getArmorStand(b);
|
final ArmorStand as = getArmorStand(b);
|
||||||
boolean delete = true;
|
|
||||||
if (as != null) {
|
if (as != null) {
|
||||||
String input = "";
|
String input = "";
|
||||||
for (String line : event.getLines()) {
|
for (String line : event.getLines()) {
|
||||||
@ -400,58 +403,27 @@ public class MainListener implements Listener {
|
|||||||
if(MC_USERNAME_PATTERN.matcher(input).matches()) {
|
if(MC_USERNAME_PATTERN.matcher(input).matches()) {
|
||||||
final String name = input;
|
final String name = input;
|
||||||
b.setMetadata("protected", new FixedMetadataValue(plugin, true));
|
b.setMetadata("protected", new FixedMetadataValue(plugin, true));
|
||||||
b.setType(Material.SKULL);
|
|
||||||
final Skull s = (Skull) b.getState();
|
|
||||||
s.setSkullType(SkullType.PLAYER);
|
|
||||||
delete = false;
|
|
||||||
event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait);
|
event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait);
|
||||||
new BukkitRunnable() {
|
String cmd = "give " + event.getPlayer().getName() + " minecraft:skull 1 3 {SkullOwner:\"" + name + "\"}";
|
||||||
@Override
|
String current = b.getWorld().getGameRuleValue("sendCommandFeedback");
|
||||||
public void run() {
|
b.getWorld().setGameRuleValue("sendCommandFeedback", "false");
|
||||||
final boolean ok = Utils.loadProfile(name);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
||||||
new BukkitRunnable() {
|
b.getWorld().setGameRuleValue("sendCommandFeedback", current);
|
||||||
@Override
|
boolean found = false;
|
||||||
public void run() {
|
for(int slot : event.getPlayer().getInventory().all(Material.SKULL_ITEM).keySet()) {
|
||||||
if (ok) {
|
ItemStack skull = event.getPlayer().getInventory().getItem(slot);
|
||||||
s.setOwner(name);
|
SkullMeta sm = (SkullMeta) skull.getItemMeta();
|
||||||
s.update();
|
if(sm.hasOwner() && name.equalsIgnoreCase(sm.getOwner())) {
|
||||||
new BukkitRunnable() {
|
as.setHelmet(skull);
|
||||||
int n = 0;
|
event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + name);
|
||||||
ItemStack skull;
|
event.getPlayer().getInventory().setItem(slot, null);
|
||||||
@Override
|
found = true;
|
||||||
public void run() {
|
break;
|
||||||
if(++n > 20) {
|
|
||||||
this.cancel();
|
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + Config.headFailed);
|
|
||||||
b.setType(Material.AIR);
|
|
||||||
b.setData((byte) 0);
|
|
||||||
b.removeMetadata("protected", plugin);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
skull = b.getDrops().iterator().next();
|
|
||||||
if(skull.getType() == Material.SKULL_ITEM && skull.getData().getData() == (byte) 3) {
|
|
||||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
|
||||||
if(meta.hasOwner() && meta.getOwner().equalsIgnoreCase(name)) {
|
|
||||||
as.setHelmet(skull);
|
|
||||||
event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + name);
|
|
||||||
b.setType(Material.AIR);
|
|
||||||
b.setData((byte) 0);
|
|
||||||
b.removeMetadata("protected", plugin);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, 10L, 10L);
|
|
||||||
} else {
|
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + Config.noHead + ChatColor.GOLD + " " + name);
|
|
||||||
b.setType(Material.AIR);
|
|
||||||
b.setData((byte) 0);
|
|
||||||
b.removeMetadata("protected", plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTask(plugin);
|
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
}
|
||||||
|
if(!found) {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.GOLD + Config.headFailed);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName);
|
event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName);
|
||||||
}
|
}
|
||||||
@ -461,10 +433,8 @@ public class MainListener implements Listener {
|
|||||||
b.removeMetadata("armorStand", plugin);
|
b.removeMetadata("armorStand", plugin);
|
||||||
b.removeMetadata("setName", plugin);
|
b.removeMetadata("setName", plugin);
|
||||||
b.removeMetadata("setSkull", plugin);
|
b.removeMetadata("setSkull", plugin);
|
||||||
if(delete) {
|
b.setType(Material.AIR);
|
||||||
b.setType(Material.AIR);
|
b.setData((byte) 0);
|
||||||
b.setData((byte) 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,66 +6,124 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class NBT {
|
class NBT {
|
||||||
|
|
||||||
static boolean toggleSlotsDisabled(ArmorStand as) {
|
static boolean toggleSlotsDisabled(ArmorStand as) {
|
||||||
Object nmsEntity = getNmsEntity(as);
|
boolean slotsDisabled = getDisabledSlots(as) == 0;
|
||||||
if(nmsEntity == null) return false;
|
setSlotsDisabled(as, slotsDisabled);
|
||||||
Object tag = getTag(nmsEntity);
|
|
||||||
if(tag == null) return false;
|
|
||||||
boolean slotsDisabled = getInt(tag, "DisabledSlots") == 0;
|
|
||||||
setInt(tag, "DisabledSlots", slotsDisabled ? 2039583 : 0);
|
|
||||||
saveTagA(nmsEntity, tag);
|
|
||||||
return slotsDisabled;
|
return slotsDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean toggleInvulnerability(ArmorStand as) {
|
|
||||||
Object nmsEntity = getNmsEntity(as);
|
|
||||||
if(nmsEntity == null) return false;
|
|
||||||
Object tag = getTag(nmsEntity);
|
|
||||||
if(tag == null) return false;
|
|
||||||
boolean invulnerable = !getBoolean(tag, "Invulnerable");
|
|
||||||
setBoolean(tag, "Invulnerable", invulnerable);
|
|
||||||
saveTagF(nmsEntity, tag);
|
|
||||||
return invulnerable;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) {
|
|
||||||
Object nmsEntity = getNmsEntity(as);
|
|
||||||
if(nmsEntity == null) return;
|
|
||||||
Object tag = getTag(nmsEntity);
|
|
||||||
if(tag == null) return;
|
|
||||||
setInt(tag, "DisabledSlots", slotsDisabled ? 2039583 : 0);
|
|
||||||
saveTagA(nmsEntity, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setInvulnerable(ArmorStand as, boolean invulnerable) {
|
|
||||||
Object nmsEntity = getNmsEntity(as);
|
|
||||||
if(nmsEntity == null) return;
|
|
||||||
Object tag = getTag(nmsEntity);
|
|
||||||
if(tag == null) return;
|
|
||||||
setBoolean(tag, "Invulnerable", invulnerable);
|
|
||||||
saveTagF(nmsEntity, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isInvulnerable(ArmorStand as) {
|
|
||||||
Object nmsEntity = getNmsEntity(as);
|
|
||||||
if (nmsEntity == null) return false;
|
|
||||||
Object tag = getTag(nmsEntity);
|
|
||||||
return tag != null && getBoolean(tag, "Invulnerable");
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
Object tag = getTag(nmsEntity);
|
if(Main.one_nine) {
|
||||||
if (tag == null) return 0;
|
Field f;
|
||||||
return getInt(tag, "DisabledSlots");
|
try {
|
||||||
|
f = nmsEntity.getClass().getDeclaredField("bz");
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
f.setAccessible(true);
|
||||||
|
try {
|
||||||
|
return (Integer) f.get(nmsEntity);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
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.one_nine) {
|
||||||
|
Field f;
|
||||||
|
try {
|
||||||
|
f = nmsEntity.getClass().getDeclaredField("bz");
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
f.setAccessible(true);
|
||||||
|
try {
|
||||||
|
f.set(nmsEntity, slotsDisabled ? 2039583 : 0);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object tag = getTag(nmsEntity);
|
||||||
|
if (tag == null) return;
|
||||||
|
setInt(tag, "DisabledSlots", slotsDisabled ? 2039583 : 0);
|
||||||
|
saveTagA(nmsEntity, tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean toggleInvulnerability(ArmorStand as) {
|
||||||
|
boolean isInvulnerable = !isInvulnerable(as);
|
||||||
|
setInvulnerable(as, isInvulnerable);
|
||||||
|
return isInvulnerable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isInvulnerable(ArmorStand as) {
|
||||||
|
Object nmsEntity = getNmsEntity(as);
|
||||||
|
if (nmsEntity == null) return false;
|
||||||
|
if(Main.one_nine) {
|
||||||
|
Field f;
|
||||||
|
try {
|
||||||
|
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
f.setAccessible(true);
|
||||||
|
try {
|
||||||
|
return (Boolean) f.get(nmsEntity);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object tag = getTag(nmsEntity);
|
||||||
|
return tag != null && getBoolean(tag, "Invulnerable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setInvulnerable(ArmorStand as, boolean invulnerable) {
|
||||||
|
Object nmsEntity = getNmsEntity(as);
|
||||||
|
if (nmsEntity == null) return;
|
||||||
|
if(Main.one_nine) {
|
||||||
|
Field f;
|
||||||
|
try {
|
||||||
|
f = Utils.getNMSClass("Entity").getDeclaredField("invulnerable");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
f.setAccessible(true);
|
||||||
|
try {
|
||||||
|
f.set(nmsEntity, invulnerable);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object tag = getTag(nmsEntity);
|
||||||
|
if(tag == null) return;
|
||||||
|
setBoolean(tag, "Invulnerable", invulnerable);
|
||||||
|
saveTagF(nmsEntity, tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Object getNmsEntity(org.bukkit.entity.Entity entity) {
|
private static Object getNmsEntity(org.bukkit.entity.Entity entity) {
|
||||||
try {
|
try {
|
||||||
return entity.getClass().getMethod("getHandle").invoke(entity);
|
return entity.getClass().getMethod("getHandle").invoke(entity);
|
||||||
@ -76,6 +134,7 @@ class NBT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Object getTag(Object nmsEntity) {
|
private static Object getTag(Object nmsEntity) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Method method = nmsEntity.getClass().getMethod("getNBTTag");
|
Method method = nmsEntity.getClass().getMethod("getNBTTag");
|
||||||
Object tag = method.invoke(nmsEntity);
|
Object tag = method.invoke(nmsEntity);
|
||||||
|
@ -13,6 +13,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ class Utils {
|
|||||||
|
|
||||||
static void actionBarMsg(Player p, String msg) {
|
static void actionBarMsg(Player p, String msg) {
|
||||||
try {
|
try {
|
||||||
Object chat = getNMSClass("ChatSerializer").getMethod("a", String.class).invoke(null, "{text:\"" + msg + "\"}");
|
Object chat = getNMSClass("ChatSerializer").getMethod("a", String.class).invoke(null, "{\"text\":\"" + msg + "\",\"color\":\"green\"}");
|
||||||
Object packet = getNMSClass("PacketPlayOutChat").getConstructor(getNMSClass("IChatBaseComponent"), byte.class).newInstance(chat, (byte) 2);
|
Object packet = getNMSClass("PacketPlayOutChat").getConstructor(getNMSClass("IChatBaseComponent"), byte.class).newInstance(chat, (byte) 2);
|
||||||
sendPacket(p, packet);
|
sendPacket(p, packet);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -120,17 +121,6 @@ class Utils {
|
|||||||
return Class.forName("net.minecraft.server." + Main.NMS_VERSION + "." + nmsClassString);
|
return Class.forName("net.minecraft.server." + Main.NMS_VERSION + "." + nmsClassString);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean loadProfile(String name) {
|
|
||||||
try {
|
|
||||||
Object server = getNMSClass("MinecraftServer").getMethod("getServer").invoke(null);
|
|
||||||
Object cache = server.getClass().getMethod("getUserCache").invoke(server);
|
|
||||||
return cache.getClass().getMethod("getProfile", String.class).invoke(cache, name) != null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sendPacket(Player p, Object packet) {
|
private static void sendPacket(Player p, Object packet) {
|
||||||
try {
|
try {
|
||||||
Object player = p.getClass().getMethod("getHandle").invoke(p);
|
Object player = p.getClass().getMethod("getHandle").invoke(p);
|
||||||
@ -169,4 +159,37 @@ class Utils {
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String getNmsName(Material m) {
|
||||||
|
try {
|
||||||
|
Class block = getNMSClass("Block");
|
||||||
|
Class item = getNMSClass("Item");
|
||||||
|
Class registryBlocks = getNMSClass("RegistryBlocks");
|
||||||
|
Class registryMaterials = getNMSClass("RegistryMaterials");
|
||||||
|
Class regKey = getNMSClass("MinecraftKey");
|
||||||
|
Object registry = block.getDeclaredField("REGISTRY").get(null);
|
||||||
|
Set<Object> set = (Set<Object>) registry.getClass().getMethod("keySet").invoke(registry);
|
||||||
|
for(Object key : set) {
|
||||||
|
Object b = registryBlocks.getMethod("get", Object.class).invoke(registry, key);
|
||||||
|
Integer id = (Integer) block.getMethod("getId", block).invoke(null, b);
|
||||||
|
if(id == m.getId()) {
|
||||||
|
return (String) regKey.getMethod("a").invoke(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registry = item.getDeclaredField("REGISTRY").get(null);
|
||||||
|
set = (Set<Object>) registry.getClass().getMethod("keySet").invoke(registry);
|
||||||
|
for(Object key : set) {
|
||||||
|
Object i = registryMaterials.getMethod("get", Object.class).invoke(registry, key);
|
||||||
|
Integer id = (Integer) item.getMethod("getId", item).invoke(null, i);
|
||||||
|
if(id == m.getId()) {
|
||||||
|
return (String) regKey.getMethod("a").invoke(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Main Config
|
# Main Config
|
||||||
#
|
#
|
||||||
# File generated by: v2.06
|
# File generated by: v2.1
|
||||||
# (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)
|
||||||
#
|
#
|
||||||
@ -13,7 +13,7 @@
|
|||||||
# - Name armor stands
|
# - Name armor stands
|
||||||
# - Toggle: Gravity, Visibility, Arms, Base, Size, Invulnerability, Equipment Lock
|
# - Toggle: Gravity, Visibility, Arms, Base, Size, Invulnerability, Equipment Lock
|
||||||
# - Manipulate the position of the Head, Body, Arms and Legs
|
# - Manipulate the position of the Head, Body, Arms and Legs
|
||||||
# - Full control over armor stand's inventory (armor & item in hand)
|
# - Full control over armor stand's inventory (armor & items in hands)
|
||||||
# - Clone armor stand tool
|
# - Clone armor stand tool
|
||||||
# - Create command block tool: Creates a command block with the command that will summon this
|
# - Create command block tool: Creates a command block with the command that will summon this
|
||||||
# armor stand in its current state
|
# armor stand in its current state
|
||||||
@ -44,6 +44,7 @@ chest: IRON_CHESTPLATE 0
|
|||||||
pants: IRON_LEGGINGS 0
|
pants: IRON_LEGGINGS 0
|
||||||
boots: IRON_BOOTS 0
|
boots: IRON_BOOTS 0
|
||||||
inHand: AIR 0
|
inHand: AIR 0
|
||||||
|
inOffHand: AIR 0
|
||||||
isVisible: true
|
isVisible: true
|
||||||
isSmall: false
|
isSmall: false
|
||||||
hasArms: true
|
hasArms: true
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Language Config
|
# Language Config
|
||||||
#
|
#
|
||||||
# File generated by: v2.06
|
# File generated by: v2.1
|
||||||
# (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)
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
|
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
|
||||||
name: ArmorStandTools
|
name: ArmorStandTools
|
||||||
version: 2.06
|
version: 2.1
|
||||||
author: St3venAU
|
author: St3venAU
|
||||||
description: Armor stand manipulation tools
|
description: Armor stand manipulation tools
|
||||||
softdepend: [WorldGuard, PlotSquared]
|
softdepend: [WorldGuard, PlotSquared]
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren