mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 15:07:36 +02:00
Use new compound shortcuts
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
fe02cf73cf
commit
d15da98182
@ -38,8 +38,7 @@ public class Tag<T> {
|
|||||||
final var updated = new SNBTParser(new StringReader(snbt)).parse();
|
final var updated = new SNBTParser(new StringReader(snbt)).parse();
|
||||||
if (!(updated instanceof NBTCompound updatedCompound))
|
if (!(updated instanceof NBTCompound updatedCompound))
|
||||||
throw new IllegalArgumentException("'" + snbt + "' is not a compound!");
|
throw new IllegalArgumentException("'" + snbt + "' is not a compound!");
|
||||||
original.clear();
|
original.copyFrom(updatedCompound);
|
||||||
updatedCompound.forEach(original::set);
|
|
||||||
} catch (NBTException e) {
|
} catch (NBTException e) {
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
}
|
}
|
||||||
@ -51,10 +50,7 @@ public class Tag<T> {
|
|||||||
* Writing will override all tags. Proceed with caution.
|
* Writing will override all tags. Proceed with caution.
|
||||||
*/
|
*/
|
||||||
@ApiStatus.Experimental
|
@ApiStatus.Experimental
|
||||||
public static final Tag<NBTCompound> NBT = new Tag<>(null, NBTCompoundLike::toCompound, (original, updated) -> {
|
public static final Tag<NBTCompound> NBT = new Tag<>(null, NBTCompoundLike::toCompound, MutableNBTCompound::copyFrom);
|
||||||
original.clear();
|
|
||||||
updated.forEach(original::set);
|
|
||||||
});
|
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
private final Function<NBTCompoundLike, T> readFunction;
|
private final Function<NBTCompoundLike, T> readFunction;
|
||||||
|
Loading…
Reference in New Issue
Block a user