Plugin Help [SOLVED] setBedSpawnLocation not working...?

Discussion in 'Plugin Help/Development/Requests' started by Fuzzybat23, Sep 19, 2015.

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

    Fuzzybat23

    I wrote a bed plugin to allow only a single sleeper to reset night to day. I got it to successfully set the new day while preserving time, it also resets the weather if it's storming. It isn't setting the player's bed spawn location, though. I've tested it a number of times, killing myself in a number of different ways, and I always end up back in world spawn. And yes, the bed is in a valid location as I've tested it with the plugin disabled and me being the only one on the server.

    The code is as follows:

    Code:
     @EventHandler
        public void onSleep(PlayerBedEnterEvent event) {
            new BukkitRunnable() {
                @Override
                public void run() {
                    // What you want to schedule goes here
                    Player player = event.getPlayer();
                    World world = player.getWorld();
                    Location bed = player.getLocation();
                   
                    long Relative_Time = 24000 - world.getTime();
    
                    world.setFullTime(world.getFullTime() + Relative_Time);
                   
                    player.setBedSpawnLocation(bed);
                   
                    if(Bukkit.getWorlds().get(0).hasStorm())
                    {
                        world.setStorm(false);
                    }
                }
            }.runTaskLater(this.plugin, 120);
        }
    Anyone see anything wrong with how I'm implementing setBedSpawnLocatin, that might be causing this?

    And please don't suggest that I use another plugin. That isn't an answer to this question ;(
     
  2. Offline

    L3N

    Try changing from:
    Code:
    player.setBedSpawnLocation(bed);
    to:
    Code:
    player.setBedSpawnLocation(bed, true);
    If it doesn't work, can you give the stack trace/error messages that you get in console(if you get any).
     
  3. Offline

    Fuzzybat23

    Alright, I added the true boolean to setBedSpawnLocation, waited for night, slept, and then drowned myself. I still woke up in world spawn. I checked the log and there was no error message.
     
  4. Offline

    L3N

    Show the list of plugins you are using, it may be a conflict with another plugin.
     
  5. Offline

    Fuzzybat23

    Homespawnplus, coreprotect 2, headmap, playerhads, motd, screamingtrees, seeplayerinventory, syncdoors, vault and votifier
     
  6. Offline

    L3N

    @Fuzzybat23 Try temporarily remove "Homespawnplus"
     
  7. Offline

    Fuzzybat23

    Yup, homespawnplus was intercepting it -.- Damn, I was using that to set a new player spawn location. Guess I'll have to write a small plugin to do only that somehow..
     
  8. Offline

    L3N

    Last edited: Sep 19, 2015
  9. Offline

    Fuzzybat23

    My code is already running on a delayed task. If I set it's delay longer, could that work?
     
  10. Offline

    L3N

    @Fuzzybat23 Wait, nevermind I dumb fucked xD you need to teleport them to their bedlocation 16L ticks when they die(In PlayerRespawnEvent).
     
    Last edited: Sep 19, 2015
  11. Offline

    Fuzzybat23

    Damn, I didn't think of doing that. Something like that would override homespawn plus so I could use both, then ;D
     
  12. Offline

    L3N

    @Fuzzybat23 Btw is not PlayerDeathEvent but PlayerRespawnEvent rather xD.
    If your question is answered mark as solved!
     
Thread Status:
Not open for further replies.

Share This Page