Résolu Setblock JAVA

bubagump1

Architecte en herbe
27 Septembre 2014
218
22
125
Oui, tu remplaces just le 'p.getWorld();' par Bukkit.getServer().getWorld("NomDuMonde");
 

RedHeadEmile

Codeur Java qui code en Java
6 Novembre 2015
121
1
130
C'est bon, mon code fonctionne, le voila en entier :
Code:
package fr.RedHeadEmile.RedHeadEmile;
 
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
 
public class Command implements Listener {
 
    public Command(RedHeadEmile redHeadEmile) {
    }
 
    @EventHandler
    public void onCommand(PlayerCommandPreprocessEvent e){
       
        Player p = e.getPlayer();
        String msg = e.getMessage();
        String[] args = msg.split(" ");
       
        if(args[0].equalsIgnoreCase("/denceore")){
            if(p.hasPermission("redheademile.danceore")){
           
            if(args.length == 1){
            p.sendMessage("§7/danceore <start | stop | tp>");
            e.setCancelled(true);
            }
           
            if(args.length == 2){
               
                final World world = Bukkit.getWorld("arene");
                final Location loc = new Location(world, 139,17,395);
               
                if(args[1].equalsIgnoreCase("tp")){
                for(Player player : Bukkit.getOnlinePlayers()){
                player.teleport(loc);
                        }
                }
           
                if(args[1].equalsIgnoreCase("start")){
                Bukkit.getServer().broadcastMessage("§6Le DenceOre §acommence §6!");
                World world1 = p.getWorld();
                world1.getBlockAt(new Location(world1, 136, 17, 393)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 18, 393)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 17, 395)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 18, 395)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 17, 397)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 18, 397)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 19, 396)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 20, 396)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 19, 394)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 20, 394)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 17, 394)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 18, 394)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 17, 396)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 18, 396)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 19, 397)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 20, 397)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 19, 395)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 20, 395)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 19, 393)).setType(Material.AIR);
                world1.getBlockAt(new Location(world1, 136, 20, 393)).setType(Material.AIR);
                for(Player pl : Bukkit.getOnlinePlayers()){
                    pl.setGameMode(GameMode.SURVIVAL);
                }
            }
                final World world1 = Bukkit.getWorld("world");
                final Location loc1 = new Location(world1, -244,70,211);
               
                if(args[1].equalsIgnoreCase("stop")){
                p.getServer().broadcastMessage("§6Le DenceOre est §cfini §6!");
                World world11 = p.getWorld();
                world11.getBlockAt(new Location(world11, 136, 17, 393)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 18, 393)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 17, 395)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 18, 395)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 17, 397)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 18, 397)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 19, 396)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 20, 396)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 19, 394)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 20, 394)).setType(Material.BEDROCK);
                world11.getBlockAt(new Location(world11, 136, 17, 394)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 18, 394)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 17, 396)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 18, 396)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 19, 397)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 20, 397)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 19, 395)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 20, 395)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 19, 393)).setType(Material.BARRIER);
                world11.getBlockAt(new Location(world11, 136, 20, 393)).setType(Material.BARRIER);
                for(Player player : Bukkit.getOnlinePlayers()){
                    player.teleport(loc1);
                }
            }
           
               
            e.setCancelled(true);
            }
            }
        }
    }   
}
 

RedHeadEmile

Codeur Java qui code en Java
6 Novembre 2015
121
1
130
Cependant, cela doit venir du plugin.yml, in game j'aimerais faire :
"/<nom du plugin>:<commande>" comme
"/essentials:home". Cela est-il possible ?