fix: NMS exceptions being thrown when applying modifiers

Spigot's validation for this is like my hoover: it sucks.
feat/data-edit-commands 3.6.5
William 5 months ago
parent d4e33aa9d2
commit 0c527202e5
No known key found for this signature in database

@ -625,7 +625,7 @@ public abstract class BukkitData implements Data {
@Nullable
private static UUID getModifierId(@NotNull AttributeModifier modifier) {
try {
return UUID.fromString(modifier.getName());
return modifier.getUniqueId();
} catch (Throwable e) {
return null;
}
@ -656,10 +656,12 @@ public abstract class BukkitData implements Data {
// Reflexively create a modern keyed attribute modifier instance. Remove in favor of API long-term.
final EquipmentSlot slot = slotId != -1 ? EquipmentSlot.values()[slotId] : null;
final Class<?> slotGroup = Class.forName(EQUIPMENT_SLOT_GROUP);
final String modifierName = modifier.name() == null ? modifier.uuid().toString() : modifier.name();
return AttributeModifier.class.getDeclaredConstructor(
NamespacedKey.class, double.class, AttributeModifier.Operation.class, slotGroup
).newInstance(
NamespacedKey.fromString(modifier.name()), modifier.amount(),
NamespacedKey.fromString(modifierName),
modifier.amount(),
AttributeModifier.Operation.values()[modifier.operationType()],
slot == null ? slotGroup.getField(EQUIPMENT_SLOT_GROUP$ANY).get(null)
: EquipmentSlot.class.getDeclaredMethod(EQUIPMENT_SLOT$getGroup).invoke(slot)

@ -3,7 +3,7 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true
javaVersion=17
plugin_version=3.6.4
plugin_version=3.6.5
plugin_archive=husksync
plugin_description=A modern, cross-server player data synchronization system

Loading…
Cancel
Save