Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ep13;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.Color;
- import org.bukkit.FireworkEffect;
- import org.bukkit.FireworkEffect.Type;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Firework;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.meta.FireworkMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- /*Voir Episode 8 sur le timer*/
- public int tache;
- public ArrayList<String> joueurs = new ArrayList <String>();/* On stock un String (chaîne de caractère) qui sera le nom du joueur.*/
- @SuppressWarnings("deprecation")//On surpime les ligne jaune (avertissement)
- public void timer()
- {
- tache = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
- @Override
- public void run() {
- for (String s : joueurs){
- Player p1 = Bukkit.getPlayer(s);
- Firework f = (Firework) p1.getWorld().spawn(p1.getLocation(), Firework.class);
- FireworkMeta fm = f.getFireworkMeta();
- fm.addEffect(FireworkEffect.builder()
- .flicker(false)
- .trail(true)
- .with(Type.BALL_LARGE)
- .withColor(Color.AQUA)
- .withColor(Color.WHITE)
- .withColor(Color.AQUA)
- .withColor(Color.WHITE)
- .build());
- fm.setPower(0);
- f.setFireworkMeta(fm);
- }
- }
- }, 0L, 20L);
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player p = (Player) sender;
- if(cmd.getName().equalsIgnoreCase("f")){
- if(!(args.length == 1)){//Si il ya plus ou moin d'un argument
- p.sendMessage("§cErreur: §6/f <on/off>: §fPermet d'activer ou désactiver les feux d'artifices.");
- return true;
- }else{
- if(args[0].equalsIgnoreCase("on")){
- p.sendMessage("§3Feux d'artifices activés !");
- joueurs.add(p.getName());/*On ajoute le joueur a L'ArrayList*/
- timer();/*On lance le timer (voir ep8)*/
- return true;
- }else if(args[0].equalsIgnoreCase("off")){
- p.sendMessage("§3Feux d'artifices stopés !");
- joueurs.remove(p.getName());
- return true;
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment