public void onPlayerRespawn(final PlayerRespawnEvent event)
	{
		final User user = ess.getUser(event.getPlayer());

		if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
		{
			return;
		}

		if (ess.getSettings().getRespawnAtHome())
		{
			Location home;
			final Location bed = user.getBedSpawnLocation();
			if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
			{
				home = bed;
			}
			else
			{
				home = user.getHome(user.getLocation());
			}
			if (home != null)
			{
				event.setRespawnLocation(home);
				return;
			}
		}
		final Location spawn = spawns.getSpawn(user.getGroup());
		if (spawn != null)
		{
			event.setRespawnLocation(spawn);
		}
	}
Ejemplo n.º 2
0
 /**
  * Get the location of a home of a Player
  *
  * @param playername The Player
  * @param home The name of the home
  * @return The location of the home
  * @throws CommandException if user is null or no home with this name
  */
 public Location getHome(String playername, String home) throws CommandException {
   User u = getEssentialsUser(playername);
   try {
     Location loc = u.getHome(home);
     if (loc == null) {
       throw new HomeException(home, u.getHomes());
     }
     return loc;
   } catch (Exception e) {
     throw new CommandException(e.getMessage());
   }
 }
	@Override
	public void onPlayerRespawn(final PlayerRespawnEvent event)
	{		
		final User user = ess.getUser(event.getPlayer());

		if (ess.getSettings().getRespawnAtHome())
		{
			Location home = user.getHome(user.getLocation());
			if (home == null)
			{
				home = user.getBedSpawnLocation();
			}
			if (home != null)
			{
				event.setRespawnLocation(home);
				return;
			}
		}
		final Location spawn = spawns.getSpawn(user.getGroup());
		if (spawn != null)
		{
			event.setRespawnLocation(spawn);
		}
	}
 private void updateCompass(final User user) {
   try {
     user.setCompassTarget(user.getHome(user.getLocation()));
   } catch (Exception ex) {
   }
 }