blob: 092e9fba16bf2162a067676eec10f6416c887905 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package org.bukkit.craftbukkit.entity;
import java.util.Collection;
import net.minecraft.server.EntityPotion;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
public CraftThrownPotion(CraftServer server, EntityPotion entity) {
super(server, entity);
}
// TODO: This one does not handle custom NBT potion effects does it?
// In that case this method could be said to be misleading or incorrect
public Collection<PotionEffect> getEffects() {
return Potion.getBrewer().getEffectsFromDamage(getHandle().getItem().getData());
}
public ItemStack getItem() {
return CraftItemStack.asBukkitCopy(getHandle().getItem());
}
public void setItem(ItemStack item) {
// The ItemStack must not be null.
Validate.notNull(item, "ItemStack cannot be null.");
// The ItemStack must be a potion.
Validate.isTrue(item.getType() == Material.POTION, "ItemStack must be a potion. This item stack was " + item.getType() + ".");
getHandle().setItem(CraftItemStack.asNMSCopy(item));
}
@Override
public EntityPotion getHandle() {
return (EntityPotion) entity;
}
@Override
public String toString() {
return "CraftThrownPotion";
}
public EntityType getType() {
return EntityType.SPLASH_POTION;
}
}
|