mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-09 17:27:37 +01:00
Fixed async scoreboard and added 1.8.8 support
This commit is contained in:
parent
07029330c6
commit
8857ae4d6c
@ -14,6 +14,7 @@ import com.songoda.skyblock.island.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.structure.Structure;
|
||||
import com.songoda.skyblock.structure.StructureManager;
|
||||
@ -39,6 +40,7 @@ public class ConfirmCommand extends SubCommand {
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
@ -108,9 +110,19 @@ public class ConfirmCommand extends SubCommand {
|
||||
.getString("Command.Island.Confirmation.Ownership.Member.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
});
|
||||
} else if (confirmation.equals(Confirmation.Reset)) {
|
||||
playerData.setConfirmation(null);
|
||||
playerData.setConfirmationTime(0);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
});
|
||||
} else if (confirmation.equals(Confirmation.Deletion)) {
|
||||
if (island.getStatus().equals(IslandStatus.OPEN)) {
|
||||
messageManager.sendMessage(player,
|
||||
@ -175,6 +187,11 @@ public class ConfirmCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1f, 1f);
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
|
@ -145,10 +145,13 @@ public class KickCommand extends SubCommand {
|
||||
&& !targetPlayer.isOp()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(targetPlayer);
|
||||
}
|
||||
|
||||
Player finalTargetPlayer = targetPlayer;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(finalTargetPlayer);
|
||||
}
|
||||
});
|
||||
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
@ -183,11 +186,11 @@ public class KickCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
switch (island.getStatus()){
|
||||
|
@ -262,9 +262,11 @@ public class IslandManager {
|
||||
data.setIsland(player.getUniqueId());
|
||||
data.setOwner(player.getUniqueId());
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
});
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
|
@ -37,85 +37,86 @@ public class Join implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
UserCacheManager userCacheManager = plugin.getUserCacheManager();
|
||||
CooldownManager cooldownManager = plugin.getCooldownManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
userCacheManager.addUser(player.getUniqueId(), player.getName());
|
||||
userCacheManager.saveAsync();
|
||||
|
||||
try {
|
||||
islandManager.loadIsland(player);
|
||||
Island island = islandManager.getIsland(player);
|
||||
boolean teleportedToIsland = false;
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.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) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
PaperLib.teleportAsync(player, 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;
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
userCacheManager.addUser(player.getUniqueId(), player.getName());
|
||||
userCacheManager.saveAsync();
|
||||
|
||||
try {
|
||||
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()};
|
||||
islandManager.loadIsland(player);
|
||||
Island island = islandManager.getIsland(player);
|
||||
boolean teleportedToIsland = false;
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.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) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
player.setFallDistance(0.0F);
|
||||
});
|
||||
teleportedToIsland = true;
|
||||
}
|
||||
|
||||
if (!teleportedToIsland) {
|
||||
islandManager.loadPlayer(player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
playerTexture = new String[]{
|
||||
"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"};
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
playerData.setTexture(playerTexture[0], playerTexture[1]);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save);
|
||||
} else {
|
||||
playerDataManager.createPlayerData(player);
|
||||
|
||||
playerDataManager.loadPlayerData(player);
|
||||
}
|
||||
|
||||
playerDataManager.storeIsland(player);
|
||||
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player));
|
||||
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
String[] playerTexture;
|
||||
|
||||
try {
|
||||
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[]{
|
||||
"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]);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save);
|
||||
} else {
|
||||
playerDataManager.createPlayerData(player);
|
||||
playerDataManager.loadPlayerData(player);
|
||||
}
|
||||
|
||||
playerDataManager.storeIsland(player);
|
||||
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player));
|
||||
|
||||
|
||||
Island island = islandManager.getIslandPlayerAt(player);
|
||||
if (island != null) {
|
||||
islandManager.updateBorder(island);
|
||||
islandManager.updateFlight(player);
|
||||
}
|
||||
|
||||
// Load Challenge
|
||||
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId());
|
||||
});
|
||||
if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
|
||||
Island island = islandManager.getIslandPlayerAt(player);
|
||||
if (island != null) {
|
||||
islandManager.updateBorder(island);
|
||||
islandManager.updateFlight(player);
|
||||
}
|
||||
|
||||
// Load Challenge
|
||||
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class Board {
|
||||
private ScoreboardLine convertIntoPieces(String line, int allowed_line_size) {
|
||||
String prefixLine = line.substring(0, Math.min(line.length(), allowed_line_size));
|
||||
String suffixLine = line.length() <= allowed_line_size ? "" : line.substring(allowed_line_size, Math.min(line.length(), allowed_line_size*2));
|
||||
|
||||
|
||||
if (prefixLine.endsWith(String.valueOf(ChatColor.COLOR_CHAR))) {
|
||||
prefixLine = ChatColor.translateAlternateColorCodes(
|
||||
ChatColor.COLOR_CHAR, prefixLine.substring(0, prefixLine.length() - 1));
|
||||
|
@ -2,7 +2,6 @@ package com.songoda.skyblock.scoreboard;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class Holder {
|
||||
|
@ -61,8 +61,11 @@ public class ScoreboardManager extends Manager {
|
||||
ScoreboardType type;
|
||||
if(island != null) {
|
||||
Visit islandVisit = island.getVisit();
|
||||
boolean hasVisitors = islandVisit.getVisitors().size() > 1;
|
||||
boolean hasMembers = islandVisit.getMembers() > 1;
|
||||
boolean hasVisitors = (islandVisit != null &&
|
||||
islandVisit.getVisitors() != null &&
|
||||
islandVisit.getVisitors().size() > 1);
|
||||
boolean hasMembers = (islandVisit != null &&
|
||||
islandVisit.getMembers() > 1);
|
||||
|
||||
if(hasMembers) {
|
||||
if(hasVisitors) {
|
||||
@ -84,7 +87,19 @@ public class ScoreboardManager extends Manager {
|
||||
setPlayerScoreboard(player, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setPlayerScoreboard(Player player, ScoreboardType type) {
|
||||
for(Driver driver : drivers) {
|
||||
if(driver.getBoardType().equals(type)) {
|
||||
driver.registerHolder(new Holder(plugin, driver, player));
|
||||
} else {
|
||||
driver.unregisterHolder(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterPlayer(Player player) {
|
||||
for(Driver driver : drivers) {
|
||||
driver.unregisterHolder(player);
|
||||
@ -122,14 +137,4 @@ public class ScoreboardManager extends Manager {
|
||||
driver.cancel();
|
||||
drivers.clear();
|
||||
}
|
||||
|
||||
public void setPlayerScoreboard(Player player, ScoreboardType type) {
|
||||
for(Driver driver : drivers) {
|
||||
if(driver.getBoardType().equals(type)) {
|
||||
driver.registerHolder(new Holder(plugin, driver, player));
|
||||
} else {
|
||||
driver.unregisterHolder(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user