-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Fixes incompatibility on 1.8 with NamespacedKey Took 3 minutes
- Loading branch information
1 parent
32c8a0b
commit 7bb9ce4
Showing
3 changed files
with
21 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/kamikazejam/kamicommon/util/nms/NMS_Methods.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.kamikazejam.kamicommon.util.nms; | ||
|
||
import com.kamikazejam.kamicommon.nms.NmsManager; | ||
import org.bukkit.enchantments.Enchantment; | ||
|
||
@SuppressWarnings("unused") | ||
public class NMS_Methods { | ||
@SuppressWarnings("deprecation") | ||
public static String getNamespaced(Enchantment enchantment) { | ||
// If after 1.13, we have access to namespaced keys | ||
if (NmsManager.getFormattedNmsDouble() >= 1130) { | ||
return NMS_Methods_1_13.getNamespaced(enchantment); | ||
}else { | ||
return "minecraft:" + enchantment.getName().toLowerCase(); | ||
} | ||
} | ||
} |
7 changes: 1 addition & 6 deletions
7
src/main/java/com/kamikazejam/kamicommon/util/nms/NMS_Methods_1_13.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
package com.kamikazejam.kamicommon.util.nms; | ||
|
||
import org.bukkit.NamespacedKey; | ||
import org.bukkit.enchantments.Enchantment; | ||
|
||
@SuppressWarnings("unused") | ||
public class NMS_Methods_1_13 { | ||
public static String getNamespaced(Enchantment enchantment) { | ||
static String getNamespaced(Enchantment enchantment) { | ||
return enchantment.getKey().getKey(); | ||
} | ||
|
||
public static Enchantment getEnchantmentByKey(String key) { | ||
return Enchantment.getByKey(NamespacedKey.minecraft(key)); | ||
} | ||
} |