-
-
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.
[1.0.6.11] fixed missing potion data class
I hate md_5 for removing a class deprecated literally few months ago without providing commodore support
- Loading branch information
Showing
5 changed files
with
65 additions
and
48 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
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
28 changes: 28 additions & 0 deletions
28
.../main/java/org/screamingsandals/simpleinventories/utils/PotionTypeSearchEngine1_20_5.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,28 @@ | ||
package org.screamingsandals.simpleinventories.utils; | ||
|
||
import org.bukkit.inventory.meta.PotionMeta; | ||
import org.bukkit.potion.PotionType; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.Locale; | ||
|
||
public class PotionTypeSearchEngine1_20_5 { | ||
public static PotionType find(String potionType) { | ||
String potion = potionType.toUpperCase(Locale.ROOT); | ||
|
||
// allow prefixing vanilla stuff with minecraft: | ||
if (potion.startsWith("MINECRAFT:")) { | ||
potion = potion.substring(10); | ||
} | ||
|
||
return PotionType.valueOf(potion); | ||
} | ||
|
||
public static void setPotionType(PotionMeta meta, PotionType potionType) { | ||
try { | ||
PotionMeta.class.getMethod("setBasePotionType", PotionType.class).invoke(meta, potionType); | ||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
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
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