Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.imwazzix.radiation;
- import java.util.ArrayList;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.Material;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerCommandPreprocessEvent;
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.PlayerInventory;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import com.connorlinfoot.actionbarapi.ActionBarAPI;
- public class Main extends JavaPlugin implements Listener{
- static ArrayList<Player> RadPlayer = new ArrayList<>();
- static private int timer = 0;
- static private int task = 0;
- public void onEnable(){
- getServer().getPluginManager().registerEvents(this, this);
- }
- public void onDisable(){
- }
- @EventHandler
- public void onCommand(PlayerCommandPreprocessEvent e){
- String msg = e.getMessage();
- String[] args = msg.split(" ");
- Player p = e.getPlayer();
- if(args[0].equalsIgnoreCase("/rad")){
- if(args.length == 2){
- Player RadP = Bukkit.getPlayer(args[1]);
- PlayerInventory inv = RadP.getInventory();
- if(RadP.isOnline()){
- 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)){
- if(!RadPlayer.contains(RadP)){
- RadPlayer.add(RadP);
- Bukkit.broadcastMessage("Rad pour " + RadP.getName());
- RadPlayer(RadP);
- e.setCancelled(true);
- }
- }
- }
- }else p.sendMessage("§a/rad <joueur>");
- }
- }
- private void RadPlayer(final Player p){
- Random r = new Random();
- task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("Radiation"), new Runnable(){
- PlayerInventory inv = p.getInventory();
- @Override
- public void run() {
- 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)){
- if(timer == 0){
- ActionBarAPI.sendActionBar(p,"§6>> §4Tu as été contaminé ! §6<<", 60);
- }else if(timer == 50){
- p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 220, 30));
- }
- if(timer <= 10){
- if(r.nextInt(7) > 5){
- Bukkit.broadcastMessage("Blink pour "+p.getName());
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
- }
- ActionBarAPI.sendActionBar(p,"§6>> §4|§a||||| §6<<");
- }else if(timer > 10 && timer <= 20){
- if(r.nextInt(7) > 4){
- Bukkit.broadcastMessage("Blink pour "+p.getName());
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
- }
- ActionBarAPI.sendActionBar(p,"§6>> §4||§a|||| §6<<");
- }else if(timer > 20 && timer <= 30){
- if(r.nextInt(7) > 3){
- Bukkit.broadcastMessage("Blink pour "+p.getName());
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
- }
- ActionBarAPI.sendActionBar(p,"§6>> §4|||§a||| §6<<");
- }else if(timer > 30 && timer <= 40){
- if(r.nextInt(7) > 2){
- Bukkit.broadcastMessage("Blink pour "+p.getName());
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
- }
- ActionBarAPI.sendActionBar(p,"§6>> §4||||§a|| §6<<");
- }else if(timer > 40 && timer <= 50){
- if(r.nextInt(7) > 1){
- Bukkit.broadcastMessage("Blink pour "+p.getName());
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 15));
- }
- ActionBarAPI.sendActionBar(p,"§6>> §4|||||§a| §6<<");
- }else if(timer > 50 && timer < 60){
- Bukkit.broadcastMessage("Blink pour "+p.getName());
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 30));
- p.damage(2);
- ActionBarAPI.sendActionBar(p,"§6>> §4|||||| §6<<");
- }else if(timer == 60){
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 25, 30));
- p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 25, 30));
- p.damage(200);
- RadPlayer.remove(p);
- timer = 0;
- Bukkit.getScheduler().cancelTask(task);
- }
- timer++;
- Bukkit.broadcastMessage("Timer pour "+p.getName()+" : "+timer);
- }else {
- Bukkit.getScheduler().cancelTask(task);
- timer = 0;
- }
- }
- }, 20, 20);
- }
- public void onPlayerQuit(PlayerQuitEvent e){
- if(RadPlayer.contains(e.getPlayer())){
- e.getPlayer().damage(200);
- RadPlayer.remove(e.getPlayer());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement