Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin {
- public void onEnable()
- {
- File f = new File("plugins/EP6", "config.yml");
- if(f.exists())
- {
- System.out.println("Fichier de configuration existant!");
- }else{
- getConfig().options().copyDefaults(false);
- getConfig().createSection("Spawn");
- getConfig().createSection("Spawn.x");
- getConfig().createSection("Spawn.y");
- getConfig().createSection("Spawn.z");
- saveConfig();
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
- {
- Player player = (Player) sender;
- if(cmd.getName().equalsIgnoreCase("setspawn"))
- {
- Location loc = player.getLocation();
- getConfig().set("Spawn.x", loc.getX());
- getConfig().set("Spawn.y", loc.getY());
- getConfig().set("Spawn.z", loc.getZ());
- saveConfig();
- player.sendMessage("§2>> Point de spawn defini acec succes!");
- }else if(cmd.getName().equalsIgnoreCase("spawn"))
- {
- Location TPSpawn = new Location(Bukkit.getWorld("world"), getConfig().getDouble("Spawn.x"), getConfig().getDouble("Spawn.y"), getConfig().getDouble("Spawn.z"));
- player.teleport(TPSpawn);
- player.sendMessage("§2>> Vous etes maintenant au spawn!");
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment