SetSpawn & Spawn commands + MOTD via Config

Discussion in 'Plugin Development' started by AdityaTD, May 23, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    AdityaTD

    Hey there everyone, I was trying to code a setspawn and spawn plugin but I wasn't able to figure out the yaw and pitch stuff also the direction. Also I wasn't able to figure out how to make MOTD Messages which support multiple lines via Config.
     
  2. Offline

    ZackBlazes

    This is what I'm using in one of my plugins:
    Setting the spawn...
    Code:
     String world = p.getWorld().getName().toString();
    Location loc = p.getLocation();
    double x = loc.getX();
    double y = loc.getY();
    double z = loc.getZ();
    float yaw = loc.getYaw();
    float pitch = loc.getPitch();
    
    config.set("Spawn.X", x);
    config.set("Spawn.Y", y);
    config.set("Spawn.Z", z);
    config.set("Spawn.Yaw", yaw);
    config.set("Spawn.Pitch", pitch);
    config.set("Spawn.World", world);
    
    p.sendMessage(GOLD + prefix + GREEN + " Spawn set!");
    
    loc.getWorld().setSpawnLocation(loc.getBlockX(),
           loc.getBlockY() + 1, loc.getBlockZ());
    World worlds = Bukkit.getWorlds().get(0);
    worlds.setSpawnLocation(loc.getBlockX(),
           loc.getBlockY() + 1, loc.getBlockZ());
    
    And for teleporting to it...
    Code:
    World world = Bukkit.getWorld(config.getString("Spawn.World"));
    double x = config.getInt("Spawn.X");
    double y = config.getInt("Spawn.Y");
    double z = config.getInt("Spawn.Z");
    float yaw = config.getInt("Spawn.Yaw");
    float pitch = config.getInt("Spawn.Pitch");
    
    Location spawn = new Location(world, x, y, z, yaw, pitch);
    
    p.sendMessage(GOLD + prefix + GREEN + " Teleported to spawn!");
     
  3. Offline

    AdityaTD

    Umagowd thanks man ya saved my day. :)
     
  4. Offline

    ZackBlazes

    @AdityaTD Hopefully it works for you. If you don't understand anything feel free to ask.
     
Thread Status:
Not open for further replies.

Share This Page