Expand ArmorStand API (#1277)
Add the following: - Add proper methods for getting and setting items in both hands. Deprecates old methods - Enable/Disable slot interactions
Dieser Commit ist enthalten in:
Ursprung
e356cd3989
Commit
4fb5e0fe14
117
Spigot-API-Patches/0128-Expand-ArmorStand-API.patch
Normale Datei
117
Spigot-API-Patches/0128-Expand-ArmorStand-API.patch
Normale Datei
@ -0,0 +1,117 @@
|
||||
From b10e72a40d9419d2c2537dc78d67d42275aec749 Mon Sep 17 00:00:00 2001
|
||||
From: willies952002 <admin@domnian.com>
|
||||
Date: Thu, 26 Jul 2018 02:22:44 -0400
|
||||
Subject: [PATCH] Expand ArmorStand API
|
||||
|
||||
Add the following:
|
||||
- Add proper methods for getting and setting items in both hands. Deprecates old methods
|
||||
- Enable/Disable slot interactions
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/ArmorStand.java b/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
index 099da6ce..7a8f4eb7 100644
|
||||
--- a/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
+++ b/src/main/java/org/bukkit/entity/ArmorStand.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
+import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
@@ -10,7 +11,12 @@ public interface ArmorStand extends LivingEntity {
|
||||
* currently holding
|
||||
*
|
||||
* @return the held item
|
||||
+ // Paper start - Deprecate in favor of setItemInMainHand
|
||||
+ * @deprecated use {@link ArmorStand#getItem(EquipmentSlot)} instead
|
||||
+ * @see ArmorStand#getItem(EquipmentSlot)
|
||||
+ // Paper end
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
ItemStack getItemInHand();
|
||||
|
||||
/**
|
||||
@@ -18,7 +24,12 @@ public interface ArmorStand extends LivingEntity {
|
||||
* holding
|
||||
*
|
||||
* @param item the item to hold
|
||||
+ // Paper start - Deprecate in favor of setItemInMainHand
|
||||
+ * @deprecated use {@link ArmorStand#setItem(EquipmentSlot, ItemStack)} instead
|
||||
+ * @see ArmorStand#setItem(EquipmentSlot, ItemStack)
|
||||
+ // Paper end
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
void setItemInHand(ItemStack item);
|
||||
|
||||
/**
|
||||
@@ -275,5 +286,67 @@ public interface ArmorStand extends LivingEntity {
|
||||
* @param move {@code true} if this armour stand can move, {@code false} otherwise
|
||||
*/
|
||||
void setCanMove(boolean move);
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the item the armor stand has
|
||||
+ * equip in the given equipment slot
|
||||
+ *
|
||||
+ * @param slot the equipment slot to get
|
||||
+ */
|
||||
+ ItemStack getItem(final org.bukkit.inventory.EquipmentSlot slot);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the item the armor stand has
|
||||
+ * equip in the given equipment slot
|
||||
+ *
|
||||
+ * @param slot the equipment slot to set
|
||||
+ * @param item the item to hold
|
||||
+ */
|
||||
+ void setItem(final org.bukkit.inventory.EquipmentSlot slot, final ItemStack item);
|
||||
+
|
||||
+ /**
|
||||
+ * Get the list of disabled slots
|
||||
+ *
|
||||
+ * @return list of disabled slots
|
||||
+ */
|
||||
+ java.util.Set<org.bukkit.inventory.EquipmentSlot> getDisabledSlots();
|
||||
+
|
||||
+ /**
|
||||
+ * Set the disabled slots
|
||||
+ *
|
||||
+ * This makes it so a player is unable to interact with the Armor Stand to place, remove, or replace an item in the given slot(s)
|
||||
+ * Note: Once a slot is disabled, the only way to get an item back it to break the armor stand.
|
||||
+ *
|
||||
+ * @param slots var-arg array of slots to lock
|
||||
+ */
|
||||
+ void setDisabledSlots(org.bukkit.inventory.EquipmentSlot... slots);
|
||||
+
|
||||
+ /**
|
||||
+ * Disable specific slots, adding them
|
||||
+ * to the currently disabled slots
|
||||
+ *
|
||||
+ * This makes it so a player is unable to interact with the Armor Stand to place, remove, or replace an item in the given slot(s)
|
||||
+ * Note: Once a slot is disabled, the only way to get an item back it to break the armor stand.
|
||||
+ *
|
||||
+ * @param slots var-arg array of slots to lock
|
||||
+ */
|
||||
+ void addDisabledSlots(final org.bukkit.inventory.EquipmentSlot... slots);
|
||||
+
|
||||
+ /**
|
||||
+ * Remove the given slots from the disabled
|
||||
+ * slots list, enabling them.
|
||||
+ *
|
||||
+ * This makes it so a player is able to interact with the Armor Stand to place, remove, or replace an item in the given slot(s)
|
||||
+ *
|
||||
+ * @param slots var-arg array of slots to unlock
|
||||
+ */
|
||||
+ void removeDisabledSlots(final org.bukkit.inventory.EquipmentSlot... slots);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if a specific slot is disabled
|
||||
+ *
|
||||
+ * @return {@code true} if the slot is disabled, else {@code false}.
|
||||
+ */
|
||||
+ boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot);
|
||||
// Paper end
|
||||
}
|
||||
--
|
||||
2.17.0
|
||||
|
@ -1,4 +1,4 @@
|
||||
From d865cb389ffae2dd8e7bc86b347c9230c26350bb Mon Sep 17 00:00:00 2001
|
||||
From be4311568ddb5dfe4be686cec3907e7ac9018ae3 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 16 Apr 2016 00:39:33 -0400
|
||||
Subject: [PATCH] Configurable RCON IP address
|
||||
@ -6,7 +6,7 @@ Subject: [PATCH] Configurable RCON IP address
|
||||
For servers with multiple IP's, ability to bind to a specific interface.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/RemoteControlListener.java b/src/main/java/net/minecraft/server/RemoteControlListener.java
|
||||
index 6f0176f6ff..c237f239f3 100644
|
||||
index 6f0176f6f..c237f239f 100644
|
||||
--- a/src/main/java/net/minecraft/server/RemoteControlListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/RemoteControlListener.java
|
||||
@@ -24,7 +24,7 @@ public class RemoteControlListener extends RemoteConnectionThread {
|
||||
@ -19,5 +19,5 @@ index 6f0176f6ff..c237f239f3 100644
|
||||
if (0 == this.h) {
|
||||
this.h = this.i + 10;
|
||||
--
|
||||
2.18.0
|
||||
2.17.0
|
||||
|
||||
|
130
Spigot-Server-Patches/0323-Implement-Expanded-ArmorStand-API.patch
Normale Datei
130
Spigot-Server-Patches/0323-Implement-Expanded-ArmorStand-API.patch
Normale Datei
@ -0,0 +1,130 @@
|
||||
From 60a2a3f91ddbd0a8c79ee9246e6ff03df41dc9b4 Mon Sep 17 00:00:00 2001
|
||||
From: willies952002 <admin@domnian.com>
|
||||
Date: Thu, 26 Jul 2018 02:25:46 -0400
|
||||
Subject: [PATCH] Implement Expanded ArmorStand API
|
||||
|
||||
Add the following:
|
||||
- Add proper methods for getting and setting items in both hands. Deprecates old methods
|
||||
- Enable/Disable slot interactions
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||
index e9a746f13..3b2b94d8c 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||
@@ -36,7 +36,7 @@ public class EntityArmorStand extends EntityLiving {
|
||||
private final NonNullList<ItemStack> bF;
|
||||
private boolean bG;
|
||||
public long h;
|
||||
- private int bH;
|
||||
+ private int bH;public void setDisabledSlots(int i) { bH = i;} public int getDisabledSlots() { return bH ;} // Paper - OBFHELPER
|
||||
private boolean bI;
|
||||
public Vector3f headPose;
|
||||
public Vector3f bodyPose;
|
||||
@@ -362,6 +362,7 @@ public class EntityArmorStand extends EntityLiving {
|
||||
return enumitemslot;
|
||||
}
|
||||
|
||||
+ public boolean isSlotDisabled(EnumItemSlot slot) { return this.c(slot); } // Paper - OBFHELPER
|
||||
private boolean c(EnumItemSlot enumitemslot) {
|
||||
return (this.bH & 1 << enumitemslot.c()) != 0;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
||||
index 124c3185b..9f5c3b92e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
||||
@@ -30,11 +30,13 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
||||
}
|
||||
|
||||
@Override
|
||||
+ @Deprecated // Paper
|
||||
public ItemStack getItemInHand() {
|
||||
return getEquipment().getItemInHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
+ @Deprecated // Paper
|
||||
public void setItemInHand(ItemStack item) {
|
||||
getEquipment().setItemInHand(item);
|
||||
}
|
||||
@@ -222,5 +224,78 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
||||
public void setCanMove(boolean move) {
|
||||
getHandle().canMove = move;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack getItem(org.bukkit.inventory.EquipmentSlot slot) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(slot, "slot");
|
||||
+ return getHandle().getEquipment(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot)).asBukkitMirror();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setItem(org.bukkit.inventory.EquipmentSlot slot, ItemStack item) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(slot, "slot");
|
||||
+ switch (slot) {
|
||||
+ case HAND:
|
||||
+ getEquipment().setItemInMainHand(item);
|
||||
+ return;
|
||||
+ case OFF_HAND:
|
||||
+ getEquipment().setItemInOffHand(item);
|
||||
+ return;
|
||||
+ case FEET:
|
||||
+ setBoots(item);
|
||||
+ return;
|
||||
+ case LEGS:
|
||||
+ setLeggings(item);
|
||||
+ break;
|
||||
+ case CHEST:
|
||||
+ setChestplate(item);
|
||||
+ return;
|
||||
+ case HEAD:
|
||||
+ setHelmet(item);
|
||||
+ return;
|
||||
+ }
|
||||
+ throw new UnsupportedOperationException(slot.name());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public java.util.Set<org.bukkit.inventory.EquipmentSlot> getDisabledSlots() {
|
||||
+ java.util.Set<org.bukkit.inventory.EquipmentSlot> disabled = new java.util.HashSet<>();
|
||||
+ for (org.bukkit.inventory.EquipmentSlot slot : org.bukkit.inventory.EquipmentSlot.values()) {
|
||||
+ if (this.isSlotDisabled(slot)) {
|
||||
+ disabled.add(slot);
|
||||
+ }
|
||||
+ }
|
||||
+ return disabled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setDisabledSlots(org.bukkit.inventory.EquipmentSlot... slots) {
|
||||
+ int disabled = 0;
|
||||
+ for (org.bukkit.inventory.EquipmentSlot slot : slots) {
|
||||
+ if (slot == org.bukkit.inventory.EquipmentSlot.OFF_HAND) continue;
|
||||
+ net.minecraft.server.EnumItemSlot nmsSlot = org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot);
|
||||
+ disabled += (1 << nmsSlot.c()) + (1 << (nmsSlot.c() + 8)) + (1 << (nmsSlot.c() + 16));
|
||||
+ }
|
||||
+ getHandle().setDisabledSlots(disabled);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void addDisabledSlots(org.bukkit.inventory.EquipmentSlot... slots) {
|
||||
+ java.util.Set<org.bukkit.inventory.EquipmentSlot> disabled = getDisabledSlots();
|
||||
+ java.util.Collections.addAll(disabled, slots);
|
||||
+ setDisabledSlots(disabled.toArray(new org.bukkit.inventory.EquipmentSlot[0]));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void removeDisabledSlots(org.bukkit.inventory.EquipmentSlot... slots) {
|
||||
+ java.util.Set<org.bukkit.inventory.EquipmentSlot> disabled = getDisabledSlots();
|
||||
+ for (final org.bukkit.inventory.EquipmentSlot slot : slots) disabled.remove(slot);
|
||||
+ setDisabledSlots(disabled.toArray(new org.bukkit.inventory.EquipmentSlot[0]));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot) {
|
||||
+ return getHandle().isSlotDisabled(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot));
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
--
|
||||
2.17.0
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren