Skip to content

Commit ca11673

Browse files
Allow Pdc to get the Plugin
1 parent 22afea9 commit ca11673

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed
Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
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-
261
package me.flame.menus.components.nbt;
272

283
import me.flame.menus.util.VersionHelper;
294
import org.bukkit.inventory.ItemStack;
5+
import org.bukkit.plugin.java.JavaPlugin;
306
import org.jetbrains.annotations.NotNull;
317

328
/**
339
* Ideally this wouldn't need to be a util, but because of the {@link LegacyNbt} it makes it easier. Legacy
3410
* Will use the PDC wrapper if version is higher than 1.14
11+
* @author TriumphTeam
3512
*/
36-
public final class ItemNbt {
3713

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();
3917

4018
/**
4119
* Sets an NBT tag to the an {@link ItemStack}.
@@ -46,7 +24,7 @@ public final class ItemNbt {
4624
* @return An {@link ItemStack} that has NBT set.
4725
*/
4826
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);
5028
}
5129

5230
/**
@@ -57,7 +35,7 @@ public static ItemStack setString(@NotNull final ItemStack itemStack, @NotNull f
5735
* @return The tag that was stored in the {@link ItemStack}.
5836
*/
5937
public static String getString(@NotNull final ItemStack itemStack, @NotNull final String key) {
60-
return nbt.getString(itemStack, key);
38+
return WRAPPER.getString(itemStack, key);
6139
}
6240

6341
/**
@@ -70,7 +48,7 @@ public static String getString(@NotNull final ItemStack itemStack, @NotNull fina
7048
* @return An {@link ItemStack} with a boolean value set.
7149
*/
7250
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);
7452
}
7553

7654
/**
@@ -81,6 +59,6 @@ public static ItemStack setBoolean(@NotNull final ItemStack itemStack, @NotNull
8159
* @return An {@link ItemStack} that has the tag removed.
8260
*/
8361
public static ItemStack removeTag(@NotNull final ItemStack itemStack, @NotNull final String key) {
84-
return nbt.removeTag(itemStack, key);
62+
return WRAPPER.removeTag(itemStack, key);
8563
}
8664
}

0 commit comments

Comments
 (0)