How to set, and tp to spawn?

Discussion in 'Plugin Development' started by Havers, Feb 23, 2011.

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

    Saturisk

    Hello! I had this same query, i just recently started working with Bukkit, and wanted this too. Thanks! Very helpful, just one question. Does this requite more libraries or more recent libraries then the Bukkit-0.0.1 SNAPSHOT? If so could you point me towards where to find them?
     
  2. Offline

    Edward Hand

    You also need CraftBukkit, which you can find in the same place as Bukkit
     
  3. Offline

    Saturisk

    Oh okay! Thanks!
    --- merged: Feb 24, 2011 9:01 PM ---
    Alright so i set this up using your guys's guidelines and such, thanks for the info by the way,but i came to a problem with the "server.q.a.(getLocation)etc..." it gives me this error: "The method a(int, int) in the type WorldProvider is not applicable for the arguments (int, int, int)" am i missing an import or something or did i mess something up?
     
  4. Offline

    Edward Hand

    You are running minecraft beta 1.3, aren't you?
     
  5. Offline

    Saturisk

    Yes. And i read about it, to my documentation in the CraftBukkit Snapshot a only supports one "int" on a void class. Am i wrong?
    --- merged: Feb 24, 2011 10:54 PM ---
    Let me guess.... It doesn't work on 1.3.
     
  6. Offline

    Edward Hand

    It should. If you followed the code on the previous page correctly it should work perfectly.
     
  7. Offline

    Saturisk

    i followed the code to a 'T' but under the "if(player.isOp()) {" the: Server.q.a(int, int, int)" part the a is broken. (the underlying red line dunno how to explain it) and so i read the reference and it says in my craftbukkit a only supports one int.
     
  8. Offline

    Edward Hand

    You remembered to define 'server' like this, right?
    Code:
    WorldServer server = ((CraftWorld)player.getWorld()).getHandle();
     
  9. Offline

    Saturisk

    Here is my code:
    Code:
    ackage sPackage;
    
    import java.awt.Color;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerListener;
    
    import net.minecraft.server.WorldServer;
    import org.bukkit.craftbukkit.CraftWorld;
    
    public class SaturiskPlayerListener extends PlayerListener{
    
            public void onPlayerJoin(PlayerEvent event) {
    
                    Player player = event.getPlayer();
                    player.sendMessage("Welcome to the server, " + player.getName());
            }
    
            public void onPlayerCommand(PlayerChatEvent event) {
                    String[] s = event.getMessage().split(" ");
                    if(s[0] != null) {
                            if(s[0].equalsIgnoreCase("/spawn")) {
    
    
                            }
                    } else if(s[0].equalsIgnoreCase("/setspawn")) {
                            Player player = event.getPlayer();
                            if(player.isOp()) {
                                    WorldServer server = ((CraftWorld)player.getWorld()).getHandle();
                                    server.q.a(player.getLocation().getBlockX(),player.getLocation().getBlockY(),player.getLocation().getBlockZ());
    
                                    player.sendMessage(Color.RED + "Spawn set");
                            }
                    } else  if(s[0].equalsIgnoreCase("/help")) {
                                    Player player = event.getPlayer();
                                    player.sendMessage("I can't do that, " + player.getName());
                            }
            }
    }
    i didn't just copy paste i wrote down things till i understood it
     
  10. Offline

    Edward Hand

    You're saying it thinks server.q is a WorldProvider class?
    That means you're still using the old Beta 1.2 version of craftbukkit. Redownload the latest version.
     
  11. Offline

    Saturisk

    It says i'm using:git-Bukkit-0.0.0-444-g9e8ca13-b424jnks (MC: 1.2_01), i know i'm using build 444. Or am i looking at the wrong thing. I need Craftbukkit? Where can i download it. Its from the lukegb website thing isn't it?
     
  12. Offline

    xpansive

    Whoops, I say getSpawnLocation() and assumed setSpawnLocation() existed [​IMG]
     
  13. Offline

    Edward Hand

    http://ci.bukkit.org/job/dev-CraftBukkit/
     
  14. Offline

    Saturisk

    I got everything set up, but when i hit '/setspawn' my server says unknown console command. Any ideas?
    --- merged: Feb 25, 2011 5:09 AM ---
    Scrap that, sorry i say things before i check things out. It is actually this:
    Code:
    public void onPlayerCommand(PlayerChatEvent event) {
            String[] s = event.getMessage().split(" ");
            if(s[0] != null) {
                    if(s[0].equalsIgnoreCase("/spawn")) {
    
                    }
            } else if(s[0].equalsIgnoreCase("/setspawn")) {
                    Player player = event.getPlayer();
                    if(player.isOp()) {
                            WorldServer server = ((CraftWorld)player.getWorld()).getHandle();
                            server.q.a(player.getLocation().getBlockX(),player.getLocation().getBlockY(),player.getLocation().getBlockZ());
    
                            player.sendMessage(Color.RED + "Spawn set");
                    }
            } else  if(s[0].equalsIgnoreCase("/cani")) {
                            Player player = event.getPlayer();
                            player.sendMessage("I can't do that, " + player.getName());
                    }
    }
    i changed '/help' to '/cani' and it didn't work, theres no errors so somethings saying something thats not working. Any ideas?
     
  15. Offline

    Edward Hand

    Well, your conditional checks are a bit messed up....

    Code:
    if(s[0] != null) {
        //stuff you're doing
    }else if(s[0].equalsIgnoreCase("/cani")){
        //other stuff
    }
    In what circumstance would 'other stuff' ever be called? None that I can see.

    You've got all the right things, just not connected together quite right. Do this:
    Code:
    if(s[0] != null){
        if(s[0].equalsIgnoreCase("/spawn"){
             //stuffs
        }else if(s[0].equalsIgnoreCase("/setSpawn")
             //more stuff
        }
    }
    etc...
     
  16. Offline

    Havers

    Argh, cant make the /spawn to work :(
     
  17. Offline

    Saturisk

    Havers, read what Edward just put up about mine. The conditionals are a little bit wrong with the else if parts, so take a look and see what you can do.
     
  18. Offline

    Edward Hand

    Also, "It doesn't work" isn't very informative. When asking for help, try to give as much detail as possible about what you mean so that we can give you the best help.
     
  19. Offline

    Saturisk

    Alright so i changed it, and now i have this:

    Code:
    public void onPlayerCommand(PlayerChatEvent event) {
            String[] s = event.getMessage().split(" ");
            if(s[0] != null){
                if(s[0].equalsIgnoreCase("/spawn")){
                     //stuffs
                }else if(s[0].equalsIgnoreCase("/setSpawn")){
    
                    Player player = event.getPlayer();
    
                        WorldServer server = ((CraftWorld)player.getWorld()).getHandle();
                        server.q.a(player.getLocation().getBlockX(),player.getLocation().getBlockY(),player.getLocation().getBlockZ());
    
                }
      
                }
            }
    Do i have to set anything for spawn? I think i do, just don't know the general idea.
     
  20. Offline

    Plague

    Do you mean set for /spawn? - No, just read the spawn location and TeleportTo()
    Or you mean in the /setspawn? No I just do this one command. BUT I'm not sure what will become of it in multiworld setups.
     
  21. Offline

    Saturisk

    Well, thanks for responding by the way, but for the setspawn with the server.q.a it's getting the location of when you setspawn, i'm pretty sure it's not setting the spawn point right there right?
     
  22. Offline

    Plague

    Umm what? :)
    server.q.a sets the location of the span to the coordinates you give it...
     
  23. Offline

    Saturisk

    Crap. I think i read how to do this wrong.........
    I read this thread before this and another one about it and thought i understood it.

    When i say '/setspawn' what is it telling it to do, did i get my code right?

    And sorry i'm still learning [​IMG]
     
  24. Offline

    Plague

    Your ode takes the player's location and uses it for setting the new spawn location.
     
  25. Offline

    Saturisk

    Wow i did get it right?
    woah..... theres a first for everything i guess
    And if i change the names i could make a simple warp plugin too right?
     
  26. Offline

    Plague

    What names?
    You can make any plugin you want if you want to...
     
  27. Offline

    Saturisk

    Sorry, bad explanation, and Edward helped answer my question, i meant if i changed /setspawn to /setwarp, but it wouldn't be my warp it would be everyones warp and that wouldn't work on my server
     
Thread Status:
Not open for further replies.

Share This Page