Level scanning and async offline player permission lookups

This commit is contained in:
Esophose 2019-07-25 11:00:50 -06:00
parent 077856e311
commit 0f03c26cc0
6 changed files with 280 additions and 269 deletions

View File

@ -40,12 +40,14 @@ public class RefreshHologramsCommand extends SubCommand {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
leaderboardManager.clearLeaderboard(); LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
leaderboardManager.resetLeaderboard(); leaderboardManager.clearLeaderboard();
leaderboardManager.setupLeaderHeads(); leaderboardManager.resetLeaderboard();
leaderboardManager.setupLeaderHeads();
skyblock.getHologramManager().resetHologram(); Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
});
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message")); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message"));
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);

View File

@ -90,11 +90,13 @@ public class ReloadCommand extends SubCommand {
levellingManager.unregisterMaterials(); levellingManager.unregisterMaterials();
levellingManager.registerMaterials(); levellingManager.registerMaterials();
leaderboardManager.clearLeaderboard(); Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
leaderboardManager.resetLeaderboard(); leaderboardManager.clearLeaderboard();
leaderboardManager.setupLeaderHeads(); leaderboardManager.resetLeaderboard();
leaderboardManager.setupLeaderHeads();
hologramManager.resetHologram(); Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
});
limitManager.reload(); limitManager.reload();

View File

@ -25,96 +25,98 @@ public class BanCommand extends SubCommand {
@Override @Override
public void onCommandByPlayer(Player player, String[] args) { public void onCommandByPlayer(Player player, String[] args) {
MessageManager messageManager = skyblock.getMessageManager(); Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
IslandManager islandManager = skyblock.getIslandManager(); MessageManager messageManager = skyblock.getMessageManager();
SoundManager soundManager = skyblock.getSoundManager(); IslandManager islandManager = skyblock.getIslandManager();
FileManager fileManager = skyblock.getFileManager(); SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) { if (args.length == 1) {
Island island = islandManager.getIsland(player); Island island = islandManager.getIsland(player);
if (island == null) { if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message")); messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Visitor.Banning")) { .getBoolean("Island.Visitor.Banning")) {
if (island.hasRole(IslandRole.Owner, player.getUniqueId()) if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId())
&& island.getSetting(IslandRole.Operator, "Ban").getStatus())) { && island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban")) if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
return;
UUID targetPlayerUUID = null;
String targetPlayerName = null;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
return; return;
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID == null) { UUID targetPlayerUUID = null;
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message")); String targetPlayerName = null;
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.hasRole(IslandRole.Member, targetPlayerUUID)
|| island.hasRole(IslandRole.Operator, targetPlayerUUID)
|| island.hasRole(IslandRole.Owner, targetPlayerUUID)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Member.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getBan().isBanned(targetPlayerUUID)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Already.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player",
targetPlayerName));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
if (island.isCoopPlayer(targetPlayerUUID)) { if (targetPlayer == null) {
island.removeCoopPlayer(targetPlayerUUID); OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
return;
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
} }
Ban ban = island.getBan(); if (targetPlayerUUID == null) {
ban.addBan(player.getUniqueId(), targetPlayerUUID); messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message"));
ban.save(); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.hasRole(IslandRole.Member, targetPlayerUUID)
|| island.hasRole(IslandRole.Operator, targetPlayerUUID)
|| island.hasRole(IslandRole.Owner, targetPlayerUUID)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Member.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getBan().isBanned(targetPlayerUUID)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Already.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player",
targetPlayerName));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
if (targetPlayer != null) { if (island.isCoopPlayer(targetPlayerUUID)) {
if (islandManager.isPlayerAtIsland(island, targetPlayer)) { island.removeCoopPlayer(targetPlayerUUID);
messageManager.sendMessage(targetPlayer, }
configLoad.getString("Command.Island.Ban.Banned.Target.Message")
.replace("%player", player.getName()));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
LocationUtil.teleportPlayerToSpawn(targetPlayer); Ban ban = island.getBan();
ban.addBan(player.getUniqueId(), targetPlayerUUID);
ban.save();
if (targetPlayer != null) {
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
messageManager.sendMessage(targetPlayer,
configLoad.getString("Command.Island.Ban.Banned.Target.Message")
.replace("%player", player.getName()));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
LocationUtil.teleportPlayerToSpawn(targetPlayer);
}
} }
} }
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} }
} else { } else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Permission.Message")); messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Disabled.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} }
} else { } else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Disabled.Message")); messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Invalid.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} }
} else { });
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Invalid.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} }
@Override @Override

View File

@ -33,227 +33,231 @@ public class KickCommand extends SubCommand {
@Override @Override
public void onCommandByPlayer(Player player, String[] args) { public void onCommandByPlayer(Player player, String[] args) {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
MessageManager messageManager = skyblock.getMessageManager(); ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
IslandManager islandManager = skyblock.getIslandManager(); MessageManager messageManager = skyblock.getMessageManager();
SoundManager soundManager = skyblock.getSoundManager(); IslandManager islandManager = skyblock.getIslandManager();
FileManager fileManager = skyblock.getFileManager(); SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
PlayerData playerData = playerDataManager.getPlayerData(player); PlayerData playerData = playerDataManager.getPlayerData(player);
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
if (args.length == 1) { if (args.length == 1) {
Island island = islandManager.getIsland(player); Island island = islandManager.getIsland(player);
if (island == null) { if (island == null) {
messageManager.sendMessage(player, messageManager.sendMessage(player,
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message")); languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId())
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) { && island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
UUID targetPlayerUUID = null; UUID targetPlayerUUID = null;
String targetPlayerName = null; String targetPlayerName = null;
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban")) if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
return;
Set<UUID> islandMembers = island.getRole(IslandRole.Member),
islandOperators = island.getRole(IslandRole.Operator),
islandVisitors = islandManager.getVisitorsAtIsland(island);
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
return; return;
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID.equals(player.getUniqueId())) { Set<UUID> islandMembers = island.getRole(IslandRole.Member),
messageManager.sendMessage(player, islandOperators = island.getRole(IslandRole.Operator),
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message")); islandVisitors = islandManager.getVisitorsAtIsland(island);
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (islandOperators.contains(player.getUniqueId()) if (targetPlayer == null) {
&& islandOperators.contains(targetPlayerUUID)) { OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
messageManager.sendMessage(player, languageConfig.getFileConfiguration() targetPlayerUUID = targetPlayerOffline.getUniqueId();
.getString("Command.Island.Kick.Role.Operator.Message")); targetPlayerName = targetPlayerOffline.getName();
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) { if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
messageManager.sendMessage(player, return;
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
if (island.isCoopPlayer(targetPlayerUUID)) {
messageManager.sendMessage(player,
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else { } else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player,
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (islandOperators.contains(player.getUniqueId())
&& islandOperators.contains(targetPlayerUUID)) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Role.Operator.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) {
messageManager.sendMessage(player,
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
if (island.isCoopPlayer(targetPlayerUUID)) {
messageManager.sendMessage(player,
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
APIUtil.fromImplementation(IslandRole.Visitor),
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
if (!islandKickEvent.isCancelled()) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
messageManager.sendMessage(player,
languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Kicked.Sender.Message")
.replace("%player", targetPlayerName));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
messageManager.sendMessage(targetPlayer,
languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Kicked.Target.Message")
.replace("%player", player.getName()));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
}
}
} else if (islandMembers.contains(targetPlayerUUID) || islandOperators.contains(targetPlayerUUID)) {
IslandRole islandRole = IslandRole.Member;
if (islandOperators.contains(targetPlayerUUID)) {
islandRole = IslandRole.Operator;
}
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
APIUtil.fromImplementation(IslandRole.Visitor), APIUtil.fromImplementation(islandRole),
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player); Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
if (!islandKickEvent.isCancelled()) { if (!islandKickEvent.isCancelled()) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
messageManager.sendMessage(player, messageManager.sendMessage(player,
languageConfig.getFileConfiguration() languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Kicked.Sender.Message") .getString("Command.Island.Kick.Kicked.Sender.Message")
.replace("%player", targetPlayerName)); .replace("%player", targetPlayerName));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
messageManager.sendMessage(targetPlayer, if (targetPlayer == null) {
languageConfig.getFileConfiguration() Config config = fileManager
.getString("Command.Island.Kick.Kicked.Target.Message") .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
.replace("%player", player.getName())); targetPlayerUUID.toString() + ".yml"));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); FileConfiguration configLoad = config.getFileConfiguration();
}
}
} else if (islandMembers.contains(targetPlayerUUID) || islandOperators.contains(targetPlayerUUID)) {
IslandRole islandRole = IslandRole.Member;
if (islandOperators.contains(targetPlayerUUID)) { configLoad.set("Statistics.Island.Playtime", null);
islandRole = IslandRole.Operator; configLoad.set("Statistics.Island.Join", null);
} configLoad.set("Island.Owner", null);
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), try {
APIUtil.fromImplementation(islandRole), configLoad.save(config.getFile());
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player); } catch (IOException e) {
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent); e.printStackTrace();
}
} else {
messageManager.sendMessage(targetPlayer,
languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Kicked.Target.Message")
.replace("%player", player.getName()));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
if (!islandKickEvent.isCancelled()) { if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
messageManager.sendMessage(player, LocationUtil.teleportPlayerToSpawn(targetPlayer);
languageConfig.getFileConfiguration() }
.getString("Command.Island.Kick.Kicked.Sender.Message")
.replace("%player", targetPlayerName));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
if (targetPlayer == null) { if (scoreboardManager != null) {
Config config = fileManager Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), scoreboard.cancel();
targetPlayerUUID.toString() + ".yml")); scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
FileConfiguration configLoad = config.getFileConfiguration(); .getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
.getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
configLoad.set("Statistics.Island.Playtime", null); playerData = playerDataManager.getPlayerData(targetPlayer);
configLoad.set("Statistics.Island.Join", null); playerData.setPlaytime(0);
configLoad.set("Island.Owner", null); playerData.setMemberSince(null);
playerData.setOwner(null);
try { playerData.setChat(false);
configLoad.save(config.getFile()); playerData.save();
} catch (IOException e) {
e.printStackTrace();
}
} else {
messageManager.sendMessage(targetPlayer,
languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Kicked.Target.Message")
.replace("%player", player.getName()));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
} }
if (scoreboardManager != null) { if (islandMembers.contains(targetPlayerUUID)) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer); island.removeRole(IslandRole.Member, targetPlayerUUID);
scoreboard.cancel(); } else if (islandOperators.contains(targetPlayerUUID)) {
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig island.removeRole(IslandRole.Operator, targetPlayerUUID);
.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
.getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
} }
playerData = playerDataManager.getPlayerData(targetPlayer); island.save();
playerData.setPlaytime(0);
playerData.setMemberSince(null);
playerData.setOwner(null);
playerData.setChat(false);
playerData.save();
}
if (islandMembers.contains(targetPlayerUUID)) { Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
island.removeRole(IslandRole.Member, targetPlayerUUID);
} else if (islandOperators.contains(targetPlayerUUID)) {
island.removeRole(IslandRole.Operator, targetPlayerUUID);
}
island.save(); if (islandMembersOnline.size() == 1) {
for (UUID islandMembersOnlineList : islandMembersOnline) {
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island); if (targetPlayerData.isChat()) {
targetPlayerData.setChat(false);
if (islandMembersOnline.size() == 1) { messageManager.sendMessage(targetPlayer, fileManager
for (UUID islandMembersOnlineList : islandMembersOnline) { .getConfig(new File(skyblock.getDataFolder(), "language.yml"))
if (!islandMembersOnlineList.equals(player.getUniqueId())) { .getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); }
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
if (targetPlayerData.isChat()) {
targetPlayerData.setChat(false);
messageManager.sendMessage(targetPlayer, fileManager
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
} }
} }
} }
}
if (scoreboardManager != null) { if (scoreboardManager != null) {
if (island.getRole(IslandRole.Member).size() == 0 if (island.getRole(IslandRole.Member).size() == 0
&& island.getRole(IslandRole.Operator).size() == 0) { && island.getRole(IslandRole.Operator).size() == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player); Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.cancel(); scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); .getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
if (islandManager.getVisitorsAtIsland(island).size() == 0) { if (islandManager.getVisitorsAtIsland(island).size() == 0) {
scoreboard.setDisplayList(languageConfig.getFileConfiguration() scoreboard.setDisplayList(languageConfig.getFileConfiguration()
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); .getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
} else { } else {
scoreboard.setDisplayList(languageConfig.getFileConfiguration() scoreboard.setDisplayList(languageConfig.getFileConfiguration()
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); .getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
}
scoreboard.run();
} }
scoreboard.run();
} }
} }
} else {
if (island.isOpen()) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Occupant.Visit.Open.Message"));
} else {
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Occupant.Visit.Closed.Message"));
}
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} }
} else { } else {
if (island.isOpen()) { if (island.isOpen()) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration() messageManager.sendMessage(player, languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Occupant.Visit.Open.Message")); .getString("Command.Island.Kick.Permission.Visit.Open.Message"));
} else { } else {
messageManager.sendMessage(player, languageConfig.getFileConfiguration() messageManager.sendMessage(player, languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Occupant.Visit.Closed.Message")); .getString("Command.Island.Kick.Permission.Visit.Closed.Message"));
} }
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} }
} else { } else {
if (island.isOpen()) { messageManager.sendMessage(player,
messageManager.sendMessage(player, languageConfig.getFileConfiguration() languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"));
.getString("Command.Island.Kick.Permission.Visit.Open.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
.getString("Command.Island.Kick.Permission.Visit.Closed.Message"));
}
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} }
} else { });
messageManager.sendMessage(player,
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} }
@Override @Override

View File

@ -44,10 +44,6 @@ public class LevellingManager {
private Set<Island> activeIslandScans = new HashSet<>(); private Set<Island> activeIslandScans = new HashSet<>();
private List<LevellingMaterial> materialStorage = new ArrayList<>(); private List<LevellingMaterial> materialStorage = new ArrayList<>();
private Method getBlockTypeIdMethod = null;
private Method getBlockTypeDataMethod = null;
private Method getMaterialMethod = null;
public LevellingManager(SkyBlock skyblock) { public LevellingManager(SkyBlock skyblock) {
this.skyblock = skyblock; this.skyblock = skyblock;
@ -119,27 +115,17 @@ public class LevellingManager {
ChunkSnapshot chunkSnapshot = chunkSnapshotList.getChunkSnapshot(); ChunkSnapshot chunkSnapshot = chunkSnapshotList.getChunkSnapshot();
try { try {
org.bukkit.Material blockMaterial = org.bukkit.Material.AIR; org.bukkit.Material blockMaterial;
int blockData = 0; int blockData = 0;
EntityType spawnerType = null; EntityType spawnerType = null;
if (NMSVersion > 12) { if (NMSVersion > 12) {
blockMaterial = chunkSnapshot.getBlockType(x, y, z); blockMaterial = chunkSnapshot.getBlockType(x, y, z);
} else { } else {
if (getBlockTypeIdMethod == null) { LegacyChunkSnapshotData data = LegacyChunkSnapshotFetcher.fetch(chunkSnapshot, x, y, z);
getBlockTypeIdMethod = chunkSnapshot.getClass().getMethod("getBlockTypeId", int.class, int.class, int.class);
}
if (getBlockTypeDataMethod == null) { blockMaterial = data.getMaterial();
getBlockTypeDataMethod = chunkSnapshot.getClass().getMethod("getBlockData", int.class, int.class, int.class); blockData = data.getData();
}
if (getMaterialMethod == null) {
getMaterialMethod = blockMaterial.getClass().getMethod("getMaterial", int.class);
}
blockMaterial = (org.bukkit.Material) getMaterialMethod.invoke(null, (int) getBlockTypeIdMethod.invoke(chunkSnapshot, x, y, z));
blockData = (int) getBlockTypeDataMethod.invoke(chunkSnapshot, x, y, z);
} }
if (blacklistedMaterials.contains(blockMaterial)) if (blacklistedMaterials.contains(blockMaterial))

View File

@ -201,6 +201,12 @@ public class Interact implements Listener {
return; return;
} }
if (event.getItem() != null && event.getItem().getType() == Material.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
event.setCancelled(true);
return;
}
if (block.getType() == Materials.SWEET_BERRY_BUSH.parseMaterial()) { if (block.getType() == Materials.SWEET_BERRY_BUSH.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) { if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true); event.setCancelled(true);
@ -783,6 +789,15 @@ public class Interact implements Listener {
} }
} }
} }
else if (entity.getType().equals(EntityType.SHEEP)) {
if (!islandManager.hasPermission(player, entity.getLocation(), "EntityPlacement")) {
event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
else if (entity.getType().equals(EntityType.ITEM_FRAME)){ else if (entity.getType().equals(EntityType.ITEM_FRAME)){
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) { if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) {
event.setCancelled(true); event.setCancelled(true);