mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-14 03:21:29 +01:00
Add support for extended and/or upgraded potions in the item syntax.
This commit adds support for altering the data portion of a potion item by prefixing either `long_` or `strong_` to get extended duration or level II versions of the given potion, respectively. Closes #520
This commit is contained in:
parent
dd31a11b60
commit
054220a32e
@ -11,6 +11,7 @@ These changes will (most likely) be included in the next version.
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
- Extended and upgraded potions are now supported in the item syntax by prepending `long_` or `strong_` to the data portion of a potion item (e.g. `potion:strong_instant_heal:1` will yield a Potion of Healing II). Check the wiki for details.
|
||||
- Tridents and crossbows are now considered weapons with regards to the `unbreakable-weapons` flag. All class items that have durability now have their unbreakable flag set to true unless the `unbreakable-weapons` and/or `unbreakable-armor` flags are set to `false`.
|
||||
- Leaderboards now work again on servers running Minecraft 1.14+.
|
||||
- Class chests (non-linked) now work again on servers running Minecraft 1.14+.
|
||||
|
@ -100,22 +100,28 @@ public class ItemParser
|
||||
}
|
||||
|
||||
private static ItemStack withPotionMeta(ItemStack stack, String data) {
|
||||
PotionType type = getPotionType(data);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
PotionMeta meta = (PotionMeta) stack.getItemMeta();
|
||||
meta.setBasePotionData(new PotionData(type));
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
PotionType type;
|
||||
boolean extended = false;
|
||||
boolean upgraded = false;
|
||||
|
||||
private static PotionType getPotionType(String data) {
|
||||
if (data.startsWith("long_")) {
|
||||
extended = true;
|
||||
data = data.substring(5);
|
||||
}
|
||||
if (data.startsWith("strong_")) {
|
||||
upgraded = true;
|
||||
data = data.substring(7);
|
||||
}
|
||||
try {
|
||||
return PotionType.valueOf(data.toUpperCase());
|
||||
type = PotionType.valueOf(data.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PotionMeta meta = (PotionMeta) stack.getItemMeta();
|
||||
meta.setBasePotionData(new PotionData(type, extended, upgraded));
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static Optional<Material> getType(String item) {
|
||||
|
Loading…
Reference in New Issue
Block a user