mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-19 10:20:59 +02:00
Merge branch 'development' into 'master'
Build 77 See merge request Songoda/fabledskyblock!16
This commit is contained in:
commit
f91755125a
17
build.gradle
17
build.gradle
@ -2,7 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
|
||||
apply plugin: 'java'
|
||||
|
||||
group 'com.songoda.fabledskyblock'
|
||||
version 'Build-75'
|
||||
version 'Build-77'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
@ -32,10 +32,16 @@ dependencies {
|
||||
implementation (group: 'me.robin', name: 'leaderheads', version: '1.0')
|
||||
|
||||
// EpicSpawners
|
||||
implementation (group: 'com.songoda', name: 'epicspawners', version: '5.7.1')
|
||||
implementation (group: 'com.songoda', name: 'epicspawners', version: '6-pre4')
|
||||
|
||||
// EpicAnchors
|
||||
implementation (group: 'com.songoda', name: 'epicanchors', version: '1.2.5')
|
||||
|
||||
// UltimateStacker
|
||||
implementation (group: 'com.songoda', name: 'ultimatestacker', version: '1.3.1')
|
||||
|
||||
// WildStacker
|
||||
implementation (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b14')
|
||||
implementation (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b15')
|
||||
|
||||
// WorldEdit
|
||||
implementation (group: 'com.sk89q', name: 'worldedit', version: '7.0.0')
|
||||
@ -44,11 +50,14 @@ dependencies {
|
||||
shade (group: 'org.apache.commons', name: 'commons-lang3', version: '3.0')
|
||||
shade (group: 'commons-io', name: 'commons-io', version: '2.5')
|
||||
|
||||
// JetBrains Annotations
|
||||
compile (group: 'org.jetbrains', name: 'annotations', version: '13.0')
|
||||
|
||||
// Songoda Updater
|
||||
shade (group: 'com.songoda', name: 'songodaupdater', version: '1')
|
||||
|
||||
// Spigot
|
||||
implementation (group: 'org.spigotmc', name: 'spigot', version: '1.14')
|
||||
implementation (group: 'org.spigotmc', name: 'spigot', version: '1.14.1')
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
#Wed Jun 05 03:45:54 MDT 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
|
||||
|
@ -17,6 +17,7 @@ import me.goodandevil.skyblock.invite.InviteManager;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.listeners.*;
|
||||
import me.goodandevil.skyblock.menus.Rollback;
|
||||
import me.goodandevil.skyblock.menus.admin.Creator;
|
||||
@ -61,6 +62,7 @@ public class SkyBlock extends JavaPlugin {
|
||||
private UpgradeManager upgradeManager;
|
||||
private PlayerDataManager playerDataManager;
|
||||
private CooldownManager cooldownManager;
|
||||
private LimitManager limitManager;
|
||||
private ScoreboardManager scoreboardManager;
|
||||
private InviteManager inviteManager;
|
||||
private BiomeManager biomeManager;
|
||||
@ -96,6 +98,7 @@ public class SkyBlock extends JavaPlugin {
|
||||
upgradeManager = new UpgradeManager(this);
|
||||
playerDataManager = new PlayerDataManager(this);
|
||||
cooldownManager = new CooldownManager(this);
|
||||
limitManager = new LimitManager(this);
|
||||
|
||||
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Scoreboard.Enable")) {
|
||||
@ -155,6 +158,8 @@ public class SkyBlock extends JavaPlugin {
|
||||
pluginManager.registerEvents(new EpicSpawners(this), this);
|
||||
if (pluginManager.isPluginEnabled("WildStacker"))
|
||||
pluginManager.registerEvents(new WildStacker(this), this);
|
||||
if (pluginManager.isPluginEnabled("UltimateStacker"))
|
||||
pluginManager.registerEvents(new UltimateStacker(this), this);
|
||||
|
||||
pluginManager.registerEvents(new Rollback(), this);
|
||||
pluginManager.registerEvents(new Levelling(), this);
|
||||
@ -256,6 +261,10 @@ public class SkyBlock extends JavaPlugin {
|
||||
return cooldownManager;
|
||||
}
|
||||
|
||||
public LimitManager getLimitManager() {
|
||||
return limitManager;
|
||||
}
|
||||
|
||||
public ScoreboardManager getScoreboardManager() {
|
||||
return scoreboardManager;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import me.goodandevil.skyblock.hologram.HologramManager;
|
||||
import me.goodandevil.skyblock.hologram.HologramType;
|
||||
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
@ -39,13 +40,14 @@ public class ReloadCommand extends SubCommand {
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
|
||||
"cause issues that could put the plugin in an unstable state. " +
|
||||
"If you encounter any issues please stop your server, edit the configuration files, " +
|
||||
"and then start your server again. This command does NOT reload all the plugin files, only " +
|
||||
"the config.yml, language.yml, generators.yml, and levelling.yml.");
|
||||
"the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -94,6 +96,8 @@ public class ReloadCommand extends SubCommand {
|
||||
|
||||
hologramManager.resetHologram();
|
||||
|
||||
limitManager.reload();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandRole;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.player.OfflinePlayer;
|
||||
@ -45,6 +46,9 @@ public class BanCommand extends SubCommand {
|
||||
&& island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
@ -52,6 +56,9 @@ public class BanCommand extends SubCommand {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
|
||||
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
|
@ -32,6 +32,17 @@ public class ChatCommand extends SubCommand {
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
if (playerData.isChat() && island != null) {
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false));
|
||||
playerData.setChat(false);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message"));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
@ -42,23 +53,12 @@ public class ChatCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true));
|
||||
playerData.setChat(true);
|
||||
|
||||
if (playerData.isChat()) {
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false));
|
||||
playerData.setChat(false);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message"));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true));
|
||||
playerData.setChat(true);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message"));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message"));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,11 @@ public class CoopCommand extends SubCommand {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = offlinePlayer.getUniqueId();
|
||||
targetPlayerName = offlinePlayer.getName();
|
||||
|
||||
if (targetPlayerUUID != null && !Bukkit.getOfflinePlayer(targetPlayerUUID).hasPlayedBefore()) {
|
||||
targetPlayerUUID = null;
|
||||
targetPlayerName = null;
|
||||
}
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
|
@ -49,6 +49,9 @@ public class KickAllCommand extends SubCommand {
|
||||
for (UUID islandVisitorList : islandVisitors) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitorList);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
continue;
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
Bukkit.getServer().getOfflinePlayer(islandVisitorList), player);
|
||||
|
@ -8,6 +8,7 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandRole;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
@ -58,6 +59,9 @@ public class KickCommand extends SubCommand {
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
|
||||
Set<UUID> islandMembers = island.getRole(IslandRole.Member),
|
||||
islandOperators = island.getRole(IslandRole.Operator),
|
||||
islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
@ -66,6 +70,9 @@ public class KickCommand extends SubCommand {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
|
||||
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
|
@ -70,7 +70,7 @@ public class SetSpawnCommand extends SubCommand {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (location.getY() - location.getBlockY() != 0.0D) {
|
||||
} else if (!player.getLocation().clone().subtract(0, 0.1, 0).getBlock().getType().isSolid()) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
@ -92,11 +92,13 @@ public class SetSpawnCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
|
||||
Material type = location.getBlock().getType();
|
||||
if (type.isSolid() && type.isOccluding()) {
|
||||
location.getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
if (location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
|
||||
Material typeBelow = location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType();
|
||||
if (typeBelow.isSolid() && type.isOccluding()) {
|
||||
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
@ -104,7 +106,7 @@ public class SetSpawnCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
Location newSpawnLocation = new Location(location.getWorld(), location.getBlockX() + 0.5, location.getBlockY(), location.getBlockZ() + 0.5, location.getYaw(), location.getPitch());
|
||||
Location newSpawnLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
island.setLocation(world, environment, newSpawnLocation);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
|
@ -6,6 +6,7 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.economy.EconomyManager;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
@ -51,6 +52,7 @@ public class UnlockCommand extends SubCommand {
|
||||
}
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
IslandWorld islandWorld = IslandWorld.valueOf(type);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Owner.Message"));
|
||||
@ -58,21 +60,15 @@ public class UnlockCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Config islandData = fileManager
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
||||
island.getOwnerUUID().toString() + ".yml"));
|
||||
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
|
||||
double price = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getDouble("Island.World." + type + ".UnlockPrice");
|
||||
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type);
|
||||
|
||||
if (unlocked) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Unlocked.Message").replace(
|
||||
"%type%", type));
|
||||
if (islandManager.isIslandWorldUnlocked(island, islandWorld)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Unlocked.Message").replace("%type%", type));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
double price = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
|
||||
|
||||
if (!economyManager.hasBalance(player, price)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Money.Message").replace(
|
||||
"%cost%", NumberUtil.formatNumberByDecimal(price)));
|
||||
@ -81,9 +77,10 @@ public class UnlockCommand extends SubCommand {
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||
configLoadIslandData.set("Unlocked." + type, true);
|
||||
economyManager.withdraw(player, price);
|
||||
|
||||
islandManager.unlockIslandWorld(island, islandWorld);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Finish.Message").replace(
|
||||
"%type%", type));
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public class FileManager {
|
||||
}
|
||||
|
||||
Map<String, File> configFiles = new LinkedHashMap<>();
|
||||
configFiles.put("limits.yml", new File(skyblock.getDataFolder(), "limits.yml"));
|
||||
configFiles.put("worlds.yml", new File(skyblock.getDataFolder(), "worlds.yml"));
|
||||
configFiles.put("levelling.yml", new File(skyblock.getDataFolder(), "levelling.yml"));
|
||||
configFiles.put("config.yml", new File(skyblock.getDataFolder(), "config.yml"));
|
||||
|
@ -12,6 +12,7 @@ import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.upgrade.Upgrade;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import me.goodandevil.skyblock.utils.world.LocationUtil;
|
||||
import me.goodandevil.skyblock.utils.world.WorldBorder;
|
||||
import me.goodandevil.skyblock.visit.Visit;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
@ -804,8 +805,7 @@ public class Island {
|
||||
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
|
||||
double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice");
|
||||
|
||||
boolean unlocked =
|
||||
configLoadIslandData.getBoolean("Unlocked." + type);
|
||||
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type);
|
||||
if (price == -1) {
|
||||
configLoadIslandData.set("Unlocked." + type, true);
|
||||
unlocked = true;
|
||||
|
@ -214,7 +214,8 @@ public class IslandManager {
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () ->
|
||||
Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player)));
|
||||
|
||||
skyblock.getPlayerDataManager().getPlayerData(player).setIsland(player.getUniqueId());
|
||||
|
||||
@ -256,6 +257,11 @@ public class IslandManager {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getBiomeManager()
|
||||
.setBiome(island, biome), 20L);
|
||||
|
||||
// Recalculate island level after 5 seconds
|
||||
if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -549,11 +555,12 @@ public class IslandManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadIslandAtLocation(Location location) {
|
||||
public Island loadIslandAtLocation(Location location) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
||||
|
||||
if (!configFile.exists()) return;
|
||||
if (!configFile.exists())
|
||||
return null;
|
||||
|
||||
for (File fileList : configFile.listFiles()) {
|
||||
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
|
||||
@ -570,14 +577,15 @@ public class IslandManager {
|
||||
|
||||
if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) {
|
||||
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
|
||||
this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
return;
|
||||
return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {
|
||||
@ -684,8 +692,7 @@ public class IslandManager {
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(
|
||||
new File(skyblock.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml"));
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml"));
|
||||
|
||||
if (config.getFileConfiguration().getString("Location." + world.name()) == null) {
|
||||
pasteStructure(island, world);
|
||||
@ -712,18 +719,22 @@ public class IslandManager {
|
||||
|
||||
public void resetIsland(Island island) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
pasteStructure(island, worldList);
|
||||
if (isIslandWorldUnlocked(island, worldList)) {
|
||||
pasteStructure(island, worldList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pasteStructure(Island island, IslandWorld world) {
|
||||
if (!isIslandWorldUnlocked(island, world))
|
||||
return;
|
||||
|
||||
StructureManager structureManager = skyblock.getStructureManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Structure structure;
|
||||
|
||||
if (island.getStructure() != null && !island.getStructure().isEmpty()
|
||||
&& structureManager.containsStructure(island.getStructure())) {
|
||||
if (island.getStructure() != null && !island.getStructure().isEmpty() && structureManager.containsStructure(island.getStructure())) {
|
||||
structure = structureManager.getStructure(island.getStructure());
|
||||
} else {
|
||||
structure = structureManager.getStructures().get(0);
|
||||
@ -737,17 +748,14 @@ public class IslandManager {
|
||||
for (IslandEnvironment environmentList : IslandEnvironment.values()) {
|
||||
if (environmentList == IslandEnvironment.Island) {
|
||||
island.addLocation(world, environmentList, islandLocation);
|
||||
fileManager.setLocation(config, "Location." + world.name() + "." + environmentList.name(),
|
||||
islandLocation, true);
|
||||
fileManager.setLocation(config, "Location." + world.name() + "." + environmentList.name(), islandLocation, true);
|
||||
} else {
|
||||
island.addLocation(world, environmentList, islandLocation.clone().add(0.5D, 0.0D, 0.5D));
|
||||
fileManager.setLocation(config, "Location." + world.name() + ".Spawn." + environmentList.name(),
|
||||
islandLocation.clone().add(0.5D, 0.0D, 0.5D), true);
|
||||
fileManager.setLocation(config, "Location." + world.name() + ".Spawn." + environmentList.name(), islandLocation.clone().add(0.5D, 0.0D, 0.5D), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Spawn.Protection")) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE));
|
||||
}
|
||||
|
||||
@ -787,9 +795,58 @@ public class IslandManager {
|
||||
|
||||
setNextAvailableLocation(world, islandLocation);
|
||||
saveNextAvailableLocation(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks an island world and pastes the island structure there
|
||||
*
|
||||
* @param island The island to unlock for
|
||||
* @param islandWorld The island world type to unlock
|
||||
*/
|
||||
public void unlockIslandWorld(Island island, IslandWorld islandWorld) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
Config islandData = fileManager
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
||||
island.getOwnerUUID().toString() + ".yml"));
|
||||
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
|
||||
|
||||
configLoadIslandData.set("Unlocked." + islandWorld.name(), true);
|
||||
|
||||
pasteStructure(island, islandWorld);
|
||||
|
||||
// Recalculate island level after 5 seconds
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
|
||||
if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an island world is unlocked
|
||||
*
|
||||
* @param island The island to check
|
||||
* @param islandWorld The island world to check
|
||||
* @return true if the island world is unlocked, otherwise false
|
||||
*/
|
||||
public boolean isIslandWorldUnlocked(Island island, IslandWorld islandWorld) {
|
||||
if (islandWorld == IslandWorld.Normal)
|
||||
return true;
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
Config islandData = fileManager
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
||||
island.getOwnerUUID().toString() + ".yml"));
|
||||
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
|
||||
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.name());
|
||||
|
||||
if (!unlocked) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
double price = configLoad.getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
|
||||
if (price == -1)
|
||||
unlocked = true;
|
||||
}
|
||||
|
||||
return unlocked;
|
||||
}
|
||||
|
||||
public Set<UUID> getVisitorsAtIsland(Island island) {
|
||||
@ -1169,18 +1226,18 @@ public class IslandManager {
|
||||
if (isFlyUpgradeEnabled) {
|
||||
boolean upgradeEnabled = island != null && island.isUpgrade(Upgrade.Type.Fly);
|
||||
setPlayerFlying = upgradeEnabled;
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
player.setAllowFlight(upgradeEnabled);
|
||||
});
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> player.setAllowFlight(upgradeEnabled));
|
||||
}
|
||||
|
||||
boolean hasFlyPermission = player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.*");
|
||||
if (hasFlyPermission && island != null && !setPlayerFlying) {
|
||||
if (island == null || setPlayerFlying)
|
||||
return;
|
||||
|
||||
boolean hasGlobalFlyPermission = player.hasPermission("fabledskyblock.*") || player.hasPermission("fabledskyblock.fly.*");
|
||||
boolean hasOwnIslandFlyPermission = player.hasPermission("fabledskyblock.fly") && island.getRole(player) != null && island.getRole(player) != IslandRole.Visitor;
|
||||
if (hasGlobalFlyPermission || hasOwnIslandFlyPermission) {
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
boolean canFlyInWorld = worldManager.isIslandWorld(player.getWorld());
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
player.setAllowFlight(canFlyInWorld);
|
||||
});
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> player.setAllowFlight(canFlyInWorld));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1341,6 +1398,14 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
public boolean isLocationAtIsland(Island island, org.bukkit.Location location, IslandWorld world) {
|
||||
return LocationUtil.isLocationAtLocationRadius(location, island.getLocation(world, IslandEnvironment.Island), island.getRadius());
|
||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Island);
|
||||
if (islandLocation == null)
|
||||
return false;
|
||||
|
||||
double size = island.getRadius();
|
||||
if (size % 2 == 1)
|
||||
size++;
|
||||
|
||||
return LocationUtil.isLocationAtLocationRadius(location.clone().add(0.5, 0, 0.5), islandLocation, size);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class LeaderboardManager {
|
||||
|
||||
if (enableExemptions && economyManager.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(),
|
||||
Bukkit.getOfflinePlayer(ownerUUID),
|
||||
"fabledskyblock.island.top.exempt"))
|
||||
"fabledskyblock.top.exempt"))
|
||||
continue;
|
||||
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
|
@ -29,7 +29,7 @@ public class Chunk {
|
||||
|
||||
private int initialNumberOfChunks = -1;
|
||||
private Set<ChunkPosition> chunkPositions = new HashSet<>();
|
||||
private Set<ChunkSnapshot> chunkSnapshots = new HashSet<>();
|
||||
private Set<LevelChunkSnapshotWrapper> chunkSnapshots = new HashSet<>();
|
||||
private boolean isReady = false;
|
||||
private boolean isFinished = false;
|
||||
|
||||
@ -62,7 +62,7 @@ public class Chunk {
|
||||
return this.isReady;
|
||||
}
|
||||
|
||||
public Set<ChunkSnapshot> getAvailableChunkSnapshots() {
|
||||
public Set<LevelChunkSnapshotWrapper> getAvailableChunkSnapshots() {
|
||||
this.isReady = false;
|
||||
return this.chunkSnapshots;
|
||||
}
|
||||
@ -72,6 +72,8 @@ public class Chunk {
|
||||
}
|
||||
|
||||
public void prepareNextChunkSnapshots() {
|
||||
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
||||
|
||||
Bukkit.getScheduler().runTask(this.skyblock, () -> {
|
||||
this.chunkSnapshots.clear();
|
||||
|
||||
@ -93,10 +95,22 @@ public class Chunk {
|
||||
int z = chunkPosition.getZ();
|
||||
if (!world.isChunkLoaded(x, z)) {
|
||||
world.loadChunk(x, z);
|
||||
this.chunkSnapshots.add(world.getChunkAt(x, z).getChunkSnapshot());
|
||||
org.bukkit.Chunk chunk = world.getChunkAt(x, z);
|
||||
ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot();
|
||||
if (isWildStackerEnabled) {
|
||||
this.chunkSnapshots.add(new WildStackerChunkSnapshotWrapper(chunkSnapshot, com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager().getStackedSnapshot(chunk, true)));
|
||||
} else {
|
||||
this.chunkSnapshots.add(new ChunkSnapshotWrapper(chunkSnapshot));
|
||||
}
|
||||
world.unloadChunk(x, z);
|
||||
} else {
|
||||
this.chunkSnapshots.add(world.getChunkAt(x, z).getChunkSnapshot());
|
||||
org.bukkit.Chunk chunk = world.getChunkAt(x, z);
|
||||
ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot();
|
||||
if (isWildStackerEnabled) {
|
||||
this.chunkSnapshots.add(new WildStackerChunkSnapshotWrapper(chunkSnapshot, com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager().getStackedSnapshot(chunk, true)));
|
||||
} else {
|
||||
this.chunkSnapshots.add(new ChunkSnapshotWrapper(chunkSnapshot));
|
||||
}
|
||||
}
|
||||
it.remove();
|
||||
}
|
||||
@ -148,27 +162,4 @@ public class Chunk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ChunkPosition {
|
||||
private World world;
|
||||
private int x, z;
|
||||
|
||||
public ChunkPosition(World world, int x, int z) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package me.goodandevil.skyblock.levelling;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
public class ChunkPosition {
|
||||
private World world;
|
||||
private int x, z;
|
||||
|
||||
public ChunkPosition(World world, int x, int z) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package me.goodandevil.skyblock.levelling;
|
||||
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
|
||||
public class ChunkSnapshotWrapper extends LevelChunkSnapshotWrapper {
|
||||
|
||||
public ChunkSnapshotWrapper(ChunkSnapshot chunkSnapshot) {
|
||||
super(chunkSnapshot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWildStackerData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package me.goodandevil.skyblock.levelling;
|
||||
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
|
||||
public abstract class LevelChunkSnapshotWrapper {
|
||||
|
||||
private ChunkSnapshot chunkSnapshot;
|
||||
|
||||
public LevelChunkSnapshotWrapper(ChunkSnapshot chunkSnapshot) {
|
||||
this.chunkSnapshot = chunkSnapshot;
|
||||
}
|
||||
|
||||
public ChunkSnapshot getChunkSnapshot() {
|
||||
return this.chunkSnapshot;
|
||||
}
|
||||
|
||||
abstract boolean hasWildStackerData();
|
||||
|
||||
}
|
@ -41,8 +41,14 @@ public class LevellingManager {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
|
||||
private Set<Island> activeIslandScans = new HashSet<>();
|
||||
private List<LevellingMaterial> materialStorage = new ArrayList<>();
|
||||
|
||||
private Method getBlockTypeMethod = null;
|
||||
private Method getBlockTypeIdMethod = null;
|
||||
private Method getBlockTypeDataMethod = null;
|
||||
private Method getMaterialMethod = null;
|
||||
|
||||
public LevellingManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
|
||||
@ -62,6 +68,8 @@ public class LevellingManager {
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeIslandScans.add(island);
|
||||
|
||||
Chunk chunk = new Chunk(skyblock, island);
|
||||
chunk.prepareInitial();
|
||||
|
||||
@ -80,10 +88,12 @@ public class LevellingManager {
|
||||
int worldMaxHeight = height;
|
||||
|
||||
boolean isEpicSpawnersEnabled = Bukkit.getPluginManager().isPluginEnabled("EpicSpawners");
|
||||
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
||||
boolean isUltimateStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker");
|
||||
|
||||
Map<LevellingData, Long> levellingData = new HashMap<>();
|
||||
Set<Location> spawnerLocations = new HashSet<>(); // These have to be checked synchronously :(
|
||||
Set<Location> epicSpawnerLocations = new HashSet<>();
|
||||
Set<Location> ultimateStackerSpawnerLocations = new HashSet<>();
|
||||
|
||||
List<Material> blacklistedMaterials = new ArrayList<>();
|
||||
blacklistedMaterials.add(Materials.AIR.getPostMaterial());
|
||||
@ -98,20 +108,17 @@ public class LevellingManager {
|
||||
if (!chunk.isReadyToScan()) return;
|
||||
|
||||
if (chunk.isFinished()) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, player, island), 1);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, epicSpawnerLocations, ultimateStackerSpawnerLocations, player, island), 1);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Method getBlockTypeMethod = null;
|
||||
Method getBlockTypeIdMethod = null;
|
||||
Method getBlockTypeDataMethod = null;
|
||||
Method getMaterialMethod = null;
|
||||
|
||||
for (ChunkSnapshot chunkSnapshotList : chunk.getAvailableChunkSnapshots()) {
|
||||
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 {
|
||||
org.bukkit.Material blockMaterial = org.bukkit.Material.AIR;
|
||||
int blockData = 0;
|
||||
@ -119,20 +126,20 @@ public class LevellingManager {
|
||||
|
||||
if (NMSVersion > 12) {
|
||||
if (getBlockTypeMethod == null) {
|
||||
getBlockTypeMethod = chunkSnapshotList.getClass()
|
||||
getBlockTypeMethod = chunkSnapshot.getClass()
|
||||
.getMethod("getBlockType", int.class, int.class, int.class);
|
||||
}
|
||||
|
||||
blockMaterial = (org.bukkit.Material) getBlockTypeMethod
|
||||
.invoke(chunkSnapshotList, x, y, z);
|
||||
.invoke(chunkSnapshot, x, y, z);
|
||||
} else {
|
||||
if (getBlockTypeIdMethod == null) {
|
||||
getBlockTypeIdMethod = chunkSnapshotList.getClass()
|
||||
getBlockTypeIdMethod = chunkSnapshot.getClass()
|
||||
.getMethod("getBlockTypeId", int.class, int.class, int.class);
|
||||
}
|
||||
|
||||
if (getBlockTypeDataMethod == null) {
|
||||
getBlockTypeDataMethod = chunkSnapshotList.getClass()
|
||||
getBlockTypeDataMethod = chunkSnapshot.getClass()
|
||||
.getMethod("getBlockData", int.class, int.class, int.class);
|
||||
}
|
||||
|
||||
@ -143,8 +150,8 @@ public class LevellingManager {
|
||||
|
||||
blockMaterial = (org.bukkit.Material) getMaterialMethod.invoke(
|
||||
blockMaterial,
|
||||
(int) getBlockTypeIdMethod.invoke(chunkSnapshotList, x, y, z));
|
||||
blockData = (int) getBlockTypeDataMethod.invoke(chunkSnapshotList, x, y, z);
|
||||
(int) getBlockTypeIdMethod.invoke(chunkSnapshot, x, y, z));
|
||||
blockData = (int) getBlockTypeDataMethod.invoke(chunkSnapshot, x, y, z);
|
||||
}
|
||||
|
||||
if (blacklistedMaterials.contains(blockMaterial))
|
||||
@ -153,24 +160,30 @@ public class LevellingManager {
|
||||
long amount = 1;
|
||||
|
||||
if (blockMaterial == Materials.SPAWNER.parseMaterial()) {
|
||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
||||
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.api.EpicSpawners epicSpawners = com.songoda.epicspawners.api.EpicSpawnersAPI.getImplementation();
|
||||
com.songoda.epicspawners.EpicSpawners epicSpawners = com.songoda.epicspawners.EpicSpawners.getInstance();
|
||||
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
|
||||
com.songoda.epicspawners.api.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location);
|
||||
amount = spawner.getSpawnerDataCount();
|
||||
spawnerType = spawner.getCreatureSpawner().getSpawnedType();
|
||||
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;
|
||||
}
|
||||
|
||||
if (isWildStackerEnabled && spawnerType == null) {
|
||||
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
|
||||
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
|
||||
if (spawner != null) {
|
||||
amount = spawner.getStackAmount();
|
||||
spawnerType = spawner.getSpawnedType();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,25 +192,23 @@ public class LevellingManager {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (isWildStackerEnabled) {
|
||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
||||
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
|
||||
com.bgsoftware.wildstacker.api.objects.StackedBarrel barrel = wildStacker.getStackedBarrel(location);
|
||||
if (barrel != null) {
|
||||
amount = barrel.getStackAmount();
|
||||
blockMaterial = barrel.getType();
|
||||
blockData = barrel.getData();
|
||||
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_", ""));
|
||||
blockData = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial) && amount == 1) {
|
||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
||||
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) {
|
||||
@ -211,8 +222,7 @@ public class LevellingManager {
|
||||
Long totalAmountInteger = levellingData.get(data);
|
||||
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
|
||||
levellingData.put(data, totalAmount);
|
||||
} catch (IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -225,7 +235,7 @@ public class LevellingManager {
|
||||
}.runTaskTimerAsynchronously(skyblock, 0L, 1L);
|
||||
}
|
||||
|
||||
private void finalizeMaterials(Map<LevellingData, Long> levellingData, Set<Location> spawnerLocations, Player player, Island island) {
|
||||
private void finalizeMaterials(Map<LevellingData, Long> levellingData, Set<Location> spawnerLocations, Set<Location> epicSpawnerLocations, Set<Location> ultimateStackerSpawnerLocations, Player player, Island island) {
|
||||
for (Location location : spawnerLocations) {
|
||||
if (!(location.getBlock().getState() instanceof CreatureSpawner))
|
||||
continue;
|
||||
@ -239,6 +249,37 @@ public class LevellingManager {
|
||||
levellingData.put(data, totalAmount);
|
||||
}
|
||||
|
||||
for (Location location : epicSpawnerLocations) {
|
||||
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)
|
||||
continue;
|
||||
|
||||
int amount = spawner.getFirstStack().getStackSize();
|
||||
EntityType spawnerType = spawner.getCreatureSpawner().getSpawnedType();
|
||||
|
||||
LevellingData data = new LevellingData(Materials.SPAWNER.parseMaterial(), (byte) 0, spawnerType);
|
||||
Long totalAmountInteger = levellingData.get(data);
|
||||
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
|
||||
levellingData.put(data, totalAmount);
|
||||
}
|
||||
}
|
||||
|
||||
for (Location location : ultimateStackerSpawnerLocations) {
|
||||
com.songoda.ultimatestacker.spawner.SpawnerStack spawnerStack = com.songoda.ultimatestacker.UltimateStacker.getInstance().getSpawnerStackManager().getSpawner(location);
|
||||
if (spawnerStack == null)
|
||||
continue;
|
||||
|
||||
int amount = spawnerStack.getAmount();
|
||||
EntityType spawnerType = ((CreatureSpawner) location.getBlock().getState()).getSpawnedType();
|
||||
|
||||
LevellingData data = new LevellingData(Materials.SPAWNER.parseMaterial(), (byte) 0, spawnerType);
|
||||
Long totalAmountInteger = levellingData.get(data);
|
||||
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
|
||||
levellingData.put(data, totalAmount);
|
||||
}
|
||||
|
||||
Map<String, Long> materials = new HashMap<>();
|
||||
for (LevellingData data : levellingData.keySet()) {
|
||||
long amount = levellingData.get(data);
|
||||
@ -266,6 +307,8 @@ public class LevellingManager {
|
||||
me.goodandevil.skyblock.menus.Levelling.getInstance().open(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.activeIslandScans.remove(island);
|
||||
}
|
||||
|
||||
public void registerMaterials() {
|
||||
@ -283,12 +326,16 @@ public class LevellingManager {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: The material '" + materialKey
|
||||
+ "' is not a Material type. Make sure the material name is a 1.13 material name. Please correct this in the 'levelling.yml' file.");
|
||||
+ "' is not a Material type. Make sure the material name is a 1.14 material name. Please correct this in the 'levelling.yml' file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIslandLevelBeingScanned(Island island) {
|
||||
return this.activeIslandScans.contains(island);
|
||||
}
|
||||
|
||||
public void unregisterMaterials() {
|
||||
materialStorage.clear();
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package me.goodandevil.skyblock.levelling;
|
||||
|
||||
import com.bgsoftware.wildstacker.api.objects.StackedSnapshot;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
|
||||
public class WildStackerChunkSnapshotWrapper extends LevelChunkSnapshotWrapper {
|
||||
|
||||
private StackedSnapshot stackedSnapshot;
|
||||
|
||||
public WildStackerChunkSnapshotWrapper(ChunkSnapshot chunkSnapshot, StackedSnapshot stackedSnapshot) {
|
||||
super(chunkSnapshot);
|
||||
this.stackedSnapshot = stackedSnapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWildStackerData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public StackedSnapshot getStackedSnapshot() {
|
||||
return this.stackedSnapshot;
|
||||
}
|
||||
|
||||
}
|
109
src/main/java/me/goodandevil/skyblock/limit/LimitManager.java
Normal file
109
src/main/java/me/goodandevil/skyblock/limit/LimitManager.java
Normal file
@ -0,0 +1,109 @@
|
||||
package me.goodandevil.skyblock.limit;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LimitManager {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private Map<Materials, Long> blockLimits;
|
||||
|
||||
public LimitManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
this.blockLimits = new HashMap<>();
|
||||
|
||||
this.reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.blockLimits.clear();
|
||||
|
||||
FileConfiguration limitsConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "limits.yml")).getFileConfiguration();
|
||||
ConfigurationSection blockLimitSection = limitsConfig.getConfigurationSection("block");
|
||||
|
||||
if (blockLimitSection != null) {
|
||||
for (String materialString : blockLimitSection.getKeys(false)) {
|
||||
Materials material = Materials.fromString(materialString);
|
||||
if (material != null) {
|
||||
long limit = blockLimitSection.getLong(materialString);
|
||||
this.blockLimits.put(material, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max number of a type of block a player can place
|
||||
* @param player The player to check
|
||||
* @param block The block to check
|
||||
* @return The max number of the type of block the player can place
|
||||
*/
|
||||
public long getBlockLimit(Player player, Block block) {
|
||||
if (player.hasPermission("fabledskyblock.limit.block.*"))
|
||||
return -1;
|
||||
|
||||
long limit = -1;
|
||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
if (this.blockLimits.containsKey(material))
|
||||
limit = Math.max(limit, this.blockLimits.get(material));
|
||||
|
||||
Set<PermissionAttachmentInfo> permissions = player.getEffectivePermissions()
|
||||
.stream()
|
||||
.filter(x -> x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block." + material.name().toLowerCase()))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (PermissionAttachmentInfo permission : permissions) {
|
||||
try {
|
||||
String permString = permission.getPermission();
|
||||
String numberString = permString.substring(permString.lastIndexOf(".") + 1);
|
||||
if (numberString.equals("*"))
|
||||
return -1;
|
||||
|
||||
limit = Math.max(limit, Integer.parseInt(numberString));
|
||||
} catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has exceeded the number of blocks they can place
|
||||
* @param player The player to check
|
||||
* @param block The block to check
|
||||
* @return true if the player has exceeded the block limit, otherwise false
|
||||
*/
|
||||
public boolean isBlockLimitExceeded(Player player, Block block) {
|
||||
IslandManager islandManager = this.skyblock.getIslandManager();
|
||||
|
||||
long limit = this.getBlockLimit(player, block);
|
||||
if (limit == -1)
|
||||
return false;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
long totalPlaced;
|
||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
|
||||
} else {
|
||||
totalPlaced = island.getLevel().getMaterialAmount(Materials.getMaterials(block.getType(), block.getData()).name());
|
||||
}
|
||||
|
||||
return limit < totalPlaced + 1;
|
||||
}
|
||||
|
||||
}
|
@ -5,18 +5,24 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.generator.Generator;
|
||||
import me.goodandevil.skyblock.generator.GeneratorManager;
|
||||
import me.goodandevil.skyblock.island.*;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.stackable.Stackable;
|
||||
import me.goodandevil.skyblock.stackable.StackableManager;
|
||||
import me.goodandevil.skyblock.upgrade.Upgrade;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.StringUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import me.goodandevil.skyblock.utils.world.LocationUtil;
|
||||
import me.goodandevil.skyblock.world.WorldManager;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -44,7 +50,7 @@ public class Block implements Listener {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.block.Block block = event.getBlock();
|
||||
@ -128,10 +134,8 @@ public class Block implements Listener {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (LocationUtil.isLocationLocation(block.getLocation(),
|
||||
island.getLocation(world, IslandEnvironment.Main)
|
||||
.clone()
|
||||
.subtract(0.0D, 1.0D, 0.0D))) {
|
||||
if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))
|
||||
|| LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone())) {
|
||||
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
@ -160,13 +164,14 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.block.Block block = event.getBlock();
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
||||
|
||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||
@ -177,6 +182,14 @@ public class Block implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (levellingManager.isIslandLevelBeingScanned(island)) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
@ -188,12 +201,9 @@ public class Block implements Listener {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.WorldBorder.Block")) {
|
||||
if (block.getType() == Material.DISPENSER) {
|
||||
if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(),
|
||||
island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 2.0D)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (configLoad.getBoolean("Island.WorldBorder.Block") && block.getType() == Material.DISPENSER) {
|
||||
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,13 +216,11 @@ public class Block implements Listener {
|
||||
}
|
||||
|
||||
// Specific check for beds
|
||||
if (block.getType().name().equals("BED") || block.getType().name().contains("_BED")) {
|
||||
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.isLocationAffectingLocation(bedBlock.getLocation(), island.getLocation(world, IslandEnvironment.Main)))
|
||||
isObstructing = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (isObstructing) {
|
||||
@ -226,6 +234,21 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
if (limitManager.isBlockLimitExceeded(player, block)) {
|
||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
||||
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " ")))
|
||||
.replace("%limit", NumberUtil.formatNumber(limitManager.getBlockLimit(player, block))));
|
||||
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!configLoad.getBoolean("Island.Block.Level.Enable"))
|
||||
return;
|
||||
|
||||
@ -272,11 +295,14 @@ public class Block implements Listener {
|
||||
|
||||
org.bukkit.block.Block block = event.getToBlock();
|
||||
|
||||
// Protect spawn location and outside of border
|
||||
if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 1.0D)) {
|
||||
// Protect outside of border
|
||||
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main)) && configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||
}
|
||||
|
||||
// Protect spawn
|
||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main)) && configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -293,7 +319,7 @@ public class Block implements Listener {
|
||||
island.hasRole(IslandRole.Member, p.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Coop, p.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Operator, p.getUniqueId());
|
||||
if (isMember && LocationUtil.isLocationAtLocationRadius(p.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius())) {
|
||||
if (isMember && islandManager.isLocationAtIsland(island, p.getLocation(), world)) {
|
||||
possiblePlayers.add(p);
|
||||
}
|
||||
}
|
||||
@ -336,7 +362,7 @@ public class Block implements Listener {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (org.bukkit.block.Block block : event.getBlocks()) {
|
||||
if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 2.0D)) {
|
||||
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world) || !islandManager.isLocationAtIsland(island, block.getRelative(event.getDirection()).getLocation(), world)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -392,7 +418,7 @@ public class Block implements Listener {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (org.bukkit.block.Block block : event.getBlocks()) {
|
||||
if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 2.0D)) {
|
||||
if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -468,7 +494,7 @@ public class Block implements Listener {
|
||||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
|
||||
island.hasRole(IslandRole.Operator, player.getUniqueId());
|
||||
if (isMember && LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(world, IslandEnvironment.Island), island.getRadius())) {
|
||||
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
|
||||
possiblePlayers.add(player);
|
||||
}
|
||||
}
|
||||
@ -630,48 +656,49 @@ public class Block implements Listener {
|
||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
return;
|
||||
|
||||
if (event.getBlocks().isEmpty())
|
||||
return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
|
||||
if (island == null)
|
||||
return;
|
||||
|
||||
// Check spawn block protection
|
||||
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
||||
|
||||
for (org.bukkit.block.Block block : event.getBlocks()) {
|
||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
||||
event.setCancelled(true);
|
||||
// PortalCreateEvent.getBlocks() changed from ArrayList<Block> to ArrayList<BlockState> in 1.14.1... why...
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
List<BlockState> blocks = event.getBlocks();
|
||||
if (event.getBlocks().isEmpty())
|
||||
return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
|
||||
if (island == null)
|
||||
return;
|
||||
|
||||
// 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)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<org.bukkit.block.Block> blocks = (List<org.bukkit.block.Block>) event.getClass().getMethod("getBlocks").invoke(event);
|
||||
if (blocks.isEmpty())
|
||||
return;
|
||||
|
||||
@EventHandler
|
||||
public void onEntityCreatePortal(EntityCreatePortalEvent event) {
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Island island = islandManager.getIslandAtLocation(blocks.get(0).getLocation());
|
||||
if (island == null)
|
||||
return;
|
||||
|
||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
return;
|
||||
// Check spawn block protection
|
||||
IslandWorld world = worldManager.getIslandWorld(blocks.get(0).getWorld());
|
||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
||||
|
||||
if (event.getBlocks().isEmpty())
|
||||
return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
|
||||
if (island == null)
|
||||
return;
|
||||
|
||||
// Check spawn block protection
|
||||
IslandWorld world = worldManager.getIslandWorld(event.getBlocks().get(0).getWorld());
|
||||
Location islandLocation = island.getLocation(world, IslandEnvironment.Main);
|
||||
|
||||
for (org.bukkit.block.BlockState block : event.getBlocks()) {
|
||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
for (org.bukkit.block.Block block : blocks) {
|
||||
if (LocationUtil.isLocationAffectingLocation(block.getLocation(), islandLocation)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ public class Entity implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Fix a bug in spigot where arrows with flame still apply flame even if the event is cancelled
|
||||
|
||||
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if the shot entity isn't damaged
|
||||
if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) {
|
||||
player.setFireTicks(0);
|
||||
event.setCancelled(true);
|
||||
@ -157,8 +157,7 @@ public class Entity implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getDamager() instanceof Projectile
|
||||
&& ((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||
if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||
Player player = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
|
||||
@ -167,6 +166,11 @@ public class Entity implements Listener {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (entity.getType() == EntityType.ITEM_FRAME && !islandManager.hasPermission(player, entity.getLocation(), "HangingDestroy")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
|
||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "PvP")) {
|
||||
event.setCancelled(true);
|
||||
@ -214,7 +218,7 @@ public class Entity implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// Fix a bug in spigot where arrows with flame still apply flame even if the event is cancelled
|
||||
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if the shot entity isn't damaged
|
||||
if (event.isCancelled() && event.getEntity() != null && event.getDamager() instanceof Arrow && ((Arrow)event.getDamager()).getShooter() instanceof Player) {
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
if (arrow.getFireTicks() != 0) {
|
||||
|
@ -3,9 +3,16 @@ package me.goodandevil.skyblock.listeners;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.limit.LimitManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -22,6 +29,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
@ -48,7 +56,7 @@ public class Interact implements Listener {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.block.Block block = event.getClickedBlock();
|
||||
@ -61,15 +69,97 @@ public class Interact implements Listener {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
StackableManager stackableManager = skyblock.getStackableManager();
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
if (island == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (block.getType() == Material.DRAGON_EGG) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getState() instanceof Beacon) { // ChunkCollectors support
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Beacon")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getState() instanceof InventoryHolder || block.getState() instanceof CreatureSpawner) { // EpicHoppers/EpicSpawners support
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||
if (event.getItem() != null && event.getItem().getType() == Material.EGG) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (stackableManager != null
|
||||
&& stackableManager.getStackableMaterials().contains(event.getMaterial())
|
||||
&& event.getClickedBlock().getType() == event.getMaterial()
|
||||
&& !player.isSneaking()) {
|
||||
&& !player.isSneaking() && islandManager.hasPermission(player, block.getLocation(), "Place")
|
||||
&& (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") || player.hasPermission("fabledskyblock.stackable"))) {
|
||||
if (NMSUtil.getVersionNumber() > 8) {
|
||||
if (event.getHand() == EquipmentSlot.OFF_HAND) return;
|
||||
}
|
||||
|
||||
if (levellingManager.isIslandLevelBeingScanned(island)) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
if (limitManager.isBlockLimitExceeded(player, block)) {
|
||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
||||
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " ")))
|
||||
.replace("%limit", NumberUtil.formatNumber(limitManager.getBlockLimit(player, block))));
|
||||
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = event.getClickedBlock().getLocation();
|
||||
if (stackableManager.isStacked(location)) {
|
||||
Stackable stackable = stackableManager.getStack(location, event.getMaterial());
|
||||
@ -84,8 +174,6 @@ public class Interact implements Listener {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
|
||||
Materials materials = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
if (materials == null) return;
|
||||
@ -107,17 +195,6 @@ public class Interact implements Listener {
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getType() == Material.BEACON) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Beacon")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getType() == Materials.LEGACY_BED_BLOCK.parseMaterial()
|
||||
@ -243,7 +320,8 @@ public class Interact implements Listener {
|
||||
|| block.getType() == Materials.BIRCH_BUTTON.parseMaterial()
|
||||
|| block.getType() == Materials.JUNGLE_BUTTON.parseMaterial()
|
||||
|| block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
|
||||
|| block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial()) {
|
||||
|| block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial()
|
||||
|| block.getType() == Materials.LEVER.parseMaterial()) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -271,7 +349,8 @@ public class Interact implements Listener {
|
||||
|| block.getType() == Materials.JUNGLE_TRAPDOOR.parseMaterial()
|
||||
|| block.getType() == Materials.ACACIA_TRAPDOOR.parseMaterial()
|
||||
|| block.getType() == Materials.DARK_OAK_TRAPDOOR.parseMaterial()
|
||||
|| block.getType() == Material.NOTE_BLOCK || block.getType() == Material.HOPPER
|
||||
|| block.getType() == Material.NOTE_BLOCK
|
||||
|| block.getType() == Material.HOPPER
|
||||
|| block.getType() == Materials.COMPARATOR.parseMaterial()
|
||||
|| block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_OFF.parseMaterial()
|
||||
|| block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_ON.parseMaterial()
|
||||
@ -313,8 +392,8 @@ public class Interact implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getType() == Materials.LEGACY_CAKE_BLOCK.getPostMaterial()) {
|
||||
if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
|
||||
} else if (block.getType() == Material.TNT) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
@ -324,8 +403,8 @@ public class Interact implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getType() == Material.DRAGON_EGG) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
|
||||
} else if (block.getType() == Materials.LEGACY_CAKE_BLOCK.getPostMaterial()) {
|
||||
if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
@ -394,6 +473,39 @@ public class Interact implements Listener {
|
||||
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
|
||||
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
|
||||
if (com.songoda.epicanchors.EpicAnchorsPlugin.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack is = event.getPlayer().getItemInHand();
|
||||
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
block.setType(Material.AIR);
|
||||
player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1));
|
||||
player.updateInventory();
|
||||
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 10.0F, 10.0F);
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (block.getType() == Material.TNT) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
|
||||
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
|
||||
if (com.songoda.epicanchors.EpicAnchorsPlugin.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack is = event.getPlayer().getItemInHand();
|
||||
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
@ -439,7 +551,7 @@ public class Interact implements Listener {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
} else if (event.getItem().getType() == Materials.BAT_SPAWN_EGG.parseMaterial()) {
|
||||
} else if (event.getItem().getType().name().contains("SPAWN_EGG")) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "SpawnEgg")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -464,6 +576,7 @@ public class Interact implements Listener {
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
// Note: Cast is necessary as it is ambiguous without it in 1.8
|
||||
if (player.getTargetBlock((Set<Material>) null, 5).getType() == Material.FIRE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
|
||||
event.setCancelled(true);
|
||||
@ -475,7 +588,9 @@ public class Interact implements Listener {
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.PHYSICAL) {
|
||||
if (block.getType() == Materials.FARMLAND.parseMaterial()) {
|
||||
if (block.getType() == Materials.TURTLE_EGG.parseMaterial()) {
|
||||
event.setCancelled(true);
|
||||
} else if (block.getType() == Materials.FARMLAND.parseMaterial()) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -490,7 +605,9 @@ public class Interact implements Listener {
|
||||
|| block.getType() == Materials.BIRCH_PRESSURE_PLATE.parseMaterial()
|
||||
|| block.getType() == Materials.JUNGLE_PRESSURE_PLATE.parseMaterial()
|
||||
|| block.getType() == Materials.ACACIA_PRESSURE_PLATE.parseMaterial()
|
||||
|| block.getType() == Materials.DARK_OAK_PRESSURE_PLATE.parseMaterial()) {
|
||||
|| block.getType() == Materials.DARK_OAK_PRESSURE_PLATE.parseMaterial()
|
||||
|| block.getType() == Materials.LIGHT_WEIGHTED_PRESSURE_PLATE.parseMaterial()
|
||||
|| block.getType() == Materials.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -504,7 +621,6 @@ public class Interact implements Listener {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,8 +786,7 @@ public class Interact implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(entity instanceof StorageMinecart){
|
||||
} else if(entity instanceof StorageMinecart){
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -682,8 +797,7 @@ public class Interact implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (entity.getType() == EntityType.MINECART || entity.getType() == EntityType.BOAT) {
|
||||
} else if (entity.getType() == EntityType.MINECART || entity.getType() == EntityType.BOAT) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "MinecartBoat")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -692,6 +806,17 @@ public class Interact implements Listener {
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.MINECART_HOPPER) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Hopper")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -166,5 +166,11 @@ public class Join implements Listener {
|
||||
scoreboard.run();
|
||||
scoreboardManager.storeScoreboard(player, scoreboard);
|
||||
}
|
||||
|
||||
Island island = islandManager.getIslandPlayerAt(player);
|
||||
if (island != null) {
|
||||
islandManager.updateBorder(island);
|
||||
islandManager.updateFlight(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Move implements Listener {
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
|
||||
if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) {
|
||||
if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,7 +51,8 @@ public class Move implements Listener {
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (!worldManager.isIslandWorld(player.getWorld())) return;
|
||||
if (!worldManager.isIslandWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
||||
|
||||
@ -181,19 +182,7 @@ public class Move implements Listener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Config config = skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (LocationUtil.isLocationAtLocationRadius(to,
|
||||
island.getLocation(world, IslandEnvironment.Island), island.getRadius() + 2)) {
|
||||
if (!configLoad.getBoolean("Island.WorldBorder.Enable")) {
|
||||
player.teleport(player.getLocation()
|
||||
.add(from.toVector().subtract(to.toVector()).normalize().multiply(2.0D)));
|
||||
player.setFallDistance(0.0F);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius() + 0.5)) {
|
||||
if (island.getVisit().isVisitor(player.getUniqueId())) {
|
||||
player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
|
||||
} else {
|
||||
@ -212,6 +201,15 @@ public class Move implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// Load the island they are now on if one exists
|
||||
if (player.hasPermission("fabledskyblock.bypass")) {
|
||||
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
|
||||
if (loadedIsland != null) {
|
||||
playerData.setIsland(loadedIsland.getOwnerUUID());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(player);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
|
@ -36,93 +36,97 @@ public class Quit implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
InviteManager inviteManager = skyblock.getInviteManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
InviteManager inviteManager = skyblock.getInviteManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
try {
|
||||
playerData.setLastOnline(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date()));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
playerData.setLastOnline(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date()));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island != null) {
|
||||
Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
|
||||
if (island != null) {
|
||||
Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
|
||||
|
||||
if (islandMembersOnline.size() == 1) {
|
||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Levelling, offlinePlayer);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer);
|
||||
if (islandMembersOnline.size() == 1) {
|
||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Levelling, offlinePlayer);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer);
|
||||
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Ownership, offlinePlayer);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer);
|
||||
} else if (islandMembersOnline.size() == 2) {
|
||||
for (UUID islandMembersOnlineList : islandMembersOnline) {
|
||||
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
|
||||
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Ownership, offlinePlayer);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer);
|
||||
} else if (islandMembersOnline.size() == 2) {
|
||||
for (UUID islandMembersOnlineList : islandMembersOnline) {
|
||||
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
|
||||
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
|
||||
if (targetPlayerData.isChat()) {
|
||||
targetPlayerData.setChat(false);
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
|
||||
if (targetPlayerData.isChat()) {
|
||||
targetPlayerData.setChat(false);
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Island is = island;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> islandManager.unloadIsland(is, player));
|
||||
}
|
||||
|
||||
islandManager.unloadIsland(island, player);
|
||||
}
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Biome, player);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Biome, player);
|
||||
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Biome, player);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Biome, player);
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Creation, player);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Creation, player);
|
||||
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Creation, player);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Creation, player);
|
||||
playerDataManager.savePlayerData(player);
|
||||
playerDataManager.unloadPlayerData(player);
|
||||
|
||||
playerDataManager.savePlayerData(player);
|
||||
playerDataManager.unloadPlayerData(player);
|
||||
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Coop.Unload")) {
|
||||
for (Island islandList : islandManager.getCoopIslands(player)) {
|
||||
islandList.removeCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
if (playerData != null && playerData.getIsland() != null && islandManager.containsIsland(playerData.getIsland())) {
|
||||
island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||
|
||||
if (!island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
&& !island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
islandManager.unloadIsland(island, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (inviteManager.hasInvite(player.getUniqueId())) {
|
||||
Invite invite = inviteManager.getInvite(player.getUniqueId());
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(invite.getOwnerUUID());
|
||||
|
||||
if (targetPlayer != null) {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration()
|
||||
.getString("Command.Island.Invite.Invited.Sender.Disconnected.Message")
|
||||
.replace("%player", player.getName()));
|
||||
skyblock.getSoundManager().playSound(targetPlayer, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Coop.Unload")) {
|
||||
for (Island islandList : islandManager.getCoopIslands(player)) {
|
||||
islandList.removeCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
inviteManager.removeInvite(player.getUniqueId());
|
||||
}
|
||||
if (playerData != null && playerData.getIsland() != null && islandManager.containsIsland(playerData.getIsland())) {
|
||||
island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||
|
||||
if (!island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
&& !island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
final Island is = island;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> islandManager.unloadIsland(is, null));
|
||||
}
|
||||
}
|
||||
|
||||
if (inviteManager.hasInvite(player.getUniqueId())) {
|
||||
Invite invite = inviteManager.getInvite(player.getUniqueId());
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(invite.getOwnerUUID());
|
||||
|
||||
if (targetPlayer != null) {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration()
|
||||
.getString("Command.Island.Invite.Invited.Sender.Disconnected.Message")
|
||||
.replace("%player", player.getName()));
|
||||
skyblock.getSoundManager().playSound(targetPlayer, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
inviteManager.removeInvite(player.getUniqueId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,11 @@ public class Teleport implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCause) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
|
@ -0,0 +1,89 @@
|
||||
package me.goodandevil.skyblock.listeners;
|
||||
|
||||
import com.songoda.ultimatestacker.events.SpawnerBreakEvent;
|
||||
import com.songoda.ultimatestacker.events.SpawnerPlaceEvent;
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandLevel;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.world.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class UltimateStacker implements Listener {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
|
||||
public UltimateStacker(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawnerPlace(SpawnerPlaceEvent event) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SkyBlock.getInstance(), () -> {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
|
||||
Location location = event.getBlock().getLocation();
|
||||
if (!worldManager.isIslandWorld(location.getWorld())) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(location);
|
||||
|
||||
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
Materials materials = Materials.getSpawner(event.getSpawnerType());
|
||||
if (materials != null) {
|
||||
IslandLevel level = island.getLevel();
|
||||
|
||||
long materialAmount = 0;
|
||||
if (level.hasMaterial(materials.name())) {
|
||||
materialAmount = level.getMaterialAmount(materials.name());
|
||||
}
|
||||
|
||||
level.setMaterialAmount(materials.name(), materialAmount + event.getAmount() - 1); // Normal place event still goes off
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawnerBreak(SpawnerBreakEvent event) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
|
||||
Location location = event.getBlock().getLocation();
|
||||
if (!worldManager.isIslandWorld(location.getWorld())) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(location);
|
||||
|
||||
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
Materials materials = Materials.getSpawner(event.getSpawnerType());
|
||||
if (materials != null) {
|
||||
IslandLevel level = island.getLevel();
|
||||
|
||||
if (level.hasMaterial(materials.name())) {
|
||||
long materialAmount = level.getMaterialAmount(materials.name());
|
||||
|
||||
if (materialAmount - event.getAmount() <= 0) {
|
||||
level.removeMaterial(materials.name());
|
||||
} else {
|
||||
level.setMaterialAmount(materials.name(), materialAmount - event.getAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -237,52 +237,4 @@ public class WildStacker implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Readd after WildStacker 2.7.4 is released. A feature is being added that will let us multiply the drops by 2x.
|
||||
// @EventHandler
|
||||
// public void onMobStack(EntityStackEvent event) {
|
||||
// LivingEntity livingEntity = event.getEntity().getLivingEntity();
|
||||
//
|
||||
// // Certain entities shouldn't drop twice the amount
|
||||
// if (livingEntity instanceof Player ||
|
||||
// livingEntity instanceof ArmorStand ||
|
||||
// livingEntity instanceof Horse) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (NMSUtil.getVersionNumber() > 8) {
|
||||
// if (livingEntity instanceof Donkey || livingEntity instanceof Mule)
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (livingEntity.hasMetadata("SkyBlock")) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// IslandManager islandManager = skyblock.getIslandManager();
|
||||
//
|
||||
// if (skyblock.getWorldManager().isIslandWorld(livingEntity.getWorld())) {
|
||||
// Island island = islandManager.getIslandAtLocation(livingEntity.getLocation());
|
||||
//
|
||||
// if (island != null) {
|
||||
// List<Upgrade> upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Drops);
|
||||
//
|
||||
// if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()
|
||||
// && island.isUpgrade(Upgrade.Type.Drops)) {
|
||||
// StackedEntity entity = event.getEntity();
|
||||
// StackedEntity target = event.getTarget();
|
||||
//
|
||||
// List<ItemStack> drops = target.getDrops(0);
|
||||
// for (ItemStack item : drops) {
|
||||
// item.setAmount(item.getAmount() * 2);
|
||||
// }
|
||||
//
|
||||
// List<ItemStack> newDrops = entity.getDrops(0);
|
||||
// newDrops.addAll(drops);
|
||||
//
|
||||
// entity.setTempLootTable(newDrops);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.player.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class Coop {
|
||||
|
||||
@ -164,6 +165,7 @@ public class Coop {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
Set<UUID> coopPlayers = island.getCoopPlayers();
|
||||
coopPlayers.removeIf(x -> !Bukkit.getOfflinePlayer(x).hasPlayedBefore());
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = coopPlayers.size() - playerMenuPage * 36;
|
||||
|
||||
|
@ -91,6 +91,10 @@ public class Weather {
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if (is.getType() == Materials.BARRIER.parseMaterial()) {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((is.getType() == Materials.SUNFLOWER.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Weather.Item.Time.Displayname"))))) {
|
||||
@ -112,9 +116,12 @@ public class Weather {
|
||||
|
||||
if (!island.isWeatherSynchronized()) {
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
all.resetPlayerTime();
|
||||
all.resetPlayerWeather();
|
||||
all.setPlayerTime(island.getTime(),
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
all.setPlayerWeather(island.getWeather());
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,6 +139,11 @@ public class Weather {
|
||||
|
||||
if (!island.isWeatherSynchronized()) {
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
all.resetPlayerTime();
|
||||
all.resetPlayerWeather();
|
||||
all.setPlayerTime(island.getTime(),
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
all.setPlayerWeather(island.getWeather());
|
||||
}
|
||||
}
|
||||
@ -183,25 +195,25 @@ public class Weather {
|
||||
|
||||
if (islandTime == 0) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Dawn");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Day");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dawn");
|
||||
} else if (islandTime == 1000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Day");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Noon");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Day");
|
||||
} else if (islandTime == 6000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Noon");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dusk");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Noon");
|
||||
} else if (islandTime == 12000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Dusk");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Night");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dusk");
|
||||
} else if (islandTime == 13000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Night");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Midnight");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Night");
|
||||
} else if (islandTime == 18000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Midnight");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dawn");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Midnight");
|
||||
}
|
||||
|
||||
if (island.getWeather() == WeatherType.CLEAR) {
|
||||
if (island.getWeather() != WeatherType.CLEAR) {
|
||||
weatherChoice = configLoad.getString("Menu.Weather.Item.Weather.Choice.Downfall");
|
||||
} else {
|
||||
weatherChoice = configLoad.getString("Menu.Weather.Item.Weather.Choice.Clear");
|
||||
@ -215,21 +227,34 @@ public class Weather {
|
||||
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG),
|
||||
configLoad.getString("Menu.Weather.Item.Info.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Info.Lore"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Info.Lore." + (island.isWeatherSynchronized() ? "Synchronised" : "Unsynchronised")),
|
||||
new Placeholder[] { new Placeholder("%synchronised", weatherSynchronised),
|
||||
new Placeholder("%time_name", timeName), new Placeholder("%time", "" + island.getTime()),
|
||||
new Placeholder("%weather", island.getWeatherName()) },
|
||||
null, null), 0);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(),
|
||||
configLoad.getString("Menu.Weather.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
nInv.addItem(nInv.createItem(Materials.SUNFLOWER.parseItem(),
|
||||
configLoad.getString("Menu.Weather.Item.Time.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Time.Lore"),
|
||||
new Placeholder[] { new Placeholder("%choice", timeChoice) }, null, null), 2);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.GHAST_TEAR),
|
||||
configLoad.getString("Menu.Weather.Item.Weather.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Weather.Lore"),
|
||||
new Placeholder[] { new Placeholder("%choice", weatherChoice) }, null, null), 3);
|
||||
|
||||
if (!island.isWeatherSynchronized()) {
|
||||
nInv.addItem(nInv.createItem(Materials.SUNFLOWER.parseItem(),
|
||||
configLoad.getString("Menu.Weather.Item.Time.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Time.Lore"),
|
||||
new Placeholder[] { new Placeholder("%choice", timeChoice) }, null, null), 2);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.GHAST_TEAR),
|
||||
configLoad.getString("Menu.Weather.Item.Weather.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Weather.Lore"),
|
||||
new Placeholder[] { new Placeholder("%choice", weatherChoice) }, null, null), 3);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.BARRIER.parseItem(),
|
||||
configLoad.getString("Menu.Weather.Item.Disabled.Time.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Disabled.Time.Lore"),
|
||||
new Placeholder[] { new Placeholder("%choice", timeChoice) }, null, null), 2);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER),
|
||||
configLoad.getString("Menu.Weather.Item.Disabled.Weather.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Disabled.Weather.Lore"),
|
||||
new Placeholder[] { new Placeholder("%choice", weatherChoice) }, null, null), 3);
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.TRIPWIRE_HOOK),
|
||||
configLoad.getString("Menu.Weather.Item.Synchronised.Displayname"),
|
||||
configLoad.getStringList("Menu.Weather.Item.Synchronised.Lore"),
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.goodandevil.skyblock.utils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public final class NumberUtil {
|
||||
@ -10,7 +11,7 @@ public final class NumberUtil {
|
||||
}
|
||||
|
||||
public static String formatNumberByDecimal(double number) {
|
||||
String withoutDecimal = new DecimalFormat("0.#").format(number), withDecimal = "";
|
||||
String withoutDecimal = new DecimalFormat("0.#").format(number).replace(",", "."), withDecimal = "";
|
||||
|
||||
if (withoutDecimal.contains(".")) {
|
||||
withDecimal = "." + withoutDecimal.split("\\.")[1];
|
||||
@ -24,6 +25,7 @@ public final class NumberUtil {
|
||||
long itemCostWithoutDecimalValue = Long.valueOf(withoutDecimal);
|
||||
|
||||
return formatNumber(itemCostWithoutDecimalValue) + withDecimal;
|
||||
|
||||
}
|
||||
|
||||
public static String formatNumberBySuffix(long number) {
|
||||
|
@ -30,7 +30,7 @@ public class MaterialUtil {
|
||||
} else if (material == Materials.LEGACY_SUGAR_CANE_BLOCK.getPostMaterial()) {
|
||||
material = Material.SUGAR_CANE;
|
||||
} else if (material == Material.TRIPWIRE) {
|
||||
material = Material.TRIPWIRE_HOOK;
|
||||
material = Material.STRING;
|
||||
} else if (material == Material.FLOWER_POT) {
|
||||
material = Materials.LEGACY_FLOWER_POT_ITEM.getPostMaterial();
|
||||
} else if (material.name().startsWith("POTTED_")) {
|
||||
|
@ -1130,7 +1130,7 @@ public enum Materials {
|
||||
Materials pmat = null;
|
||||
|
||||
for (Materials mat : Materials.values()) {
|
||||
if (name.toUpperCase().equals(mat.old12Mat)) {
|
||||
if (name.equalsIgnoreCase(mat.old12Mat)) {
|
||||
if (pmat == null) {
|
||||
pmat = mat;
|
||||
}
|
||||
@ -1179,7 +1179,7 @@ public enum Materials {
|
||||
return Materials.valueOf(mat.toString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
for (Materials xmat : Materials.values()) {
|
||||
if (xmat.old12Mat.equals(mat.toString())) {
|
||||
if (xmat.old12Mat.equalsIgnoreCase(mat.toString())) {
|
||||
return xmat;
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ public final class LocationUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
double x = Math.abs(location1.getX() - location2.getX()) - 1;
|
||||
double z = Math.abs(location1.getZ() - location2.getZ()) - 1;
|
||||
double x = Math.abs(location1.getX() - location2.getX());
|
||||
double z = Math.abs(location1.getZ() - location2.getZ());
|
||||
|
||||
return x < radius && z < radius;
|
||||
return x <= radius && z <= radius;
|
||||
}
|
||||
|
||||
public static List<Location> getLocations(Location minLocation, Location maxLocation) {
|
||||
|
@ -36,11 +36,12 @@ public final class WorldBorder {
|
||||
|
||||
public static void send(Player player, Color color, double size, Location centerLocation) {
|
||||
try {
|
||||
// Adjust border size to fit around whole-blocks, odd numbers only!
|
||||
size += size % 2 == 0 ? 1 : 0;
|
||||
if (centerLocation == null || centerLocation.getWorld() == null)
|
||||
return;
|
||||
|
||||
if (size % 2 == 1)
|
||||
size++;
|
||||
|
||||
centerLocation = centerLocation.clone();
|
||||
centerLocation.add(.5, 0, .5);
|
||||
Object worldBorder = worldBorderClass.getConstructor().newInstance();
|
||||
|
||||
if (NMSUtil.getVersionNumber() < 9) {
|
||||
@ -55,7 +56,7 @@ public final class WorldBorder {
|
||||
}
|
||||
|
||||
Method setCenter = worldBorder.getClass().getMethod("setCenter", double.class, double.class);
|
||||
setCenter.invoke(worldBorder, centerLocation.getX(), centerLocation.getZ());
|
||||
setCenter.invoke(worldBorder, centerLocation.getBlockX(), centerLocation.getBlockZ());
|
||||
|
||||
Method setSize = worldBorder.getClass().getMethod("setSize", double.class);
|
||||
setSize.invoke(worldBorder, size);
|
||||
|
@ -288,8 +288,6 @@ public final class BlockUtil {
|
||||
banner.addPattern(new Pattern(DyeColor.valueOf(pattern[1].toUpperCase()),
|
||||
PatternType.valueOf(pattern[0].toUpperCase())));
|
||||
}
|
||||
|
||||
block.getState().update();
|
||||
} else if (blockTypeState == BlockStateType.BEACON) {
|
||||
Beacon beacon = (Beacon) block.getState();
|
||||
String[] potionEffect = blockData.getPotionEffect().split(":");
|
||||
@ -375,8 +373,6 @@ public final class BlockUtil {
|
||||
for (int i = 0; i < blockData.getSignLines().length; i++) {
|
||||
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', blockData.getSignLines()[i]));
|
||||
}
|
||||
|
||||
sign.update();
|
||||
} else if (blockTypeState == BlockStateType.SKULL) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
|
||||
@ -388,7 +384,6 @@ public final class BlockUtil {
|
||||
} else {
|
||||
skull.setOwner(blockData.getSkullOwner());
|
||||
}
|
||||
skull.update();
|
||||
} else {
|
||||
if (NMSVersion > 8) {
|
||||
if (blockTypeState == BlockStateType.ENDGATEWAY) {
|
||||
|
@ -14,9 +14,9 @@ Island:
|
||||
# The size of an Island when created.
|
||||
# [!] Do not go over the maximum.
|
||||
# [!] Even numbers WILL create world border issues.
|
||||
Minimum: 101
|
||||
Minimum: 100
|
||||
# The maximum size of an Island based on the permission node 'skyblock.size.<size>'.
|
||||
Maximum: 201
|
||||
Maximum: 200
|
||||
Creation:
|
||||
# Rather than opening the 'Island Creator' menu. Create an island
|
||||
# as soon as a player performs the '/island' or '/island create'
|
||||
@ -38,7 +38,7 @@ Island:
|
||||
# Delete the Island world when changing the liquid option.
|
||||
# If lava disabled, the world will be a water world.
|
||||
# -1 to disable Nether and End unlock prices.
|
||||
# Valid Enrivonments: NORMAL, NETHER, THE_END
|
||||
# Valid Environments: NORMAL, NETHER, THE_END
|
||||
Normal:
|
||||
Name: "island_normal_world"
|
||||
IslandSpawnHeight: 72
|
||||
@ -174,6 +174,8 @@ Island:
|
||||
# time cycle or be fixed.
|
||||
Cycle: false
|
||||
Levelling:
|
||||
# Run a scan automatically when pasting an island structure
|
||||
ScanAutomatically: true
|
||||
# Include Points: 0 in the '/is level' GUI
|
||||
IncludeEmptyPointsInList: true
|
||||
# Island Level Points divided by value
|
||||
@ -283,3 +285,5 @@ Island:
|
||||
Enable: true
|
||||
Stackable:
|
||||
Enable: true
|
||||
# fabledskyblock.stackables
|
||||
RequirePermission: false
|
||||
|
File diff suppressed because it is too large
Load Diff
3
src/main/resources/limits.yml
Normal file
3
src/main/resources/limits.yml
Normal file
@ -0,0 +1,3 @@
|
||||
block:
|
||||
BEDROCK: 0
|
||||
END_PORTAL_FRAME: 12
|
@ -4,7 +4,7 @@ version: @version@
|
||||
api-version: 1.13
|
||||
description: A unique SkyBlock plugin
|
||||
author: Songoda
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads, EpicSpawners, WildStacker, WorldEdit]
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
|
||||
loadbefore: [Multiverse-Core]
|
||||
commands:
|
||||
island:
|
||||
|
Loading…
Reference in New Issue
Block a user