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

    Havers

    Hi,

    I'm creating my first plugin, and trying something i tought to be easy.
    Simpel set spawn, and by writing /spawn, be tp'ed there.

    How do i set spawn to the X,Y,Z coordinates i'm at?
    Where should i save them? Is a textfile fine?
     
  2. Offline

    xpansive

    world.setSpawnLocation and getSpawnLocation
     
  3. Offline

    Edward Hand

    world.setSpawnLocation exists?
     
  4. Offline

    Havers

    You will have to be more spesific.
    I can't find them in the documentation.
     
  5. Offline

    Plague

    World.getSpawnLogation() works perfetly, but there is no set function, craftbukkit 432, bukkit 412
    --- merged: Feb 23, 2011 7:21 PM ---
    quoted to get the master coder's attention :)
     
  6. Offline

    Havers

    I tried this code;

    I get that i got no string named Spawn(x,y,z). Should i just make String SpawnX, SpawnY, spawnZ?
     
  7. Offline

    Plague

    No, there's no such variable at the moment, I think the devs didn't get around to it and deobfuscate it, I'll wait if Edward has no hint :)
     
  8. Offline

    Edward Hand

    Of course he does!

    And Havers, stop inventing non-existant variables! :p

    The first line is fine. After that, use this:
    Code:
    server.q.a(player.getLocation().getBlockX(),player.getLocation().getBlockY(),player.getLocation().getBlockZ())
     
  9. Offline

    Havers

    Thank you!

    Now: Tricky one; Where should i save spawn? Some of my friends suggested to save it directly to the map, but unfamiliar howto. Should i just use a txt-file?

    (And inventing non-existing variables is fun! You should try it! :) )
     
  10. Offline

    Edward Hand

    I'm pretty sure the code I just gave you is persistent (the server will automatically save it to the map for you). Only one way to find out though...
     
  11. Offline

    Plague

    Oh my God Edward, that's it! Thanks.
     
  12. Offline

    Havers

    Oh, thanks :p
    I would love to try it out, but the new launcher have some problems... Or, its one problem. I cant log in. New launcher for mac = Do not download.
     
  13. Offline

    Plague

    Doesn't work for me on linux too, but I think it's the https server, use the old launcher and you can login just fine.
     
  14. Offline

    Edward Hand

    How does your PlgSetspawn work then?
     
  15. Offline

    Havers

    I kinda forgot to backup it..
     
  16. Offline

    Edward Hand

  17. Offline

    Plague

    Now exactly like that, previously there were deobfuscated spawnX/Y/Z variables that I used. Even further back it was Nijikokun's code.
    Attached, It's not actually a ZIP, just fooling the forum filer, it's a jar :)
     

    Attached Files:

  18. Offline

    Edward Hand

    I just this second made a mod that allows you to shoot exploding chickens! I don't know why I'm telling you. It's just cool!
    --- merged: Feb 23, 2011 8:22 PM ---
    Whether it has any release value is another thing entirely...
     
  19. Offline

    Plague

    Edward, really, wouldn't you just like to see central europe and to analyze current viruses in an antivirus company? ;)
     
  20. Offline

    Havers

    Saved-My-Life!! THANK YOU!

    Hm, Cant seem to work.

    I have two plugins in one, you can say. At one part, it says Hi when you join. On the other hand, it set's spawn.

    havers.java http://pastebin.com/KxFgPv53
    PlayerListener http://pastebin.com/qbxGb104

    Problem is, bukkit won't let me make my own commands, i think.
     
  21. Offline

    Plague

    You have to register PLAYER_COMMAND, not PLAYER_CHAT
     
  22. Offline

    Edward Hand

  23. Offline

    Plague

  24. Offline

    Edward Hand

    I notice you're boycotting it lol.
    I just copy+paste the same code into all my plugins to get permissions to work. Takes like 10 seconds and prevents the hundreds and hundreds of posts from the Permissions Trolls. (I swear they're just trying to be difficult).
     
  25. Offline

    Havers

    Still cant make it work.
     
  26. Offline

    Edward Hand

    Code:
    System.out.println("some message here")
    will print a message to the server console. You can use that to find out where things stop working. (Put something like that as the first line in your onPlayerCommand() function to check the function is being called, and so on)
     
  27. Offline

    Havers

    The problem was in the if(s[0] != NULL) :)
    How do i make spawn more presice? I spawn in a range of 10 blocks..

    How do i get the exactly coordinates of spawn-location?
     
  28. Offline

    Edward Hand

    Code:
    Location spawnLocation = theWorld.getSpawnLocation();
    (replacing 'theWorld' with a reference to the world)
    then use spawnLocation.getX(),spawnLocation.getY(),spawnLocation.getZ()
     
  29. Offline

    Havers

    Thank you, now the /setspawn command work as i want. Think i know how to do the /spawn.

    How do i do so i actually spawn at the coordinates i sat? Not in a range of 10 blocks?
     
  30. Offline

    Plague

    Edward already gave the code for /setspawn ;)

    If you mean after the character dies, you can listen to ENTITY_DEATH event and revive the player yourself if I'm not mistaken. Then you'll prevent the randomness. I also think there already is a plugin for it.
     
Thread Status:
Not open for further replies.

Share This Page