Exemple #1
0
 public void trackUUID(final UUID uuid, final String name, boolean replace) {
   if (uuid != null) {
     keys.add(uuid);
     if (name != null && name.length() > 0) {
       final String keyName = StringUtil.safeString(name);
       if (!names.containsKey(keyName)) {
         names.put(keyName, uuid);
         uuidMap.writeUUIDMap();
       } else if (!names.get(keyName).equals(uuid)) {
         if (replace) {
           ess.getLogger()
               .info(
                   "Found new UUID for "
                       + name
                       + ". Replacing "
                       + names.get(keyName).toString()
                       + " with "
                       + uuid.toString());
           names.put(keyName, uuid);
           uuidMap.writeUUIDMap();
         } else {
           if (ess.getSettings().isDebug()) {
             ess.getLogger()
                 .info(
                     "Found old UUID for "
                         + name
                         + " ("
                         + uuid.toString()
                         + "). Not adding to usermap.");
           }
         }
       }
     }
   }
 }
Exemple #2
0
	public void setHome(String name, Location loc)
	{
		//Invalid names will corrupt the yaml
		name = StringUtil.safeString(name);
		homes.put(name, loc);
		config.setProperty("homes." + name, loc);
		config.save();
	}
Exemple #3
0
	protected UserData(Player base, IEssentials ess)
	{
		super(base);
		this.ess = ess;
		folder = new File(ess.getDataFolder(), "userdata");
		if (!folder.exists())
		{
			folder.mkdirs();
		}
		config = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(base.getName()) + ".yml"));
		reloadConfig();
	}
Exemple #4
0
 public void removeUser(final String name) {
   if (names == null) {
     ess.getLogger().warning("Name collection is null, cannot remove user.");
     return;
   }
   UUID uuid = names.get(name);
   if (uuid != null) {
     keys.remove(uuid);
     users.invalidate(uuid);
   }
   names.remove(name);
   names.remove(StringUtil.safeString(name));
 }
Exemple #5
0
	public void delHome(String name) throws Exception
	{
		String search = getHomeName(name);
		if (!homes.containsKey(search))
		{
			search = StringUtil.safeString(search);
		}
		if (homes.containsKey(search))
		{
			homes.remove(search);
			config.removeProperty("homes." + search);
			config.save();
		}
		else
		{
			throw new Exception(_("invalidHome", search));
		}
	}
Exemple #6
0
  public User getUser(final String name) {
    try {
      final String sanitizedName = StringUtil.safeString(name);
      if (names.containsKey(sanitizedName)) {
        final UUID uuid = names.get(sanitizedName);
        return getUser(uuid);
      }

      final File userFile = getUserFileFromString(sanitizedName);
      if (userFile.exists()) {
        ess.getLogger().info("Importing user " + name + " to usermap.");
        User user = new User(new OfflinePlayer(sanitizedName, ess.getServer()), ess);
        trackUUID(user.getBase().getUniqueId(), user.getName(), true);
        return user;
      }
      return null;
    } catch (UncheckedExecutionException ex) {
      return null;
    }
  }
Exemple #7
0
 public File getUserFileFromString(final String name) {
   final File userFolder = new File(ess.getDataFolder(), "userdata");
   return new File(userFolder, StringUtil.sanitizeFileName(name) + ".yml");
 }
Exemple #8
0
	public void setBanReason(String reason)
	{
		config.setProperty("ban.reason", StringUtil.sanitizeString(reason));
		config.save();
	}