Skip to content

Instantly share code, notes, and snippets.

@keepoff07
Created April 27, 2015 09:30
Show Gist options
  • Save keepoff07/58023a220a39b5a9bd65 to your computer and use it in GitHub Desktop.
Save keepoff07/58023a220a39b5a9bd65 to your computer and use it in GitHub Desktop.
[Bukkit] DefaultPotion (for 1.8.x): ダメージ値でデフォルトのPotionEffectを返す
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class DefaultPotion {
private static PotionEffect[][][] effect = {
{
{
null,
null,
null,
null
},
{
new PotionEffect(PotionEffectType.REGENERATION, 900, 0),
new PotionEffect(PotionEffectType.REGENERATION, 450, 1),
new PotionEffect(PotionEffectType.REGENERATION, 2400, 0),
new PotionEffect(PotionEffectType.REGENERATION, 1200, 1)
},
{
new PotionEffect(PotionEffectType.SPEED, 3600, 0),
new PotionEffect(PotionEffectType.SPEED, 1800, 1),
new PotionEffect(PotionEffectType.SPEED, 9600, 0),
new PotionEffect(PotionEffectType.SPEED, 4800, 1)
},
{
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 3600, 0),
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 3600, 0),
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0),
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0)
},
{
new PotionEffect(PotionEffectType.POISON, 900, 0),
new PotionEffect(PotionEffectType.POISON, 450, 1),
new PotionEffect(PotionEffectType.POISON, 2400, 0),
new PotionEffect(PotionEffectType.POISON, 1200, 1)
},
{
new PotionEffect(PotionEffectType.HEAL, 1, 0),
new PotionEffect(PotionEffectType.HEAL, 1, 1),
new PotionEffect(PotionEffectType.HEAL, 1, 0),
new PotionEffect(PotionEffectType.HEAL, 1, 1)
},
{
new PotionEffect(PotionEffectType.NIGHT_VISION, 3600, 0),
new PotionEffect(PotionEffectType.NIGHT_VISION, 3600, 0),
new PotionEffect(PotionEffectType.NIGHT_VISION, 9600, 0),
new PotionEffect(PotionEffectType.NIGHT_VISION, 9600, 0)
},
{
null,
null,
null,
null
},
{
new PotionEffect(PotionEffectType.WEAKNESS, 1800, 0),
new PotionEffect(PotionEffectType.WEAKNESS, 1800, 0),
new PotionEffect(PotionEffectType.WEAKNESS, 4800, 0),
new PotionEffect(PotionEffectType.WEAKNESS, 4800, 0)
},
{
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3600, 0),
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1800, 1),
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 9600, 0),
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 4800, 1)
},
{
new PotionEffect(PotionEffectType.SLOW, 1800, 0),
new PotionEffect(PotionEffectType.SLOW, 1800, 0),
new PotionEffect(PotionEffectType.SLOW, 4800, 0),
new PotionEffect(PotionEffectType.SLOW, 4800, 0)
},
{
new PotionEffect(PotionEffectType.JUMP, 3600, 0),
new PotionEffect(PotionEffectType.JUMP, 1800, 1),
new PotionEffect(PotionEffectType.JUMP, 9600, 0),
new PotionEffect(PotionEffectType.JUMP, 4800, 1)
},
{
new PotionEffect(PotionEffectType.HARM, 1, 0),
new PotionEffect(PotionEffectType.HARM, 1, 1),
new PotionEffect(PotionEffectType.HARM, 1, 0),
new PotionEffect(PotionEffectType.HARM, 1, 1)
},
{
new PotionEffect(PotionEffectType.WATER_BREATHING, 3600, 0),
new PotionEffect(PotionEffectType.WATER_BREATHING, 3600, 0),
new PotionEffect(PotionEffectType.WATER_BREATHING, 9600, 0),
new PotionEffect(PotionEffectType.WATER_BREATHING, 9600, 0)
},
{
new PotionEffect(PotionEffectType.INVISIBILITY, 3600, 0),
new PotionEffect(PotionEffectType.INVISIBILITY, 3600, 0),
new PotionEffect(PotionEffectType.INVISIBILITY, 9600, 0),
new PotionEffect(PotionEffectType.INVISIBILITY, 9600, 0)
},
{
null,
null,
null,
null
}
},
{
{
null,
null,
null,
null
},
{
new PotionEffect(PotionEffectType.REGENERATION, 675, 0),
new PotionEffect(PotionEffectType.REGENERATION, 338, 1),
new PotionEffect(PotionEffectType.REGENERATION, 1800, 0),
new PotionEffect(PotionEffectType.REGENERATION, 900, 1)
},
{
new PotionEffect(PotionEffectType.SPEED, 2700, 0),
new PotionEffect(PotionEffectType.SPEED, 1350, 1),
new PotionEffect(PotionEffectType.SPEED, 7200, 0),
new PotionEffect(PotionEffectType.SPEED, 3600, 1)
},
{
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 2700, 0),
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 2700, 0),
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 7200, 0),
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 7200, 0)
},
{
new PotionEffect(PotionEffectType.POISON, 675, 0),
new PotionEffect(PotionEffectType.POISON, 338, 1),
new PotionEffect(PotionEffectType.POISON, 1800, 0),
new PotionEffect(PotionEffectType.POISON, 900, 1)
},
{
new PotionEffect(PotionEffectType.HEAL, 1, 0),
new PotionEffect(PotionEffectType.HEAL, 1, 1),
new PotionEffect(PotionEffectType.HEAL, 1, 0),
new PotionEffect(PotionEffectType.HEAL, 1, 1)
},
{
new PotionEffect(PotionEffectType.NIGHT_VISION, 2700, 0),
new PotionEffect(PotionEffectType.NIGHT_VISION, 2700, 0),
new PotionEffect(PotionEffectType.NIGHT_VISION, 7200, 0),
new PotionEffect(PotionEffectType.NIGHT_VISION, 7200, 0)
},
{
null,
null,
null,
null
},
{
new PotionEffect(PotionEffectType.WEAKNESS, 1350, 0),
new PotionEffect(PotionEffectType.WEAKNESS, 1350, 0),
new PotionEffect(PotionEffectType.WEAKNESS, 3600, 0),
new PotionEffect(PotionEffectType.WEAKNESS, 3600, 0)
},
{
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 2700, 0),
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1350, 1),
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 7200, 0),
new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3600, 1)
},
{
new PotionEffect(PotionEffectType.SLOW, 1350, 0),
new PotionEffect(PotionEffectType.SLOW, 1350, 0),
new PotionEffect(PotionEffectType.SLOW, 3600, 0),
new PotionEffect(PotionEffectType.SLOW, 3600, 0)
},
{
new PotionEffect(PotionEffectType.JUMP, 2700, 0),
new PotionEffect(PotionEffectType.JUMP, 1350, 1),
new PotionEffect(PotionEffectType.JUMP, 7200, 0),
new PotionEffect(PotionEffectType.JUMP, 3600, 1)
},
{
new PotionEffect(PotionEffectType.HARM, 1, 0),
new PotionEffect(PotionEffectType.HARM, 1, 1),
new PotionEffect(PotionEffectType.HARM, 1, 0),
new PotionEffect(PotionEffectType.HARM, 1, 1)
},
{
new PotionEffect(PotionEffectType.WATER_BREATHING, 2700, 0),
new PotionEffect(PotionEffectType.WATER_BREATHING, 2700, 0),
new PotionEffect(PotionEffectType.WATER_BREATHING, 7200, 0),
new PotionEffect(PotionEffectType.WATER_BREATHING, 7200, 0)
},
{
new PotionEffect(PotionEffectType.INVISIBILITY, 2700, 0),
new PotionEffect(PotionEffectType.INVISIBILITY, 2700, 0),
new PotionEffect(PotionEffectType.INVISIBILITY, 7200, 0),
new PotionEffect(PotionEffectType.INVISIBILITY, 7200, 0)
},
{
null,
null,
null,
null
}
}
};
public static PotionEffect getDefault(short damage) {
int isSplash = damage / 16384;
int minID = damage % 128;
int mainID = minID % 16;
int subID = minID / 32;
return effect[isSplash][mainID][subID];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment