mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-25 08:51:33 +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();
|
||||
|
||||
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();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
hologramManager.resetHologram();
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
|
||||
});
|
||||
|
||||
limitManager.reload();
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class BanCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
@ -115,6 +116,7 @@ public class BanCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,7 @@ public class KickCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
@ -100,7 +101,8 @@ public class KickCommand extends SubCommand {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
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);
|
||||
@ -128,7 +130,8 @@ public class KickCommand extends SubCommand {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
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()) {
|
||||
messageManager.sendMessage(player,
|
||||
@ -254,6 +257,7 @@ public class KickCommand extends SubCommand {
|
||||
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