Advertisement
Guest User

Untitled

a guest
May 16th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. package fr.imwazzix.radiation;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Material;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.Listener;
  10. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  11. import org.bukkit.event.player.PlayerQuitEvent;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.inventory.PlayerInventory;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15. import org.bukkit.potion.PotionEffect;
  16. import org.bukkit.potion.PotionEffectType;
  17.  
  18. import com.connorlinfoot.actionbarapi.ActionBarAPI;
  19.  
  20. public class Main extends JavaPlugin implements Listener{
  21.  
  22. static ArrayList<Player> RadPlayer = new ArrayList<>();
  23. static private int timer = 0;
  24. static private int task = 0;
  25.  
  26. public void onEnable(){
  27.  
  28. getServer().getPluginManager().registerEvents(this, this);
  29.  
  30. }
  31.  
  32. public void onDisable(){
  33.  
  34.  
  35. }
  36.  
  37. @EventHandler
  38. public void onCommand(PlayerCommandPreprocessEvent e){
  39.  
  40. String msg = e.getMessage();
  41. String[] args = msg.split(" ");
  42. Player p = e.getPlayer();
  43.  
  44. if(args[0].equalsIgnoreCase("/rad")){
  45. if(args.length == 2){
  46. Player RadP = Bukkit.getPlayer(args[1]);
  47. PlayerInventory inv = RadP.getInventory();
  48. if(RadP.isOnline()){
  49. if(inv.getBoots() != new ItemStack(Material.CHAINMAIL_BOOTS) && inv.getLeggings() != new ItemStack(Material.CHAINMAIL_LEGGINGS) && inv.getChestplate() != new ItemStack(Material.CHAINMAIL_CHESTPLATE) && inv.getHelmet() != new ItemStack(Material.CHAINMAIL_HELMET)){
  50. if(!RadPlayer.contains(RadP)){
  51. RadPlayer.add(RadP);
  52. Bukkit.broadcastMessage("Rad pour " + RadP.getName());
  53. RadPlayer(RadP);
  54. e.setCancelled(true);
  55. }
  56. }
  57. }
  58. }else p.sendMessage("§a/rad <joueur>");
  59. }
  60. }
  61.  
  62.  
  63. private void RadPlayer(final Player p){
  64. Random r = new Random();
  65. task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("Radiation"), new Runnable(){
  66. PlayerInventory inv = p.getInventory();
  67. @Override
  68. public void run() {
  69. if(RadPlayer.contains(p) || p.isDead() == false || inv.getBoots() != new ItemStack(Material.CHAINMAIL_BOOTS) && inv.getLeggings() != new ItemStack(Material.CHAINMAIL_LEGGINGS) && inv.getChestplate() != new ItemStack(Material.CHAINMAIL_CHESTPLATE) && inv.getHelmet() != new ItemStack(Material.CHAINMAIL_HELMET)){
  70.  
  71. if(timer == 0){
  72. ActionBarAPI.sendActionBar(p,"§6>> §4Tu as été contaminé ! §6<<", 60);
  73. }else if(timer == 50){
  74. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 220, 30));
  75. }
  76.  
  77. if(timer <= 10){
  78. if(r.nextInt(7) > 5){
  79. Bukkit.broadcastMessage("Blink pour "+p.getName());
  80. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
  81. }
  82. ActionBarAPI.sendActionBar(p,"§6>> §4|§a||||| §6<<");
  83. }else if(timer > 10 && timer <= 20){
  84. if(r.nextInt(7) > 4){
  85. Bukkit.broadcastMessage("Blink pour "+p.getName());
  86. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
  87. }
  88. ActionBarAPI.sendActionBar(p,"§6>> §4||§a|||| §6<<");
  89. }else if(timer > 20 && timer <= 30){
  90. if(r.nextInt(7) > 3){
  91. Bukkit.broadcastMessage("Blink pour "+p.getName());
  92. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
  93. }
  94. ActionBarAPI.sendActionBar(p,"§6>> §4|||§a||| §6<<");
  95. }else if(timer > 30 && timer <= 40){
  96. if(r.nextInt(7) > 2){
  97. Bukkit.broadcastMessage("Blink pour "+p.getName());
  98. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
  99. }
  100. ActionBarAPI.sendActionBar(p,"§6>> §4||||§a|| §6<<");
  101. }else if(timer > 40 && timer <= 50){
  102. if(r.nextInt(7) > 1){
  103. Bukkit.broadcastMessage("Blink pour "+p.getName());
  104. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
  105. }
  106. ActionBarAPI.sendActionBar(p,"§6>> §4|||||§a| §6<<");
  107. }else if(timer > 50 && timer < 60){
  108. Bukkit.broadcastMessage("Blink pour "+p.getName());
  109. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 30));
  110. p.damage(2);
  111. ActionBarAPI.sendActionBar(p,"§6>> §4|||||| §6<<");
  112. }else if(timer == 60){
  113. p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 30));
  114. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 25, 30));
  115. p.damage(200);
  116. RadPlayer.remove(p);
  117. timer = 0;
  118. Bukkit.getScheduler().cancelTask(task);
  119. }
  120. timer++;
  121. Bukkit.broadcastMessage("Timer pour "+p.getName()+" : "+timer);
  122. }else {
  123. Bukkit.getScheduler().cancelTask(task);
  124. timer = 0;
  125. }
  126. }
  127.  
  128. }, 20, 20);
  129. }
  130.  
  131. public void onPlayerQuit(PlayerQuitEvent e){
  132.  
  133. if(RadPlayer.contains(e.getPlayer())){
  134. e.getPlayer().damage(200);
  135. RadPlayer.remove(e.getPlayer());
  136. }
  137.  
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement