Fixed NotSerializableException when killing certain entities (fixes #589)
This commit is contained in:
parent
77a4a9476a
commit
a93bf2f047
3 changed files with 29 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attributable;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
|
@ -231,6 +232,11 @@ public class EntityUtil {
|
|||
else if (entity instanceof Cat) {
|
||||
Cat cat = (Cat) entity;
|
||||
if (count == 0) {
|
||||
if (value instanceof String) {
|
||||
NamespacedKey namespacedKey = NamespacedKey.fromString((String) value);
|
||||
value = Bukkit.getRegistry(Cat.Type.class).get(namespacedKey);
|
||||
// value = RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT).get((NamespacedKey)value);
|
||||
}
|
||||
Cat.Type set = (Cat.Type) value;
|
||||
cat.setCatType(set);
|
||||
}
|
||||
|
|
@ -327,6 +333,10 @@ public class EntityUtil {
|
|||
if (count == 0) {
|
||||
if (abstractVillager instanceof Villager) {
|
||||
Villager villager = (Villager) abstractVillager;
|
||||
if (value instanceof String) {
|
||||
NamespacedKey namespacedKey = NamespacedKey.fromString((String) value);
|
||||
value = Bukkit.getRegistry(Profession.class).get(namespacedKey);
|
||||
}
|
||||
Profession set = (Profession) value;
|
||||
villager.setProfession(set);
|
||||
}
|
||||
|
|
@ -334,6 +344,10 @@ public class EntityUtil {
|
|||
else if (count == 1) {
|
||||
if (abstractVillager instanceof Villager && value instanceof Villager.Type) {
|
||||
Villager villager = (Villager) abstractVillager;
|
||||
if (value instanceof String) {
|
||||
NamespacedKey namespacedKey = NamespacedKey.fromString((String) value);
|
||||
value = Bukkit.getRegistry(Villager.Type.class).get(namespacedKey);
|
||||
}
|
||||
Villager.Type set = (Villager.Type) value;
|
||||
villager.setVillagerType(set);
|
||||
}
|
||||
|
|
@ -427,6 +441,10 @@ public class EntityUtil {
|
|||
zombieVillager.setBaby(set);
|
||||
}
|
||||
else if (count == 1) {
|
||||
if (value instanceof String) {
|
||||
NamespacedKey namespacedKey = NamespacedKey.fromString((String) value);
|
||||
value = Bukkit.getRegistry(Profession.class).get(namespacedKey);
|
||||
}
|
||||
Profession set = (Profession) value;
|
||||
zombieVillager.setVillagerProfession(set);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue