3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-29 04:50:09 +01:00
Dieser Commit ist enthalten in:
Steven 2016-05-19 01:32:57 +08:00
Ursprung 86322971f7
Commit f13d121919
6 geänderte Dateien mit 23 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -26,12 +26,13 @@ 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; static boolean oneNine, oneNineFour;
@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"); oneNine = NMS_VERSION.startsWith("v1_9");
oneNineFour = NMS_VERSION.startsWith("v1_9_R2");
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);
@ -183,7 +184,12 @@ 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) {
clone.getEquipment().setItemInMainHand(as.getEquipment().getItemInMainHand());
clone.getEquipment().setItemInOffHand(as.getEquipment().getItemInOffHand());
} else {
clone.setItemInHand(as.getItemInHand()); clone.setItemInHand(as.getItemInHand());
}
clone.setHeadPose(as.getHeadPose()); clone.setHeadPose(as.getHeadPose());
clone.setBodyPose(as.getBodyPose()); clone.setBodyPose(as.getBodyPose());
clone.setLeftArmPose(as.getLeftArmPose()); clone.setLeftArmPose(as.getLeftArmPose());

Datei anzeigen

@ -332,13 +332,18 @@ 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.isHoldingTool((Player) event.getDamager())) { if(event.getEntity() instanceof ArmorStand) {
if(NBT.isInvulnerable((ArmorStand) event.getEntity())) {
event.setCancelled(true);
}
if(event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) {
event.setCancelled(true); event.setCancelled(true);
if(noCooldown(event.getDamager())) { if(noCooldown(event.getDamager())) {
Utils.cycleInventory((Player) event.getDamager()); Utils.cycleInventory((Player) event.getDamager());
} }
} }
} }
}
private boolean noCooldown(Entity e) { private boolean noCooldown(Entity e) {
for(MetadataValue meta : e.getMetadata("lastDrop")) { for(MetadataValue meta : e.getMetadata("lastDrop")) {

Datei anzeigen

@ -24,7 +24,7 @@ class NBT {
if(Main.oneNine) { if(Main.oneNine) {
Field f; Field f;
try { try {
f = nmsEntity.getClass().getDeclaredField("bz"); f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
return 0; return 0;
@ -49,7 +49,7 @@ class NBT {
if(Main.oneNine) { if(Main.oneNine) {
Field f; Field f;
try { try {
f = nmsEntity.getClass().getDeclaredField("bz"); f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
return; return;

Datei anzeigen

@ -4,7 +4,7 @@
# #
# Main Config # Main Config
# #
# File generated by: v2.1.2 # File generated by: v2.1.3
# (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.2 # File generated by: v2.1.3
# (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.2 version: 2.1.3
author: St3venAU author: St3venAU
description: Armor stand manipulation tools description: Armor stand manipulation tools
softdepend: [WorldGuard, PlotSquared] softdepend: [WorldGuard, PlotSquared]