mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
SPIGOT-5766: The VillagerReplenishTradeEvent is now called when a villager restocks its trades.
By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
aa53cef96f
commit
7a54f9da31
1 changed files with 25 additions and 11 deletions
|
@ -33,23 +33,37 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +453,14 @@
|
||||
@@ -357,7 +365,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
||||
|
||||
- merchantrecipe.resetUses();
|
||||
+ // CraftBukkit start
|
||||
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ merchantrecipe.resetUses();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.lastRestockGameTime = this.level.getGameTime();
|
||||
@@ -415,7 +429,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
||||
|
||||
- merchantrecipe.addToSpecialPriceDiff(-MathHelper.floor((float) i * merchantrecipe.getPriceMultiplier()));
|
||||
- merchantrecipe.resetUses();
|
||||
+ // CraftBukkit start
|
||||
+ int bonus = -MathHelper.floor((float) i * merchantrecipe.getPriceMultiplier());
|
||||
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
|
||||
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ merchantrecipe.addToSpecialPriceDiff(event.getBonus());
|
||||
+ merchantrecipe.resetUses();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +489,7 @@
|
||||
@@ -474,7 +494,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
|
@ -58,7 +72,7 @@
|
|||
Logger logger = EntityVillager.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -816,7 +831,12 @@
|
||||
@@ -816,7 +836,12 @@
|
||||
}
|
||||
|
||||
entitywitch.setPersistenceRequired();
|
||||
|
@ -72,7 +86,7 @@
|
|||
this.releaseAllPois();
|
||||
this.discard();
|
||||
} else {
|
||||
@@ -837,6 +857,13 @@
|
||||
@@ -837,6 +862,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -86,7 +100,7 @@
|
|||
this.onItemPickup(entityitem);
|
||||
this.take(entityitem, itemstack.getCount());
|
||||
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
||||
@@ -949,7 +976,7 @@
|
||||
@@ -949,7 +981,7 @@
|
||||
|
||||
if (entityirongolem != null) {
|
||||
if (entityirongolem.checkSpawnRules(worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.checkSpawnObstruction(worldserver)) {
|
||||
|
@ -95,7 +109,7 @@
|
|||
return entityirongolem;
|
||||
}
|
||||
|
||||
@@ -1027,7 +1054,7 @@
|
||||
@@ -1027,7 +1059,7 @@
|
||||
@Override
|
||||
public void startSleeping(BlockPosition blockposition) {
|
||||
super.startSleeping(blockposition);
|
||||
|
@ -104,7 +118,7 @@
|
|||
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||
}
|
||||
@@ -1035,7 +1062,7 @@
|
||||
@@ -1035,7 +1067,7 @@
|
||||
@Override
|
||||
public void stopSleeping() {
|
||||
super.stopSleeping();
|
||||
|
|
Loading…
Reference in a new issue