mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-12 01:31:22 +01:00
Merge branch 'development' into 'master'
Build 78.3 See merge request Songoda/fabledskyblock!22
This commit is contained in:
commit
c152af3b32
@ -15,6 +15,9 @@ dependencies {
|
|||||||
// Vault
|
// Vault
|
||||||
compileOnly (group: 'net.milkbowl', name: 'vault', version: '1.7.1')
|
compileOnly (group: 'net.milkbowl', name: 'vault', version: '1.7.1')
|
||||||
|
|
||||||
|
// Reserve
|
||||||
|
compileOnly (group: 'net.tnemc', name: 'Reserve', version: '0.1.3.0')
|
||||||
|
|
||||||
// Leaderheads
|
// Leaderheads
|
||||||
compileOnly (group: 'me.robin', name: 'leaderheads', version: '1.0')
|
compileOnly (group: 'me.robin', name: 'leaderheads', version: '1.0')
|
||||||
|
|
||||||
@ -28,7 +31,7 @@ dependencies {
|
|||||||
compileOnly (group: 'com.songoda', name: 'ultimatestacker', version: '1.3.1')
|
compileOnly (group: 'com.songoda', name: 'ultimatestacker', version: '1.3.1')
|
||||||
|
|
||||||
// WildStacker
|
// WildStacker
|
||||||
compileOnly (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b15')
|
compileOnly (group: 'com.github.OmerBenGera', name: 'WildStackerAPI', version: 'b15')
|
||||||
|
|
||||||
// WorldEdit
|
// WorldEdit
|
||||||
compileOnly (group: 'com.sk89q', name: 'worldedit', version: '7.0.0')
|
compileOnly (group: 'com.sk89q', name: 'worldedit', version: '7.0.0')
|
||||||
|
@ -58,7 +58,7 @@ public class Ban {
|
|||||||
skyblock.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
|
skyblock.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
|
||||||
.getAPIWrapper(),
|
.getAPIWrapper(),
|
||||||
Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned));
|
Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(islandBanEvent);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
|
||||||
|
|
||||||
if (!islandBanEvent.isCancelled()) {
|
if (!islandBanEvent.isCancelled()) {
|
||||||
List<String> islandBans = new ArrayList<>();
|
List<String> islandBans = new ArrayList<>();
|
||||||
|
@ -3,16 +3,25 @@ package me.goodandevil.skyblock.economy;
|
|||||||
import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
|
import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
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.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class EconomyManager {
|
public class EconomyManager {
|
||||||
|
|
||||||
private Economy economy = null;
|
// Vault
|
||||||
private Permission permission = null;
|
private Economy vaultEconomy = null;
|
||||||
|
private Permission vaultPermission = null;
|
||||||
|
|
||||||
|
// Reserve
|
||||||
|
private EconomyAPI reserveEconomy = null;
|
||||||
|
// private PermissionsAPI reservePermission = null;
|
||||||
|
|
||||||
public EconomyManager() {
|
public EconomyManager() {
|
||||||
setup();
|
setup();
|
||||||
@ -23,48 +32,68 @@ public class EconomyManager {
|
|||||||
RegisteredServiceProvider<Economy> economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
|
||||||
if (economyRsp != null)
|
if (economyRsp != null)
|
||||||
economy = economyRsp.getProvider();
|
this.vaultEconomy = economyRsp.getProvider();
|
||||||
|
|
||||||
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
if (permissionRsp != null)
|
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) {
|
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) {
|
public boolean hasBalance(Player player, double money) {
|
||||||
return getBalance(player) >= money;
|
return this.getBalance(player) >= money;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void withdraw(Player player, double money) {
|
public void withdraw(Player player, double money) {
|
||||||
if (economy != null)
|
if (this.vaultEconomy != null)
|
||||||
economy.withdrawPlayer(player, money);
|
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));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deposit(Player player, double money) {
|
public void deposit(Player player, double money) {
|
||||||
if (economy != null) {
|
if (this.vaultEconomy != null)
|
||||||
economy.depositPlayer(player, money);
|
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));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
|
public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
|
||||||
if (permission != null)
|
if (this.vaultPermission != null)
|
||||||
return permission.playerHas(world, offlinePlayer, perm);
|
return this.vaultPermission.playerHas(world, offlinePlayer, perm);
|
||||||
|
|
||||||
|
// if (this.reservePermission != null) {
|
||||||
|
// // TODO
|
||||||
|
// }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEconomy() {
|
public boolean isEconomy() {
|
||||||
return economy != null;
|
return this.vaultEconomy != null || this.reserveEconomy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPermission() {
|
public boolean isPermission() {
|
||||||
return permission != null;
|
return this.vaultPermission != null/* || this.reservePermission != null*/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,11 +75,11 @@ public class GeneratorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLava(Block block) {
|
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) {
|
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) {
|
public boolean isGenerator(Block block) {
|
||||||
@ -98,122 +98,6 @@ public class GeneratorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
@ -256,7 +140,7 @@ public class GeneratorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Materials getRandomMaterials(Generator generator) {
|
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<>();
|
List<Materials> weightedList = new ArrayList<>();
|
||||||
for (GeneratorMaterial generatorMaterial : generator.getGeneratorMaterials())
|
for (GeneratorMaterial generatorMaterial : generator.getGeneratorMaterials())
|
||||||
for (int i = 0; i < generatorMaterial.getChance() * 30; i++)
|
for (int i = 0; i < generatorMaterial.getChance() * 30; i++)
|
||||||
|
@ -219,19 +219,16 @@ public class IslandManager {
|
|||||||
|
|
||||||
skyblock.getPlayerDataManager().getPlayerData(player).setIsland(player.getUniqueId());
|
skyblock.getPlayerDataManager().getPlayerData(player).setIsland(player.getUniqueId());
|
||||||
|
|
||||||
config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
|
||||||
configLoad = config.getFileConfiguration();
|
|
||||||
|
|
||||||
if (scoreboardManager != null) {
|
if (scoreboardManager != null) {
|
||||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
||||||
scoreboard.cancel();
|
scoreboard.cancel();
|
||||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||||
configLoad.getString("Scoreboard.Island.Solo.Displayname")));
|
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||||
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||||
scoreboard.run();
|
scoreboard.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
|
||||||
if (structure.getCommands() != null) {
|
if (structure.getCommands() != null) {
|
||||||
for (String commandList : structure.getCommands()) {
|
for (String commandList : structure.getCommands()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||||
@ -241,7 +238,7 @@ public class IslandManager {
|
|||||||
|
|
||||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||||
player.setFallDistance(0.0F);
|
player.setFallDistance(0.0F);
|
||||||
});
|
}, configLoad.getInt("Island.Creation.TeleportTimeout") * 20);
|
||||||
|
|
||||||
String biomeName = fileManager
|
String biomeName = fileManager
|
||||||
.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||||
|
@ -7,6 +7,7 @@ import me.goodandevil.skyblock.island.Island;
|
|||||||
import me.goodandevil.skyblock.island.IslandLevel;
|
import me.goodandevil.skyblock.island.IslandLevel;
|
||||||
import me.goodandevil.skyblock.island.IslandManager;
|
import me.goodandevil.skyblock.island.IslandManager;
|
||||||
import me.goodandevil.skyblock.island.IslandWorld;
|
import me.goodandevil.skyblock.island.IslandWorld;
|
||||||
|
import me.goodandevil.skyblock.message.MessageManager;
|
||||||
import me.goodandevil.skyblock.stackable.Stackable;
|
import me.goodandevil.skyblock.stackable.Stackable;
|
||||||
import me.goodandevil.skyblock.stackable.StackableManager;
|
import me.goodandevil.skyblock.stackable.StackableManager;
|
||||||
import me.goodandevil.skyblock.utils.version.Materials;
|
import me.goodandevil.skyblock.utils.version.Materials;
|
||||||
@ -31,9 +32,11 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -41,7 +44,8 @@ public class LevellingManager {
|
|||||||
|
|
||||||
private final SkyBlock skyblock;
|
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<>();
|
private List<LevellingMaterial> materialStorage = new ArrayList<>();
|
||||||
|
|
||||||
public LevellingManager(SkyBlock skyblock) {
|
public LevellingManager(SkyBlock skyblock) {
|
||||||
@ -53,17 +57,29 @@ public class LevellingManager {
|
|||||||
public void calculatePoints(Player player, Island island) {
|
public void calculatePoints(Player player, Island island) {
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
|
MessageManager messageManager = skyblock.getMessageManager();
|
||||||
StackableManager stackableManager = skyblock.getStackableManager();
|
StackableManager stackableManager = skyblock.getStackableManager();
|
||||||
|
|
||||||
if (player != null && islandManager.getIslandPlayerAt(player) != island) {
|
FileConfiguration languageConfig = this.skyblock.getFileManager().getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||||
String message = ChatColor.translateAlternateColorCodes('&', this.skyblock.getFileManager()
|
|
||||||
.getConfig(new File(this.skyblock.getDataFolder(), "language.yml"))
|
if (!this.isIslandLevelBeingScanned(island) && player != null && islandManager.getIslandPlayerAt(player) != island) {
|
||||||
.getFileConfiguration().getString("Command.Island.Level.Scanning.NotOnIsland.Message"));
|
messageManager.sendMessage(player, languageConfig.getString("Command.Island.Level.Scanning.NotOnIsland.Message"));
|
||||||
player.sendMessage(message);
|
|
||||||
return;
|
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 chunk = new Chunk(skyblock, island);
|
||||||
chunk.prepareInitial();
|
chunk.prepareInitial();
|
||||||
@ -100,8 +116,10 @@ public class LevellingManager {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!chunk.isReadyToScan()) return;
|
if (!chunk.isReadyToScan())
|
||||||
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
if (chunk.isFinished()) {
|
if (chunk.isFinished()) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, epicSpawnerLocations, ultimateStackerSpawnerLocations, player, island), 1);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, epicSpawnerLocations, ultimateStackerSpawnerLocations, player, island), 1);
|
||||||
cancel();
|
cancel();
|
||||||
@ -153,7 +171,7 @@ public class LevellingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chunkSnapshotList.hasWildStackerData()) {
|
if (chunkSnapshotList.hasWildStackerData()) {
|
||||||
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper)chunkSnapshotList).getStackedSnapshot();
|
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper) chunkSnapshotList).getStackedSnapshot();
|
||||||
if (snapshot.isStackedSpawner(location)) {
|
if (snapshot.isStackedSpawner(location)) {
|
||||||
Map.Entry<Integer, EntityType> spawnerData = snapshot.getStackedSpawner(location);
|
Map.Entry<Integer, EntityType> spawnerData = snapshot.getStackedSpawner(location);
|
||||||
amount = spawnerData.getKey();
|
amount = spawnerData.getKey();
|
||||||
@ -167,7 +185,7 @@ public class LevellingManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (chunkSnapshotList.hasWildStackerData()) {
|
if (chunkSnapshotList.hasWildStackerData()) {
|
||||||
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper)chunkSnapshotList).getStackedSnapshot();
|
com.bgsoftware.wildstacker.api.objects.StackedSnapshot snapshot = ((WildStackerChunkSnapshotWrapper) chunkSnapshotList).getStackedSnapshot();
|
||||||
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
|
World world = Bukkit.getWorld(chunkSnapshot.getWorldName());
|
||||||
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
|
Location location = new Location(world, chunkSnapshot.getX() * 16 + x, y, chunkSnapshot.getZ() * 16 + z);
|
||||||
if (snapshot.isStackedBarrel(location)) {
|
if (snapshot.isStackedBarrel(location)) {
|
||||||
@ -205,6 +223,9 @@ public class LevellingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
}.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() {
|
public void registerMaterials() {
|
||||||
@ -307,7 +336,7 @@ public class LevellingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIslandLevelBeingScanned(Island island) {
|
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() {
|
public void unregisterMaterials() {
|
||||||
@ -385,4 +414,22 @@ public class LevellingManager {
|
|||||||
return Materials.getMaterials(this.material, this.data);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ public class Block implements Listener {
|
|||||||
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||||
boolean isObstructing = false;
|
boolean isObstructing = false;
|
||||||
// Directly on the block
|
// Directly on the block
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
isObstructing = true;
|
isObstructing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ public class Block implements Listener {
|
|||||||
if (!isObstructing && event.getBlock().getState().getData() instanceof org.bukkit.material.Bed) {
|
if (!isObstructing && event.getBlock().getState().getData() instanceof org.bukkit.material.Bed) {
|
||||||
BlockFace bedDirection = ((org.bukkit.material.Bed) event.getBlock().getState().getData()).getFacing();
|
BlockFace bedDirection = ((org.bukkit.material.Bed) event.getBlock().getState().getData()).getFacing();
|
||||||
org.bukkit.block.Block bedBlock = block.getRelative(bedDirection);
|
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;
|
isObstructing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ public class Block implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Protect spawn
|
// 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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -391,13 +391,13 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||||
// Check exact block
|
// Check exact block
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check block in direction
|
// 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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
// Check piston head
|
// Check piston head
|
||||||
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||||
if (LocationUtil.isLocationAffectingLocation(event.getBlock().getRelative(event.getDirection()).getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(event.getBlock().getRelative(event.getDirection()).getLocation(), island, world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ public class Block implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -586,7 +586,7 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main))) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -660,7 +660,7 @@ public class Block implements Listener {
|
|||||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
||||||
|
|
||||||
for (org.bukkit.block.BlockState block : event.getBlocks()) {
|
for (org.bukkit.block.BlockState block : event.getBlocks()) {
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -687,10 +687,9 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
||||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
|
||||||
|
|
||||||
for (BlockState block : blocks) {
|
for (BlockState block : blocks) {
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -708,10 +707,9 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(blocks.get(0).getWorld());
|
IslandWorld world = worldManager.getIslandWorld(blocks.get(0).getWorld());
|
||||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
|
||||||
|
|
||||||
for (org.bukkit.block.Block block : blocks) {
|
for (org.bukkit.block.Block block : blocks) {
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -739,9 +737,8 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(placeLocation.getWorld());
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,7 @@ public class Bucket implements Listener {
|
|||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
skyblock.getMessageManager().sendMessage(player,
|
skyblock.getMessageManager().sendMessage(player,
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
|
@ -418,8 +418,8 @@ public class Entity implements Listener {
|
|||||||
org.bukkit.block.Block block = event.getBlock();
|
org.bukkit.block.Block block = event.getBlock();
|
||||||
|
|
||||||
// Check spawn block falling, this can be a bit glitchy, but it's better than nothing
|
// 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(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0, 1, 0))
|
||||||
if (LocationUtil.isLocationLocation(block.getLocation(), islandLocation.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")) {
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -451,7 +451,7 @@ public class Entity implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Check entities interacting with spawn
|
// 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")) {
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -112,7 +112,7 @@ public class Interact implements Listener {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (block.getState() instanceof Cauldron) { // WildStacker stackables
|
} else if (block.getType() == Material.CAULDRON) { // WildStacker stackables
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "Place") || !islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "Place") || !islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ public class Interact implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getItem() != null && event.getItem().getType() == Material.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
if (event.getItem() != null && event.getItem().getType() == Materials.BONE_MEAL.parseMaterial() && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
||||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -587,7 +587,7 @@ public class Interact implements Listener {
|
|||||||
player.updateInventory();
|
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")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "SpawnEgg")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class Teleport implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCause) {
|
if (isCause && event.getCause() != TeleportCause.ENDER_PEARL) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class Bans {
|
|||||||
nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
|
nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
|
||||||
ChatColor.translateAlternateColorCodes('&',
|
ChatColor.translateAlternateColorCodes('&',
|
||||||
configLoad.getString("Menu.Bans.Item.Ban.Displayname")
|
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),
|
configLoad.getStringList("Menu.Bans.Item.Ban.Lore"), null, null, null),
|
||||||
inventorySlot);
|
inventorySlot);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -31,7 +32,7 @@ public class Stackable {
|
|||||||
|
|
||||||
public Stackable(Location location, Material material) {
|
public Stackable(Location location, Material material) {
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
this.location = location;
|
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
SkyBlock.getInstance().getSoundManager().playSound(location, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
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) {
|
public Stackable(UUID uuid, Location location, Material material, int size) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.location = location;
|
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
@ -78,22 +79,25 @@ public class Stackable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addOne() {
|
public void addOne() {
|
||||||
this.size ++;
|
this.size++;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takeOne() {
|
public void takeOne() {
|
||||||
this.size --;
|
this.size--;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
SkyBlock.getInstance().getSoundManager().playSound(this.location, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay() {
|
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) {
|
if (this.size > 1) {
|
||||||
this.removeDisplay();
|
|
||||||
this.createDisplay();
|
this.createDisplay();
|
||||||
this.display.setCustomName(this.getCustomName());
|
this.display.setCustomName(this.getCustomName());
|
||||||
this.display.setCustomNameVisible(true);
|
this.display.setCustomNameVisible(true);
|
||||||
@ -126,12 +130,10 @@ public class Stackable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find any stragglers
|
// 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)) {
|
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.isValid()) {
|
if (entity instanceof ArmorStand)
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
File configFile = new File(SkyBlock.getInstance().getDataFolder().toString() + "/island-data");
|
File configFile = new File(SkyBlock.getInstance().getDataFolder().toString() + "/island-data");
|
||||||
|
@ -1059,6 +1059,8 @@ public enum Materials {
|
|||||||
String old12Mat;
|
String old12Mat;
|
||||||
int data;
|
int data;
|
||||||
boolean is13Plusonly;
|
boolean is13Plusonly;
|
||||||
|
private Material cachedMaterial;
|
||||||
|
private boolean isMaterialParsed = false;
|
||||||
|
|
||||||
Materials(String old13Mat, String old12Mat, int data) {
|
Materials(String old13Mat, String old12Mat, int data) {
|
||||||
this(old13Mat, old12Mat, data, false);
|
this(old13Mat, old12Mat, data, false);
|
||||||
@ -1129,7 +1131,24 @@ public enum Materials {
|
|||||||
|
|
||||||
Materials pmat = null;
|
Materials pmat = null;
|
||||||
|
|
||||||
|
// Try 1.13+ names
|
||||||
for (Materials mat : Materials.values()) {
|
for (Materials mat : Materials.values()) {
|
||||||
|
if (name.equalsIgnoreCase(mat.name())) {
|
||||||
|
if (pmat == null) {
|
||||||
|
pmat = mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((byte) mat.data) == data) {
|
||||||
|
cachedSearch.put(mat.name() + "," + data, mat);
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try 1.12- names
|
||||||
|
for (Materials mat : Materials.values()) {
|
||||||
|
if (name.equalsIgnoreCase(mat.name()))
|
||||||
|
|
||||||
if (name.equalsIgnoreCase(mat.old12Mat)) {
|
if (name.equalsIgnoreCase(mat.old12Mat)) {
|
||||||
if (pmat == null) {
|
if (pmat == null) {
|
||||||
pmat = mat;
|
pmat = mat;
|
||||||
@ -1142,13 +1161,9 @@ public enum Materials {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmat != null) {
|
|
||||||
return pmat;
|
return pmat;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSpawner() {
|
public boolean isSpawner() {
|
||||||
return this.name().startsWith("SPAWNER");
|
return this.name().startsWith("SPAWNER");
|
||||||
}
|
}
|
||||||
@ -1236,20 +1251,31 @@ public enum Materials {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Material parseMaterial() {
|
public Material parseMaterial() {
|
||||||
if (this.isSpawner() && this != Materials.SPAWNER)
|
if (this.cachedMaterial != null || this.isMaterialParsed)
|
||||||
return Materials.SPAWNER.parseMaterial();
|
return this.cachedMaterial;
|
||||||
|
|
||||||
|
if (this.isSpawner() && this != Materials.SPAWNER) {
|
||||||
|
this.cachedMaterial = Materials.SPAWNER.parseMaterial();
|
||||||
|
return this.cachedMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
Material mat = Material.matchMaterial(this.toString());
|
Material mat = Material.matchMaterial(this.toString());
|
||||||
if (mat != null)
|
if (mat != null) {
|
||||||
return mat;
|
this.cachedMaterial = mat;
|
||||||
|
return this.cachedMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
if (old13Mat != null) {
|
if (old13Mat != null) {
|
||||||
mat = Material.matchMaterial(old13Mat);
|
mat = Material.matchMaterial(old13Mat);
|
||||||
if (mat != null)
|
if (mat != null) {
|
||||||
return mat;
|
this.cachedMaterial = mat;
|
||||||
|
return this.cachedMaterial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Material.matchMaterial(old12Mat);
|
this.cachedMaterial = Material.matchMaterial(old12Mat);
|
||||||
|
this.isMaterialParsed = true;
|
||||||
|
return this.cachedMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material getPostMaterial() {
|
public Material getPostMaterial() {
|
||||||
|
@ -4,7 +4,9 @@ import me.goodandevil.skyblock.SkyBlock;
|
|||||||
import me.goodandevil.skyblock.config.FileManager;
|
import me.goodandevil.skyblock.config.FileManager;
|
||||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||||
import me.goodandevil.skyblock.island.Island;
|
import me.goodandevil.skyblock.island.Island;
|
||||||
|
import me.goodandevil.skyblock.island.IslandEnvironment;
|
||||||
import me.goodandevil.skyblock.island.IslandManager;
|
import me.goodandevil.skyblock.island.IslandManager;
|
||||||
|
import me.goodandevil.skyblock.island.IslandWorld;
|
||||||
import me.goodandevil.skyblock.utils.math.VectorUtil;
|
import me.goodandevil.skyblock.utils.math.VectorUtil;
|
||||||
import me.goodandevil.skyblock.utils.version.Materials;
|
import me.goodandevil.skyblock.utils.version.Materials;
|
||||||
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
|
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
|
||||||
@ -32,7 +34,12 @@ public final class LocationUtil {
|
|||||||
return false;
|
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 headHeight = location2.clone().add(0, 1, 0);
|
||||||
Location feetHeight = location2.clone();
|
Location feetHeight = location2.clone();
|
||||||
Location groundHeight = location2.clone().add(0, -1, 0);
|
Location groundHeight = location2.clone().add(0, -1, 0);
|
||||||
|
@ -34,6 +34,8 @@ Island:
|
|||||||
Enable: true
|
Enable: true
|
||||||
# Time until player can create another island.
|
# Time until player can create another island.
|
||||||
Time: 60
|
Time: 60
|
||||||
|
# [!] How many seconds to wait before teleporting to a newly created island
|
||||||
|
TeleportTimeout: 1
|
||||||
World:
|
World:
|
||||||
# Delete the Island world when changing the liquid option.
|
# Delete the Island world when changing the liquid option.
|
||||||
# If lava disabled, the world will be a water world.
|
# If lava disabled, the world will be a water world.
|
||||||
|
@ -84,6 +84,12 @@ Command:
|
|||||||
Message: '&bSkyBlock &8| &cError&8: &eYou cannot initiate an Island level scan without being on your Island.'
|
Message: '&bSkyBlock &8| &cError&8: &eYou cannot initiate an Island level scan without being on your Island.'
|
||||||
BlockPlacing:
|
BlockPlacing:
|
||||||
Message: '&bSkyBlock &8 | &cError:&8: &eYou cannot place blocks during an Island level scan. Please wait for the scan to finish.'
|
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:
|
Cooldown:
|
||||||
Word:
|
Word:
|
||||||
Minute: minute(s)
|
Minute: minute(s)
|
||||||
|
@ -4,7 +4,7 @@ version: @version@
|
|||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: A unique SkyBlock plugin
|
description: A unique SkyBlock plugin
|
||||||
author: Songoda
|
author: Songoda
|
||||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
|
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
|
||||||
loadbefore: [Multiverse-Core]
|
loadbefore: [Multiverse-Core]
|
||||||
commands:
|
commands:
|
||||||
island:
|
island:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
allprojects {
|
allprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
group = 'com.goodandevil.skyblock'
|
group = 'com.goodandevil.skyblock'
|
||||||
version = 'Build-78'
|
version = 'Build-78.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
@ -14,6 +14,10 @@ subprojects {
|
|||||||
maven {
|
maven {
|
||||||
url = 'http://repo.songoda.com/artifactory/private'
|
url = 'http://repo.songoda.com/artifactory/private'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = 'https://jitpack.io'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user