Social-Respawn 1.2

Brings You Back To the World You Died In

  1. augesrob.com
    Tested Minecraft Versions:
    • 1.9
    • 1.10
    Contributors:
    Henzz
    Please Remember To Rate This Plugin
    Please Be Honest, Please do not post bugs as reviews post them in the discussion tab above.


    --------------------{Command and Permissions}--------------------​

    TESTED ON 1.9.4

    Commands:

    /swset:
    description: Sets the spawn point for that world
    permission: social.swset (OPS)

    --------------------{Planned To Add}--------------------​

    • Not Sure At The Moment

    --------------------{Known Bugs}--------------------​

    • If you have essentials spawn and multiverse together this plugin wont work

    • Remove Essentials Spawn
    • Open commands.yml in main directory and change/edit your config
    Code (Text):
    # This is the commands configuration file for Bukkit.
    # For documentation on how to make use of this file, check out the Bukkit Wiki at
    # http://wiki.bukkit.org/Commands.yml
    #
    # If you need help on this file, feel free to join us on irc or leave a message
    # on the forums asking for advice.
    #
    # IRC: #spigot @ irc.spi.gt
    #    (If this means nothing to you, just go to http://www.spigotmc.org/pages/irc/ )
    # Forums: http://www.spigotmc.org/
    # Bug tracker: http://www.spigotmc.org/go/bugs

    command-block-overrides: []
    aliases:
      icanhasbukkit:
      - version $1-
      spawn:
      - "mvspawn"
     
    • Restart/Start Your server
    --------------------{Open Source Code}--------------------
    If you use this source code please let me know. Thanks :)
    Code (Text):

    package me.socialclubz.com;

    import java.util.Set;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.PluginCommand;
    import org.bukkit.configuration.ConfigurationSection;
    import org.bukkit.configuration.file.FileConfiguration;
    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;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class respawn
      extends JavaPlugin
      implements Listener
    {
      private final ChatColor GREEN = ChatColor.GREEN;
      private Set<String> allowedWorlds;
      public void onEnable()
      {
        getServer().getPluginManager().registerEvents(this, this);
        saveDefaultConfig();
        this.allowedWorlds = getConfig().getConfigurationSection("worlds").getKeys(false);
        getCommand("swset").setExecutor(this);
      }
      @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
      public void onDeath(PlayerRespawnEvent event)
      {
        Player player = event.getPlayer();
        if ((this.allowedWorlds.size() > 0) && (this.allowedWorlds.contains(player.getWorld().getName())))
        {
          event.setRespawnLocation(getLocation(player.getWorld().getName()));
          player.sendMessage(this.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.0D, 1.0D, 0.0D);
        if ((cmd.getName().equalsIgnoreCase("swset")) &&
          (args.length == 0))
        {
          if ((underneath.getBlock() == null) || (underneath.getBlock().getType() == Material.AIR))
          {
            player.sendMessage(this.GREEN + "Cannot save spawn point on nothing.");
            return true;
          }
          saveSpawn(player.getLocation());
          player.sendMessage(this.GREEN + "Successfully saved new spawn point.");
        }
        return true;
      }
      private void saveSpawn(Location loc)
      {
        reloadConfig();
        getConfig().set("worlds." + loc.getWorld().getName() + ".x", Integer.valueOf(loc.getBlockX()));
        getConfig().set("worlds." + loc.getWorld().getName() + ".y", Integer.valueOf(loc.getBlockY()));
        getConfig().set("worlds." + loc.getWorld().getName() + ".z", Integer.valueOf(loc.getBlockZ()));
        getConfig().set("worlds." + loc.getWorld().getName() + ".yaw", Float.valueOf(loc.getYaw()));
        getConfig().set("worlds." + loc.getWorld().getName() + ".pitch", Float.valueOf(loc.getPitch()));
        saveConfig();
      }
      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);
      }
    }


     

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Please note: If you find any bugs please post them in the discussion area.
    All my plugins are coded and compiled in java 8 and only for Spigot 1.9 and above

    If you are also a coder who wants to help me fix bugs and or tweak anything let me know what I should change or add.
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Recent Updates

  1. Updated to 1.10
  2. Plugin name spelling mistake