mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-27 12:45:25 +01:00
Run player login ASync.
This commit is contained in:
parent
01cb3fbfe2
commit
6225fec17b
@ -685,7 +685,8 @@ public class IslandManager {
|
|||||||
banManager.createIsland(island.getOwnerUUID());
|
banManager.createIsland(island.getOwnerUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper()));
|
Bukkit.getScheduler().runTask(skyblock, () ->
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper())));
|
||||||
|
|
||||||
return island;
|
return island;
|
||||||
}
|
}
|
||||||
|
@ -36,115 +36,117 @@ public class Join implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||||
UserCacheManager userCacheManager = skyblock.getUserCacheManager();
|
UserCacheManager userCacheManager = skyblock.getUserCacheManager();
|
||||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
userCacheManager.addUser(player.getUniqueId(), player.getName());
|
userCacheManager.addUser(player.getUniqueId(), player.getName());
|
||||||
userCacheManager.saveAsync();
|
userCacheManager.saveAsync();
|
||||||
|
|
||||||
try {
|
|
||||||
Island island = islandManager.loadIsland(player);
|
|
||||||
boolean teleportedToIsland = false;
|
|
||||||
|
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.Join.Spawn")) {
|
|
||||||
LocationUtil.teleportPlayerToSpawn(player);
|
|
||||||
} else if (configLoad.getBoolean("Island.Join.Island") && island != null) {
|
|
||||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
|
||||||
player.setFallDistance(0.0F);
|
|
||||||
teleportedToIsland = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!teleportedToIsland) {
|
|
||||||
islandManager.loadPlayer(player);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
playerDataManager.loadPlayerData(player);
|
|
||||||
|
|
||||||
if (playerDataManager.hasPlayerData(player)) {
|
|
||||||
String[] playerTexture;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
Island island = islandManager.loadIsland(player);
|
||||||
Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile");
|
boolean teleportedToIsland = false;
|
||||||
GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer);
|
|
||||||
Property property = gameProfile.getProperties().get("textures").iterator().next();
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||||
playerTexture = new String[] { property.getSignature(), property.getValue() };
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
if (configLoad.getBoolean("Island.Join.Spawn")) {
|
||||||
|
LocationUtil.teleportPlayerToSpawn(player);
|
||||||
|
} else if (configLoad.getBoolean("Island.Join.Island") && island != null) {
|
||||||
|
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
teleportedToIsland = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!teleportedToIsland) {
|
||||||
|
islandManager.loadPlayer(player);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
playerTexture = new String[] {
|
e.printStackTrace();
|
||||||
"K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=",
|
|
||||||
"eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19" };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
|
||||||
playerData.setTexture(playerTexture[0], playerTexture[1]);
|
|
||||||
playerData.save();
|
|
||||||
} else {
|
|
||||||
playerDataManager.createPlayerData(player);
|
|
||||||
playerDataManager.loadPlayerData(player);
|
playerDataManager.loadPlayerData(player);
|
||||||
}
|
|
||||||
|
|
||||||
playerDataManager.storeIsland(player);
|
if (playerDataManager.hasPlayerData(player)) {
|
||||||
|
String[] playerTexture;
|
||||||
|
|
||||||
cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
|
try {
|
||||||
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
|
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||||
|
Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile");
|
||||||
|
GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer);
|
||||||
|
Property property = gameProfile.getProperties().get("textures").iterator().next();
|
||||||
|
playerTexture = new String[]{property.getSignature(), property.getValue()};
|
||||||
|
} catch (Exception e) {
|
||||||
|
playerTexture = new String[]{
|
||||||
|
"K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVs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ubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"};
|
||||||
|
}
|
||||||
|
|
||||||
if (scoreboardManager != null) {
|
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
playerData.setTexture(playerTexture[0], playerTexture[1]);
|
||||||
Scoreboard scoreboard = new Scoreboard(skyblock, player);
|
playerData.save();
|
||||||
Island island = islandManager.getIsland(player);
|
} else {
|
||||||
|
playerDataManager.createPlayerData(player);
|
||||||
|
playerDataManager.loadPlayerData(player);
|
||||||
|
}
|
||||||
|
|
||||||
if (island != null) {
|
playerDataManager.storeIsland(player);
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
|
||||||
|
|
||||||
cooldownManager.addCooldownPlayer(CooldownType.Levelling, cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer));
|
cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
|
||||||
cooldownManager.addCooldownPlayer(CooldownType.Ownership, cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer));
|
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
|
||||||
|
|
||||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
if (scoreboardManager != null) {
|
||||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||||
|
Scoreboard scoreboard = new Scoreboard(skyblock, player);
|
||||||
|
Island island = islandManager.getIsland(player);
|
||||||
|
|
||||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
if (island != null) {
|
||||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
||||||
|
|
||||||
|
cooldownManager.addCooldownPlayer(CooldownType.Levelling, cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer));
|
||||||
|
cooldownManager.addCooldownPlayer(CooldownType.Ownership, cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer));
|
||||||
|
|
||||||
|
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||||
|
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||||
|
|
||||||
|
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||||
|
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||||
|
} else {
|
||||||
|
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
|
||||||
|
|
||||||
|
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||||
|
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
|
||||||
|
} else {
|
||||||
|
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
|
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||||
|
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
|
||||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
|
|
||||||
} else {
|
|
||||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
scoreboard.run();
|
||||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
scoreboardManager.storeScoreboard(player, scoreboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
scoreboard.run();
|
Island island = islandManager.getIslandPlayerAt(player);
|
||||||
scoreboardManager.storeScoreboard(player, scoreboard);
|
if (island != null) {
|
||||||
}
|
islandManager.updateBorder(island);
|
||||||
|
islandManager.updateFlight(player);
|
||||||
|
}
|
||||||
|
|
||||||
Island island = islandManager.getIslandPlayerAt(player);
|
// Load Challenge
|
||||||
if (island != null) {
|
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId());
|
||||||
islandManager.updateBorder(island);
|
});
|
||||||
islandManager.updateFlight(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load Challenge
|
|
||||||
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user