mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-30 14:13:29 +01:00
Merge branch 'development'
This commit is contained in:
commit
736947bf73
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>skyblock</artifactId>
|
||||
<version>2.2.6</version>
|
||||
<version>2.2.7</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>FabledSkyblock-${project.version}</finalName>
|
||||
|
@ -15,7 +15,7 @@ import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.confirmation.ConfirmationTask;
|
||||
import com.songoda.skyblock.cooldown.CooldownManager;
|
||||
import com.songoda.skyblock.generator.GeneratorManager;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.tasks.HologramTask;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.reward.RewardManager;
|
||||
@ -77,7 +77,7 @@ public class SkyBlock extends SongodaPlugin {
|
||||
private LeaderboardManager leaderboardManager;
|
||||
private PlaceholderManager placeholderManager;
|
||||
private MessageManager messageManager;
|
||||
private HologramManager hologramManager;
|
||||
private HologramTask hologramTask;
|
||||
private LimitationInstanceHandler limitationHandler;
|
||||
private LocalizationManager localizationManager;
|
||||
private RewardManager rewardManager;
|
||||
@ -142,7 +142,6 @@ public class SkyBlock extends SongodaPlugin {
|
||||
placeholderManager.registerPlaceholders();
|
||||
|
||||
messageManager = new MessageManager(this);
|
||||
hologramManager = new HologramManager(this);
|
||||
|
||||
rewardManager = new RewardManager(this);
|
||||
rewardManager.loadRewards();
|
||||
@ -151,6 +150,9 @@ public class SkyBlock extends SongodaPlugin {
|
||||
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
|
||||
// Start Tasks
|
||||
hologramTask = HologramTask.startTask(this);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new Join(this), this);
|
||||
pluginManager.registerEvents(new Quit(this), this);
|
||||
@ -220,8 +222,8 @@ public class SkyBlock extends SongodaPlugin {
|
||||
this.cooldownManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.hologramManager != null) {
|
||||
this.hologramManager.onDisable();
|
||||
if (this.hologramTask != null) {
|
||||
this.hologramTask.onDisable();
|
||||
}
|
||||
|
||||
if (this.fabledChallenge != null) {
|
||||
@ -333,8 +335,8 @@ public class SkyBlock extends SongodaPlugin {
|
||||
return messageManager;
|
||||
}
|
||||
|
||||
public HologramManager getHologramManager() {
|
||||
return hologramManager;
|
||||
public HologramTask getHologramTask() {
|
||||
return hologramTask;
|
||||
}
|
||||
|
||||
public StackableManager getStackableManager() {
|
||||
|
@ -5,6 +5,7 @@ import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -26,23 +27,31 @@ public class BiomeManager {
|
||||
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
|
||||
int radius = (int) Math.ceil(island.getRadius());
|
||||
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
|
||||
location.getWorld().setBiome(x, z, biome);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
|
||||
location.getWorld().setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) {
|
||||
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
||||
updateBiome(island, chunk);
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> {
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) {
|
||||
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
||||
updateBiome(island, chunk);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Class<?> packetPlayOutMapChunkClass;
|
||||
private Class<?> chunkClass;
|
||||
|
||||
private void updateBiome(Island island, Chunk chunk) {
|
||||
Class<?> packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
Class<?> chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
if (packetPlayOutMapChunkClass == null) {
|
||||
packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
}
|
||||
|
||||
for (Player all : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
try {
|
||||
|
@ -41,7 +41,7 @@ public class RefreshHologramsCommand extends SubCommand {
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().updateHologram());
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramTask().updateHologram());
|
||||
});
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message"));
|
||||
|
@ -93,7 +93,7 @@ public class ReloadCommand extends SubCommand {
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().updateHologram());
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramTask().updateHologram());
|
||||
});
|
||||
|
||||
limitHandler.reloadAll();
|
||||
|
@ -5,7 +5,7 @@ import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.hologram.Hologram;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.tasks.HologramTask;
|
||||
import com.songoda.skyblock.hologram.HologramType;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -33,7 +33,7 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
HologramTask hologramManager = skyblock.getHologramTask();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
@ -5,10 +5,10 @@ import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.hologram.Hologram;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.hologram.HologramType;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.tasks.HologramTask;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -21,7 +21,7 @@ public class SetHologramCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
HologramTask hologramManager = skyblock.getHologramTask();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
@ -49,16 +49,15 @@ public class SetHologramCommand extends SubCommand {
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
|
||||
"Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
HologramType hologramType1 = HologramType
|
||||
.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
HologramType hologramType1 = HologramType
|
||||
.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
if (hologram != null)
|
||||
hologram.remove();
|
||||
if (hologram != null)
|
||||
hologram.remove();
|
||||
|
||||
hologramManager.spawnHologram(hologramType1);
|
||||
});
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () ->
|
||||
hologramManager.spawnHologram(hologramType1));
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type",
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.songoda.skyblock.hologram;
|
||||
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Hologram {
|
||||
@ -18,7 +15,9 @@ public class Hologram {
|
||||
public Hologram(HologramType type, Location location, List<String> lines) {
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
HologramManager.createHologram(location, lines);
|
||||
|
||||
Bukkit.getScheduler().runTask(SkyBlock.getInstance(),
|
||||
() -> HologramManager.createHologram(location, lines));
|
||||
}
|
||||
|
||||
public HologramType getType() {
|
||||
@ -32,10 +31,13 @@ public class Hologram {
|
||||
|
||||
public void remove() {
|
||||
HologramManager.removeHologram(location);
|
||||
Bukkit.getScheduler().runTask(SkyBlock.getInstance(),
|
||||
() -> HologramManager.removeHologram(location));
|
||||
}
|
||||
|
||||
public void update(List<String> lines) {
|
||||
HologramManager.updateHologram(location, lines);
|
||||
Bukkit.getScheduler().runTask(SkyBlock.getInstance(),
|
||||
() -> HologramManager.updateHologram(location, lines));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ public class LeaderboardTask extends BukkitRunnable {
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
skyblock.getHologramManager().updateHologram();
|
||||
skyblock.getHologramTask().updateHologram();
|
||||
}
|
||||
}
|
||||
|
@ -349,10 +349,12 @@ public class Block implements Listener {
|
||||
// Find highest generator available
|
||||
for (Generator generator : generators) {
|
||||
for (Player p : possiblePlayers) {
|
||||
if (generator.isPermission()) {
|
||||
if (!p.hasPermission(generator.getPermission()) && !p.hasPermission("fabledskyblock.generator.*") && !p.hasPermission("fabledskyblock.*")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (generator.isPermission() &&
|
||||
!p.hasPermission(generator.getPermission()) &&
|
||||
!p.hasPermission("fabledskyblock.generator.*") &&
|
||||
!p.hasPermission("fabledskyblock.*")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block);
|
||||
@ -361,7 +363,6 @@ public class Block implements Listener {
|
||||
toBlockState.setData(genState.getData());
|
||||
toBlockState.setType(genState.getType());
|
||||
toBlockState.update();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -530,6 +531,7 @@ public class Block implements Listener {
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
|
||||
if (island == null) return;
|
||||
|
||||
// Check spawn block protection
|
||||
@ -541,27 +543,33 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
Material material = block.getType();
|
||||
if (material != CompatibleMaterial.WATER.getBlockMaterial()
|
||||
&& material != CompatibleMaterial.LAVA.getBlockMaterial())
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
if (material != CompatibleMaterial.WATER
|
||||
&& material != CompatibleMaterial.LAVA)
|
||||
return;
|
||||
|
||||
BlockState state = event.getNewState();
|
||||
Material type = state.getType();
|
||||
|
||||
if (type != Material.COBBLESTONE && type != Material.STONE) return;
|
||||
|
||||
GeneratorManager generatorManager = skyblock.getGeneratorManager();
|
||||
if (generatorManager == null) return;
|
||||
|
||||
List<Generator> generators = Lists.newArrayList(generatorManager.getGenerators());
|
||||
if (generators == null || generators.isEmpty()) return;
|
||||
|
||||
if (generators.isEmpty()) return;
|
||||
|
||||
Collections.reverse(generators); // Use the highest generator available
|
||||
|
||||
// Filter valid players on the island.
|
||||
Set<Player> possiblePlayers = new HashSet<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) || island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Coop, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId());
|
||||
boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Operator, player.getUniqueId());
|
||||
|
||||
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
|
||||
possiblePlayers.add(player);
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.songoda.skyblock.hologram;
|
||||
package com.songoda.skyblock.tasks;
|
||||
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.hologram.Hologram;
|
||||
import com.songoda.skyblock.hologram.HologramType;
|
||||
import com.songoda.skyblock.island.IslandLevel;
|
||||
import com.songoda.skyblock.leaderboard.Leaderboard;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
@ -15,33 +17,45 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HologramManager {
|
||||
public class HologramTask extends BukkitRunnable {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private List<Hologram> hologramStorage = new ArrayList<>();
|
||||
private static HologramTask instance;
|
||||
private static SkyBlock plugin;
|
||||
|
||||
public HologramManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
private final List<Hologram> hologramStorage = new ArrayList<>();
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
public HologramTask(SkyBlock plug) {
|
||||
plugin = plug;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> {
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
if (hologramTypeList == HologramType.Votes) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
continue;
|
||||
}
|
||||
public static HologramTask startTask(SkyBlock plug) {
|
||||
plugin = plug;
|
||||
if (instance == null) {
|
||||
instance = new HologramTask(plugin);
|
||||
instance.runTaskTimerAsynchronously(plugin, 0, 20 * 60);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
if (hologramTypeList == HologramType.Votes) {
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
spawnHologram(hologramTypeList);
|
||||
}
|
||||
}, 200L);
|
||||
spawnHologram(hologramTypeList);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
@ -53,22 +67,21 @@ public class HologramManager {
|
||||
}
|
||||
|
||||
public void spawnHologram(HologramType type) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config locationsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
|
||||
Config locationsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml"));
|
||||
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
|
||||
|
||||
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + type) != null)
|
||||
spawnHologram(type, skyblock.getFileManager().getLocation(locationsConfig,
|
||||
spawnHologram(type, plugin.getFileManager().getLocation(locationsConfig,
|
||||
"Location.Hologram.Leaderboard." + type, true), getHologramLines(type));
|
||||
}
|
||||
|
||||
private List<String> getHologramLines(HologramType type) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
|
||||
|
||||
FileConfiguration languageConfigLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
FileConfiguration languageConfigLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
List<String> hologramLines = new ArrayList<>();
|
Loading…
Reference in New Issue
Block a user