Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. import org.bukkit.potion.PotionEffectType;
  2. import org.bukkit.potion.PotionEffect;
  3. import org.bukkit.potion.PotionType;
  4. import org.bukkit.entity.Player;
  5.  
  6. import pl.disGu.core.commands.guild.GEfektCommand;
  7.  
  8. import org.bukkit.inventory.ItemStack;
  9.  
  10. public enum EffectType
  11. {
  12. REGEN("REGEN", 0, "REGEN", 0, "REGEN", 0, "REGEN", 0, 20, 150),
  13. INSTANT_HEAL("INSTANT_HEAL", 1, "INSTANT_HEAL", 1, "INSTANT_HEAL", 1, "INSTANT_HEAL", 1, true, 240, -1),
  14. SPEED("SPEED", 2, "SPEED", 2, "SPEED", 2, "SPEED", 2, 18, 90),
  15. FIRE_RESISTANCE("FIRE_RESISTANCE", 3, "FIRE_RESISTANCE", 3, "FIRE_RESISTANCE", 3, "FIRE_RESISTANCE", 3, 16, 512),
  16. HASTE("HASTE", 4, "HASTE", 4, "HASTE", 4, "HASTE", 4, 32, 300),
  17. INSTANT_DAMAGE("INSTANT_DAMAGE", 5, "INSTANT_DAMAGE", 5, "INSTANT_DAMAGE", 5, "INSTANT_DAMAGE", 5, true, 20, -1);
  18.  
  19. private final boolean isInstant;
  20. private final int cost;
  21. private final int duration;
  22.  
  23. private EffectType(final String s4, final int n4, final String s3, final int n3, final String s2, final int n2, final String s, final int n, final boolean isInstant, final int cost, final int duration) {
  24. this.cost = cost;
  25. this.isInstant = isInstant;
  26. this.duration = duration;
  27. }
  28.  
  29. private EffectType(final String s4, final int n4, final String s3, final int n3, final String s2, final int n2, final String s, final int n, final int cost, final int duration) {
  30. this.cost = cost;
  31. this.isInstant = false;
  32. this.duration = duration;
  33. }
  34.  
  35. public boolean isInstant() {
  36. return this.isInstant;
  37. }
  38.  
  39. public int getCost() {
  40. return this.cost;
  41. }
  42.  
  43. public int getDuration() {
  44. return this.duration;
  45. }
  46.  
  47. public static EffectType getEffectType(final ItemStack item) {
  48. if (GEfektCommand.getFireResistancePotion().isSimilar(item)) {
  49. return EffectType.FIRE_RESISTANCE;
  50. }
  51. if (GEfektCommand.getHastePotion().isSimilar(item)) {
  52. return EffectType.HASTE;
  53. }
  54. if (GEfektCommand.getRegenPotion().isSimilar(item)) {
  55. return EffectType.REGEN;
  56. }
  57. if (GEfektCommand.getSpeedPotion().isSimilar(item)) {
  58. return EffectType.SPEED;
  59. }
  60. return null;
  61. }
  62.  
  63. public static EffectType getEffectTypeRandom() {
  64. final int random = RandomUtil.getRandInt(1, 4);
  65. if (random == 1) {
  66. return EffectType.FIRE_RESISTANCE;
  67. }
  68. if (random == 2) {
  69. return EffectType.HASTE;
  70. }
  71. if (random == 3) {
  72. return EffectType.REGEN;
  73. }
  74. if (random == 4) {
  75. return EffectType.SPEED;
  76. }
  77. return null;
  78. }
  79.  
  80. public static void applyPotion(final Player player, final EffectType type, final long timeTo) {
  81. System.out.println("Time to:" + timeTo + " Time now:" + System.currentTimeMillis());
  82. final long timeLeft = timeTo - System.currentTimeMillis();
  83. Math.round(timeLeft / 1000L);
  84. if (type == EffectType.FIRE_RESISTANCE) {
  85. player.addPotionEffect(new PotionEffect(PotionType.FIRE_RESISTANCE.getEffectType(), 10240, 1), true);
  86. }
  87. else if (type == EffectType.HASTE) {
  88. player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 6000, 1), true);
  89. }
  90. else if (type == EffectType.INSTANT_DAMAGE) {
  91. player.addPotionEffect(new PotionEffect(PotionType.INSTANT_DAMAGE.getEffectType(), 0, 2));
  92. }
  93. else if (type == EffectType.INSTANT_HEAL) {
  94. player.addPotionEffect(new PotionEffect(PotionType.INSTANT_HEAL.getEffectType(), 0, 2));
  95. }
  96. else if (type == EffectType.REGEN) {
  97. player.addPotionEffect(new PotionEffect(PotionType.REGEN.getEffectType(), 3000, 1), true);
  98. }
  99. else if (type == EffectType.SPEED) {
  100. player.addPotionEffect(new PotionEffect(PotionType.SPEED.getEffectType(), 1800, 1), true);
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement