Respawn In Same World You Died In

Discussion in 'Archived: Plugin Requests' started by PhoKing, Apr 27, 2014.

  1. Offline


    Our server really needs a plugin to allow players in certain worlds to respawn in the same world they died in.

    I only need it for a couple worlds, so the plugin would have to have a config file where I could add the world name to a list where I want the plugin to work.

    Example: Players die in our KitsPVP world, but they get teleported back to the main hub spawn. We need them to get teleported right back to the KitsPVP world spawn.

    HUGE thanks in advance! Our server cannot move forward until we get this sorted out.

    Great work could result in a DEV staff position on our server if you're interested.
  2. Consider it done. And yes I'll be interested in dev position
  3. Offline


  4. Offline


    I will do it :D.

    I am uploading it right now

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
  5. Offline


    You can set respawn worlds with multiverse just saying
  6. Offline


  7. Offline


    Alright so. Not to be mean but did you miss the part where I said

    I put it in and players were re-spawning in the same world they died in, in EVERY WORLD. I only need it in a world named pvp

    So can you make it so players only respawn in the same world they died in if they are in world 'pvp'??

    Thanks for the efforts though man!!!
  8. Offline


    PhoKing bro use multiverse u can define a respawn world per world in the config. And if you use essentials you might have to take out essentials spawn bc it might conflict
  9. Offline


    Last edited by a moderator: Jun 7, 2016
  10. Offline


    Whoops! I missed that part :p but no worries, It was only a few lines of code. Glad to see someone else finished it tho. PhoKing
  11. Offline


    22 minutes including upload time and time to type up your post,
    Man your a fast dev, even though that plugin is really light-weight.
  12. Offline


  13. Offline


    There's actually a problem with the plugin.

    So the config was setup like this when I looked into config file.
    # List the worlds you want the plugin to work on
    - world
    - world_nether
    - world_the_end
    But the weird thing is.. I didn't touch the config, and it respawned me in the same world for 'pvp' only. Even though in config it says it should respawn me in same world at world,nether, and end.

    So I changed the config to this..
    # List the worlds you want the plugin to work on
    - pvp
    - minigameshub
    But the plugin STILL only works in the world pvp.

    Any idea why the config file isn't working?

    Thanks man.
  14. Offline


    Jnxd_ likes this.
  15. Offline


    Can you give a source code??
  16. Offline


    import java.util.Set;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerRespawnEvent;
    public class SameWorld extends JavaPlugin implements Listener {
        private final ChatColor GREEN = ChatColor.GREEN;
        private Set<String> allowedWorlds;
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
            allowedWorlds = getConfig().getConfigurationSection("worlds").getKeys(false);
        @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
        public void onDeath(PlayerRespawnEvent event) {
            Player player = event.getPlayer();
            if (allowedWorlds.size() > 0 && allowedWorlds.contains(player.getWorld().getName())) {
                player.sendMessage(GREEN + "You respawned in the same world.");
        public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args) {
            if (!(sender instanceof Player)) {
                return true;
            Player player = (Player) sender;
            Location loc = player.getLocation();
            Location underneath = loc.subtract(0.0, 1.0, 0.0);
            if (cmd.getName().equalsIgnoreCase("swset")) {
                if (args.length == 0) {
                    if (underneath.getBlock() == null || underneath.getBlock().getType() == Material.AIR) {
                        player.sendMessage(GREEN + "Cannot save spawn point on nothing.");
                        return true;
                    player.sendMessage(GREEN + "Successfully saved new spawn point.");
            return true;
        private void saveSpawn(Location loc) {
            getConfig().set("worlds."+loc.getWorld().getName()+".x", loc.getBlockX());
            getConfig().set("worlds."+loc.getWorld().getName()+".y", loc.getBlockY());
            getConfig().set("worlds."+loc.getWorld().getName()+".z", loc.getBlockZ());
            getConfig().set("worlds."+loc.getWorld().getName()+".yaw", loc.getYaw());
            getConfig().set("worlds."+loc.getWorld().getName()+".pitch", loc.getPitch());
        private Location getLocation(String path) {
            int x = getConfig().getInt("worlds."+path+".x");
            int y = getConfig().getInt("worlds."+path+".y");
            int z = getConfig().getInt("worlds."+path+".z");
            float yaw = (float) getConfig().getDouble("worlds."+path+".yaw");
            float pitch = (float) getConfig().getDouble("worlds."+path+".pitch");
            return new Location(Bukkit.getWorld(path), x+0.5D, y, z+0.5D, yaw, pitch);

Share This Page