Bug fixes, performance improvements, EpicAnchors support, lang update

This commit is contained in:
Esophose 2019-05-26 19:14:36 -06:00
parent 0a0eb18506
commit 4e988d15dc
8 changed files with 3498 additions and 3429 deletions

View File

@ -33,6 +33,9 @@ dependencies {
// EpicSpawners
implementation (group: 'com.songoda', name: 'epicspawners', version: '6-pre4')
// EpicAnchors
implementation (group: 'com.songoda', name: 'epicanchors', version: '1.2.5')
// WildStacker
implementation (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b14')

View File

@ -6,6 +6,7 @@ import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.economy.EconomyManager;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.IslandWorld;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.NumberUtil;
@ -51,6 +52,7 @@ public class UnlockCommand extends SubCommand {
}
Island island = islandManager.getIsland(player);
IslandWorld islandWorld = IslandWorld.valueOf(type);
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Owner.Message"));
@ -58,21 +60,15 @@ public class UnlockCommand extends SubCommand {
return;
}
Config islandData = fileManager
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
island.getOwnerUUID().toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
double price = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getDouble("Island.World." + type + ".UnlockPrice");
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type);
if (unlocked) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Unlocked.Message").replace(
"%type%", type));
if (islandManager.isIslandWorldUnlocked(island, islandWorld)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Unlocked.Message").replace("%type%", type));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
double price = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
if (!economyManager.hasBalance(player, price)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Money.Message").replace(
"%cost%", NumberUtil.formatNumberByDecimal(price)));
@ -81,9 +77,10 @@ public class UnlockCommand extends SubCommand {
}
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
configLoadIslandData.set("Unlocked." + type, true);
economyManager.withdraw(player, price);
islandManager.unlockIslandWorld(island, islandWorld);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Finish.Message").replace(
"%type%", type));
}

View File

@ -805,8 +805,7 @@ public class Island {
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice");
boolean unlocked =
configLoadIslandData.getBoolean("Unlocked." + type);
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type);
if (price == -1) {
configLoadIslandData.set("Unlocked." + type, true);
unlocked = true;

View File

@ -257,6 +257,9 @@ public class IslandManager {
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getBiomeManager()
.setBiome(island, biome), 20L);
// Recalculate island level after 5 seconds
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
return true;
}
@ -685,8 +688,7 @@ public class IslandManager {
WorldManager worldManager = skyblock.getWorldManager();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(
new File(skyblock.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml"));
Config config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml"));
if (config.getFileConfiguration().getString("Location." + world.name()) == null) {
pasteStructure(island, world);
@ -713,18 +715,22 @@ public class IslandManager {
public void resetIsland(Island island) {
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
pasteStructure(island, worldList);
if (isIslandWorldUnlocked(island, worldList)) {
pasteStructure(island, worldList);
}
}
}
public void pasteStructure(Island island, IslandWorld world) {
if (!isIslandWorldUnlocked(island, world))
return;
StructureManager structureManager = skyblock.getStructureManager();
FileManager fileManager = skyblock.getFileManager();
Structure structure;
if (island.getStructure() != null && !island.getStructure().isEmpty()
&& structureManager.containsStructure(island.getStructure())) {
if (island.getStructure() != null && !island.getStructure().isEmpty() && structureManager.containsStructure(island.getStructure())) {
structure = structureManager.getStructure(island.getStructure());
} else {
structure = structureManager.getStructures().get(0);
@ -738,17 +744,14 @@ public class IslandManager {
for (IslandEnvironment environmentList : IslandEnvironment.values()) {
if (environmentList == IslandEnvironment.Island) {
island.addLocation(world, environmentList, islandLocation);
fileManager.setLocation(config, "Location." + world.name() + "." + environmentList.name(),
islandLocation, true);
fileManager.setLocation(config, "Location." + world.name() + "." + environmentList.name(), islandLocation, true);
} else {
island.addLocation(world, environmentList, islandLocation.clone().add(0.5D, 0.0D, 0.5D));
fileManager.setLocation(config, "Location." + world.name() + ".Spawn." + environmentList.name(),
islandLocation.clone().add(0.5D, 0.0D, 0.5D), true);
fileManager.setLocation(config, "Location." + world.name() + ".Spawn." + environmentList.name(), islandLocation.clone().add(0.5D, 0.0D, 0.5D), true);
}
}
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Spawn.Protection")) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
Bukkit.getServer().getScheduler().runTask(skyblock, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE));
}
@ -788,11 +791,58 @@ public class IslandManager {
setNextAvailableLocation(world, islandLocation);
saveNextAvailableLocation(world);
}
/**
* Unlocks an island world and pastes the island structure there
*
* @param island The island to unlock for
* @param islandWorld The island world type to unlock
*/
public void unlockIslandWorld(Island island, IslandWorld islandWorld) {
FileManager fileManager = skyblock.getFileManager();
Config islandData = fileManager
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
island.getOwnerUUID().toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
configLoadIslandData.set("Unlocked." + islandWorld.name(), true);
pasteStructure(island, islandWorld);
// Recalculate island level after 5 seconds
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
}
/**
* Checks if an island world is unlocked
*
* @param island The island to check
* @param islandWorld The island world to check
* @return true if the island world is unlocked, otherwise false
*/
public boolean isIslandWorldUnlocked(Island island, IslandWorld islandWorld) {
if (islandWorld == IslandWorld.Normal)
return true;
FileManager fileManager = skyblock.getFileManager();
Config islandData = fileManager
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
island.getOwnerUUID().toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.name());
if (!unlocked) {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
double price = configLoad.getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
if (price == -1)
unlocked = true;
}
return unlocked;
}
public Set<UUID> getVisitorsAtIsland(Island island) {
Map<UUID, PlayerData> playerDataStorage = skyblock.getPlayerDataManager().getPlayerData();
Set<UUID> islandVisitors = new HashSet<>();
@ -1342,10 +1392,13 @@ public class IslandManager {
}
public boolean isLocationAtIsland(Island island, org.bukkit.Location location, IslandWorld world) {
Location islandLocation = island.getLocation(world, IslandEnvironment.Island).clone().add(0.5, 0, 0.5);
Location islandLocation = island.getLocation(world, IslandEnvironment.Island);
if (islandLocation == null)
return false;
double size = island.getRadius();
size += size % 2 == 0 ? 1 : 0;
return LocationUtil.isLocationAtLocationRadius(location, islandLocation, size);
return LocationUtil.isLocationAtLocationRadius(location.clone().add(0.5, 0, 0.5), islandLocation, size);
}
}

View File

@ -54,7 +54,7 @@ public class LeaderboardManager {
if (enableExemptions && economyManager.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(),
Bukkit.getOfflinePlayer(ownerUUID),
"fabledskyblock.island.top.exempt"))
"fabledskyblock.top.exempt"))
continue;
Visit visit = visitManager.getIslands().get(ownerUUID);

View File

@ -3,6 +3,7 @@ package me.goodandevil.skyblock.listeners;
import java.io.File;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -399,6 +400,13 @@ public class Interact implements Listener {
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
if (com.songoda.epicanchors.EpicAnchorsPlugin.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
event.setCancelled(true);
return;
}
}
ItemStack is = event.getPlayer().getItemInHand();
if (is == null || is.getType() == Material.AIR) {

View File

@ -76,6 +76,11 @@ public class Teleport implements Listener {
return;
}
if (isCause) {
event.setCancelled(true);
return;
}
}
if (playerDataManager.hasPlayerData(player)) {

File diff suppressed because it is too large Load Diff