Merge branch 'master' into file-system-rewrite

This commit is contained in:
Esophose 2019-08-15 00:44:37 -06:00
commit d8e26f7d03
17 changed files with 287 additions and 282 deletions

View File

@ -15,6 +15,9 @@ dependencies {
// Vault
compileOnly (group: 'net.milkbowl', name: 'vault', version: '1.7.1')
// Reserve
compileOnly (group: 'net.tnemc', name: 'Reserve', version: '0.1.3.0')
// Leaderheads
compileOnly (group: 'me.robin', name: 'leaderheads', version: '1.0')
@ -28,7 +31,7 @@ dependencies {
compileOnly (group: 'com.songoda', name: 'ultimatestacker', version: '1.3.1')
// WildStacker
compileOnly (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b15')
compileOnly (group: 'com.github.OmerBenGera', name: 'WildStackerAPI', version: 'b15')
// WorldEdit
compileOnly (group: 'com.sk89q', name: 'worldedit', version: '7.0.0')

View File

@ -52,7 +52,7 @@ public class Ban {
skyblock.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
.getAPIWrapper(),
Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned));
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
if (!islandBanEvent.isCancelled()) {
List<String> islandBans = new ArrayList<>();

View File

@ -3,16 +3,25 @@ package me.goodandevil.skyblock.economy;
import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import net.tnemc.core.Reserve;
import net.tnemc.core.economy.EconomyAPI;
import net.tnemc.core.permissions.PermissionsAPI;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import java.math.BigDecimal;
public class EconomyManager {
private Economy economy = null;
private Permission permission = null;
// Vault
private Economy vaultEconomy = null;
private Permission vaultPermission = null;
// Reserve
private EconomyAPI reserveEconomy = null;
// private PermissionsAPI reservePermission = null;
public EconomyManager() {
setup();
@ -23,48 +32,68 @@ public class EconomyManager {
RegisteredServiceProvider<Economy> economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (economyRsp != null)
economy = economyRsp.getProvider();
this.vaultEconomy = economyRsp.getProvider();
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
if (permissionRsp != null)
permission = permissionRsp.getProvider();
this.vaultPermission = permissionRsp.getProvider();
} else if (Bukkit.getServer().getPluginManager().getPlugin("Reserve") != null) {
if (Reserve.instance().economyProvided())
this.reserveEconomy = Reserve.instance().economy();
// if (Reserve.instance().permissionsProvided())
// this.reservePermission = Reserve.instance().permissions();
}
}
public double getBalance(Player player) {
return economy == null ? 0.0D : economy.getBalance(player);
if (this.vaultEconomy != null)
return this.vaultEconomy.getBalance(player);
if (this.reserveEconomy != null)
return this.reserveEconomy.getHoldings(player.getUniqueId()).doubleValue();
return 0;
}
public boolean hasBalance(Player player, double money) {
return getBalance(player) >= money;
return this.getBalance(player) >= money;
}
public void withdraw(Player player, double money) {
if (economy != null)
economy.withdrawPlayer(player, money);
if (this.vaultEconomy != null)
this.vaultEconomy.withdrawPlayer(player, money);
else if (this.reserveEconomy != null)
this.reserveEconomy.removeHoldings(player.getUniqueId(), new BigDecimal(money));
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
}
public void deposit(Player player, double money) {
if (economy != null) {
economy.depositPlayer(player, money);
}
if (this.vaultEconomy != null)
this.vaultEconomy.depositPlayer(player, money);
else if (this.reserveEconomy != null)
this.reserveEconomy.addHoldings(player.getUniqueId(), new BigDecimal(money));
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
}
public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
if (permission != null)
return permission.playerHas(world, offlinePlayer, perm);
if (this.vaultPermission != null)
return this.vaultPermission.playerHas(world, offlinePlayer, perm);
// if (this.reservePermission != null) {
// // TODO
// }
return false;
}
public boolean isEconomy() {
return economy != null;
return this.vaultEconomy != null || this.reserveEconomy != null;
}
public boolean isPermission() {
return permission != null;
return this.vaultPermission != null/* || this.reservePermission != null*/;
}
}

View File

@ -75,11 +75,11 @@ public class GeneratorManager {
}
private boolean isLava(Block block) {
return block.getType().equals(Materials.LAVA.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_LAVA.parseMaterial());
return block.getType().name().contains("LAVA");
}
private boolean isWater(Block block) {
return block.getType().equals(Materials.WATER.parseMaterial()) || block.getType().equals(Materials.LEGACY_STATIONARY_WATER.parseMaterial());
return block.getType().name().contains("WATER");
}
public boolean isGenerator(Block block) {
@ -98,122 +98,6 @@ public class GeneratorManager {
}
return false;
//region GoodAndEvil his old code (garbage)
/*
if (block.getRelative(BlockFace.UP).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
&& block.getRelative(BlockFace.UP).getType() != Materials.WATER.parseMaterial()) {
Block flowBlock = null;
if ((block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getRelative(BlockFace.EAST).getType() == Materials.WATER.parseMaterial())
&& (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial()
|| block.getRelative(BlockFace.WEST).getType() == Materials.LAVA.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.EAST)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.EAST)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.NORTH, BlockFace.SOUTH)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.SOUTH, BlockFace.NORTH)) {
return false;
}
flowBlock = block.getRelative(BlockFace.EAST);
} else if ((block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial() || block.getRelative(BlockFace.EAST).getType() == Materials.LAVA.parseMaterial())
&& (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_WATER
.getPostMaterial()
|| block.getRelative(BlockFace.WEST).getType() == Materials.WATER.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.WEST)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.WEST)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.NORTH, BlockFace.SOUTH)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.SOUTH, BlockFace.NORTH)) {
return false;
}
flowBlock = block.getRelative(BlockFace.WEST);
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_WATER
.getPostMaterial()
|| block.getRelative(BlockFace.NORTH).getType() == Materials.WATER.parseMaterial()))
&& (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == Materials.LAVA.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.NORTH)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.NORTH)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.WEST, BlockFace.EAST)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.EAST, BlockFace.WEST)) {
return false;
}
flowBlock = block.getRelative(BlockFace.NORTH);
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_LAVA
.getPostMaterial()
|| block.getRelative(BlockFace.NORTH).getType() == Materials.LAVA.parseMaterial()))
&& (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_WATER
.getPostMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == Materials.WATER.parseMaterial())
&& (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.SOUTH)
.getType() == Material.AIR
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock()
.getRelative(BlockFace.SOUTH)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
if (!isFlowingTowardsBlock(block, BlockFace.WEST, BlockFace.EAST)) {
return false;
} else if (!isFlowingTowardsBlock(block, BlockFace.EAST, BlockFace.WEST)) {
return false;
}
flowBlock = block.getRelative(BlockFace.SOUTH);
}
if (flowBlock != null) {
return isFlowingBlock(flowBlock);
}
}
return false;
}
private boolean isFlowingTowardsBlock(Block block, BlockFace blockFace1, BlockFace blockFace2) {
if (block.getRelative(blockFace1).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getRelative(blockFace1).getType() == Materials.WATER.parseMaterial()) {
if (isFlowingBlock(block.getRelative(blockFace1)) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D)
.getBlock().getRelative(blockFace1).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace1)
.getType() == Materials.WATER.parseMaterial())) {
if (block.getRelative(blockFace2).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getRelative(blockFace2).getType() == Materials.WATER.parseMaterial()) {
if (isFlowingBlock(block.getRelative(blockFace2)) && (block.getLocation().clone()
.subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace2)
.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|| block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(blockFace2)
.getType() == Materials.WATER.parseMaterial())) {
return true;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
}
return true;
*/
//endregion
}
@SuppressWarnings("deprecation")
@ -256,7 +140,7 @@ public class GeneratorManager {
}
public Materials getRandomMaterials(Generator generator) {
if (generator.getGeneratorMaterials() != null && generator.getGeneratorMaterials().size() != 0) {
if (generator.getGeneratorMaterials() != null && generator.getGeneratorMaterials().stream().anyMatch(x -> x.getChance() > 0)) {
List<Materials> weightedList = new ArrayList<>();
for (GeneratorMaterial generatorMaterial : generator.getGeneratorMaterials())
for (int i = 0; i < generatorMaterial.getChance() * 30; i++)

View File

@ -7,6 +7,7 @@ import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandLevel;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.IslandWorld;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.stackable.Stackable;
import me.goodandevil.skyblock.stackable.StackableManager;
import me.goodandevil.skyblock.utils.version.Materials;
@ -31,9 +32,11 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.logging.Level;
@ -41,7 +44,8 @@ public class LevellingManager {
private final SkyBlock skyblock;
private Set<Island> activeIslandScans = new HashSet<>();
private Island activelyScanningIsland = null;
private Queue<QueuedIsland> islandsInQueue = new LinkedList<>();
private List<LevellingMaterial> materialStorage = new ArrayList<>();
public LevellingManager(SkyBlock skyblock) {
@ -53,17 +57,29 @@ public class LevellingManager {
public void calculatePoints(Player player, Island island) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
MessageManager messageManager = skyblock.getMessageManager();
StackableManager stackableManager = skyblock.getStackableManager();
if (player != null && islandManager.getIslandPlayerAt(player) != island) {
String message = ChatColor.translateAlternateColorCodes('&', this.skyblock.getFileManager()
.getConfig(new File(this.skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Command.Island.Level.Scanning.NotOnIsland.Message"));
player.sendMessage(message);
FileConfiguration languageConfig = this.skyblock.getFileManager().getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
if (!this.isIslandLevelBeingScanned(island) && player != null && islandManager.getIslandPlayerAt(player) != island) {
messageManager.sendMessage(player, languageConfig.getString("Command.Island.Level.Scanning.NotOnIsland.Message"));
return;
}
this.activeIslandScans.add(island);
if (this.activelyScanningIsland != null) {
this.islandsInQueue.add(new QueuedIsland(player, island));
String queuedMessage = languageConfig.getString("Command.Island.Level.Scanning.Queued.Message");
islandManager.getPlayersAtIsland(island).forEach(x -> messageManager.sendMessage(x, queuedMessage));
return;
}
this.activelyScanningIsland = island;
String nowScanningMessage = languageConfig.getString("Command.Island.Level.Scanning.Started.Message");
islandManager.getPlayersAtIsland(island).forEach(x -> messageManager.sendMessage(x, nowScanningMessage));
Chunk chunk = new Chunk(skyblock, island);
chunk.prepareInitial();
@ -100,111 +116,116 @@ public class LevellingManager {
new BukkitRunnable() {
@Override
public void run() {
if (!chunk.isReadyToScan()) return;
if (chunk.isFinished()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, epicSpawnerLocations, ultimateStackerSpawnerLocations, player, island), 1);
cancel();
if (!chunk.isReadyToScan())
return;
}
for (LevelChunkSnapshotWrapper chunkSnapshotList : chunk.getAvailableChunkSnapshots()) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < worldMaxHeight; y++) {
ChunkSnapshot chunkSnapshot = chunkSnapshotList.getChunkSnapshot();
try {
if (chunk.isFinished()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, epicSpawnerLocations, ultimateStackerSpawnerLocations, player, island), 1);
cancel();
return;
}
try {
org.bukkit.Material blockMaterial;
int blockData = 0;
EntityType spawnerType = null;
for (LevelChunkSnapshotWrapper chunkSnapshotList : chunk.getAvailableChunkSnapshots()) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < worldMaxHeight; y++) {
ChunkSnapshot chunkSnapshot = chunkSnapshotList.getChunkSnapshot();
if (NMSVersion > 12) {
blockMaterial = chunkSnapshot.getBlockType(x, y, z);
} else {
LegacyChunkSnapshotData data = LegacyChunkSnapshotFetcher.fetch(chunkSnapshot, x, y, z);
try {
org.bukkit.Material blockMaterial;
int blockData = 0;
EntityType spawnerType = null;
blockMaterial = data.getMaterial();
blockData = data.getData();
}
if (NMSVersion > 12) {
blockMaterial = chunkSnapshot.getBlockType(x, y, z);
} else {
LegacyChunkSnapshotData data = LegacyChunkSnapshotFetcher.fetch(chunkSnapshot, x, y, z);
if (blacklistedMaterials.contains(blockMaterial))
continue;
blockMaterial = data.getMaterial();
blockData = data.getData();
}
long amount = 1;
if (blacklistedMaterials.contains(blockMaterial))
continue;
if (blockMaterial == Materials.SPAWNER.parseMaterial()) {
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
long amount = 1;
if (isEpicSpawnersEnabled) {
com.songoda.epicspawners.EpicSpawners epicSpawners = com.songoda.epicspawners.EpicSpawners.getInstance();
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
com.songoda.epicspawners.spawners.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location);
if (spawner != null)
epicSpawnerLocations.add(location);
if (blockMaterial == Materials.SPAWNER.parseMaterial()) {
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
if (isEpicSpawnersEnabled) {
com.songoda.epicspawners.EpicSpawners epicSpawners = com.songoda.epicspawners.EpicSpawners.getInstance();
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
com.songoda.epicspawners.spawners.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location);
if (spawner != null)
epicSpawnerLocations.add(location);
continue;
}
} else if (isUltimateStackerEnabled) {
com.songoda.ultimatestacker.spawner.SpawnerStack spawnerStack = com.songoda.ultimatestacker.UltimateStacker.getInstance().getSpawnerStackManager().getSpawner(location);
if (spawnerStack != null)
ultimateStackerSpawnerLocations.add(location);
continue;
}
} else if (isUltimateStackerEnabled) {
com.songoda.ultimatestacker.spawner.SpawnerStack spawnerStack = com.songoda.ultimatestacker.UltimateStacker.getInstance().getSpawnerStackManager().getSpawner(location);
if (spawnerStack != null)
ultimateStackerSpawnerLocations.add(location);
continue;
}
if (chunkSnapshotList.hasWildStackerData()) {
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper)chunkSnapshotList).getStackedSnapshot();
if (snapshot.isStackedSpawner(location)) {
Map.Entry<Integer, EntityType> spawnerData = snapshot.getStackedSpawner(location);
amount = spawnerData.getKey();
spawnerType = spawnerData.getValue();
if (chunkSnapshotList.hasWildStackerData()) {
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper) chunkSnapshotList).getStackedSnapshot();
if (snapshot.isStackedSpawner(location)) {
Map.Entry<Integer, EntityType> spawnerData = snapshot.getStackedSpawner(location);
amount = spawnerData.getKey();
spawnerType = spawnerData.getValue();
}
}
}
if (spawnerType == null) {
spawnerLocations.add(location);
continue;
}
} else {
if (chunkSnapshotList.hasWildStackerData()) {
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper)chunkSnapshotList).getStackedSnapshot();
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
if (snapshot.isStackedBarrel(location)) {
Map.Entry<Integer, Material> barrelData = snapshot.getStackedBarrel(location);
amount = barrelData.getKey();
blockMaterial = barrelData.getValue();
if (NMSUtil.getVersionNumber() > 12 && blockMaterial.name().startsWith("LEGACY_")) {
blockMaterial = Material.matchMaterial(blockMaterial.name().replace("LEGACY_", ""));
if (spawnerType == null) {
spawnerLocations.add(location);
continue;
}
} else {
if (chunkSnapshotList.hasWildStackerData()) {
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper) chunkSnapshotList).getStackedSnapshot();
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
if (snapshot.isStackedBarrel(location)) {
Map.Entry<Integer, Material> barrelData = snapshot.getStackedBarrel(location);
amount = barrelData.getKey();
blockMaterial = barrelData.getValue();
if (NMSUtil.getVersionNumber() > 12 && blockMaterial.name().startsWith("LEGACY_")) {
blockMaterial = Material.matchMaterial(blockMaterial.name().replace("LEGACY_", ""));
}
}
}
if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial) && amount == 1) {
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
if (stackableManager.isStacked(location)) {
Stackable stackable = stackableManager.getStack(location, blockMaterial);
if (stackable != null) {
amount = stackable.getSize();
}
}
}
}
if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial) && amount == 1) {
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
if (stackableManager.isStacked(location)) {
Stackable stackable = stackableManager.getStack(location, blockMaterial);
if (stackable != null) {
amount = stackable.getSize();
}
}
}
LevellingData data = new LevellingData(blockMaterial, (byte) blockData, spawnerType);
Long totalAmountInteger = levellingData.get(data);
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
levellingData.put(data, totalAmount);
} catch (Exception e) {
e.printStackTrace();
}
LevellingData data = new LevellingData(blockMaterial, (byte) blockData, spawnerType);
Long totalAmountInteger = levellingData.get(data);
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
levellingData.put(data, totalAmount);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
chunk.prepareNextChunkSnapshots();
chunk.prepareNextChunkSnapshots();
} catch (Exception ex) {
skyblock.getLogger().severe("An error occurred while scanning an island. This is a severe error.");
}
}
}.runTaskTimerAsynchronously(skyblock, 0L, 1L);
}
@ -282,7 +303,15 @@ public class LevellingManager {
}
}
this.activeIslandScans.remove(island);
MessageManager messageManager = skyblock.getMessageManager();
FileConfiguration languageConfig = this.skyblock.getFileManager().getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
String nowScanningMessage = languageConfig.getString("Command.Island.Level.Scanning.Done.Message");
skyblock.getIslandManager().getPlayersAtIsland(island).forEach(x -> messageManager.sendMessage(x, nowScanningMessage));
this.activelyScanningIsland = null;
QueuedIsland nextInQueue = this.islandsInQueue.poll();
if (nextInQueue != null)
this.calculatePoints(nextInQueue.getPlayer(), nextInQueue.getIsland());
}
public void registerMaterials() {
@ -307,7 +336,7 @@ public class LevellingManager {
}
public boolean isIslandLevelBeingScanned(Island island) {
return this.activeIslandScans.contains(island);
return this.islandsInQueue.stream().anyMatch(x -> x.getIsland() == island) || this.activelyScanningIsland == island;
}
public void unregisterMaterials() {
@ -385,4 +414,22 @@ public class LevellingManager {
return Materials.getMaterials(this.material, this.data);
}
}
private class QueuedIsland {
private final Player player;
private final Island island;
public QueuedIsland(Player player, Island island) {
this.player = player;
this.island = island;
}
public Player getPlayer() {
return this.player;
}
public Island getIsland() {
return this.island;
}
}
}

View File

@ -213,7 +213,7 @@ public class Block implements Listener {
if (skyblock.getFileManager().getFileConfiguration(ConfigFile.CONFIG).getBoolean("Island.Spawn.Protection")) {
boolean isObstructing = false;
// Directly on the block
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
isObstructing = true;
}
@ -221,7 +221,7 @@ public class Block implements Listener {
if (!isObstructing && event.getBlock().getState().getData() instanceof org.bukkit.material.Bed) {
BlockFace bedDirection = ((org.bukkit.material.Bed) event.getBlock().getState().getData()).getFacing();
org.bukkit.block.Block bedBlock = block.getRelative(bedDirection);
if (LocationUtil.isLocationAffectingLocation(bedBlock.getLocation(), island.getLocation(world, IslandEnvironment.Main)))
if (LocationUtil.isLocationAffectingIslandSpawn(bedBlock.getLocation(), island, world))
isObstructing = true;
}
@ -300,7 +300,7 @@ public class Block implements Listener {
}
// Protect spawn
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main)) && configLoad.getBoolean("Island.Spawn.Protection")) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@ -371,13 +371,13 @@ public class Block implements Listener {
if (config.getBoolean("Island.Spawn.Protection")) {
// Check exact block
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
event.setCancelled(true);
return;
}
// Check block in direction
if (LocationUtil.isLocationAffectingLocation(block.getRelative(event.getDirection()).getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getRelative(event.getDirection()).getLocation(), island, world)) {
event.setCancelled(true);
return;
}
@ -393,7 +393,8 @@ public class Block implements Listener {
// Check piston head
if (config.getBoolean("Island.Spawn.Protection")) {
if (LocationUtil.isLocationAffectingLocation(event.getBlock().getRelative(event.getDirection()).getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
if (configLoad.getBoolean("Island.Spawn.Protection")) {
if (LocationUtil.isLocationAffectingIslandSpawn(event.getBlock().getRelative(event.getDirection()).getLocation(), island, world)) {
event.setCancelled(true);
}
}
@ -424,7 +425,7 @@ public class Block implements Listener {
return;
}
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main)) && config.getBoolean("Island.Spawn.Protection")) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@ -463,8 +464,8 @@ public class Block implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
if (config.getBoolean("Island.Spawn.Protection")) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@ -567,8 +568,8 @@ public class Block implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
if (skyblock.getFileManager().getFileConfiguration(ConfigFile.CONFIG).getBoolean("Island.Spawn.Protection")) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@ -641,7 +642,7 @@ public class Block implements Listener {
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
for (org.bukkit.block.BlockState block : event.getBlocks()) {
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
event.setCancelled(true);
return;
}
@ -668,10 +669,9 @@ public class Block implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
for (BlockState block : blocks) {
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
event.setCancelled(true);
return;
}
@ -689,10 +689,9 @@ public class Block implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(blocks.get(0).getWorld());
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
for (org.bukkit.block.Block block : blocks) {
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
event.setCancelled(true);
return;
}
@ -720,9 +719,8 @@ public class Block implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(placeLocation.getWorld());
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
if (LocationUtil.isLocationAffectingLocation(placeLocation.getLocation(), islandLocation)) {
if (LocationUtil.isLocationAffectingIslandSpawn(placeLocation.getLocation(), island, world)) {
event.setCancelled(true);
}
}

View File

@ -77,8 +77,7 @@ public class Bucket implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))

View File

@ -418,8 +418,8 @@ public class Entity implements Listener {
org.bukkit.block.Block block = event.getBlock();
// Check spawn block falling, this can be a bit glitchy, but it's better than nothing
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
if (LocationUtil.isLocationLocation(block.getLocation(), islandLocation.clone().subtract(0, 1, 0)) &&
if ((LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0, 1, 0))
|| LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0, 1, 0))) &&
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
@ -451,7 +451,7 @@ public class Entity implements Listener {
return;
// Check entities interacting with spawn
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation) &&
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) &&
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;

View File

@ -587,7 +587,7 @@ public class Interact implements Listener {
player.updateInventory();
}
}
} else if (event.getItem().getType().name().contains("SPAWN_EGG")) {
} else if (event.getItem().getType().name().contains("SPAWN_EGG") || event.getItem().getType().name().equals("MONSTER_EGG")) {
if (!islandManager.hasPermission(player, block.getLocation(), "SpawnEgg")) {
event.setCancelled(true);

View File

@ -77,7 +77,7 @@ public class Teleport implements Listener {
return;
}
if (isCause) {
if (isCause && event.getCause() != TeleportCause.ENDER_PEARL) {
event.setCancelled(true);
return;
}

View File

@ -223,7 +223,7 @@ public class Bans {
nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Bans.Item.Ban.Displayname")
.replace("%player", targetPlayerName)),
.replace("%player", targetPlayerName == null ? "" : targetPlayerName)),
configLoad.getStringList("Menu.Bans.Item.Ban.Lore"), null, null, null),
inventorySlot);
}

View File

@ -5,6 +5,7 @@ import java.util.UUID;
import me.goodandevil.skyblock.utils.NumberUtil;
import org.apache.commons.lang3.text.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -31,7 +32,7 @@ public class Stackable {
public Stackable(Location location, Material material) {
this.uuid = UUID.randomUUID();
this.location = location;
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.material = material;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(location, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
@ -40,7 +41,7 @@ public class Stackable {
public Stackable(UUID uuid, Location location, Material material, int size) {
this.uuid = uuid;
this.location = location;
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.material = material;
this.size = size;
this.updateDisplay();
@ -78,22 +79,25 @@ public class Stackable {
}
public void addOne() {
this.size ++;
this.size++;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
this.save();
}
public void takeOne() {
this.size --;
this.size--;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
this.save();
}
private void updateDisplay() {
// The chunk needs to be loaded otherwise the getNearbyEntities() in removeDisplay() won't find anything
if (!this.location.getWorld().isChunkLoaded(this.location.getBlockX() >> 4, this.location.getBlockZ() >> 4))
this.location.getChunk().load();
if (this.size > 1) {
this.removeDisplay();
this.createDisplay();
this.display.setCustomName(this.getCustomName());
this.display.setCustomNameVisible(true);
@ -101,10 +105,10 @@ public class Stackable {
this.removeDisplay();
}
}
private void createDisplay() {
this.removeDisplay();
Location dropLocation = this.location.clone().add(0.5, 1, 0.5);
ArmorStand as = (ArmorStand) this.location.getWorld().spawnEntity(dropLocation, EntityType.ARMOR_STAND);
as.setVisible(false);
@ -124,13 +128,11 @@ public class Stackable {
if (this.display != null) {
this.display.remove();
}
// Find any stragglers
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.1, 0.5, 0.1)) {
if (entity instanceof ArmorStand && entity.isValid()) {
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.25, 0.5, 0.25))
if (entity instanceof ArmorStand)
entity.remove();
}
}
}
private void save() {
@ -138,7 +140,7 @@ public class Stackable {
FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(configFile,
SkyBlock.getInstance().getIslandManager().getIslandAtLocation(this.location).getOwnerUUID() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (this.getSize() == 0) {
configLoad.set("Stackables." + this.getUuid().toString(), null);
} else {

View File

@ -1059,6 +1059,8 @@ public enum Materials {
String old12Mat;
int data;
boolean is13Plusonly;
private Material cachedMaterial;
private boolean isMaterialParsed = false;
Materials(String old13Mat, String old12Mat, int data) {
this(old13Mat, old12Mat, data, false);
@ -1129,24 +1131,37 @@ public enum Materials {
Materials pmat = null;
// Try 1.13+ names
for (Materials mat : Materials.values()) {
if (name.equalsIgnoreCase(mat.old12Mat)) {
if (name.equalsIgnoreCase(mat.name())) {
if (pmat == null) {
pmat = mat;
}
if (((byte) mat.data) == data) {
cachedSearch.put(mat.old12Mat + "," + data, mat);
cachedSearch.put(mat.name() + "," + data, mat);
return mat;
}
}
}
if (pmat != null) {
return pmat;
// Try 1.12- names
for (Materials mat : Materials.values()) {
if (name.equalsIgnoreCase(mat.name()))
if (name.equalsIgnoreCase(mat.old12Mat)) {
if (pmat == null) {
pmat = mat;
}
if (((byte) mat.data) == data) {
cachedSearch.put(mat.old12Mat + "," + data, mat);
return mat;
}
}
}
return null;
return pmat;
}
public boolean isSpawner() {
@ -1231,25 +1246,36 @@ public enum Materials {
case "CHESTPLATE":
return true;
default:
return false;
return false;
}
}
public Material parseMaterial() {
if (this.isSpawner() && this != Materials.SPAWNER)
return Materials.SPAWNER.parseMaterial();
if (this.cachedMaterial != null || this.isMaterialParsed)
return this.cachedMaterial;
if (this.isSpawner() && this != Materials.SPAWNER) {
this.cachedMaterial = Materials.SPAWNER.parseMaterial();
return this.cachedMaterial;
}
Material mat = Material.matchMaterial(this.toString());
if (mat != null)
return mat;
if (mat != null) {
this.cachedMaterial = mat;
return this.cachedMaterial;
}
if (old13Mat != null) {
mat = Material.matchMaterial(old13Mat);
if (mat != null)
return mat;
if (mat != null) {
this.cachedMaterial = mat;
return this.cachedMaterial;
}
}
return Material.matchMaterial(old12Mat);
this.cachedMaterial = Material.matchMaterial(old12Mat);
this.isMaterialParsed = true;
return this.cachedMaterial;
}
public Material getPostMaterial() {

View File

@ -4,7 +4,9 @@ import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandEnvironment;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.IslandWorld;
import me.goodandevil.skyblock.utils.math.VectorUtil;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
@ -32,7 +34,12 @@ public final class LocationUtil {
return false;
}
public static boolean isLocationAffectingLocation(Location location1, Location location2) {
public static boolean isLocationAffectingIslandSpawn(Location location, Island island, IslandWorld world) {
return isLocationAffectingLocation(location, island.getLocation(world, IslandEnvironment.Main))
|| isLocationAffectingLocation(location, island.getLocation(world, IslandEnvironment.Visitor));
}
private static boolean isLocationAffectingLocation(Location location1, Location location2) {
Location headHeight = location2.clone().add(0, 1, 0);
Location feetHeight = location2.clone();
Location groundHeight = location2.clone().add(0, -1, 0);

View File

@ -84,6 +84,12 @@ Command:
Message: '&bSkyBlock &8| &cError&8: &eYou cannot initiate an Island level scan without being on your Island.'
BlockPlacing:
Message: '&bSkyBlock &8 | &cError:&8: &eYou cannot place blocks during an Island level scan. Please wait for the scan to finish.'
Started:
Message: '&bSkyBlock &8| &aInfo&8: &eA level scan has started on this island.'
Queued:
Message: '&bSkyBlock &8| &aInfo&8: &eA level scan has been &aqueued&e for this island. The scan will start as soon as all other queued scans are complete.'
Done:
Message: '&bSkyBlock &8| &aInfo&8: &eThe scan has completed.'
Cooldown:
Word:
Minute: minute(s)

View File

@ -4,7 +4,7 @@ version: @version@
api-version: 1.13
description: A unique SkyBlock plugin
author: Songoda
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
loadbefore: [Multiverse-Core]
commands:
island:

View File

@ -1,7 +1,7 @@
allprojects {
apply plugin: 'java'
group = 'com.goodandevil.skyblock'
version = 'Build-78'
version = 'Build-78.3'
}
subprojects {
@ -14,6 +14,10 @@ subprojects {
maven {
url = 'http://repo.songoda.com/artifactory/private'
}
maven {
url = 'https://jitpack.io'
}
}
}