Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-23 14:50:08 +01:00
Implement getters and setters for EntityItem owner and thrower
Closes #1526
Dieser Commit ist enthalten in:
Ursprung
6ec7d9f674
Commit
52ae2a1aec
@ -0,0 +1,62 @@
|
|||||||
|
From 9848837a4d460976eaaa3643870f52c3f3ecc95c Mon Sep 17 00:00:00 2001
|
||||||
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||||
|
Date: Sat, 6 Oct 2018 20:54:13 -0500
|
||||||
|
Subject: [PATCH] Implement getters and setters for EntityItem owner and
|
||||||
|
thrower
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Item.java b/src/main/java/org/bukkit/entity/Item.java
|
||||||
|
index 2e98e4f9..8049b36c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Item.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Item.java
|
||||||
|
@@ -2,6 +2,11 @@ package org.bukkit.entity;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
+// Paper start
|
||||||
|
+import javax.annotation.Nullable;
|
||||||
|
+import java.util.UUID;
|
||||||
|
+// Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Represents an Item.
|
||||||
|
*/
|
||||||
|
@@ -49,5 +54,35 @@ public interface Item extends Entity {
|
||||||
|
* @param canMobPickup True to allow non-player entity pickup
|
||||||
|
*/
|
||||||
|
public void setCanMobPickup(boolean canMobPickup);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * The owner of this item. Only the owner can pick up the item until it is within 10 seconds of despawning
|
||||||
|
+ *
|
||||||
|
+ * @return The owner's UUID
|
||||||
|
+ */
|
||||||
|
+ @Nullable
|
||||||
|
+ public UUID getOwner();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Set the owner of this item. Only the owner can pick up the item until it is within 10 seconds of despawning
|
||||||
|
+ *
|
||||||
|
+ * @param owner The owner's UUID
|
||||||
|
+ */
|
||||||
|
+ public void setOwner(@Nullable UUID owner);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get the thrower of this item.
|
||||||
|
+ *
|
||||||
|
+ * @return The thrower's UUID
|
||||||
|
+ */
|
||||||
|
+ @Nullable
|
||||||
|
+ public UUID getThrower();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Set the thrower of this item.
|
||||||
|
+ *
|
||||||
|
+ * @param thrower The thrower's UUID
|
||||||
|
+ */
|
||||||
|
+ public void setThrower(@Nullable UUID thrower);
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.19.0
|
||||||
|
|
@ -0,0 +1,96 @@
|
|||||||
|
From ee7193b21f5f53806d0e97db356d47f46d9b9d55 Mon Sep 17 00:00:00 2001
|
||||||
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||||
|
Date: Sat, 6 Oct 2018 20:54:23 -0500
|
||||||
|
Subject: [PATCH] Implement getters and setters for EntityItem owner and
|
||||||
|
thrower
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
|
||||||
|
index f596b4351..67b29c55f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||||
|
@@ -410,20 +410,22 @@ public class EntityItem extends Entity {
|
||||||
|
this.getDataWatcher().set(EntityItem.b, itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
- @Nullable
|
||||||
|
- public UUID k() {
|
||||||
|
+ @Nullable public UUID getOwner() { return k(); } // Paper - OBFHELPER
|
||||||
|
+ @Nullable public UUID k() { // Paper
|
||||||
|
return this.g;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public void setOwner(@Nullable UUID owner) { b(owner); } // Paper - OBFHELPER
|
||||||
|
public void b(@Nullable UUID uuid) {
|
||||||
|
this.g = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
- @Nullable
|
||||||
|
- public UUID l() {
|
||||||
|
+ @Nullable public UUID getThrower() { return l(); } // Paper - OBFHELPER
|
||||||
|
+ @Nullable public UUID l() { // Paper
|
||||||
|
return this.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public void setThrower(@Nullable UUID thrower) { c(thrower); } // Paper - OBFHELPER
|
||||||
|
public void c(@Nullable UUID uuid) {
|
||||||
|
this.f = uuid;
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||||
|
index 1df17f09b..3da71da5c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||||
|
@@ -9,6 +9,11 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
|
||||||
|
+// Paper start
|
||||||
|
+import javax.annotation.Nullable;
|
||||||
|
+import java.util.UUID;
|
||||||
|
+// Paper end
|
||||||
|
+
|
||||||
|
public class CraftItem extends CraftEntity implements Item {
|
||||||
|
private final EntityItem item;
|
||||||
|
|
||||||
|
@@ -21,6 +26,13 @@ public class CraftItem extends CraftEntity implements Item {
|
||||||
|
this(server, entity, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public EntityItem getHandle() {
|
||||||
|
+ return (EntityItem) entity;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
return CraftItemStack.asCraftMirror(item.getItemStack());
|
||||||
|
}
|
||||||
|
@@ -45,6 +57,24 @@ public class CraftItem extends CraftEntity implements Item {
|
||||||
|
public void setCanMobPickup(boolean canMobPickup) {
|
||||||
|
item.canMobPickup = canMobPickup;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ public UUID getOwner() {
|
||||||
|
+ return getHandle().getOwner();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setOwner(@Nullable UUID owner) {
|
||||||
|
+ getHandle().setOwner(owner);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ public UUID getThrower() {
|
||||||
|
+ return getHandle().getThrower();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setThrower(@Nullable UUID thrower) {
|
||||||
|
+ getHandle().setThrower(thrower);
|
||||||
|
+ }
|
||||||
|
// Paper End
|
||||||
|
|
||||||
|
@Override
|
||||||
|
--
|
||||||
|
2.19.0
|
||||||
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren