mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 11:05:13 +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()) {
|
while (iterator.hasNext()) {
|
||||||
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
||||||
|
|
||||||
- merchantrecipe.addToSpecialPriceDiff(-MathHelper.floor((float) i * merchantrecipe.getPriceMultiplier()));
|
- merchantrecipe.resetUses();
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ int bonus = -MathHelper.floor((float) i * merchantrecipe.getPriceMultiplier());
|
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
|
||||||
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
|
|
||||||
+ Bukkit.getPluginManager().callEvent(event);
|
+ Bukkit.getPluginManager().callEvent(event);
|
||||||
+ if (!event.isCancelled()) {
|
+ if (!event.isCancelled()) {
|
||||||
+ merchantrecipe.addToSpecialPriceDiff(event.getBonus());
|
+ merchantrecipe.resetUses();
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +489,7 @@
|
@@ -474,7 +494,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||||
super.addAdditionalSaveData(nbttagcompound);
|
super.addAdditionalSaveData(nbttagcompound);
|
||||||
|
@ -58,7 +72,7 @@
|
||||||
Logger logger = EntityVillager.LOGGER;
|
Logger logger = EntityVillager.LOGGER;
|
||||||
|
|
||||||
Objects.requireNonNull(logger);
|
Objects.requireNonNull(logger);
|
||||||
@@ -816,7 +831,12 @@
|
@@ -816,7 +836,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
entitywitch.setPersistenceRequired();
|
entitywitch.setPersistenceRequired();
|
||||||
|
@ -72,7 +86,7 @@
|
||||||
this.releaseAllPois();
|
this.releaseAllPois();
|
||||||
this.discard();
|
this.discard();
|
||||||
} else {
|
} else {
|
||||||
@@ -837,6 +857,13 @@
|
@@ -837,6 +862,13 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +100,7 @@
|
||||||
this.onItemPickup(entityitem);
|
this.onItemPickup(entityitem);
|
||||||
this.take(entityitem, itemstack.getCount());
|
this.take(entityitem, itemstack.getCount());
|
||||||
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
||||||
@@ -949,7 +976,7 @@
|
@@ -949,7 +981,7 @@
|
||||||
|
|
||||||
if (entityirongolem != null) {
|
if (entityirongolem != null) {
|
||||||
if (entityirongolem.checkSpawnRules(worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.checkSpawnObstruction(worldserver)) {
|
if (entityirongolem.checkSpawnRules(worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.checkSpawnObstruction(worldserver)) {
|
||||||
|
@ -95,7 +109,7 @@
|
||||||
return entityirongolem;
|
return entityirongolem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,7 +1054,7 @@
|
@@ -1027,7 +1059,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void startSleeping(BlockPosition blockposition) {
|
public void startSleeping(BlockPosition blockposition) {
|
||||||
super.startSleeping(blockposition);
|
super.startSleeping(blockposition);
|
||||||
|
@ -104,7 +118,7 @@
|
||||||
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
||||||
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||||
}
|
}
|
||||||
@@ -1035,7 +1062,7 @@
|
@@ -1035,7 +1067,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void stopSleeping() {
|
public void stopSleeping() {
|
||||||
super.stopSleeping();
|
super.stopSleeping();
|
||||||
|
|
Loading…
Reference in a new issue