From c03260a280347e73ed9c7018646492ffc936ea81 Mon Sep 17 00:00:00 2001 From: nick <39906142+zbkman@users.noreply.github.com> Date: Mon, 27 Apr 2020 02:13:41 -0400 Subject: [PATCH] Add getter and setter for villager's numberOfRestocksToday (#3231) --- .../0200-Villager-Restocks-API.patch | 34 +++++++++++++ .../0495-Villager-Restocks-API.patch | 50 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 Spigot-API-Patches/0200-Villager-Restocks-API.patch create mode 100644 Spigot-Server-Patches/0495-Villager-Restocks-API.patch diff --git a/Spigot-API-Patches/0200-Villager-Restocks-API.patch b/Spigot-API-Patches/0200-Villager-Restocks-API.patch new file mode 100644 index 000000000..5409032b5 --- /dev/null +++ b/Spigot-API-Patches/0200-Villager-Restocks-API.patch @@ -0,0 +1,34 @@ +From 81d3a61bd89a1671f901041a4eb7673a28231729 Mon Sep 17 00:00:00 2001 +From: zbk +Date: Sun, 26 Apr 2020 23:49:03 -0400 +Subject: [PATCH] Villager Restocks API + + +diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java +index ef48ad9b..d1579153 100644 +--- a/src/main/java/org/bukkit/entity/Villager.java ++++ b/src/main/java/org/bukkit/entity/Villager.java +@@ -77,6 +77,20 @@ public interface Villager extends AbstractVillager { + */ + public void setVillagerExperience(int experience); + ++ // Paper start ++ /** ++ * Gets the amount of times a villager has restocked their trades today ++ * @return The amount of trade restocks. ++ */ ++ public int getRestocksToday(); ++ ++ /** ++ * Sets the amount of times a villager has restocked their trades today ++ * @param restocksToday new restock count ++ */ ++ public void setRestocksToday(int restocksToday); ++ // Paper end ++ + /** + * Attempts to make this villager sleep at the given location. + *
+-- +2.25.0.windows.1 + diff --git a/Spigot-Server-Patches/0495-Villager-Restocks-API.patch b/Spigot-Server-Patches/0495-Villager-Restocks-API.patch new file mode 100644 index 000000000..641032ca4 --- /dev/null +++ b/Spigot-Server-Patches/0495-Villager-Restocks-API.patch @@ -0,0 +1,50 @@ +From 9b079b5a2e9a2b894dae9a6b4643fd033f9b14ad Mon Sep 17 00:00:00 2001 +From: zbk +Date: Sun, 26 Apr 2020 23:49:01 -0400 +Subject: [PATCH] Villager Restocks API + + +diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java +index 6e0020ae..ef2ee68c 100644 +--- a/src/main/java/net/minecraft/server/EntityVillager.java ++++ b/src/main/java/net/minecraft/server/EntityVillager.java +@@ -977,4 +977,13 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation + + return optional.isPresent() && optional1.isPresent() ? i - ((MinecraftSerializableLong) optional.get()).a() < 24000L && i - ((MinecraftSerializableLong) optional1.get()).a() < 36000L : false; + } ++ ++ // Paper start ++ public int getRestocksToday(){ ++ return this.bL; ++ } ++ public void setRestocksToday(int restocksToday){ ++ this.bL = restocksToday; ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +index a73ebaa7..a12d8711 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +@@ -82,6 +82,18 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { + getHandle().setExperience(experience); + } + ++ // Paper start ++ @Override ++ public int getRestocksToday() { ++ return getHandle().getRestocksToday(); ++ } ++ ++ @Override ++ public void setRestocksToday(int restocksToday) { ++ getHandle().setRestocksToday(restocksToday); ++ } ++ // Paper end ++ + @Override + public boolean sleep(Location location) { + Preconditions.checkArgument(location != null, "Location cannot be null"); +-- +2.25.0.windows.1 +