mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-10 09:47:42 +01:00
Level scanning and async offline player permission lookups
This commit is contained in:
parent
077856e311
commit
0f03c26cc0
@ -40,12 +40,14 @@ public class RefreshHologramsCommand extends SubCommand {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
leaderboardManager.clearLeaderboard();
|
||||
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"));
|
||||
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
|
@ -90,11 +90,13 @@ public class ReloadCommand extends SubCommand {
|
||||
levellingManager.unregisterMaterials();
|
||||
levellingManager.registerMaterials();
|
||||
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
hologramManager.resetHologram();
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
|
||||
});
|
||||
|
||||
limitManager.reload();
|
||||
|
||||
|
@ -25,96 +25,98 @@ public class BanCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
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"))
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (targetPlayerUUID == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message"));
|
||||
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);
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
island.removeCoopPlayer(targetPlayerUUID);
|
||||
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;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
Ban ban = island.getBan();
|
||||
ban.addBan(player.getUniqueId(), targetPlayerUUID);
|
||||
ban.save();
|
||||
if (targetPlayerUUID == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message"));
|
||||
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 (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);
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
island.removeCoopPlayer(targetPlayerUUID);
|
||||
}
|
||||
|
||||
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 {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,227 +33,231 @@ public class KickCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
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) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
UUID targetPlayerUUID = 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"))
|
||||
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"))
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} 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);
|
||||
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;
|
||||
} 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(),
|
||||
APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
APIUtil.fromImplementation(islandRole),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
|
||||
|
||||
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 (targetPlayer == null) {
|
||||
Config config = fileManager
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||
targetPlayerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (islandOperators.contains(targetPlayerUUID)) {
|
||||
islandRole = IslandRole.Operator;
|
||||
}
|
||||
configLoad.set("Statistics.Island.Playtime", null);
|
||||
configLoad.set("Statistics.Island.Join", null);
|
||||
configLoad.set("Island.Owner", null);
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(islandRole),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
|
||||
try {
|
||||
configLoad.save(config.getFile());
|
||||
} 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 (!islandKickEvent.isCancelled()) {
|
||||
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);
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
|
||||
if (targetPlayer == null) {
|
||||
Config config = fileManager
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||
targetPlayerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
if (scoreboardManager != null) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
|
||||
scoreboard.cancel();
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
scoreboard.run();
|
||||
}
|
||||
|
||||
configLoad.set("Statistics.Island.Playtime", null);
|
||||
configLoad.set("Statistics.Island.Join", null);
|
||||
configLoad.set("Island.Owner", null);
|
||||
|
||||
try {
|
||||
configLoad.save(config.getFile());
|
||||
} 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);
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
playerData.setMemberSince(null);
|
||||
playerData.setOwner(null);
|
||||
playerData.setChat(false);
|
||||
playerData.save();
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
|
||||
scoreboard.cancel();
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
scoreboard.run();
|
||||
if (islandMembers.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Member, targetPlayerUUID);
|
||||
} else if (islandOperators.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Operator, targetPlayerUUID);
|
||||
}
|
||||
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
playerData.setMemberSince(null);
|
||||
playerData.setOwner(null);
|
||||
playerData.setChat(false);
|
||||
playerData.save();
|
||||
}
|
||||
island.save();
|
||||
|
||||
if (islandMembers.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Member, targetPlayerUUID);
|
||||
} else if (islandOperators.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Operator, targetPlayerUUID);
|
||||
}
|
||||
Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
|
||||
|
||||
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 (islandMembersOnline.size() == 1) {
|
||||
for (UUID islandMembersOnlineList : islandMembersOnline) {
|
||||
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
|
||||
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 (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 (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
||||
scoreboard.cancel();
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
if (scoreboardManager != null) {
|
||||
if (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
||||
scoreboard.cancel();
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.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 {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Occupant.Visit.Open.Message"));
|
||||
.getString("Command.Island.Kick.Permission.Visit.Open.Message"));
|
||||
} else {
|
||||
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 {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Permission.Visit.Open.Message"));
|
||||
} 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);
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.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
|
||||
|
@ -44,10 +44,6 @@ public class LevellingManager {
|
||||
private Set<Island> activeIslandScans = new HashSet<>();
|
||||
private List<LevellingMaterial> materialStorage = new ArrayList<>();
|
||||
|
||||
private Method getBlockTypeIdMethod = null;
|
||||
private Method getBlockTypeDataMethod = null;
|
||||
private Method getMaterialMethod = null;
|
||||
|
||||
public LevellingManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
|
||||
@ -119,27 +115,17 @@ public class LevellingManager {
|
||||
ChunkSnapshot chunkSnapshot = chunkSnapshotList.getChunkSnapshot();
|
||||
|
||||
try {
|
||||
org.bukkit.Material blockMaterial = org.bukkit.Material.AIR;
|
||||
org.bukkit.Material blockMaterial;
|
||||
int blockData = 0;
|
||||
EntityType spawnerType = null;
|
||||
|
||||
if (NMSVersion > 12) {
|
||||
blockMaterial = chunkSnapshot.getBlockType(x, y, z);
|
||||
} else {
|
||||
if (getBlockTypeIdMethod == null) {
|
||||
getBlockTypeIdMethod = chunkSnapshot.getClass().getMethod("getBlockTypeId", int.class, int.class, int.class);
|
||||
}
|
||||
LegacyChunkSnapshotData data = LegacyChunkSnapshotFetcher.fetch(chunkSnapshot, x, y, z);
|
||||
|
||||
if (getBlockTypeDataMethod == null) {
|
||||
getBlockTypeDataMethod = chunkSnapshot.getClass().getMethod("getBlockData", int.class, int.class, int.class);
|
||||
}
|
||||
|
||||
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);
|
||||
blockMaterial = data.getMaterial();
|
||||
blockData = data.getData();
|
||||
}
|
||||
|
||||
if (blacklistedMaterials.contains(blockMaterial))
|
||||
|
@ -201,6 +201,12 @@ public class Interact implements Listener {
|
||||
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 (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
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)){
|
||||
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user