mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-25 00:41:26 +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,
|
||||
|
@ -146,9 +146,12 @@ public class KickCommand extends SubCommand {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
|
||||
Player finalTargetPlayer = targetPlayer;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
scoreboardManager.updatePlayerScoreboardType(targetPlayer);
|
||||
scoreboardManager.updatePlayerScoreboardType(finalTargetPlayer);
|
||||
}
|
||||
});
|
||||
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
@ -183,11 +186,11 @@ public class KickCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (scoreboardManager != null) {
|
||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
switch (island.getStatus()){
|
||||
|
@ -262,9 +262,11 @@ public class IslandManager {
|
||||
data.setIsland(player.getUniqueId());
|
||||
data.setOwner(player.getUniqueId());
|
||||
|
||||
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,8 +37,6 @@ 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();
|
||||
@ -46,6 +44,8 @@ public class Join implements Listener {
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
userCacheManager.addUser(player.getUniqueId(), player.getName());
|
||||
userCacheManager.saveAsync();
|
||||
|
||||
@ -105,9 +105,6 @@ public class Join implements Listener {
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player));
|
||||
|
||||
if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
|
||||
Island island = islandManager.getIslandPlayerAt(player);
|
||||
if (island != null) {
|
||||
@ -117,5 +114,9 @@ public class Join implements Listener {
|
||||
|
||||
// Load Challenge
|
||||
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId());
|
||||
});
|
||||
if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
@ -85,6 +88,18 @@ public class ScoreboardManager extends Manager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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