mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 22:13:42 +01:00
31 lines
1.5 KiB
Diff
31 lines
1.5 KiB
Diff
--- a/net/minecraft/server/BehaviorCareer.java
|
|
+++ b/net/minecraft/server/BehaviorCareer.java
|
|
@@ -1,6 +1,11 @@
|
|
package net.minecraft.server;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.entity.CraftVillager;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
|
+// CraftBukkit end
|
|
|
|
public class BehaviorCareer extends Behavior<EntityVillager> {
|
|
|
|
@@ -20,7 +25,14 @@
|
|
IRegistry.VILLAGER_PROFESSION.d().filter((villagerprofession) -> {
|
|
return villagerprofession.b() == villageplacetype;
|
|
}).findFirst().ifPresent((villagerprofession) -> {
|
|
- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(villagerprofession));
|
|
+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed
|
|
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED);
|
|
+ if (event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession())));
|
|
+ // CraftBukkit end
|
|
entityvillager.a(worldserver);
|
|
});
|
|
});
|