use of com.easterlyn.event.UserCreationEvent in project Easterlyn by Easterlyn.
the class User method load.
@NotNull
static User load(@NotNull EasterlynCore plugin, @NotNull final UUID uuid) {
PluginManager pluginManager = plugin.getServer().getPluginManager();
File file = new File(plugin.getDataFolder().getPath() + File.separatorChar + "users", uuid.toString() + ".yml");
ConcurrentConfiguration storage = ConcurrentConfiguration.load(plugin, file);
if (file.exists()) {
User user = new User(plugin, uuid, storage);
Player player = user.getPlayer();
if (player != null && player.getAddress() != null) {
storage.set("ip", player.getAddress().getHostString());
String previousName = storage.getString("name");
if (previousName != null && !previousName.equals(player.getName())) {
storage.set("previousName", previousName);
storage.set("name", player.getName());
pluginManager.callEvent(new PlayerNameChangeEvent(player, previousName, player.getName()));
}
}
return user;
}
Player player = Bukkit.getPlayer(uuid);
User user = new User(plugin, uuid, new ConcurrentConfiguration(plugin));
if (player != null) {
user.getStorage().set("name", player.getName());
if (player.getAddress() != null) {
user.getStorage().set("ip", player.getAddress().getHostString());
}
pluginManager.callEvent(new UserCreationEvent(user));
}
return user;
}
Aggregations