mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-16 19:51:27 +01:00
Fixed some nesting issues.
This commit is contained in:
parent
b02e594676
commit
9ba7647f53
@ -65,78 +65,79 @@ public class ScoreboardManager extends Manager {
|
||||
}
|
||||
|
||||
public void updatePlayerScoreboardType(Player player) {
|
||||
if (this.enabled) {
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
if (!this.enabled)
|
||||
return;
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Island island = islandManager.getIsland(player);
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
|
||||
if (playerData.isScoreboard()) {
|
||||
ScoreboardType type;
|
||||
if (island != null) {
|
||||
Visit islandVisit = island.getVisit();
|
||||
boolean hasVisitors = (islandVisit != null &&
|
||||
islandVisit.getVisitors() != null &&
|
||||
islandVisit.getVisitors().size() > 1);
|
||||
boolean hasMembers = (islandVisit != null &&
|
||||
islandVisit.getMembers() > 1);
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (hasMembers) {
|
||||
if (hasVisitors) {
|
||||
type = ScoreboardType.ISLAND_TEAM_VISITORS;
|
||||
} else {
|
||||
type = ScoreboardType.ISLAND_TEAM_EMPTY;
|
||||
}
|
||||
} else {
|
||||
if (hasVisitors) {
|
||||
type = ScoreboardType.ISLAND_SOLO_VISITORS;
|
||||
} else {
|
||||
type = ScoreboardType.ISLAND_SOLO_EMPTY;
|
||||
}
|
||||
}
|
||||
if (!playerData.isScoreboard())
|
||||
return;
|
||||
|
||||
ScoreboardType type;
|
||||
if (island != null) {
|
||||
Visit islandVisit = island.getVisit();
|
||||
boolean hasVisitors = (islandVisit != null &&
|
||||
islandVisit.getVisitors() != null &&
|
||||
islandVisit.getVisitors().size() > 1);
|
||||
boolean hasMembers = (islandVisit != null &&
|
||||
islandVisit.getMembers() > 1);
|
||||
|
||||
if (hasMembers) {
|
||||
if (hasVisitors) {
|
||||
type = ScoreboardType.ISLAND_TEAM_VISITORS;
|
||||
} else {
|
||||
type = ScoreboardType.NO_ISLAND;
|
||||
type = ScoreboardType.ISLAND_TEAM_EMPTY;
|
||||
}
|
||||
synchronized (player) {
|
||||
setPlayerScoreboard(player, type);
|
||||
} else {
|
||||
if (hasVisitors) {
|
||||
type = ScoreboardType.ISLAND_SOLO_VISITORS;
|
||||
} else {
|
||||
type = ScoreboardType.ISLAND_SOLO_EMPTY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
type = ScoreboardType.NO_ISLAND;
|
||||
}
|
||||
synchronized (player) {
|
||||
setPlayerScoreboard(player, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPlayerScoreboard(Player player, ScoreboardType type) {
|
||||
if (this.enabled) {
|
||||
for (Driver driver : this.drivers) {
|
||||
driver.unregisterHolder(player);
|
||||
if (driver.getBoardType() == type) {
|
||||
driver.registerHolder(new Holder(this.plugin, driver, player));
|
||||
}
|
||||
}
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
for (Driver driver : drivers) {
|
||||
driver.unregisterHolder(player);
|
||||
if (driver.getBoardType() == type)
|
||||
driver.registerHolder(new Holder(plugin, driver, player));
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterPlayer(Player player) {
|
||||
if (this.enabled) {
|
||||
for (Driver driver : this.drivers) {
|
||||
driver.unregisterHolder(player);
|
||||
}
|
||||
player.setScoreboard(this.emptyScoreboard);
|
||||
}
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
for (Driver driver : drivers)
|
||||
driver.unregisterHolder(player);
|
||||
player.setScoreboard(emptyScoreboard);
|
||||
}
|
||||
|
||||
public void addDisabledPlayer(Player player) {
|
||||
if (this.enabled) {
|
||||
this.disabledPlayers.add(player);
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.unregisterPlayer(player));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> unregisterPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDisabledPlayer(Player player) {
|
||||
if (this.enabled) {
|
||||
if (this.enabled)
|
||||
this.disabledPlayers.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayerDisabled(Player player) {
|
||||
@ -144,25 +145,25 @@ public class ScoreboardManager extends Manager {
|
||||
}
|
||||
|
||||
private void newDriver(ScoreboardType board) {
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
FileConfiguration configload = fileManager.getConfig(
|
||||
new File(this.plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
|
||||
Driver driver = new Driver(this.plugin, board);
|
||||
Driver driver = new Driver(plugin, board);
|
||||
if (configload.getBoolean("Island.Scoreboard.Async", true)) {
|
||||
driver.runTaskTimerAsynchronously(this.plugin, 1L, 1L);
|
||||
driver.runTaskTimerAsynchronously(plugin, 1L, 1L);
|
||||
} else {
|
||||
driver.runTaskTimer(this.plugin, 1L, 1L);
|
||||
driver.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
this.drivers.add(driver);
|
||||
drivers.add(driver);
|
||||
}
|
||||
|
||||
public void clearDrivers() {
|
||||
if (this.enabled) {
|
||||
if (enabled) {
|
||||
for (Driver driver : this.drivers) {
|
||||
driver.cancel();
|
||||
}
|
||||
this.drivers.clear();
|
||||
drivers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,8 @@ public class HologramTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
if (hologramTypeList == HologramType.VOTES) {
|
||||
if (!plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
if (!plugin.getConfiguration().getBoolean("Island.Visitor.Vote"))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
spawnHologram(hologramTypeList);
|
||||
}
|
||||
|
@ -1,27 +1,16 @@
|
||||
package com.craftaro.skyblock.tasks;
|
||||
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
|
||||
import com.craftaro.skyblock.SkyBlock;
|
||||
import com.craftaro.skyblock.island.IslandWorld;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Hoglin;
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Strider;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.Zoglin;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class MobNetherWaterTask extends BukkitRunnable {
|
||||
@ -44,49 +33,43 @@ public class MobNetherWaterTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.getConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)) {
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
if (plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world) == IslandWorld.NETHER) {
|
||||
for (Entity ent : world.getEntities()) {
|
||||
boolean witherSkeleton;
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
|
||||
witherSkeleton = ent.getType() == EntityType.WITHER_SKELETON;
|
||||
} else {
|
||||
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType() == Skeleton.SkeletonType.WITHER;
|
||||
}
|
||||
if ((((ent instanceof Blaze || ent instanceof MagmaCube) || ent instanceof Wither) || ent instanceof Ghast) || witherSkeleton) {
|
||||
Block block = ent.getLocation().getBlock();
|
||||
removeWater(world, block);
|
||||
removeWater(world, block.getRelative(BlockFace.UP));
|
||||
} else {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
||||
if (((ent instanceof Piglin || ent instanceof Hoglin) || ent instanceof Strider) || ent instanceof Zoglin) {
|
||||
Block block = ent.getLocation().getBlock();
|
||||
removeWater(world, block);
|
||||
removeWater(world, block.getRelative(BlockFace.UP));
|
||||
}
|
||||
} else {
|
||||
if (ent instanceof PigZombie) {
|
||||
Block block = ent.getLocation().getBlock();
|
||||
removeWater(world, block);
|
||||
removeWater(world, block.getRelative(BlockFace.UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plugin.getConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false))
|
||||
return;
|
||||
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
if (!plugin.getWorldManager().isIslandWorld(world) || plugin.getWorldManager().getIslandWorld(world) != IslandWorld.NETHER)
|
||||
continue;
|
||||
|
||||
for (Entity ent : world.getEntities())
|
||||
if (isNetherMob(ent))
|
||||
removeWaterAround(world, ent.getLocation().getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
private void removeWater(World world, Block block) {
|
||||
if (block.getType() == Material.WATER) {
|
||||
block.setType(Material.AIR, true);
|
||||
XSound.BLOCK_FIRE_EXTINGUISH.play(block.getLocation());
|
||||
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
private boolean isNetherMob(Entity ent) {
|
||||
if (ent instanceof Blaze || ent instanceof MagmaCube || ent instanceof Wither || ent instanceof Ghast)
|
||||
return true;
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
|
||||
return ent.getType() == EntityType.WITHER_SKELETON;
|
||||
} else {
|
||||
return ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType() == Skeleton.SkeletonType.WITHER;
|
||||
}
|
||||
}
|
||||
|
||||
private void removeWaterAround(World world, Block block) {
|
||||
removeWater(world, block);
|
||||
removeWater(world, block.getRelative(BlockFace.UP));
|
||||
}
|
||||
|
||||
private void removeWater(World world, Block block) {
|
||||
if (block.getType() != Material.WATER)
|
||||
return;
|
||||
block.setType(Material.AIR, true);
|
||||
XSound.BLOCK_FIRE_EXTINGUISH.play(block.getLocation());
|
||||
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user