mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-18 20:51:42 +01:00
A more optimized island deletion and some bug fixes/optimizations.
This commit is contained in:
parent
dc237e18a3
commit
412a2e5a5c
@ -29,23 +29,24 @@ public class IslandLevel {
|
|||||||
this.skyblock = skyblock;
|
this.skyblock = skyblock;
|
||||||
this.ownerUUID = ownerUUID;
|
this.ownerUUID = ownerUUID;
|
||||||
|
|
||||||
Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
final Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
final FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
Map<String, Long> materials;
|
final ConfigurationSection section = configLoad.getConfigurationSection("Levelling.Materials");
|
||||||
|
final Map<String, Long> materials;
|
||||||
|
|
||||||
ConfigurationSection materialSection = configLoad.getConfigurationSection("Leveling.Materials");
|
if (section != null) {
|
||||||
|
final Set<String> keys = section.getKeys(false);
|
||||||
|
materials = new HashMap<>(keys.size());
|
||||||
|
|
||||||
if (materialSection != null) {
|
for (String material : keys) {
|
||||||
Set<String> keys = materialSection.getKeys(false);
|
|
||||||
materials = new HashMap<>(keys.size() * 2);
|
|
||||||
|
|
||||||
for (String material : materialSection.getKeys(false)) {
|
ConfigurationSection current = section.getConfigurationSection(material);
|
||||||
|
|
||||||
final ConfigurationSection current = materialSection.getConfigurationSection(material);
|
|
||||||
|
|
||||||
if (current.isSet("Amount")) materials.put(material, current.getLong("Amount"));
|
if (current.isSet("Amount")) materials.put(material, current.getLong("Amount"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
materials = new HashMap<>();
|
materials = new HashMap<>();
|
||||||
}
|
}
|
||||||
@ -71,10 +72,11 @@ public class IslandLevel {
|
|||||||
ConfigurationSection current = materialSection.getConfigurationSection(entry.getKey());
|
ConfigurationSection current = materialSection.getConfigurationSection(entry.getKey());
|
||||||
|
|
||||||
if (current == null) continue;
|
if (current == null) continue;
|
||||||
|
|
||||||
long pointsRequired = current.getLong("Points", 0);
|
long pointsRequired = current.getLong("Points", 0);
|
||||||
|
|
||||||
if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired);
|
if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pointsEarned;
|
return pointsEarned;
|
||||||
|
@ -1,8 +1,38 @@
|
|||||||
package com.songoda.skyblock.island;
|
package com.songoda.skyblock.island;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.ChunkSnapshot;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.songoda.skyblock.SkyBlock;
|
import com.songoda.skyblock.SkyBlock;
|
||||||
import com.songoda.skyblock.api.event.island.*;
|
import com.songoda.skyblock.api.event.island.IslandCreateEvent;
|
||||||
|
import com.songoda.skyblock.api.event.island.IslandDeleteEvent;
|
||||||
|
import com.songoda.skyblock.api.event.island.IslandLoadEvent;
|
||||||
|
import com.songoda.skyblock.api.event.island.IslandOwnershipTransferEvent;
|
||||||
|
import com.songoda.skyblock.api.event.island.IslandUnloadEvent;
|
||||||
import com.songoda.skyblock.ban.BanManager;
|
import com.songoda.skyblock.ban.BanManager;
|
||||||
import com.songoda.skyblock.config.FileManager;
|
import com.songoda.skyblock.config.FileManager;
|
||||||
import com.songoda.skyblock.config.FileManager.Config;
|
import com.songoda.skyblock.config.FileManager.Config;
|
||||||
@ -10,6 +40,7 @@ import com.songoda.skyblock.cooldown.CooldownManager;
|
|||||||
import com.songoda.skyblock.cooldown.CooldownType;
|
import com.songoda.skyblock.cooldown.CooldownType;
|
||||||
import com.songoda.skyblock.invite.Invite;
|
import com.songoda.skyblock.invite.Invite;
|
||||||
import com.songoda.skyblock.invite.InviteManager;
|
import com.songoda.skyblock.invite.InviteManager;
|
||||||
|
import com.songoda.skyblock.island.removal.ChunkDeleteSplitter;
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
import com.songoda.skyblock.playerdata.PlayerData;
|
import com.songoda.skyblock.playerdata.PlayerData;
|
||||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||||
@ -32,18 +63,6 @@ import com.songoda.skyblock.utils.world.WorldBorder;
|
|||||||
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
|
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
|
||||||
import com.songoda.skyblock.visit.VisitManager;
|
import com.songoda.skyblock.visit.VisitManager;
|
||||||
import com.songoda.skyblock.world.WorldManager;
|
import com.songoda.skyblock.world.WorldManager;
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.IllegalPluginAccessException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class IslandManager {
|
public class IslandManager {
|
||||||
|
|
||||||
@ -383,6 +402,8 @@ public class IslandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
public void deleteIsland(Island island) {
|
public void deleteIsland(Island island) {
|
||||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||||
@ -396,17 +417,13 @@ public class IslandManager {
|
|||||||
Bukkit.getScheduler().runTaskLater(skyblock, () -> {
|
Bukkit.getScheduler().runTaskLater(skyblock, () -> {
|
||||||
org.bukkit.World world = worldManager.getWorld(worldList);
|
org.bukkit.World world = worldManager.getWorld(worldList);
|
||||||
Location location = island.getLocation(worldList, IslandEnvironment.Island);
|
Location location = island.getLocation(worldList, IslandEnvironment.Island);
|
||||||
|
|
||||||
if (location == null) return;
|
if (location == null) return;
|
||||||
int size = island.getSize();
|
|
||||||
int xx = location.getBlockX() - size / 2;
|
List<ChunkSnapshot> snapshots = com.songoda.skyblock.levelling.Chunk.getChunksToScan(island, worldList).stream().map(ch -> world.getChunkAt(ch.getX(), ch.getZ()))
|
||||||
int zz = location.getBlockZ() - size / 2;
|
.map(chunk -> chunk.getChunkSnapshot()).collect(Collectors.toList());
|
||||||
for (int x = xx; x < xx + size; x++) {
|
|
||||||
for (int z = zz; z < zz + size; z++) {
|
ChunkDeleteSplitter.startDeleting(world, snapshots);
|
||||||
for (int y = 0; y < world.getMaxHeight(); y++) {
|
|
||||||
new Location(world, x, y, z).getBlock().setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, i);
|
}, i);
|
||||||
i += 20L;
|
i += 20L;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public enum IslandWorld {
|
|||||||
Normal, Nether, End;
|
Normal, Nether, End;
|
||||||
|
|
||||||
public static List<IslandWorld> getIslandWorlds() {
|
public static List<IslandWorld> getIslandWorlds() {
|
||||||
List<IslandWorld> islandWorlds = new ArrayList<>();
|
List<IslandWorld> islandWorlds = new ArrayList<>(3);
|
||||||
|
|
||||||
WorldManager worldManager = SkyBlock.getInstance().getWorldManager();
|
WorldManager worldManager = SkyBlock.getInstance().getWorldManager();
|
||||||
if (worldManager.getWorld(Normal) != null)
|
if (worldManager.getWorld(Normal) != null)
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package com.songoda.skyblock.island.removal;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChunkSnapshot;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
|
||||||
|
public final class ChunkDeleteSplitter extends BukkitRunnable {
|
||||||
|
|
||||||
|
private int completedNum;
|
||||||
|
|
||||||
|
private final World world;
|
||||||
|
private final int threadCount;
|
||||||
|
private final Queue<XYZPair> toRemove;
|
||||||
|
|
||||||
|
private ChunkDeleteSplitter(World world, List<ChunkSnapshot> snapshots) {
|
||||||
|
this.toRemove = new ConcurrentLinkedQueue<>();
|
||||||
|
this.world = world;
|
||||||
|
|
||||||
|
final List<List<ChunkSnapshot>> parts = Lists.partition(snapshots, 32);
|
||||||
|
|
||||||
|
this.threadCount = parts.size();
|
||||||
|
|
||||||
|
for (List<ChunkSnapshot> sub : parts) {
|
||||||
|
queueWork(sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void queueWork(List<ChunkSnapshot> subList) {
|
||||||
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> {
|
||||||
|
for (ChunkSnapshot shot : subList) {
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
for (int y = 0; y < 256; y++) {
|
||||||
|
final Material type = shot.getBlockType(x, y, z);
|
||||||
|
|
||||||
|
if (type == Material.AIR) continue;
|
||||||
|
|
||||||
|
toRemove.add(new XYZPair(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
increment();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void increment() {
|
||||||
|
completedNum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized int get() {
|
||||||
|
return completedNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (get() != threadCount) return;
|
||||||
|
|
||||||
|
int deleteAmount = 0;
|
||||||
|
|
||||||
|
for (Iterator<XYZPair> it = toRemove.iterator(); it.hasNext();) {
|
||||||
|
|
||||||
|
if (deleteAmount == 10000) break;
|
||||||
|
|
||||||
|
final XYZPair pair = it.next();
|
||||||
|
|
||||||
|
world.getBlockAt(pair.getX(), pair.getY(), pair.getZ()).setType(Material.AIR);
|
||||||
|
|
||||||
|
deleteAmount++;
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toRemove.isEmpty()) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startDeleting(World world, List<ChunkSnapshot> snapshots) {
|
||||||
|
|
||||||
|
final ChunkDeleteSplitter splitter = new ChunkDeleteSplitter(world, snapshots);
|
||||||
|
|
||||||
|
splitter.runTaskTimer(SkyBlock.getInstance(), 5, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.songoda.skyblock.island.removal;
|
||||||
|
|
||||||
|
public class XYZPair {
|
||||||
|
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int z;
|
||||||
|
|
||||||
|
public XYZPair(final int x, final int y, final int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -42,9 +42,11 @@ public class LeaderboardManager {
|
|||||||
|
|
||||||
visitManager.loadIslands();
|
visitManager.loadIslands();
|
||||||
|
|
||||||
List<LeaderboardPlayer> islandLevels = new ArrayList<>();
|
int arraySize = visitManager.getIslands().size();
|
||||||
List<LeaderboardPlayer> islandBanks = new ArrayList<>();
|
|
||||||
List<LeaderboardPlayer> islandVotes = new ArrayList<>();
|
List<LeaderboardPlayer> islandLevels = new ArrayList<>(arraySize);
|
||||||
|
List<LeaderboardPlayer> islandBanks = new ArrayList<>(arraySize);
|
||||||
|
List<LeaderboardPlayer> islandVotes = new ArrayList<>(arraySize);
|
||||||
|
|
||||||
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||||
.getFileConfiguration().getBoolean("Island.Leaderboard.Exemptions.Enable");
|
.getFileConfiguration().getBoolean("Island.Leaderboard.Exemptions.Enable");
|
||||||
@ -87,7 +89,7 @@ public class LeaderboardManager {
|
|||||||
VisitManager visitManager = skyblock.getVisitManager();
|
VisitManager visitManager = skyblock.getVisitManager();
|
||||||
visitManager.loadIslands();
|
visitManager.loadIslands();
|
||||||
|
|
||||||
List<LeaderboardPlayer> leaderboardPlayers = new ArrayList<>();
|
List<LeaderboardPlayer> leaderboardPlayers = new ArrayList<>(visitManager.getIslands().size());
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Level:
|
case Level:
|
||||||
@ -145,9 +147,11 @@ public class LeaderboardManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Leaderboard getLeaderboardFromPosition(Leaderboard.Type type, int position) {
|
public Leaderboard getLeaderboardFromPosition(Leaderboard.Type type, int position) {
|
||||||
for (Leaderboard leaderboardPlayerList : leaderboardStorage)
|
for (Leaderboard leaderboardPlayerList : leaderboardStorage) {
|
||||||
if (leaderboardPlayerList.getType() == type && leaderboardPlayerList.getPosition() == position)
|
if (leaderboardPlayerList.getType() == type && leaderboardPlayerList.getPosition() == position) {
|
||||||
return leaderboardPlayerList;
|
return leaderboardPlayerList;
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,11 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Chunk {
|
public class Chunk {
|
||||||
@ -43,7 +46,7 @@ public class Chunk {
|
|||||||
|
|
||||||
for (IslandWorld islandWorld : IslandWorld.getIslandWorlds()) {
|
for (IslandWorld islandWorld : IslandWorld.getIslandWorlds()) {
|
||||||
if (islandWorld == IslandWorld.Normal || (islandWorld == IslandWorld.Nether && hasNether) || (islandWorld == IslandWorld.End && hasEnd)) {
|
if (islandWorld == IslandWorld.Normal || (islandWorld == IslandWorld.Nether && hasNether) || (islandWorld == IslandWorld.End && hasEnd)) {
|
||||||
this.getChunksToScan(islandWorld);
|
chunkPositions.addAll(getChunksToScan(island, islandWorld));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,12 +133,15 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getChunksToScan(IslandWorld islandWorld) {
|
public static List<ChunkPosition> getChunksToScan(Island island, IslandWorld islandWorld) {
|
||||||
Location islandLocation = this.island.getLocation(islandWorld, IslandEnvironment.Island);
|
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island);
|
||||||
|
|
||||||
|
if (islandLocation == null) return new ArrayList<>(0);
|
||||||
|
|
||||||
World world = islandLocation.getWorld();
|
World world = islandLocation.getWorld();
|
||||||
|
|
||||||
Location minLocation = new Location(world, islandLocation.getBlockX() - this.island.getRadius(), 0, islandLocation.getBlockZ() - this.island.getRadius());
|
Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius());
|
||||||
Location maxLocation = new Location(world, islandLocation.getBlockX() + this.island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + this.island.getRadius());
|
Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius());
|
||||||
|
|
||||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||||
int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||||
@ -143,10 +149,14 @@ public class Chunk {
|
|||||||
int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX());
|
int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||||
int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||||
|
|
||||||
|
List<ChunkPosition> positions = new LinkedList<>();
|
||||||
|
|
||||||
for (int x = minX; x < maxX + 16; x += 16) {
|
for (int x = minX; x < maxX + 16; x += 16) {
|
||||||
for (int z = minZ; z < maxZ + 16; z += 16) {
|
for (int z = minZ; z < maxZ + 16; z += 16) {
|
||||||
this.chunkPositions.add(new ChunkPosition(world, x >> 4, z >> 4));
|
positions.add(new ChunkPosition(world, x >> 4, z >> 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return positions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ public class Portal implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Tick {
|
public static class Tick {
|
||||||
private int tick = 1;
|
private int tick = 1;
|
||||||
private long last = System.currentTimeMillis() - 1001;
|
private long last = System.currentTimeMillis() - 1001;
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@ public class Respawn implements Listener {
|
|||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.Death.Respawn.Island")) {
|
if (configLoad.getBoolean("Island.Death.Respawn.Island")) {
|
||||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
Location playerLocation = player.getLocation();
|
||||||
|
Island island = islandManager.getIslandAtLocation(playerLocation);
|
||||||
|
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
Location playerLocation = player.getLocation().clone(), islandLocation;
|
Location islandLocation;
|
||||||
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
||||||
|
|
||||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||||
@ -67,10 +68,8 @@ public class Respawn implements Listener {
|
|||||||
if (config.getFileConfiguration().getString("Location.Spawn") == null) {
|
if (config.getFileConfiguration().getString("Location.Spawn") == null) {
|
||||||
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set.");
|
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set.");
|
||||||
} else {
|
} else {
|
||||||
Location playerLocation = player.getLocation().clone(),
|
Location playerLocation = player.getLocation(), spawnLocation = fileManager.getLocation(config, "Location.Spawn", true);
|
||||||
spawnLocation = fileManager.getLocation(config, "Location.Spawn", true);
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerTeleportEvent(player, playerLocation, spawnLocation));
|
||||||
Bukkit.getServer().getPluginManager()
|
|
||||||
.callEvent(new PlayerTeleportEvent(player, playerLocation, spawnLocation));
|
|
||||||
event.setRespawnLocation(spawnLocation);
|
event.setRespawnLocation(spawnLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class Generator implements Listener {
|
|||||||
com.songoda.skyblock.generator.Generator generator = generatorManager
|
com.songoda.skyblock.generator.Generator generator = generatorManager
|
||||||
.getGenerator(((Generator.Viewer) playerData.getViewer()).getName());
|
.getGenerator(((Generator.Viewer) playerData.getViewer()).getName());
|
||||||
|
|
||||||
List<String> permissionLore = new ArrayList<>();
|
final List<String> permissionLore;
|
||||||
|
|
||||||
if (generator.isPermission()) {
|
if (generator.isPermission()) {
|
||||||
permissionLore = configLoad
|
permissionLore = configLoad
|
||||||
|
@ -36,7 +36,7 @@ public class MessageManager {
|
|||||||
messages.add(ChatColor.translateAlternateColorCodes('&', messageList));
|
messages.add(ChatColor.translateAlternateColorCodes('&', messageList));
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(messages.toArray(new String[0]));
|
sender.sendMessage(messages.toArray(new String[messages.size()]));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ public class MessageManager {
|
|||||||
messages.add(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', messageList)));
|
messages.add(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', messageList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(messages.toArray(new String[0]));
|
sender.sendMessage(messages.toArray(new String[messages.size()]));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', message)));
|
sender.sendMessage(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', message)));
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,16 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EZPlaceholder extends PlaceholderExpansion implements Listener {
|
public class EZPlaceholder extends PlaceholderExpansion {
|
||||||
|
|
||||||
private final SkyBlock skyblock;
|
private final SkyBlock skyblock;
|
||||||
|
|
||||||
public EZPlaceholder(SkyBlock skyblock) {
|
public EZPlaceholder(SkyBlock skyblock) {
|
||||||
this.skyblock = skyblock;
|
this.skyblock = skyblock;
|
||||||
Bukkit.getPluginManager().registerEvents(this, skyblock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
|
@ -400,7 +400,7 @@ public class PlaceholderManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPlaceholders() {
|
public List<String> getPlaceholders() {
|
||||||
List<String> placeholders = new ArrayList<>();
|
List<String> placeholders = new ArrayList<>(25);
|
||||||
placeholders.add("fabledskyblock_island_exists");
|
placeholders.add("fabledskyblock_island_exists");
|
||||||
placeholders.add("fabledskyblock_island_isopen");
|
placeholders.add("fabledskyblock_island_isopen");
|
||||||
placeholders.add("fabledskyblock_island_size");
|
placeholders.add("fabledskyblock_island_size");
|
||||||
|
@ -84,11 +84,8 @@ public class StackableManager {
|
|||||||
|
|
||||||
public Stackable getStack(Location location, Material material) {
|
public Stackable getStack(Location location, Material material) {
|
||||||
Stackable stackable = stacks.get(location);
|
Stackable stackable = stacks.get(location);
|
||||||
|
|
||||||
if (stackable != null && stackable.getMaterial() == material)
|
return stackable != null && stackable.getMaterial() == material ? stackable : null;
|
||||||
return stacks.get(location);
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stackable addStack(Stackable stackable) {
|
public Stackable addStack(Stackable stackable) {
|
||||||
|
@ -59,11 +59,8 @@ public class UpgradeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Upgrade> getUpgrades(Upgrade.Type type) {
|
public List<Upgrade> getUpgrades(Upgrade.Type type) {
|
||||||
if (upgradeStorage.containsKey(type)) {
|
return upgradeStorage.get(type);
|
||||||
return upgradeStorage.get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUpgrade(Upgrade.Type type, int value) {
|
public void addUpgrade(Upgrade.Type type, int value) {
|
||||||
|
@ -237,16 +237,16 @@ public final class LocationUtil {
|
|||||||
int rndX = rnd.nextInt(xRange);
|
int rndX = rnd.nextInt(xRange);
|
||||||
int rndZ = rnd.nextInt(zRange);
|
int rndZ = rnd.nextInt(zRange);
|
||||||
|
|
||||||
if (loadChunk) {
|
if (loadChunk) world.getChunkAt(new Location(world, rndX, 10, rndZ));
|
||||||
Chunk chunk = world.getChunkAt(new Location(world, rndX, 10, rndZ));
|
|
||||||
world.loadChunk(chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
double rndY = -1;
|
double rndY = -1;
|
||||||
|
|
||||||
if (world.getEnvironment() == Environment.NETHER) {
|
if (world.getEnvironment() == Environment.NETHER) {
|
||||||
|
|
||||||
|
Location rndLoc = new Location(world, rndX, 0, rndZ);
|
||||||
|
|
||||||
for (int i = 120; i > 0; i--) {
|
for (int i = 120; i > 0; i--) {
|
||||||
Location rndLoc = new Location(world, rndX, i, rndZ);
|
rndLoc.setY(i);
|
||||||
|
|
||||||
if (rndLoc.getBlock().getType() != Material.AIR
|
if (rndLoc.getBlock().getType() != Material.AIR
|
||||||
&& rndLoc.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR
|
&& rndLoc.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||||
@ -254,7 +254,6 @@ public final class LocationUtil {
|
|||||||
&& rndLoc.clone().add(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.AIR
|
&& rndLoc.clone().add(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||||
&& rndLoc.clone().add(0.0D, 4.0D, 0.0D).getBlock().getType() == Material.AIR) {
|
&& rndLoc.clone().add(0.0D, 4.0D, 0.0D).getBlock().getType() == Material.AIR) {
|
||||||
rndY = i;
|
rndY = i;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,7 @@ public class VisitManager {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
HashMap<UUID, Visit> visitIslands = getIslands();
|
HashMap<UUID, Visit> visitIslands = getIslands();
|
||||||
|
|
||||||
for (UUID visitIslandList : visitIslands.keySet()) {
|
for (Visit visit : visitIslands.values()) {
|
||||||
Visit visit = visitIslands.get(visitIslandList);
|
|
||||||
visit.save();
|
visit.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user