[X] Have you checked the wiki page to see if your suggestion is already added?
[X] Have you checked the Current bugs project to see if your suggestion was already submitted and or denied?
[X] Have you asked if the feature already exists in the Discord Server? (Or got redirected to a Github issue here)
Is your feature request related to a problem? Please describe.
Auto full potion: when /cpg is executed
Describe the solution you'd like
To get the potion type from an ItemStack in Spigot and Paper, you can use the following code snippet in Java:
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
public class PotionExample {
public PotionType getPotionTypeFromItemStack(ItemStack itemStack) {
if (itemStack != null && itemStack.getType() == Material.POTION) {
if (itemStack.hasItemMeta() && itemStack.getItemMeta() instanceof PotionMeta) {
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
PotionData potionData = potionMeta.getBasePotionData();
return potionData.getType();
}
}
return null; // Return null if the ItemStack is not a potion or doesn't have potion meta
}
// Example usage
public static void main(String[] args) {
ItemStack potionItemStack = new ItemStack(Material.POTION); // Replace this with your actual ItemStack
PotionExample potionExample = new PotionExample();
PotionType potionType = potionExample.getPotionTypeFromItemStack(potionItemStack);
System.out.println("Potion Type: " + potionType);
}
}
This code checks if the ItemStack is a potion, has item meta, and if the item meta is an instance of PotionMeta. It then retrieves the base potion data and gets the potion type from it. The getPotionTypeFromItemStack method returns the PotionType or null if the conditions are not met.
Make sure to replace potionItemStack with your actual ItemStack.
Snippet from chat gpt. Will be trying to add later but placing here to remember or if someone else on the team wants to take a stab at it.
Describe alternatives you've considered
None
Screenshots/Videos (you can drag and drop files or paste links)
Terms
Is your feature request related to a problem? Please describe.
Auto full potion: when /cpg is executed
Describe the solution you'd like
To get the potion type from an ItemStack in Spigot and Paper, you can use the following code snippet in Java:
This code checks if the ItemStack is a potion, has item meta, and if the item meta is an instance of PotionMeta. It then retrieves the base potion data and gets the potion type from it. The
getPotionTypeFromItemStack
method returns the PotionType or null if the conditions are not met.Make sure to replace
potionItemStack
with your actual ItemStack.Snippet from chat gpt. Will be trying to add later but placing here to remember or if someone else on the team wants to take a stab at it.
Describe alternatives you've considered
None
Screenshots/Videos (you can drag and drop files or paste links)
No response