1
- /**
2
- * MIT License
3
- * <p>
4
- * Copyright (c) 2021 TriumphTeam
5
- * Copyright (c) 2023 FlameyosFlow
6
- * <p>
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- * <p>
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- * <p>
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
26
1
package me .flame .menus .components .nbt ;
27
2
28
3
import me .flame .menus .util .VersionHelper ;
29
4
import org .bukkit .inventory .ItemStack ;
5
+ import org .bukkit .plugin .java .JavaPlugin ;
30
6
import org .jetbrains .annotations .NotNull ;
31
7
32
8
/**
33
9
* Ideally this wouldn't need to be a util, but because of the {@link LegacyNbt} it makes it easier. Legacy
34
10
* Will use the PDC wrapper if version is higher than 1.14
11
+ * @author TriumphTeam
35
12
*/
36
- public final class ItemNbt {
37
13
38
- private static final NbtWrapper nbt = VersionHelper .IS_PDC_VERSION ? new Pdc () : new LegacyNbt ();
14
+ //changed
15
+ public final class ItemNbt {
16
+ public static final NbtWrapper WRAPPER = VersionHelper .IS_PDC_VERSION ? new Pdc (JavaPlugin .getProvidingPlugin (ItemNbt .class )) : new LegacyNbt ();
39
17
40
18
/**
41
19
* Sets an NBT tag to the an {@link ItemStack}.
@@ -46,7 +24,7 @@ public final class ItemNbt {
46
24
* @return An {@link ItemStack} that has NBT set.
47
25
*/
48
26
public static ItemStack setString (@ NotNull final ItemStack itemStack , @ NotNull final String key , @ NotNull final String value ) {
49
- return nbt .setString (itemStack , key , value );
27
+ return WRAPPER .setString (itemStack , key , value );
50
28
}
51
29
52
30
/**
@@ -57,7 +35,7 @@ public static ItemStack setString(@NotNull final ItemStack itemStack, @NotNull f
57
35
* @return The tag that was stored in the {@link ItemStack}.
58
36
*/
59
37
public static String getString (@ NotNull final ItemStack itemStack , @ NotNull final String key ) {
60
- return nbt .getString (itemStack , key );
38
+ return WRAPPER .getString (itemStack , key );
61
39
}
62
40
63
41
/**
@@ -70,7 +48,7 @@ public static String getString(@NotNull final ItemStack itemStack, @NotNull fina
70
48
* @return An {@link ItemStack} with a boolean value set.
71
49
*/
72
50
public static ItemStack setBoolean (@ NotNull final ItemStack itemStack , @ NotNull final String key , final boolean value ) {
73
- return nbt .setBoolean (itemStack , key , value );
51
+ return WRAPPER .setBoolean (itemStack , key , value );
74
52
}
75
53
76
54
/**
@@ -81,6 +59,6 @@ public static ItemStack setBoolean(@NotNull final ItemStack itemStack, @NotNull
81
59
* @return An {@link ItemStack} that has the tag removed.
82
60
*/
83
61
public static ItemStack removeTag (@ NotNull final ItemStack itemStack , @ NotNull final String key ) {
84
- return nbt .removeTag (itemStack , key );
62
+ return WRAPPER .removeTag (itemStack , key );
85
63
}
86
64
}
0 commit comments