mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-13 10:11:26 +01:00
Merge remote-tracking branch 'songoda/master' into development
This commit is contained in:
commit
805fb9d1e8
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>skyblock</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.3.9</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -52,6 +52,7 @@ import net.coreprotect.CoreProtectAPI;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -107,6 +108,22 @@ public class SkyBlock extends SongodaPlugin {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
// Add ymlFiles to cache
|
||||
private FileConfiguration biomes;
|
||||
private FileConfiguration challenges;
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration generators;
|
||||
private FileConfiguration language;
|
||||
private FileConfiguration levelling;
|
||||
private FileConfiguration limits;
|
||||
private FileConfiguration menus;
|
||||
private FileConfiguration placeholders;
|
||||
private FileConfiguration rewards;
|
||||
private FileConfiguration scoreboard;
|
||||
private FileConfiguration settings;
|
||||
private FileConfiguration stackables;
|
||||
private FileConfiguration upgrades;
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
@ -143,6 +160,12 @@ public class SkyBlock extends SongodaPlugin {
|
||||
com.songoda.core.hooks.HologramManager.load(this);
|
||||
|
||||
fileManager = new FileManager(this);
|
||||
|
||||
if (!loadConfigs()) {
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
permissionManager = new PermissionManager(this);
|
||||
localizationManager = new LocalizationManager();
|
||||
worldManager = new WorldManager(this);
|
||||
@ -163,11 +186,12 @@ public class SkyBlock extends SongodaPlugin {
|
||||
structureManager = new StructureManager(this);
|
||||
soundManager = new SoundManager(this);
|
||||
|
||||
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Generator.Enable")) {
|
||||
|
||||
if (this.config.getBoolean("Island.Generator.Enable")) {
|
||||
generatorManager = new GeneratorManager(this);
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.Enable")) {
|
||||
if (this.config.getBoolean("Island.Stackable.Enable")) {
|
||||
stackableManager = new StackableManager(this);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> stackableManager.loadSavedStackables(), 5L);
|
||||
}
|
||||
@ -184,8 +208,15 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
bankManager = new BankManager(this);
|
||||
|
||||
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
|
||||
if (this.config.getBoolean("Island.Task.PlaytimeTask")) {
|
||||
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
}
|
||||
|
||||
if (this.config.getBoolean("Island.Task.VisitTask")) {
|
||||
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
}
|
||||
|
||||
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
|
||||
// Start Tasks
|
||||
@ -234,7 +265,7 @@ public class SkyBlock extends SongodaPlugin {
|
||||
this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
|
||||
}
|
||||
|
||||
switch (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getString("Economy.Manager", "Default")) {
|
||||
switch (this.config.getString("Economy.Manager", "Default")) {
|
||||
case "Vault":
|
||||
getEconomyManager().setEconomy("Vault");
|
||||
break;
|
||||
@ -244,6 +275,8 @@ public class SkyBlock extends SongodaPlugin {
|
||||
case "Reserve":
|
||||
getEconomyManager().setEconomy("Reserve");
|
||||
break;
|
||||
default:
|
||||
this.getLogger().warning("EconomyManager is default");
|
||||
}
|
||||
|
||||
this.coreProtectAPI = loadCoreProtect();
|
||||
@ -253,59 +286,43 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
if (this.userCacheManager != null) {
|
||||
if (this.userCacheManager != null)
|
||||
this.userCacheManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.scoreboardManager != null) {
|
||||
if (this.scoreboardManager != null)
|
||||
this.scoreboardManager.disable();
|
||||
}
|
||||
|
||||
if (this.islandManager != null) {
|
||||
if (this.islandManager != null)
|
||||
this.islandManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.visitManager != null) {
|
||||
if (this.visitManager != null)
|
||||
this.visitManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.banManager != null) {
|
||||
if (this.banManager != null)
|
||||
this.banManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.playerDataManager != null) {
|
||||
if (this.playerDataManager != null)
|
||||
this.playerDataManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.cooldownManager != null) {
|
||||
if (this.cooldownManager != null)
|
||||
this.cooldownManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.hologramTask != null) {
|
||||
if (this.hologramTask != null)
|
||||
this.hologramTask.onDisable();
|
||||
}
|
||||
|
||||
if (this.mobNetherWaterTask != null) {
|
||||
if (this.mobNetherWaterTask != null)
|
||||
this.mobNetherWaterTask.onDisable();
|
||||
}
|
||||
|
||||
if (this.fabledChallenge != null) {
|
||||
if (this.fabledChallenge != null)
|
||||
this.fabledChallenge.onDisable();
|
||||
}
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
}
|
||||
|
||||
private CoreProtectAPI loadCoreProtect() {
|
||||
Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
|
||||
if (plugin != null) { // Check before loading classes
|
||||
if (plugin instanceof CoreProtect) { // Check that CoreProtect is loaded
|
||||
CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI();
|
||||
if (CoreProtect.isEnabled()) { // Check that the API is enabled
|
||||
if (CoreProtect.APIVersion() >= 6) { // Check that a compatible version of the API is loaded
|
||||
return CoreProtect;
|
||||
}
|
||||
// Check that the API is enabled and Check that a compatible version of the API is loaded
|
||||
if (CoreProtect.isEnabled() && CoreProtect.APIVersion() >= 6) {
|
||||
return CoreProtect;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,7 +331,8 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
|
||||
if (!loadConfigs()) this.getLogger().warning("Config are not reload !");
|
||||
else this.getLogger().info("Configurations Loaded !");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -322,7 +340,32 @@ public class SkyBlock extends SongodaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String formatText(String string) {
|
||||
|
||||
private boolean loadConfigs() {
|
||||
try {
|
||||
biomes = this.getFileManager().getConfig(new File(this.getDataFolder(),"biomes.yml")).getFileConfiguration();
|
||||
challenges = this.getFileManager().getConfig(new File(this.getDataFolder(),"challenges.yml")).getFileConfiguration();
|
||||
config = this.getFileManager().getConfig(new File(this.getDataFolder(),"config.yml")).getFileConfiguration();
|
||||
generators = this.getFileManager().getConfig(new File(this.getDataFolder(),"generators.yml")).getFileConfiguration();
|
||||
language = this.getFileManager().getConfig(new File(this.getDataFolder(),"language.yml")).getFileConfiguration();
|
||||
levelling = this.getFileManager().getConfig(new File(this.getDataFolder(),"levelling.yml")).getFileConfiguration();
|
||||
limits = this.getFileManager().getConfig(new File(this.getDataFolder(),"limits.yml")).getFileConfiguration();
|
||||
menus = this.getFileManager().getConfig(new File(this.getDataFolder(),"menus.yml")).getFileConfiguration();
|
||||
placeholders = this.getFileManager().getConfig(new File(this.getDataFolder(),"placeholders.yml")).getFileConfiguration();
|
||||
rewards = this.getFileManager().getConfig(new File(this.getDataFolder(),"rewards.yml")).getFileConfiguration();
|
||||
scoreboard = this.getFileManager().getConfig(new File(this.getDataFolder(),"scoreboard.yml")).getFileConfiguration();
|
||||
settings = this.getFileManager().getConfig(new File(this.getDataFolder(),"settings.yml")).getFileConfiguration();
|
||||
stackables = this.getFileManager().getConfig(new File(this.getDataFolder(),"stackables.yml")).getFileConfiguration();
|
||||
upgrades = this.getFileManager().getConfig(new File(this.getDataFolder(),"upgrades.yml")).getFileConfiguration();
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String formatText(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
@ -478,4 +521,34 @@ public class SkyBlock extends SongodaPlugin {
|
||||
public EconomyManager getEconomyManager() {
|
||||
return economyManager;
|
||||
}
|
||||
|
||||
|
||||
public FileConfiguration getBiomes() { return biomes; }
|
||||
|
||||
public FileConfiguration getChallenges() { return challenges; }
|
||||
|
||||
public FileConfiguration getConfiguration() { return config; }
|
||||
|
||||
public FileConfiguration getGenerators() { return generators; }
|
||||
|
||||
public FileConfiguration getLanguage() { return language; }
|
||||
|
||||
public FileConfiguration getLevelling() { return levelling; }
|
||||
|
||||
public FileConfiguration getLimits() { return limits; }
|
||||
|
||||
public FileConfiguration getMenus() { return menus; }
|
||||
|
||||
public FileConfiguration getPlaceholders() { return placeholders; }
|
||||
|
||||
public FileConfiguration getRewards() { return rewards; }
|
||||
|
||||
public FileConfiguration getSettings() { return settings; }
|
||||
|
||||
public FileConfiguration getStackables() { return stackables; }
|
||||
|
||||
public FileConfiguration getUpgrades() { return upgrades; }
|
||||
|
||||
public FileConfiguration getScoreboard() { return scoreboard; }
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.bank.BankManager;
|
||||
import com.songoda.skyblock.bank.Transaction;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -15,6 +16,8 @@ public class TransactionLog {
|
||||
}
|
||||
|
||||
public List<Transaction> getLogForPlayer(UUID uuid) {
|
||||
return getImplementation().getTransactionList(Bukkit.getPlayer(uuid));
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) return null;
|
||||
return getImplementation().getTransactionList(player);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.api.biome;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.core.compatibility.CompatibleBiome;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -20,6 +21,6 @@ public class BiomeManager {
|
||||
Preconditions.checkArgument(island != null, "Cannot set biome to null island");
|
||||
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
|
||||
|
||||
this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, biome, null);
|
||||
this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, CompatibleBiome.getBiome(biome), null);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class IslandUpgradeEvent extends IslandEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private IslandUpgrade upgrade;
|
||||
private final IslandUpgrade upgrade;
|
||||
|
||||
public IslandUpgradeEvent(Island island, Player player, IslandUpgrade upgrade) {
|
||||
super(island);
|
||||
|
@ -8,8 +8,8 @@ public class IslandWeatherChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final boolean sync;
|
||||
private WeatherType weather;
|
||||
private int time;
|
||||
private final WeatherType weather;
|
||||
private final int time;
|
||||
|
||||
public IslandWeatherChangeEvent(Island island, WeatherType weather, int time, boolean sync) {
|
||||
super(island);
|
||||
|
@ -8,7 +8,7 @@ public class PlayerIslandChatSwitchEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean chat;
|
||||
private final boolean chat;
|
||||
|
||||
public PlayerIslandChatSwitchEvent(Player player, Island island, boolean chat) {
|
||||
super(player, island);
|
||||
|
@ -9,7 +9,7 @@ public class PlayerVoteEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
private static HandlerList HANDLERS = new HandlerList();
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public PlayerVoteEvent(Player player, Island island) {
|
||||
super(player, island);
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerVoteRemoveEvent extends PlayerEvent {
|
||||
private static HandlerList HANDLERS = new HandlerList();
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public PlayerVoteRemoveEvent(Player player, Island island) {
|
||||
super(player, island);
|
||||
|
@ -8,8 +8,8 @@ public class PlayerWithdrawMoneyEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private Player player;
|
||||
private double money;
|
||||
private final Player player;
|
||||
private final double money;
|
||||
|
||||
public PlayerWithdrawMoneyEvent(Player player, double money) {
|
||||
this.player = player;
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
public class IslandInvitation {
|
||||
|
||||
private final Player invited, inviter;
|
||||
private int time;
|
||||
private final int time;
|
||||
|
||||
public IslandInvitation(Player invited, Player inviter, int time) {
|
||||
this.invited = invited;
|
||||
|
@ -499,9 +499,7 @@ public class Island {
|
||||
if (!(object instanceof Island))
|
||||
return false;
|
||||
Island other = (Island) object;
|
||||
if (!other.getIslandUUID().equals(getIslandUUID()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return other.getIslandUUID().equals(getIslandUUID());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import org.bukkit.World;
|
||||
|
||||
public class IslandLocation {
|
||||
|
||||
private IslandEnvironment environment;
|
||||
private IslandWorld world;
|
||||
private Location location;
|
||||
private final IslandEnvironment environment;
|
||||
private final IslandWorld world;
|
||||
private final Location location;
|
||||
|
||||
public IslandLocation(IslandEnvironment environment, IslandWorld world, Location location) {
|
||||
this.environment = environment;
|
||||
|
@ -29,12 +29,6 @@ public class StructureManager {
|
||||
* @return A List of Structures for an Island
|
||||
*/
|
||||
public List<Structure> getStructures() {
|
||||
List<Structure> structures = new ArrayList<>();
|
||||
|
||||
for (Structure structureList : structureManager.getStructures()) {
|
||||
structures.add(structureList);
|
||||
}
|
||||
|
||||
return structures;
|
||||
return new ArrayList<>(structureManager.getStructures());
|
||||
}
|
||||
}
|
||||
|
@ -62,15 +62,12 @@ public class Ban {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
|
||||
|
||||
if (!islandBanEvent.isCancelled()) {
|
||||
List<String> islandBans = new ArrayList<>();
|
||||
FileConfiguration configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
for (String islandBanList : configLoad.getStringList("Bans")) {
|
||||
islandBans.add(islandBanList);
|
||||
}
|
||||
List<String> islandBans = new ArrayList<>(configLoad.getStringList("Bans"));
|
||||
|
||||
islandBans.add(banned.toString());
|
||||
configLoad.set("Bans", islandBans);
|
||||
|
@ -21,7 +21,7 @@ import java.util.UUID;
|
||||
public class BanManager {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private Map<UUID, Ban> banStorage = new HashMap<>();
|
||||
private final Map<UUID, Ban> banStorage = new HashMap<>();
|
||||
|
||||
public BanManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -40,7 +40,7 @@ public class BanManager {
|
||||
public void loadIslands() {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (!this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Visitor.Unload")) {
|
||||
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
|
||||
|
||||
@ -76,10 +76,8 @@ public class BanManager {
|
||||
public void removeVisitor(Island island) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getLanguage();
|
||||
|
||||
for (UUID visitorList : plugin.getIslandManager().getVisitorsAtIsland(island)) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
|
||||
|
@ -20,8 +20,7 @@ public class BankManager {
|
||||
|
||||
public BankManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
lang = config.getFileConfiguration();
|
||||
lang = this.plugin.getLanguage();
|
||||
log = new HashMap<>();
|
||||
loadTransactions();
|
||||
}
|
||||
@ -107,7 +106,7 @@ public class BankManager {
|
||||
}
|
||||
|
||||
// If decimals aren't allowed, check for them
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
int intAmt = (int) amt;
|
||||
if (intAmt != amt) {
|
||||
return BankResponse.DECIMALS_NOT_ALLOWED;
|
||||
@ -135,7 +134,6 @@ public class BankManager {
|
||||
|
||||
public BankResponse withdraw(Player player, Island island, double amt, boolean admin) {
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
// Make sure the amount is positive
|
||||
if (amt <= 0) {
|
||||
@ -143,7 +141,7 @@ public class BankManager {
|
||||
}
|
||||
|
||||
// If decimals aren't allowed, check for them
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
int intAmt = (int) amt;
|
||||
if (intAmt != amt) {
|
||||
return BankResponse.DECIMALS_NOT_ALLOWED;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.skyblock.biome;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleBiome;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.blockscanner.ChunkLoader;
|
||||
@ -21,8 +22,6 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class BiomeManager {
|
||||
|
||||
final ServerVersion ASYNC_OBFUSCATOR_VERSION = ServerVersion.V1_9;
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final List<Island> updatingIslands;
|
||||
@ -32,7 +31,7 @@ public class BiomeManager {
|
||||
public BiomeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.updatingIslands = new ArrayList<>();
|
||||
this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.language = SkyBlock.getInstance().getLanguage();
|
||||
this.runEveryX = language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates");
|
||||
}
|
||||
|
||||
@ -48,7 +47,7 @@ public class BiomeManager {
|
||||
updatingIslands.remove(island);
|
||||
}
|
||||
|
||||
public void setBiome(Island island, IslandWorld world, Biome biome, CompleteTask task) {
|
||||
public void setBiome(Island island, IslandWorld world, CompatibleBiome biome, CompleteTask task) {
|
||||
addUpdatingIsland(island);
|
||||
|
||||
if (island.getLocation(world, IslandEnvironment.Island) == null) return;
|
||||
@ -59,17 +58,13 @@ public class BiomeManager {
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (futureChunk) -> {
|
||||
Chunk chunk = futureChunk.join();
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there
|
||||
setChunkBiome3D(biome, chunk);
|
||||
} else {
|
||||
try {
|
||||
setChunkBiome2D(biome, chunk);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (chunk != null)
|
||||
biome.setBiome(chunk);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updateBiomePacket(island, chunk);
|
||||
|
||||
|
||||
progress.getAndIncrement();
|
||||
|
||||
if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") &&
|
||||
@ -94,61 +89,6 @@ public class BiomeManager {
|
||||
}));
|
||||
}
|
||||
|
||||
private void setChunkBiome2D(Biome biome, Chunk chunk) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){
|
||||
for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){
|
||||
World.class.getMethod("setBiome", int.class, int.class, Biome.class).invoke(chunk.getWorld(), x, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do not use - Too laggy
|
||||
private void setChunkBiome3D(Biome biome, Chunk chunk) {
|
||||
for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){
|
||||
for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){
|
||||
for(int y = 0; y < chunk.getWorld().getMaxHeight(); ++y) {
|
||||
chunk.getWorld().setBiome(x, y, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateBiomePacket(Island island, Chunk chunk) {
|
||||
Class<?> packetPlayOutMapChunkClass;
|
||||
Class<?> chunkClass;
|
||||
|
||||
packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
|
||||
for (Player player : plugin.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
try {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
||||
NMSUtil.sendPacket(player,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class, boolean.class).newInstance(player
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
|
||||
65535, true));
|
||||
} else {
|
||||
NMSUtil.sendPacket(player,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
|
||||
65535));
|
||||
}
|
||||
} else {
|
||||
NMSUtil.sendPacket(player,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class)
|
||||
.newInstance(player.getLocation().getChunk().getClass().getMethod("getHandle")
|
||||
.invoke(chunk), true, 20));
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface CompleteTask {
|
||||
void onCompleteUpdate();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
this.completedNum = new AtomicInteger();
|
||||
this.island = island;
|
||||
|
||||
FileConfiguration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
FileConfiguration config = SkyBlock.getInstance().getConfiguration();
|
||||
|
||||
int threadCount = 0;
|
||||
|
||||
|
@ -38,9 +38,7 @@ public class ChunkLoader extends BukkitRunnable {
|
||||
boolean chunkForChunk,
|
||||
ChunkForChunkScannerTask chunkTask,
|
||||
CompleteTask complete) {
|
||||
chunkPerTick = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
chunkPerTick = SkyBlock.getInstance().getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
|
||||
this.completeTask = complete;
|
||||
this.chunkTask = chunkTask;
|
||||
@ -78,9 +76,7 @@ public class ChunkLoader extends BukkitRunnable {
|
||||
boolean chunkForChunk,
|
||||
ChunkScannerTask generalTask,
|
||||
CompleteTask complete) {
|
||||
chunkPerTick = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
chunkPerTick = SkyBlock.getInstance().getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
|
||||
this.completeTask = complete;
|
||||
this.generalTask = generalTask;
|
||||
|
@ -2,11 +2,15 @@ package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.bank.BankManager;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,9 +21,7 @@ import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Challenge {
|
||||
@ -117,6 +119,63 @@ public class Challenge {
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
CHALLENGE {
|
||||
|
||||
@Override
|
||||
public Object convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
String[] test = value.split("\\.");
|
||||
if (test.length != 6) {
|
||||
throw new IllegalArgumentException("Your config is not good, correct syntax : CHALLENGE:category.[id_category].challenges.[id_challenges].count.[count_times]");
|
||||
}
|
||||
List<Integer> integerList = new ArrayList<Integer>();
|
||||
|
||||
Arrays.stream(test).filter(condition -> !condition.equalsIgnoreCase("category") && !condition.equalsIgnoreCase("challenges") && !condition.equalsIgnoreCase("count")).forEachOrdered(condition -> {
|
||||
try {
|
||||
integerList.add(Integer.parseInt(condition));
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + condition + "\" isn't a valid number (value = \"" + value + "\")");
|
||||
}
|
||||
});
|
||||
return integerList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj){
|
||||
List<Integer> is = (List<Integer>) obj;
|
||||
SkyBlock instance = SkyBlock.getInstance();
|
||||
FileManager.Config config = instance.getFileManager().getConfig(new File(new File(instance.getDataFolder(), "challenge-data"), p.getUniqueId().toString() + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
ConfigurationSection section = fileConfig.getConfigurationSection("challenges");
|
||||
for (String k : (section != null) ? section.getKeys(false) : new HashSet<String>()) {
|
||||
int id = fileConfig.getInt("challenges." + k + ".id");
|
||||
if (is.get(0) == id) {
|
||||
ChallengeCategory cc = SkyBlock.getInstance().getFabledChallenge().getChallengeManager().getChallenge(id);
|
||||
if (cc != null) {
|
||||
ConfigurationSection section2 = fileConfig.getConfigurationSection("challenges." + k + ".challenges");
|
||||
if (section2 != null && !section2.getKeys(false).isEmpty() && section2.getKeys(false).stream().map(d -> "challenges." + k + ".challenges." + d).anyMatch(key -> is.get(1) == fileConfig.getInt(key + ".id") && fileConfig.getInt(key + ".count") >= is.get(2))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeReward(Player p, Object obj) {
|
||||
// Nothing
|
||||
}
|
||||
},
|
||||
ITEM {
|
||||
// An item
|
||||
|
||||
@ -131,7 +190,7 @@ public class Challenge {
|
||||
// The id
|
||||
String id = index == -1 ? value : value.substring(0, index);
|
||||
// Check if it's a Minecraft item
|
||||
Material m = CompatibleMaterial.getMaterial(id).getMaterial();
|
||||
CompatibleMaterial m = CompatibleMaterial.getMaterial(id);
|
||||
//Material m = Material.matchMaterial(id);
|
||||
if (m == null)
|
||||
throw new IllegalArgumentException(
|
||||
@ -146,68 +205,58 @@ public class Challenge {
|
||||
"\"" + strAmount + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
}
|
||||
}
|
||||
return new ItemStack(m, amount);
|
||||
ItemStack item = m.getItem();
|
||||
item.setAmount(amount);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
boolean ignoreLore = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
boolean ignoreLore = SkyBlock.getInstance().getConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
if(obj instanceof ItemStack){
|
||||
// Check if player has specific item in his inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
if(ignoreLore){
|
||||
return p.getInventory().contains(is.getType(), is.getAmount());
|
||||
return p.getInventory().contains(is, is.getAmount());
|
||||
}
|
||||
return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount());
|
||||
return p.getInventory().containsAtLeast(is, is.getAmount());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
boolean ignoreLore = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
|
||||
if(obj instanceof ItemStack){
|
||||
// Remove specific item in player's inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
int toRemove = is.getAmount();
|
||||
for(ItemStack jis : p.getInventory().getContents()) {
|
||||
if(jis != null) {
|
||||
boolean isItem;
|
||||
if(ignoreLore){
|
||||
isItem = jis.getType().equals(is.getType());
|
||||
} else {
|
||||
isItem = jis.isSimilar(is);
|
||||
}
|
||||
|
||||
if(isItem) {
|
||||
if(jis.getAmount() <= toRemove) {
|
||||
toRemove -= jis.getAmount();
|
||||
p.getInventory().removeItem(jis);
|
||||
} else {
|
||||
jis.setAmount(jis.getAmount() - toRemove);
|
||||
toRemove = 0;
|
||||
}
|
||||
}
|
||||
if(toRemove <= 0) {
|
||||
p.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
boolean ignoreLore = SkyBlock.getInstance().getConfig().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
|
||||
if (obj instanceof ItemStack) {
|
||||
// Remove specific item in player's inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
int toRemove = is.getAmount();
|
||||
for (ItemStack jis : p.getInventory().getContents()) {
|
||||
if (jis == null) continue;
|
||||
if (ignoreLore ? ItemUtils.isSimilarMaterial(is, jis) : jis.isSimilar(is)) {
|
||||
if (jis.getAmount() <= toRemove) {
|
||||
toRemove -= jis.getAmount();
|
||||
p.getInventory().removeItem(jis);
|
||||
} else {
|
||||
jis.setAmount(jis.getAmount() - toRemove);
|
||||
toRemove = 0;
|
||||
}
|
||||
}
|
||||
if (toRemove <= 0) {
|
||||
p.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeReward(Player p, Object obj) {
|
||||
// Give specific item to player
|
||||
ItemStack is = (ItemStack) obj;
|
||||
HashMap<Integer, ItemStack> rest = p.getInventory()
|
||||
.addItem(new ItemStack(is.getType(), is.getAmount()));
|
||||
HashMap<Integer, ItemStack> rest = p.getInventory().addItem(is.clone());
|
||||
for (ItemStack restIs : rest.values())
|
||||
p.getWorld().dropItem(p.getLocation(), restIs);
|
||||
}
|
||||
@ -338,7 +387,7 @@ public class Challenge {
|
||||
},
|
||||
POTION {
|
||||
|
||||
private Pattern space = Pattern.compile(" ");
|
||||
private final Pattern space = Pattern.compile(" ");
|
||||
|
||||
@Override
|
||||
public Peer<PotionType, Peer<Integer, Integer>> convert(String value) throws IllegalArgumentException {
|
||||
|
@ -12,9 +12,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChallengeCategory {
|
||||
private int id;
|
||||
private String name;
|
||||
private HashMap<Integer, Challenge> challenges;
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final HashMap<Integer, Challenge> challenges;
|
||||
|
||||
public ChallengeCategory(int id, String name, FileConfiguration config) {
|
||||
this.id = id;
|
||||
|
@ -12,8 +12,8 @@ import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChallengeManager {
|
||||
private SkyBlock plugin;
|
||||
private HashMap<Integer, ChallengeCategory> categories;
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<Integer, ChallengeCategory> categories;
|
||||
|
||||
public ChallengeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -22,15 +22,14 @@ public class ChallengeManager {
|
||||
}
|
||||
|
||||
private void loadChallenges() {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getChallenges();
|
||||
|
||||
try {
|
||||
ConfigurationSection section = configLoad.getConfigurationSection("challenges");
|
||||
if (section != null) {
|
||||
for (String k : section.getKeys(false)) {
|
||||
int id = configLoad.getInt("challenges." + k + ".id");
|
||||
String name = ChatColor.translateAlternateColorCodes('&', configLoad.getString("challenges." + k + ".name"));
|
||||
String name = plugin.formatText(configLoad.getString("challenges." + k + ".name"));
|
||||
ChallengeCategory cc = new ChallengeCategory(id, name, configLoad);
|
||||
categories.put(id, cc);
|
||||
}
|
||||
|
@ -14,14 +14,14 @@ import java.util.UUID;
|
||||
|
||||
public class ItemChallenge {
|
||||
private Challenge challenge;
|
||||
private boolean show;
|
||||
private int row;
|
||||
private int col;
|
||||
private CompatibleMaterial type;
|
||||
private int amount;
|
||||
private List<String> lore;
|
||||
private final boolean show;
|
||||
private final int row;
|
||||
private final int col;
|
||||
private final CompatibleMaterial type;
|
||||
private final int amount;
|
||||
private final List<String> lore;
|
||||
|
||||
private String itemTitle;
|
||||
private final String itemTitle;
|
||||
|
||||
public ItemChallenge(boolean show, int row, int col, CompatibleMaterial type, int amount, List<String> lore) {
|
||||
this.show = show;
|
||||
@ -30,17 +30,12 @@ public class ItemChallenge {
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
this.lore = lore;
|
||||
|
||||
FileManager.Config langConfig = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
|
||||
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
|
||||
FileConfiguration langConfigLoad = SkyBlock.getInstance().getLanguage();
|
||||
itemTitle = langConfigLoad.getString("Challenge.Inventory.Item.Title");
|
||||
}
|
||||
|
||||
public ItemStack createItem(UUID player, int amount) {
|
||||
FileManager.Config langConfig = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
|
||||
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
|
||||
FileConfiguration langConfigLoad = SkyBlock.getInstance().getLanguage();
|
||||
|
||||
ItemStack is = type.getItem();
|
||||
is.setAmount(this.amount);
|
||||
@ -53,9 +48,8 @@ public class ItemChallenge {
|
||||
} else {
|
||||
maxAmount = String.valueOf(challenge.getMaxTimes());
|
||||
}
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
itemTitle.replace("%challenge", challenge.getName()).replace("%amount", Integer.toString(amount))
|
||||
.replace("%max", maxAmount)));
|
||||
im.setDisplayName(SkyBlock.getInstance().formatText( challenge.getName()).replace("%amount", Integer.toString(amount))
|
||||
.replace("%max", maxAmount));
|
||||
im.setLore(lore);
|
||||
is.setItemMeta(im);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
public class Peer<E, F> {
|
||||
private E key;
|
||||
private F value;
|
||||
private final E key;
|
||||
private final F value;
|
||||
|
||||
public Peer(E key, F value) {
|
||||
this.key = key;
|
||||
|
@ -17,12 +17,11 @@ import java.util.List;
|
||||
|
||||
public class DefaultInventory {
|
||||
private final Item defaultItem = new Item(new ItemStack(Material.AIR));
|
||||
private int size;
|
||||
private Item[][] items;
|
||||
private final int size;
|
||||
private final Item[][] items;
|
||||
|
||||
public DefaultInventory(SkyBlock plugin) {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getChallenges();
|
||||
size = configLoad.getInt("inventory.size");
|
||||
items = new Item[9][size];
|
||||
ConfigurationSection section = configLoad.getConfigurationSection("inventory.items");
|
||||
@ -35,7 +34,7 @@ public class DefaultInventory {
|
||||
int col = configLoad.getInt(k + ".col");
|
||||
String strItem = configLoad.getString(k + ".item");
|
||||
int amount = configLoad.getInt(k + ".amount");
|
||||
String name = ChatColor.translateAlternateColorCodes('&', configLoad.getString(k + ".name"));
|
||||
String name = plugin.formatText(configLoad.getString(k + ".name"));
|
||||
List<String> lore = toColor(configLoad.getStringList(k + ".lore"));
|
||||
int redirect = configLoad.getInt(k + ".redirect");
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(strItem);
|
||||
|
@ -3,8 +3,8 @@ package com.songoda.skyblock.challenge.defaultinv;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Item {
|
||||
private ItemStack itemStack;
|
||||
private int redirect;
|
||||
private final ItemStack itemStack;
|
||||
private final int redirect;
|
||||
|
||||
public Item(ItemStack itemStack) {
|
||||
this(itemStack, 0);
|
||||
|
@ -9,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClickableItem {
|
||||
private ItemStack item;
|
||||
private Consumer<InventoryClickEvent> event;
|
||||
private final ItemStack item;
|
||||
private final Consumer<InventoryClickEvent> event;
|
||||
|
||||
private ClickableItem(ItemStack item, Consumer<InventoryClickEvent> event) {
|
||||
this.item = item;
|
||||
|
@ -14,14 +14,14 @@ import java.util.function.Consumer;
|
||||
|
||||
public class Inventory {
|
||||
public static final String TICK = "tick";
|
||||
private HashMap<String, Object> values;
|
||||
private Player player;
|
||||
private InventoryProvider inventoryProvider;
|
||||
private int size;
|
||||
private final HashMap<String, Object> values;
|
||||
private final Player player;
|
||||
private final InventoryProvider inventoryProvider;
|
||||
private final int size;
|
||||
|
||||
private List<Integer> excluseCases;
|
||||
private ClickableItem[] items;
|
||||
private org.bukkit.inventory.Inventory bukkitInventory;
|
||||
private final List<Integer> excluseCases;
|
||||
private final ClickableItem[] items;
|
||||
private final org.bukkit.inventory.Inventory bukkitInventory;
|
||||
|
||||
public Inventory(Player player, InventoryProvider inventoryProvider, Consumer<Inventory> params) {
|
||||
this.values = new HashMap<>();
|
||||
|
@ -20,9 +20,8 @@ import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class InventoryManager implements Listener {
|
||||
private SkyBlock plugin;
|
||||
private HashMap<UUID, Inventory> inventories;
|
||||
private int task;
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<UUID, Inventory> inventories;
|
||||
|
||||
public InventoryManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -31,7 +30,7 @@ public class InventoryManager implements Listener {
|
||||
|
||||
public void init() {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
if (inventories.size() == 0)
|
||||
return;
|
||||
for (Inventory inv : inventories.values()) {
|
||||
|
@ -10,18 +10,18 @@ import java.util.List;
|
||||
|
||||
public interface InventoryProvider {
|
||||
|
||||
public String title(Inventory inv);
|
||||
String title(Inventory inv);
|
||||
|
||||
public int rows(Inventory inv);
|
||||
int rows(Inventory inv);
|
||||
|
||||
public void init(Inventory inv);
|
||||
void init(Inventory inv);
|
||||
|
||||
public void update(Inventory inv);
|
||||
void update(Inventory inv);
|
||||
|
||||
public default List<Integer> excluseCases(Inventory inv) {
|
||||
default List<Integer> excluseCases(Inventory inv) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public default void onClose(InventoryCloseEvent e, Inventory inv) {
|
||||
default void onClose(InventoryCloseEvent e, Inventory inv) {
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import java.util.logging.Level;
|
||||
|
||||
public class ChallengeInventory implements InventoryProvider {
|
||||
public static final String CATEGORY = "ChallengeCategory";
|
||||
private FabledChallenge fc;
|
||||
private final FabledChallenge fc;
|
||||
|
||||
public ChallengeInventory(FabledChallenge fc) {
|
||||
this.fc = fc;
|
||||
|
@ -6,8 +6,8 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerChallenge {
|
||||
private UUID uuid;
|
||||
private HashMap<Challenge, Integer> challenges;
|
||||
private final UUID uuid;
|
||||
private final HashMap<Challenge, Integer> challenges;
|
||||
|
||||
public PlayerChallenge(UUID uuid, HashMap<Challenge, Integer> challenges) {
|
||||
this.uuid = uuid;
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
@ -23,9 +24,9 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerManager {
|
||||
private SkyBlock plugin;
|
||||
private HashMap<UUID, HashMap<Challenge, Integer>> islands;
|
||||
private File playersDirectory;
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<UUID, HashMap<Challenge, Integer>> islands;
|
||||
private final File playersDirectory;
|
||||
|
||||
public PlayerManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -35,14 +36,12 @@ public class PlayerManager {
|
||||
playersDirectory.mkdirs();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||
loadPlayer(p.getUniqueId());
|
||||
}
|
||||
Bukkit.getServer().getOnlinePlayers().stream().map(Entity::getUniqueId).forEach(this::loadPlayer);
|
||||
});
|
||||
}
|
||||
|
||||
public HashMap<Challenge, Integer> getPlayer(UUID uuid) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
@ -63,7 +62,7 @@ public class PlayerManager {
|
||||
* The uuid of specific player
|
||||
*/
|
||||
public void loadPlayer(UUID uuid) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
@ -104,7 +103,7 @@ public class PlayerManager {
|
||||
* The uuid of specific player
|
||||
*/
|
||||
public void unloadPlayer(UUID uuid) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
@ -138,7 +137,7 @@ public class PlayerManager {
|
||||
if (c == null)
|
||||
return false;
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
@ -174,7 +173,7 @@ public class PlayerManager {
|
||||
if (!canDoChallenge(p, c))
|
||||
return false;
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
@ -193,10 +192,8 @@ public class PlayerManager {
|
||||
peer.getKey().executeReward(p, peer.getValue());
|
||||
}
|
||||
// Ok, send message
|
||||
String broadcast = ChatColor.translateAlternateColorCodes('&',
|
||||
SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Challenge.Broadcast"));
|
||||
SkyBlock instance = SkyBlock.getInstance();
|
||||
String broadcast = instance.formatText(instance.getLanguage().getString("Challenge.Broadcast"));
|
||||
if (c.isShowInChat())
|
||||
Bukkit.broadcastMessage(broadcast.replace("%player", p.getName()).replace("%challenge", c.getName())
|
||||
.replace("%amount", Integer.toString(count + 1))
|
||||
@ -205,7 +202,7 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
public void addChallenge(UUID uuid, Challenge c) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
@ -244,7 +241,7 @@ public class PlayerManager {
|
||||
if (challenges != null) {
|
||||
return challenges.getOrDefault(c, 0);
|
||||
} else {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
|
@ -38,11 +38,14 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
public CommandManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("island").setExecutor(this);
|
||||
plugin.getCommand("island").setTabCompleter(this);
|
||||
|
||||
registerSubCommands();
|
||||
PluginCommand islandCMD = plugin.getCommand("island");
|
||||
if (islandCMD != null) {
|
||||
islandCMD.setExecutor(this);
|
||||
islandCMD.setTabCompleter(this);
|
||||
registerSubCommands();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void registerSubCommands() {
|
||||
@ -127,13 +130,9 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
if (command.getName().equalsIgnoreCase("island")) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration languageConfigLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration mainConfig = config.getFileConfiguration();
|
||||
FileConfiguration languageConfigLoad = plugin.getLanguage();
|
||||
FileConfiguration mainConfig = plugin.getConfiguration();
|
||||
|
||||
Player player = null;
|
||||
|
||||
@ -189,7 +188,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
if (args.length == 2) {
|
||||
if (args[1].matches("[0-9]+")) {
|
||||
page = Integer.valueOf(args[1]);
|
||||
page = Integer.parseInt(args[1]);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
@ -221,13 +220,12 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
int page = -1;
|
||||
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Command.Help.List")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Command.Help.List")) {
|
||||
page = 1;
|
||||
|
||||
if (args.length == 3) {
|
||||
if (args[2].matches("[0-9]+")) {
|
||||
page = Integer.valueOf(args[2]);
|
||||
page = Integer.parseInt(args[2]);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
@ -493,8 +491,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
player.spigot()
|
||||
.sendMessage(
|
||||
new ChatComponent(
|
||||
ChatColor.translateAlternateColorCodes(
|
||||
'&', configLoad.getString("Command.Island.Help.Word.Next")),
|
||||
plugin.formatText(configLoad.getString("Command.Island.Help.Word.Next")),
|
||||
false, null,
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/island " + subCommandText + "help " + (page + 1)),
|
||||
@ -503,8 +500,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
player.spigot()
|
||||
.sendMessage(
|
||||
new ChatComponent(
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Command.Island.Help.Word.Previous")),
|
||||
plugin.formatText(configLoad.getString("Command.Island.Help.Word.Previous")),
|
||||
false, null,
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/island " + subCommandText + "help " + (page - 1)),
|
||||
|
@ -15,7 +15,7 @@ public abstract class SubCommand {
|
||||
|
||||
public SubCommand() {
|
||||
this.plugin = SkyBlock.getInstance();
|
||||
this.info = ChatColor.translateAlternateColorCodes('&', this.plugin.getFileManager().getConfig(new File(this.plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString(this.getInfoMessagePath()));
|
||||
this.info = this.plugin.formatText(this.plugin.getLanguage().getString(this.getInfoMessagePath()));
|
||||
}
|
||||
|
||||
public abstract void onCommandByPlayer(Player player, String[] args);
|
||||
|
@ -36,7 +36,7 @@ public class AdminBank extends SubCommand {
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
return;
|
||||
@ -60,7 +60,7 @@ public class AdminBank extends SubCommand {
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
@ -68,7 +68,7 @@ public class AdminBank extends SubCommand {
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
@ -122,7 +122,7 @@ public class AdminBank extends SubCommand {
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
@ -130,7 +130,7 @@ public class AdminBank extends SubCommand {
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
|
@ -52,7 +52,7 @@ public class ChatSpyCommand extends SubCommand {
|
||||
case "add":
|
||||
if(args.length == 2){
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
|
||||
Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer());
|
||||
Island island = islandManager.getIslandByOwner(offlinePlayer.getBukkitOfflinePlayer());
|
||||
if(island != null) {
|
||||
playerData.addChatSpyIsland(island);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message")
|
||||
@ -68,7 +68,7 @@ public class ChatSpyCommand extends SubCommand {
|
||||
case "remove":
|
||||
if(args.length == 2){
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
|
||||
Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer());
|
||||
Island island = islandManager.getIslandByOwner(offlinePlayer.getBukkitOfflinePlayer());
|
||||
if(island != null) {
|
||||
playerData.removeChatSpyIsland(island);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message")
|
||||
|
@ -92,7 +92,7 @@ public class SetBiomeCommand extends SubCommand {
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
biomeManager.setBiome(island, world, biome.getBiome(), null);
|
||||
biomeManager.setBiome(island, world, biome, null);
|
||||
if(world.equals(IslandWorld.Normal)) {
|
||||
island.setBiome(biome.getBiome());
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class SetBiomeCommand extends SubCommand {
|
||||
} else {
|
||||
CompatibleBiome finalBiome = biome;
|
||||
IslandWorld finalWorld = world;
|
||||
biomeManager.setBiome(island, world, biome.getBiome(), () -> {
|
||||
biomeManager.setBiome(island, world, biome, () -> {
|
||||
if(finalWorld.equals(IslandWorld.Normal)) {
|
||||
island.setBiome(finalBiome.getBiome());
|
||||
}
|
||||
|
@ -79,8 +79,7 @@ public class SetMaxMembers extends SubCommand {
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
island.setMaxMembers(maxMembers);
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
|
@ -79,8 +79,7 @@ public class SetSizeCommand extends SubCommand {
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
island.setSize(size);
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class AcceptCommand extends SubCommand {
|
||||
island.save();
|
||||
|
||||
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
|
||||
+ 1) >= island.getMaxMembers()) {
|
||||
+ 1) >= island.getMaxMembers(player)) {
|
||||
Map<UUID, Invite> invites = inviteManager.getInvites();
|
||||
|
||||
for (UUID inviteList : invites.keySet()) {
|
||||
|
@ -41,7 +41,7 @@ public class BanCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
} else if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Ban", IslandRole.Operator))) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
@ -27,7 +27,7 @@ public class BankCommand extends SubCommand {
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
|
@ -38,7 +38,7 @@ public class BorderCommand extends SubCommand {
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& permissionManager.hasPermission(island, "Border", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.WorldBorder.Enable")) {
|
||||
Border.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
@ -30,14 +30,14 @@ public class ChallengeCommand extends SubCommand {
|
||||
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
|
||||
|
||||
// Not loaded
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (!this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.Enable")) {
|
||||
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland")){
|
||||
if(islandManager.getIsland(player) == null){
|
||||
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message"));
|
||||
|
@ -136,7 +136,7 @@ public class ConfirmCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (economy.isEnabled() && island.getStructure() != null
|
||||
if (economy != null && economy.isEnabled() && island.getStructure() != null
|
||||
&& !island.getStructure().isEmpty()
|
||||
&& structureManager.containsStructure(island.getStructure())) {
|
||||
Structure structure = structureManager.getStructure(island.getStructure());
|
||||
|
@ -39,7 +39,7 @@ public class CoopCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
} else if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Coop.Enable")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|
@ -50,7 +50,7 @@ public class InviteCommand extends SubCommand {
|
||||
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
|
||||
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
|
||||
+ 1) >= island.getMaxMembers()) {
|
||||
+ 1) >= island.getMaxMembers(player)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Capacity.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
|
@ -28,7 +28,7 @@ public class LeaderboardCommand extends SubCommand {
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
if (args.length == 0) {
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player)
|
||||
.setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Browse));
|
||||
@ -46,7 +46,7 @@ public class LeaderboardCommand extends SubCommand {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Bank));
|
||||
break;
|
||||
case "votes":
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Votes));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Leaderboard.Disabled.Message"));
|
||||
|
@ -126,8 +126,7 @@ public class OwnerCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
} else {
|
||||
int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Confirmation.Timeout");
|
||||
int confirmationTime = this.plugin.getConfiguration().getInt("Island.Confirmation.Timeout");
|
||||
|
||||
playerData.setOwnership(targetPlayerUUID);
|
||||
playerData.setConfirmation(Confirmation.Ownership);
|
||||
|
@ -34,105 +34,16 @@ public class SetSpawnCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
IslandEnvironment environment;
|
||||
|
||||
if (args[0].equalsIgnoreCase("Main")) {
|
||||
environment = IslandEnvironment.Main;
|
||||
setIslandSpawn(IslandEnvironment.Main, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
|
||||
} else if (args[0].equalsIgnoreCase("Visitor")) {
|
||||
environment = IslandEnvironment.Visitor;
|
||||
setIslandSpawn(IslandEnvironment.Visitor, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
|
||||
} else if (args[0].equalsIgnoreCase("All")){
|
||||
setIslandSpawn(IslandEnvironment.Main, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
|
||||
setIslandSpawn(IslandEnvironment.Visitor, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Spawn.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& (plugin.getPermissionManager().hasPermission(island,
|
||||
environment.name() + "Spawn", IslandRole.Operator)))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (islandManager.isPlayerAtIsland(island, player)) {
|
||||
IslandWorld world = plugin.getWorldManager().getIslandWorld(player.getWorld());
|
||||
Location location = player.getLocation();
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
|
||||
CompatibleMaterial toCompare = CompatibleMaterial.getMaterial(location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType());
|
||||
|
||||
if(toCompare == CompatibleMaterial.AIR
|
||||
|| toCompare == CompatibleMaterial.MOVING_PISTON
|
||||
|| toCompare == CompatibleMaterial.ICE
|
||||
|| toCompare == CompatibleMaterial.PISTON_HEAD) {
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} 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, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (location.getBlock().isLiquid()
|
||||
|| location.clone().add(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (CompatibleMaterial.getMaterial(location.getBlock().getType()) == CompatibleMaterial.NETHER_PORTAL
|
||||
|| CompatibleMaterial.getMaterial(location.clone().add(0.0D, 1.0D, 0.0D).getBlock()
|
||||
.getType()) == CompatibleMaterial.NETHER_PORTAL) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else {
|
||||
CompatibleMaterial type = CompatibleMaterial.getMaterial(location.getBlock().getType());
|
||||
if (type.isSolid() && type.isOccluding()) {
|
||||
location.getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
CompatibleMaterial typeBelow = CompatibleMaterial.getMaterial(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();
|
||||
}
|
||||
|
||||
islandManager.removeSpawnProtection(island.getLocation(world, environment));
|
||||
}
|
||||
}
|
||||
|
||||
Location newSpawnLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
island.setLocation(world, environment, newSpawnLocation);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn",
|
||||
environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn",
|
||||
environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn",
|
||||
environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Role.Message")
|
||||
.replace("%spawn", environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -163,6 +74,97 @@ public class SetSpawnCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"main", "visitor"};
|
||||
return new String[]{ "main", "visitor" , "all"};
|
||||
}
|
||||
|
||||
|
||||
private void setIslandSpawn(IslandEnvironment environment, Island island, IslandManager islandManager, Player player, FileConfiguration configLoad, FileManager fileManager, MessageManager messageManager, SoundManager soundManager) {
|
||||
if (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& (plugin.getPermissionManager().hasPermission(island,
|
||||
environment.name() + "Spawn", IslandRole.Operator)))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (islandManager.isPlayerAtIsland(island, player)) {
|
||||
IslandWorld world = plugin.getWorldManager().getIslandWorld(player.getWorld());
|
||||
Location location = player.getLocation();
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
|
||||
CompatibleMaterial toCompare = CompatibleMaterial.getMaterial(location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType());
|
||||
|
||||
if(toCompare == CompatibleMaterial.AIR
|
||||
|| toCompare == CompatibleMaterial.MOVING_PISTON
|
||||
|| toCompare == CompatibleMaterial.ICE
|
||||
|| toCompare == CompatibleMaterial.PISTON_HEAD) {
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} 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, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (location.getBlock().isLiquid()
|
||||
|| location.clone().add(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (CompatibleMaterial.getMaterial(location.getBlock().getType()) == CompatibleMaterial.NETHER_PORTAL
|
||||
|| CompatibleMaterial.getMaterial(location.clone().add(0.0D, 1.0D, 0.0D).getBlock()
|
||||
.getType()) == CompatibleMaterial.NETHER_PORTAL) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else {
|
||||
CompatibleMaterial type = CompatibleMaterial.getMaterial(location.getBlock().getType());
|
||||
if (type.isSolid() && type.isOccluding()) {
|
||||
location.getBlock().breakNaturally();
|
||||
}
|
||||
|
||||
CompatibleMaterial typeBelow = CompatibleMaterial.getMaterial(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();
|
||||
}
|
||||
|
||||
islandManager.removeSpawnProtection(island.getLocation(world, environment));
|
||||
}
|
||||
}
|
||||
|
||||
Location newSpawnLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
island.setLocation(world, environment, newSpawnLocation);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn",
|
||||
environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn",
|
||||
environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn",
|
||||
environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Role.Message")
|
||||
.replace("%spawn", environment.name().toLowerCase()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,15 @@ import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import com.songoda.skyblock.visit.Visit;
|
||||
import com.songoda.skyblock.visit.VisitManager;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -35,25 +37,22 @@ public class TeleportCommand extends SubCommand {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
UUID islandOwnerUUID;
|
||||
String targetPlayerName;
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||
Island island = islandManager.getIsland(offlinePlayer);
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.None.Message", "Command.Island.Teleport.Island.None.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetOfflinePlayer.getOwner();
|
||||
targetPlayerName = targetOfflinePlayer.getName();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
return;
|
||||
}
|
||||
|
||||
UUID islandOwnerUUID = island.getOwnerUUID();
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.None.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
|
||||
}
|
||||
else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
|
||||
if (visitManager.hasIsland(islandOwnerUUID)) {
|
||||
Visit visit = visitManager.getIsland(islandOwnerUUID);
|
||||
boolean isCoopPlayer = false;
|
||||
@ -63,24 +62,29 @@ public class TeleportCommand extends SubCommand {
|
||||
if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isCoopPlayer(player.getUniqueId())) {
|
||||
isCoopPlayer = true;
|
||||
}
|
||||
|
||||
if (visit.getStatus().equals(IslandStatus.WHITELISTED) && islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isPlayerWhitelisted(player.getUniqueId())) {
|
||||
isWhitelistedPlayer = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (visit.getStatus().equals(IslandStatus.OPEN) ||
|
||||
isCoopPlayer ||
|
||||
isWhitelistedPlayer ||
|
||||
player.hasPermission("fabledskyblock.bypass") ||
|
||||
player.hasPermission("fabledskyblock.bypass.*") ||
|
||||
player.hasPermission("fabledskyblock.*")) {
|
||||
|
||||
if (!islandManager.containsIsland(islandOwnerUUID)) {
|
||||
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
}
|
||||
|
||||
islandManager.visitIsland(player, islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)));
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", targetPlayerName));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", args[0]));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
@ -107,12 +111,11 @@ public class TeleportCommand extends SubCommand {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Owner.Message"));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Owner.Message", "Command.Island.Teleport.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message"));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message", "Command.Island.Teleport.Teleported.Yourself.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
|
||||
PaperLib.getChunkAtAsync(loc).thenRun((() -> {
|
||||
@ -127,6 +130,7 @@ public class TeleportCommand extends SubCommand {
|
||||
player.setFallDistance(0.0F);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class UnbanCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
} else if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|
@ -45,7 +45,7 @@ public class UnlockCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + type + ".Enable")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.World." + type + ".Enable")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Disabled.Message").replace("%type%", type));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
|
@ -37,7 +37,7 @@ public class ValueCommand extends SubCommand {
|
||||
|
||||
if (materials != null && levellingManager.hasWorth(materials)) {
|
||||
double worth = levellingManager.getWorth(materials);
|
||||
double level = worth / (double) fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Levelling.Division");
|
||||
double level = worth / (double) this.plugin.getConfiguration().getInt("Island.Levelling.Division");
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Value.Value.Message").replace("%material", WordUtils.capitalizeFully(materials.name().toLowerCase().replace("_", " ")))
|
||||
|
@ -40,7 +40,7 @@ public class VoteCommand extends SubCommand {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (!this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Visitor.Vote")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
@ -15,7 +15,7 @@ public class FileChecker {
|
||||
|
||||
private final FileManager fileManager;
|
||||
|
||||
private Map<File.Type, File> loadedFiles;
|
||||
private final Map<File.Type, File> loadedFiles;
|
||||
|
||||
public FileChecker(SkyBlock plugin, FileManager fileManager, String configurationFileName, boolean applyComments) {
|
||||
this.fileManager = fileManager;
|
||||
@ -87,10 +87,10 @@ public class FileChecker {
|
||||
|
||||
public static class File {
|
||||
|
||||
private java.io.File configFile;
|
||||
private final java.io.File configFile;
|
||||
private FileConfiguration configLoad;
|
||||
|
||||
private HashMap<String, Object> configKeys;
|
||||
private final HashMap<String, Object> configKeys;
|
||||
|
||||
public File(FileManager fileManager, java.io.File configFile, FileConfiguration configLoad) {
|
||||
this.configFile = configFile;
|
||||
|
@ -333,7 +333,7 @@ public class FileManager {
|
||||
|
||||
public static class Config {
|
||||
|
||||
private File configFile;
|
||||
private final File configFile;
|
||||
private FileConfiguration configLoad;
|
||||
|
||||
public Config(FileManager fileManager, java.io.File configPath) {
|
||||
|
@ -18,7 +18,7 @@ public class CooldownManager {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
|
||||
private Map<CooldownType, List<CooldownPlayer>> cooldownStorage = new EnumMap<>(CooldownType.class);
|
||||
private final Map<CooldownType, List<CooldownPlayer>> cooldownStorage = new EnumMap<>(CooldownType.class);
|
||||
|
||||
public CooldownManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -95,7 +95,7 @@ public class CooldownManager {
|
||||
int time = 0;
|
||||
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
|
||||
time = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
time = this.plugin.getConfiguration()
|
||||
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
||||
|
||||
Config config = fileManager
|
||||
@ -111,7 +111,7 @@ public class CooldownManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||
time = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
time = this.plugin.getConfiguration()
|
||||
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
||||
|
||||
Config config = plugin.getFileManager()
|
||||
|
@ -20,8 +20,7 @@ public class CooldownTask extends BukkitRunnable {
|
||||
|
||||
if (cooldownPlayers == null) return;
|
||||
|
||||
for (int i = 0; i < cooldownPlayers.size(); i++) {
|
||||
CooldownPlayer cooldownPlayer = cooldownPlayers.get(i);
|
||||
for (CooldownPlayer cooldownPlayer : cooldownPlayers) {
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
|
||||
cooldown.setTime(cooldown.getTime() - 1);
|
||||
|
@ -15,16 +15,14 @@ public class EconomyManager extends Manager {
|
||||
economy = com.songoda.core.hooks.EconomyManager.getEconomy();
|
||||
}
|
||||
|
||||
public boolean setEconomy(String economyString) {
|
||||
public void setEconomy(String economyString) {
|
||||
Hook hook = com.songoda.core.hooks.EconomyManager.getManager().getHook(economyString);
|
||||
if(hook != null &&
|
||||
hook.isEnabled() &&
|
||||
hook instanceof Economy &&
|
||||
!hook.equals(com.songoda.core.hooks.EconomyManager.getManager().getCurrentHook())) {
|
||||
this.economy = (Economy) hook;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Economy getEconomy() {
|
||||
|
@ -30,8 +30,7 @@ public class GeneratorManager {
|
||||
}
|
||||
|
||||
public void registerGenerators() {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "generators.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getGenerators();
|
||||
|
||||
if (configLoad.getString("Generators") == null)
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
|
||||
public class GeneratorMaterial {
|
||||
|
||||
private CompatibleMaterial materials;
|
||||
private final CompatibleMaterial materials;
|
||||
private double chance;
|
||||
|
||||
public GeneratorMaterial(CompatibleMaterial materials, double chance) {
|
||||
|
@ -24,12 +24,11 @@ public class GuiBank extends Gui {
|
||||
|
||||
public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
|
||||
super(2, returnGui);
|
||||
this.plugin = plugin;;
|
||||
this.plugin = plugin;
|
||||
this.soundManager = plugin.getSoundManager();
|
||||
this.island = island;
|
||||
this.admin = admin;
|
||||
this.languageLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.languageLoad = this.plugin.getLanguage();
|
||||
if(island != null) {
|
||||
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
|
||||
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Title")));
|
||||
|
@ -42,8 +42,7 @@ public class GuiBankSelector extends Gui {
|
||||
this.island = island;
|
||||
this.returnGui = returnGui;
|
||||
this.admin = admin;
|
||||
this.languageLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.languageLoad = this.plugin.getLanguage();
|
||||
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
|
||||
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Input.Title")));
|
||||
paint();
|
||||
@ -92,14 +91,14 @@ public class GuiBankSelector extends Gui {
|
||||
switch(type){
|
||||
case DEPOSIT:
|
||||
amount = economy.getBalance(event.player);
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
amount = Math.floor(amount);
|
||||
}
|
||||
response = bankManager.deposit(event.player, island, amount, admin);
|
||||
break;
|
||||
case WITHDRAW:
|
||||
amount = island.getBankBalance();
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
amount = Math.floor(amount);
|
||||
}
|
||||
response = bankManager.withdraw(event.player, island, amount, admin);
|
||||
|
@ -21,11 +21,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiBankTransaction extends Gui {
|
||||
private final SkyBlock plugin;
|
||||
private final BankManager bankManager;
|
||||
private final SoundManager soundManager;
|
||||
private final FileConfiguration languageLoad;
|
||||
private final FileManager.Config config;
|
||||
private final Gui returnGui;
|
||||
private final int transactions;
|
||||
private final List<Transaction> transactionList;
|
||||
@ -33,17 +30,13 @@ public class GuiBankTransaction extends Gui {
|
||||
|
||||
public GuiBankTransaction(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
|
||||
super(returnGui);
|
||||
this.plugin = plugin;
|
||||
this.bankManager = plugin.getBankManager();
|
||||
BankManager bankManager = plugin.getBankManager();
|
||||
this.soundManager = plugin.getSoundManager();
|
||||
this.transactionList = bankManager.getTransactions(island.getOwnerUUID());
|
||||
this.transactions = this.transactionList.size();
|
||||
this.returnGui = returnGui;
|
||||
this.admin = admin;
|
||||
this.languageLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
|
||||
this.languageLoad = plugin.getLanguage();
|
||||
if(transactions == 0){
|
||||
setRows(2);
|
||||
} else if(transactions > 4*9){
|
||||
|
@ -22,8 +22,7 @@ public class BiomeIcon {
|
||||
|
||||
public BiomeIcon(SkyBlock plugin, CompatibleBiome biome){
|
||||
this.biome = biome;
|
||||
FileConfiguration biomeConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(),"biomes.yml")).getFileConfiguration();
|
||||
|
||||
FileConfiguration biomeConfig = plugin.getBiomes();
|
||||
CompatibleMaterial tempMat = CompatibleMaterial.getMaterial(biomeConfig.getString("Biomes." + biome.name() + ".DisplayItem.Material"));
|
||||
if(tempMat == null){
|
||||
tempMat = CompatibleMaterial.STONE;
|
||||
|
@ -33,11 +33,8 @@ public class GuiBiome extends Gui {
|
||||
private final SkyBlock plugin;
|
||||
private final Island island;
|
||||
private final FileConfiguration languageLoad;
|
||||
private final FileConfiguration config;
|
||||
private final Gui returnGui;
|
||||
private final Player player;
|
||||
private final IslandWorld world;
|
||||
private final boolean admin;
|
||||
|
||||
public GuiBiome(SkyBlock plugin, Player player, Island island, IslandWorld world, Gui returnGui, boolean admin) {
|
||||
super(6, returnGui);
|
||||
@ -45,9 +42,7 @@ public class GuiBiome extends Gui {
|
||||
this.island = island;
|
||||
this.world = world;
|
||||
this.player = player;
|
||||
this.returnGui = returnGui;
|
||||
this.admin = admin;
|
||||
this.config = plugin.getFileManager()
|
||||
FileConfiguration config = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
this.languageLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
@ -189,7 +184,7 @@ public class GuiBiome extends Gui {
|
||||
}
|
||||
cooldownManager.createPlayer(CooldownType.Biome, player);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
biomeManager.setBiome(island, IslandWorld.Normal, icon.biome.getBiome(), () -> {
|
||||
biomeManager.setBiome(island, IslandWorld.Normal, icon.biome, () -> {
|
||||
if(languageLoad.getBoolean("Command.Island.Biome.Completed.Should-Display-Message")){
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F);
|
||||
|
@ -48,7 +48,7 @@ public class GuiPermissions extends Gui {
|
||||
this.returnGui = returnGui;
|
||||
this.languageLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
this.configLoad = this.plugin.getConfiguration();
|
||||
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings." + role.name() + ".Title")));
|
||||
setDefaultItem(null);
|
||||
paint();
|
||||
|
@ -51,7 +51,7 @@ public class GuiPermissionsSelector extends Gui {
|
||||
new GuiAdminPermissions(plugin, IslandRole.Operator, this) :
|
||||
new GuiPermissions(plugin, player, island, IslandRole.Operator, this)));
|
||||
|
||||
boolean isCoop = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
boolean isCoop = plugin.getConfiguration()
|
||||
.getBoolean("Island.Coop.Enable");
|
||||
|
||||
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
|
||||
|
@ -9,8 +9,8 @@ import java.util.List;
|
||||
|
||||
public class Hologram {
|
||||
|
||||
private HologramType type;
|
||||
private Location location;
|
||||
private final HologramType type;
|
||||
private final Location location;
|
||||
|
||||
public Hologram(HologramType type, Location location, List<String> lines) {
|
||||
this.type = type;
|
||||
|
@ -6,10 +6,10 @@ import java.util.UUID;
|
||||
|
||||
public class Invite {
|
||||
|
||||
private UUID playerUUID;
|
||||
private UUID senderUUID;
|
||||
private final UUID playerUUID;
|
||||
private final UUID senderUUID;
|
||||
private UUID islandOwnerUUID;
|
||||
private String senderName;
|
||||
private final String senderName;
|
||||
private int time;
|
||||
|
||||
public Invite(Player player, Player sender, UUID islandOwnerUUID, int time) {
|
||||
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
||||
|
||||
public class InviteManager {
|
||||
|
||||
private Map<UUID, Invite> inviteStorage = new HashMap<>();
|
||||
private final Map<UUID, Invite> inviteStorage = new HashMap<>();
|
||||
|
||||
public InviteManager(SkyBlock plugin) {
|
||||
new InviteTask(this, plugin).runTaskTimerAsynchronously(plugin, 0L, 20L);
|
||||
|
@ -32,8 +32,7 @@ public class InviteTask extends BukkitRunnable {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getLanguage();
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (inviteManager.hasInvite(all.getUniqueId())) {
|
||||
|
@ -60,10 +60,8 @@ public class Island {
|
||||
|
||||
this.islandUUID = UUID.randomUUID();
|
||||
this.ownerUUID = player.getUniqueId();
|
||||
this.size = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getInt("Island.Size.Minimum");
|
||||
this.maxMembers = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getInt("Island.Member.Capacity", 3);
|
||||
this.size = this.plugin.getConfiguration().getInt("Island.Size.Minimum");
|
||||
this.maxMembers = this.plugin.getConfiguration().getInt("Island.Member.Capacity", 3);
|
||||
|
||||
if (this.size > 1000) {
|
||||
this.size = 50;
|
||||
@ -72,8 +70,7 @@ public class Island {
|
||||
if (player.isOnline()) {
|
||||
int customSize = PlayerUtils.getNumberFromPermission(player.getPlayer(), "fabledskyblock.size", 0);
|
||||
if (customSize > 0 || player.getPlayer().hasPermission("fabledskyblock.*")) {
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getConfiguration();
|
||||
|
||||
int minimumSize = configLoad.getInt("Island.Size.Minimum");
|
||||
int maximumSize = configLoad.getInt("Island.Size.Maximum");
|
||||
@ -101,10 +98,8 @@ public class Island {
|
||||
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
|
||||
|
||||
Config config = fileManager.getConfig(new File(configFile, ownerUUID + ".yml"));
|
||||
Config defaultSettingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "settings.yml"));
|
||||
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
|
||||
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
|
||||
FileConfiguration mainConfigLoad = this.plugin.getConfiguration();
|
||||
|
||||
if (fileManager.isFileExist(new File(configFile, ownerUUID + ".yml"))) {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -136,7 +131,7 @@ public class Island {
|
||||
}
|
||||
|
||||
if (configLoad.getString("Border") == null) {
|
||||
configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false));
|
||||
configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
|
||||
configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
|
||||
}
|
||||
|
||||
@ -192,7 +187,7 @@ public class Island {
|
||||
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
|
||||
.getString("Settings." + roleList.name() + "." + permission.getName()) == null) {
|
||||
permissions.add(
|
||||
new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration()
|
||||
new IslandPermission(permission, this.plugin.getSettings()
|
||||
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
|
||||
} else {
|
||||
permissions.add(new IslandPermission(permission, settingsDataConfig.getFileConfiguration()
|
||||
@ -234,7 +229,7 @@ public class Island {
|
||||
|
||||
configLoad.set("UUID", islandUUID.toString());
|
||||
configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status").toUpperCase());
|
||||
configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false));
|
||||
configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
|
||||
configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
|
||||
configLoad.set("Biome.Type", mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase());
|
||||
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); // TODO: Synchronized
|
||||
@ -249,7 +244,7 @@ public class Island {
|
||||
|
||||
for (BasicPermission permission : allPermissions) {
|
||||
permissions.add(
|
||||
new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration()
|
||||
new IslandPermission(permission, this.plugin.getSettings()
|
||||
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
|
||||
}
|
||||
|
||||
@ -311,10 +306,15 @@ public class Island {
|
||||
.getFileConfiguration().getString("Ownership.Original"));
|
||||
}
|
||||
|
||||
public int getMaxMembers() {
|
||||
return maxMembers;
|
||||
public int getMaxMembers(Player player) {
|
||||
try {
|
||||
return PlayerUtils.getNumberFromPermission(Objects.requireNonNull(player.getPlayer()), "fabledskyblock.members", maxMembers);
|
||||
} catch (Exception ignored) {
|
||||
return maxMembers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setMaxMembers(int maxMembers) {
|
||||
if (maxMembers > 100000 || maxMembers < 0) {
|
||||
maxMembers = 2;
|
||||
@ -912,8 +912,7 @@ public class Island {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Coop.Unload")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Coop.Unload")) {
|
||||
config = fileManager
|
||||
.getConfig(new File(plugin.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml"));
|
||||
configLoad = config.getFileConfiguration();
|
||||
@ -941,8 +940,7 @@ public class Island {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getConfiguration();
|
||||
Config islandData = fileManager
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"),
|
||||
ownerUUID.toString() + ".yml"));
|
||||
@ -955,9 +953,9 @@ public class Island {
|
||||
unlocked = true;
|
||||
}
|
||||
|
||||
if (!unlocked) {
|
||||
if (!unlocked && player != null) {
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
this.plugin.getLanguage()
|
||||
.getString("Island.Unlock." + type.name() + ".Message").replace(
|
||||
"%cost%", NumberUtil.formatNumberByDecimal(price)));
|
||||
|
||||
@ -1005,4 +1003,10 @@ public class Island {
|
||||
this.removeWhitelistedPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Island{" +
|
||||
"ownerUUID=" + ownerUUID +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ public class IslandLevel {
|
||||
}
|
||||
|
||||
public long getPoints() {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getLevelling();
|
||||
|
||||
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
|
||||
|
||||
@ -104,9 +103,8 @@ public class IslandLevel {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
FileConfiguration configLoad = this.plugin.getLevelling();
|
||||
|
||||
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
|
||||
|
||||
@ -131,14 +129,14 @@ public class IslandLevel {
|
||||
}
|
||||
|
||||
public long getLevel() {
|
||||
long division = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Division");
|
||||
long division = this.plugin.getConfiguration().getLong("Island.Levelling.Division");
|
||||
|
||||
if (division == 0) {
|
||||
division = 1;
|
||||
}
|
||||
|
||||
long points = getPoints();
|
||||
long subtract = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Subtract");
|
||||
long subtract = this.plugin.getConfiguration().getLong("Island.Levelling.Subtract");
|
||||
if(points >= subtract){
|
||||
points -= subtract;
|
||||
} else {
|
||||
@ -156,8 +154,8 @@ public class IslandLevel {
|
||||
if (level <= highestLevel)
|
||||
return;
|
||||
|
||||
final FileConfiguration language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
final FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
final FileConfiguration language = this.plugin.getLanguage();
|
||||
final FileConfiguration config = this.plugin.getConfiguration();
|
||||
|
||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(ownerUUID);
|
||||
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.Location;
|
||||
|
||||
public class IslandLocation {
|
||||
|
||||
private IslandWorld world;
|
||||
private IslandEnvironment environment;
|
||||
private final IslandWorld world;
|
||||
private final IslandEnvironment environment;
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
|
@ -47,7 +47,6 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -80,17 +79,14 @@ public class IslandManager {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "worlds.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
offset = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Creation.Distance", 1200);
|
||||
offset = plugin.getConfiguration().getInt("Island.Creation.Distance", 1200);
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.name() + ".nextAvailableLocation");
|
||||
islandPositions.add(new IslandPosition(worldList, configSection.getDouble("x"), configSection.getDouble("z")));
|
||||
}
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
loadIsland(all);
|
||||
}
|
||||
Bukkit.getOnlinePlayers().forEach(this::loadIsland);
|
||||
for (Island island : getIslands().values()) {
|
||||
if (island.isAlwaysLoaded())
|
||||
loadIslandAtLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island));
|
||||
@ -144,10 +140,9 @@ public class IslandManager {
|
||||
if (islandPositionList.getWorld() == world) {
|
||||
|
||||
Config config_world = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "worlds.yml"));
|
||||
Config config_config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
|
||||
FileConfiguration configLoad_world = config_world.getFileConfiguration();
|
||||
FileConfiguration configLoad_config = config_config.getFileConfiguration();
|
||||
FileConfiguration configLoad_config = plugin.getConfiguration();
|
||||
int x = (int) configLoad_world.get("World." + world.name() + ".nextAvailableLocation.island_number");
|
||||
int islandHeight = configLoad_config.getInt("Island.World." + world.name() + ".IslandSpawnHeight", 72);
|
||||
while (true) {
|
||||
@ -215,13 +210,13 @@ public class IslandManager {
|
||||
final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2);
|
||||
|
||||
if ((amt = data.getIslandCreationCount()) >= highest) {
|
||||
plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage"));
|
||||
plugin.getLanguage().getString("Island.Creator.Error.MaxCreationMessage");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) {
|
||||
plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.Message"));
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Creator.Error.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return false;
|
||||
@ -247,8 +242,7 @@ public class IslandManager {
|
||||
|
||||
if (!banManager.hasIsland(island.getOwnerUUID())) banManager.createIsland(island.getOwnerUUID());
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = this.plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*")
|
||||
&& !player.hasPermission("fabledskyblock.*"))
|
||||
@ -271,17 +265,17 @@ public class IslandManager {
|
||||
player.setFallDistance(0.0F);
|
||||
}, configLoad.getInt("Island.Creation.TeleportTimeout") * 20);
|
||||
|
||||
String biomeName = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase();
|
||||
String biomeName = this.plugin.getConfiguration().getString("Island.Biome.Default.Type").toUpperCase();
|
||||
CompatibleBiome cBiome;
|
||||
try {
|
||||
cBiome = CompatibleBiome.valueOf(biomeName);
|
||||
} catch (Exception ex) {
|
||||
cBiome = CompatibleBiome.PLAINS;
|
||||
}
|
||||
Biome biome = cBiome.getBiome();
|
||||
final CompatibleBiome compatibleBiome = cBiome;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(plugin, () ->
|
||||
plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, biome, () -> {
|
||||
plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, compatibleBiome, () -> {
|
||||
if (structure.getCommands() != null) {
|
||||
for (String commandList : structure.getCommands()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
|
||||
@ -300,17 +294,15 @@ public class IslandManager {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
PlayerData data = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLang = config.getFileConfiguration();
|
||||
config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configMain = config.getFileConfiguration();
|
||||
FileConfiguration configLang = plugin.getLanguage();
|
||||
FileConfiguration configMain = plugin.getConfiguration();
|
||||
|
||||
|
||||
if (data != null) {
|
||||
final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2);
|
||||
|
||||
if ((data.getIslandCreationCount()) >= highest) {
|
||||
plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage"));
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Creator.Error.MaxCreationMessage"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -427,8 +419,7 @@ public class IslandManager {
|
||||
level.save();
|
||||
level.setOwnerUUID(player.getUniqueId());
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Ownership.Password.Reset")) {
|
||||
island.setPassword(null);
|
||||
@ -465,7 +456,7 @@ public class IslandManager {
|
||||
fileManager.unloadConfig(newIslandDataFile);
|
||||
oldIslandDataFile.renameTo(newIslandDataFile);
|
||||
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)){
|
||||
File oldChallengeDataFile = new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), uuid2.toString() + ".yml");
|
||||
File newChallengeDataFile = new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), player.getUniqueId().toString() + ".yml");
|
||||
@ -555,7 +546,11 @@ public class IslandManager {
|
||||
}
|
||||
}
|
||||
|
||||
startDeletion(island, worldManager);
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Deletion.DeleteIsland", true)) {
|
||||
startDeletion(island, worldManager);
|
||||
}
|
||||
|
||||
plugin.getVisitManager().deleteIsland(island.getOwnerUUID());
|
||||
plugin.getBanManager().deleteIsland(island.getOwnerUUID());
|
||||
@ -565,9 +560,6 @@ public class IslandManager {
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer);
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
boolean cooldownCreationEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable");
|
||||
boolean cooldownDeletionEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable");
|
||||
|
||||
@ -621,7 +613,7 @@ public class IslandManager {
|
||||
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), island.getOwnerUUID().toString() + ".yml"));
|
||||
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID().toString() + ".yml"));
|
||||
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml"));
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)){
|
||||
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID().toString() + ".yml"));
|
||||
}
|
||||
@ -663,7 +655,7 @@ public class IslandManager {
|
||||
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/level-data", FastUUID.toString(uuid) + ".yml"));
|
||||
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/setting-data", FastUUID.toString(uuid) + ".yml"));
|
||||
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/visit-data", FastUUID.toString(uuid) + ".yml"));
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)){
|
||||
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/challenge-data", FastUUID.toString(uuid) + ".yml"));
|
||||
}
|
||||
@ -742,14 +734,14 @@ public class IslandManager {
|
||||
try {
|
||||
UUID islandOwnerUUID = FastUUID.parseUUID(file.getName().split("\\.")[0]);
|
||||
|
||||
Island island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
Island island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
if(island != null) {
|
||||
island.setSize(island.getSize() + diff);
|
||||
island.save();
|
||||
} else {
|
||||
loadIsland(file);
|
||||
island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
island.setSize(island.getSize() + diff);
|
||||
island.save();
|
||||
@ -779,14 +771,14 @@ public class IslandManager {
|
||||
try {
|
||||
UUID islandOwnerUUID = FastUUID.parseUUID(file.getName().split("\\.")[0]);
|
||||
|
||||
Island island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
Island island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
if(island != null) {
|
||||
island.setSize(size);
|
||||
island.save();
|
||||
} else {
|
||||
loadIsland(file);
|
||||
island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
island.setSize(size);
|
||||
island.save();
|
||||
@ -929,9 +921,6 @@ public class IslandManager {
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (island.isDeleted()) return;
|
||||
|
||||
island.save();
|
||||
@ -958,7 +947,7 @@ public class IslandManager {
|
||||
return;
|
||||
}
|
||||
|
||||
unloadIsland = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Unload");
|
||||
unloadIsland = this.plugin.getConfiguration().getBoolean("Island.Visitor.Unload");
|
||||
|
||||
if (unloadIsland) {
|
||||
VisitManager visitManager = plugin.getVisitManager();
|
||||
@ -985,7 +974,7 @@ public class IslandManager {
|
||||
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID() + ".yml"));
|
||||
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID() + ".yml"));
|
||||
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)){
|
||||
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID() + ".yml"));
|
||||
}
|
||||
@ -1059,7 +1048,7 @@ public class IslandManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE));
|
||||
}
|
||||
|
||||
@ -1116,7 +1105,7 @@ public class IslandManager {
|
||||
pasteStructure(island, islandWorld);
|
||||
|
||||
// Recalculate island level after 5 seconds
|
||||
if (fileManager.getConfig(new File(this.plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
|
||||
if (plugin.getConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> plugin.getLevellingManager().startScan(null, island), 100L);
|
||||
}
|
||||
}
|
||||
@ -1137,8 +1126,7 @@ public class IslandManager {
|
||||
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.name());
|
||||
|
||||
if (!unlocked) {
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
double price = configLoad.getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
|
||||
if (price == -1) unlocked = true;
|
||||
}
|
||||
@ -1168,10 +1156,7 @@ public class IslandManager {
|
||||
|
||||
public void visitIsland(Player player, Island island) {
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getLanguage();
|
||||
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
|
||||
@ -1181,9 +1166,7 @@ public class IslandManager {
|
||||
player.setFallDistance(0.0F);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Teleport.Unsafe.Message")));
|
||||
player.sendMessage(plugin.formatText(plugin.getLanguage().getString("Island.Teleport.Unsafe.Message")));
|
||||
}
|
||||
} else {
|
||||
int islandVisitors = getVisitorsAtIsland(island).size();
|
||||
@ -1201,8 +1184,7 @@ public class IslandManager {
|
||||
}
|
||||
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor);
|
||||
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
|
||||
if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
|
||||
Location safeLoc = LocationUtil.getSafeLocation(loc);
|
||||
if (safeLoc != null) {
|
||||
loc = safeLoc;
|
||||
@ -1215,9 +1197,7 @@ public class IslandManager {
|
||||
player.setFallDistance(0.0F);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message")));
|
||||
player.sendMessage(plugin.formatText(plugin.getLanguage().getString("Command.Island.Teleport.Unsafe.Message")));
|
||||
}
|
||||
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
|
||||
player.setFallDistance(0.0F);
|
||||
@ -1225,7 +1205,7 @@ public class IslandManager {
|
||||
|
||||
List<String> islandWelcomeMessage = island.getMessage(IslandMessage.Welcome);
|
||||
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) {
|
||||
for (String islandWelcomeMessageList : islandWelcomeMessage) {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', islandWelcomeMessageList));
|
||||
}
|
||||
@ -1237,9 +1217,7 @@ public class IslandManager {
|
||||
|
||||
public void closeIsland(Island island) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getLanguage();
|
||||
|
||||
island.setStatus(IslandStatus.CLOSED);
|
||||
|
||||
@ -1264,9 +1242,7 @@ public class IslandManager {
|
||||
|
||||
public void whitelistIsland(Island island) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getLanguage();
|
||||
|
||||
island.setStatus(IslandStatus.WHITELISTED);
|
||||
|
||||
@ -1461,8 +1437,7 @@ public class IslandManager {
|
||||
Island island = getIslandAtLocation(player.getLocation());
|
||||
|
||||
if (island != null) {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (!island.isWeatherSynchronized()) {
|
||||
player.setPlayerTime(island.getTime(), configLoad.getBoolean("Island.Weather.Time.Cycle"));
|
||||
@ -1556,8 +1531,7 @@ public class IslandManager {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getLanguage();
|
||||
|
||||
boolean coopPlayers = island.hasPermission(IslandRole.Operator, plugin.getPermissionManager().getPermission("CoopPlayers"));
|
||||
|
||||
@ -1595,8 +1569,7 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
public int getIslandSafeLevel(Island island) {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
int safeLevel = 0;
|
||||
|
||||
@ -1620,7 +1593,7 @@ public class IslandManager {
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
|
||||
if (island.isBorder()) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")) {
|
||||
double increment = island.getSize() % 2 != 0 ? 0.5d : 0.0d;
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
@ -1716,7 +1689,7 @@ public class IslandManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Island getIslandByPlayer(org.bukkit.OfflinePlayer player) {
|
||||
public Island getIslandByOwner(org.bukkit.OfflinePlayer player) {
|
||||
if (islandStorage.containsKey(player.getUniqueId())) {
|
||||
return islandStorage.get(player.getUniqueId());
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.songoda.skyblock.island;
|
||||
|
||||
public class IslandPosition {
|
||||
|
||||
private IslandWorld world;
|
||||
private final IslandWorld world;
|
||||
|
||||
private double x;
|
||||
private double z;
|
||||
|
@ -21,8 +21,7 @@ public class RewardManager {
|
||||
}
|
||||
|
||||
public void loadRewards() {
|
||||
final Config config = skyBlock.getFileManager().getConfig(new File(skyBlock.getDataFolder(), "rewards.yml"));
|
||||
final FileConfiguration configLoad = config.getFileConfiguration();
|
||||
final FileConfiguration configLoad = skyBlock.getRewards();
|
||||
|
||||
this.registeredRewards.clear();
|
||||
this.repeatRewards.clear();
|
||||
@ -59,7 +58,7 @@ public class RewardManager {
|
||||
}
|
||||
|
||||
private LevelReward loadReward(String path) {
|
||||
final FileConfiguration config = skyBlock.getFileManager().getConfig(new File(skyBlock.getDataFolder(), "rewards.yml")).getFileConfiguration();
|
||||
final FileConfiguration config = this.skyBlock.getRewards();
|
||||
|
||||
ConfigurationSection section = config.getConfigurationSection(path);
|
||||
|
||||
|
@ -5,8 +5,8 @@ import com.songoda.skyblock.visit.Visit;
|
||||
public class Leaderboard {
|
||||
|
||||
private final Visit visit;
|
||||
private Type type;
|
||||
private int position;
|
||||
private final Type type;
|
||||
private final int position;
|
||||
|
||||
public Leaderboard(Type type, Visit visit, int position) {
|
||||
this.type = type;
|
||||
|
@ -19,13 +19,13 @@ public class LeaderboardManager {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
|
||||
private List<Leaderboard> leaderboardStorage = new ArrayList<>();
|
||||
private final List<Leaderboard> leaderboardStorage = new ArrayList<>();
|
||||
|
||||
public LeaderboardManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
new LeaderboardTask(plugin).runTaskTimerAsynchronously(plugin, 0L,
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
|
||||
this.plugin.getConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
|
||||
|
||||
resetLeaderboard();
|
||||
setupLeaderHeads();
|
||||
@ -43,7 +43,7 @@ public class LeaderboardManager {
|
||||
List<LeaderboardPlayer> islandBanks = new ArrayList<>(arraySize);
|
||||
List<LeaderboardPlayer> islandVotes = new ArrayList<>(arraySize);
|
||||
|
||||
boolean enableExemptions = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
boolean enableExemptions = this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Leaderboard.Exemptions.Enable");
|
||||
|
||||
for (UUID ownerUUID : new LinkedHashSet<>(visitManager.getIslands().keySet())) {
|
||||
|
@ -4,8 +4,8 @@ import java.util.UUID;
|
||||
|
||||
public class LeaderboardPlayer {
|
||||
|
||||
private UUID uuid;
|
||||
private long value;
|
||||
private final UUID uuid;
|
||||
private final long value;
|
||||
|
||||
public LeaderboardPlayer(UUID uuid, long value) {
|
||||
this.uuid = uuid;
|
||||
|
@ -28,8 +28,7 @@ public class TopLevel extends DataCollector {
|
||||
List<Leaderboard> leaderboards = plugin.getLeaderboardManager().getLeaderboard(Leaderboard.Type.Level);
|
||||
Map<UUID, Double> topLevels = new HashMap<>(leaderboards.size());
|
||||
|
||||
for (int i = 0; i < leaderboards.size(); i++) {
|
||||
Leaderboard leaderboard = leaderboards.get(i);
|
||||
for (Leaderboard leaderboard : leaderboards) {
|
||||
Visit visit = leaderboard.getVisit();
|
||||
topLevels.put(visit.getOwnerUUID(), (double) visit.getLevel().getLevel());
|
||||
}
|
||||
|
@ -30,9 +30,8 @@ public class TopVotes extends DataCollector {
|
||||
|
||||
List<Leaderboard> leaderboards = plugin.getLeaderboardManager().getLeaderboard(Type.Votes);
|
||||
Map<UUID, Double> topLevels = new HashMap<>(leaderboards.size());
|
||||
|
||||
for (int i = 0; i < leaderboards.size(); i++) {
|
||||
Leaderboard leaderboard = leaderboards.get(i);
|
||||
|
||||
for (Leaderboard leaderboard : leaderboards) {
|
||||
Visit visit = leaderboard.getVisit();
|
||||
topLevels.put(visit.getOwnerUUID(), (double) visit.getVoters().size());
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.blockscanner.BlockInfo;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandLevel;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.levelling.amount.AmountMaterialPair;
|
||||
import com.songoda.skyblock.levelling.calculator.Calculator;
|
||||
import com.songoda.skyblock.levelling.calculator.CalculatorRegistry;
|
||||
@ -21,6 +22,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@ -29,8 +31,8 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public final class IslandLevelManager {
|
||||
|
||||
private final Map<Island, IslandScan> inScan;
|
||||
|
||||
private final Map<Island, QueuedIslandScan> inScan;
|
||||
private final Map<CompatibleMaterial, Double> worth;
|
||||
private final Map<CompatibleMaterial, AmountMaterialPair> cachedPairs;
|
||||
private final SkyBlock plugin;
|
||||
@ -44,7 +46,7 @@ public final class IslandLevelManager {
|
||||
reloadWorth();
|
||||
}
|
||||
|
||||
public void startScan(Player attemptScanner, Island island){
|
||||
public void startScan(Player attemptScanner, Island island) {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> startScan(attemptScanner, island));
|
||||
return;
|
||||
@ -52,7 +54,7 @@ public final class IslandLevelManager {
|
||||
|
||||
if (island == null) throw new IllegalArgumentException("island cannot be null");
|
||||
|
||||
Configuration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
Configuration config = SkyBlock.getInstance().getLanguage();
|
||||
MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
|
||||
|
||||
if (inScan.containsKey(island)) {
|
||||
@ -70,7 +72,17 @@ public final class IslandLevelManager {
|
||||
messageManager.sendMessage(attemptScanner, config.getString("Command.Island.Level.Scanning.Started.Message"));
|
||||
}
|
||||
|
||||
inScan.put(island, new IslandScan(plugin, island).start());
|
||||
QueuedIslandScan queuedIslandScan = new QueuedIslandScan(plugin, island);
|
||||
|
||||
queuedIslandScan.addToScan(IslandWorld.Normal);
|
||||
if (island.isRegionUnlocked(null, IslandWorld.Nether))
|
||||
queuedIslandScan.addToScan(IslandWorld.Nether);
|
||||
if (island.isRegionUnlocked(null, IslandWorld.End))
|
||||
queuedIslandScan.addToScan(IslandWorld.End);
|
||||
|
||||
queuedIslandScan.scan();
|
||||
|
||||
inScan.put(island, queuedIslandScan);
|
||||
}
|
||||
|
||||
public boolean isScanning(Island island) {
|
||||
@ -79,17 +91,18 @@ public final class IslandLevelManager {
|
||||
|
||||
void stopScan(Island island) {
|
||||
|
||||
final IslandScan scan = inScan.get(island);
|
||||
final QueuedIslandScan queuedIslandScan = inScan.get(island);
|
||||
|
||||
if (scan == null) return;
|
||||
if (queuedIslandScan == null) return;
|
||||
|
||||
inScan.remove(island);
|
||||
if (!queuedIslandScan.scan())
|
||||
inScan.remove(island);
|
||||
}
|
||||
|
||||
public void reloadWorth() {
|
||||
worth.clear();
|
||||
|
||||
final Configuration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "levelling.yml")).getFileConfiguration();
|
||||
final Configuration config = SkyBlock.getInstance().getLevelling();
|
||||
final ConfigurationSection materialSection = config.getConfigurationSection("Materials");
|
||||
|
||||
if (materialSection == null) return;
|
||||
@ -102,7 +115,7 @@ public final class IslandLevelManager {
|
||||
|
||||
if (material == null) continue;
|
||||
|
||||
worth.put(material, current.getDouble("Points"));
|
||||
worth.put(material, current.getDouble("Points", 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,8 +154,10 @@ public final class IslandLevelManager {
|
||||
final CompatibleMaterial spawner = CompatibleMaterial.SPAWNER;
|
||||
final PluginManager pm = Bukkit.getPluginManager();
|
||||
|
||||
if (pm.isPluginEnabled("EpicSpawners")) CalculatorRegistry.registerCalculator(new EpicSpawnerCalculator(), spawner);
|
||||
if (pm.isPluginEnabled("UltimateStacker")) CalculatorRegistry.registerCalculator(new UltimateStackerCalculator(), spawner);
|
||||
if (pm.isPluginEnabled("EpicSpawners"))
|
||||
CalculatorRegistry.registerCalculator(new EpicSpawnerCalculator(), spawner);
|
||||
if (pm.isPluginEnabled("UltimateStacker"))
|
||||
CalculatorRegistry.registerCalculator(new UltimateStackerCalculator(), spawner);
|
||||
}
|
||||
|
||||
private static final AmountMaterialPair EMPTY = new AmountMaterialPair(null, 0);
|
||||
@ -206,7 +221,7 @@ public final class IslandLevelManager {
|
||||
|
||||
return new AmountMaterialPair(compMaterial, amount + stackSize);
|
||||
}
|
||||
|
||||
|
||||
public void updateLevel(Island island, Location location) {
|
||||
// Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client.
|
||||
// BUG: Player can infinitely increase their level by placing a block at their
|
||||
@ -218,7 +233,7 @@ public final class IslandLevelManager {
|
||||
// placed.
|
||||
// This shouldn't cause any issues besides the task number being increased
|
||||
// insanely fast.
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)){
|
||||
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
updateLevelLocation(island, location);
|
||||
});
|
||||
@ -226,11 +241,11 @@ public final class IslandLevelManager {
|
||||
updateLevelLocation(island, location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateLevelLocation(Island island, Location location) {
|
||||
Block block = location.getBlock();
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (block.getType().toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
@ -238,30 +253,30 @@ public final class IslandLevelManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
if (material == null) {
|
||||
material = CompatibleMaterial.getMaterial(block);
|
||||
}
|
||||
|
||||
|
||||
if (material == null || material == CompatibleMaterial.AIR) return;
|
||||
|
||||
|
||||
if (material == CompatibleMaterial.SPAWNER) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") ||
|
||||
Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") ||
|
||||
Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
|
||||
return;
|
||||
|
||||
|
||||
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
||||
|
||||
|
||||
if (spawner != null)
|
||||
material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial());
|
||||
}
|
||||
|
||||
|
||||
long materialAmount = 0;
|
||||
IslandLevel level = island.getLevel();
|
||||
|
||||
|
||||
if (level.hasMaterial(material.name()))
|
||||
materialAmount = level.getMaterialAmount(material.name());
|
||||
|
||||
|
||||
level.setMaterialAmount(material.name(), materialAmount + 1);
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ import java.util.Map.Entry;
|
||||
|
||||
public final class IslandScan extends BukkitRunnable {
|
||||
|
||||
private static final NumberFormat FORMATTER = NumberFormat.getInstance();
|
||||
|
||||
private final Set<Location> doubleBlocks;
|
||||
private final Island island;
|
||||
private final IslandWorld world;
|
||||
private final Map<CompatibleMaterial, BlockAmount> amounts;
|
||||
private final Configuration language;
|
||||
private final int runEveryX;
|
||||
@ -41,12 +41,13 @@ public final class IslandScan extends BukkitRunnable {
|
||||
private int blocksSize;
|
||||
private Queue<BlockInfo> blocks;
|
||||
|
||||
public IslandScan(SkyBlock plugin, Island island) {
|
||||
public IslandScan(SkyBlock plugin, Island island, IslandWorld world) {
|
||||
if (island == null) throw new IllegalArgumentException("island cannot be null");
|
||||
this.plugin = plugin;
|
||||
this.island = island;
|
||||
this.world = world;
|
||||
this.amounts = new EnumMap<>(CompatibleMaterial.class);
|
||||
this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.language = this.plugin.getLanguage();
|
||||
this.runEveryX = language.getInt("Command.Island.Level.Scanning.Progress.Display-Every-X-Scan");
|
||||
this.doubleBlocks = new HashSet<>();
|
||||
}
|
||||
@ -54,7 +55,7 @@ public final class IslandScan extends BukkitRunnable {
|
||||
public IslandScan start() {
|
||||
final SkyBlock plugin = SkyBlock.getInstance();
|
||||
|
||||
final FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
final FileConfiguration config = this.plugin.getConfiguration();
|
||||
final FileConfiguration islandData = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration();
|
||||
|
||||
final boolean hasNether = config.getBoolean("Island.World.Nether.Enable") && islandData.getBoolean("Unlocked.Nether", false);
|
||||
@ -65,64 +66,29 @@ public final class IslandScan extends BukkitRunnable {
|
||||
|
||||
if (plugin.isPaperAsync()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
initScan(plugin, hasNether, hasEnd, snapshots);
|
||||
initScan(plugin);
|
||||
});
|
||||
} else {
|
||||
initScan(plugin, hasNether, hasEnd, snapshots);
|
||||
initScan(plugin);
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void initScan(SkyBlock plugin, boolean hasNether, boolean hasEnd, Map<World, List<ChunkSnapshot>> snapshots) {
|
||||
populate(snapshots, IslandWorld.Normal, plugin.isPaperAsync(), () -> {
|
||||
private void initScan(SkyBlock plugin) {
|
||||
|
||||
if (hasNether) {
|
||||
populate(snapshots, IslandWorld.Nether, plugin.isPaperAsync(), () -> {
|
||||
if (hasEnd) {
|
||||
populate(snapshots, IslandWorld.End, plugin.isPaperAsync(), () -> {
|
||||
BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
|
||||
this.blocks = blocks;
|
||||
this.blocksSize = blocks.size();
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
|
||||
this.blocks = blocks;
|
||||
this.blocksSize = blocks.size();
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
|
||||
this.blocks = blocks;
|
||||
this.blocksSize = blocks.size();
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||
});
|
||||
}
|
||||
final Map<World, List<ChunkSnapshot>> snapshots = new HashMap<>(3);
|
||||
|
||||
populate(snapshots, plugin.isPaperAsync(), () -> {
|
||||
BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
|
||||
this.blocks = blocks;
|
||||
this.blocksSize = blocks.size();
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void finalizeBlocks() {
|
||||
|
||||
final Map<String, Long> materials = new HashMap<>(amounts.size());
|
||||
|
||||
for (Entry<CompatibleMaterial, BlockAmount> entry : amounts.entrySet()) {
|
||||
materials.put(entry.getKey().name(), entry.getValue().getAmount());
|
||||
}
|
||||
|
||||
final IslandLevel level = island.getLevel();
|
||||
|
||||
level.setMaterials(materials);
|
||||
level.setLastCalculatedLevel(level.getLevel());
|
||||
level.setLastCalculatedPoints(level.getPoints());
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new IslandLevelChangeEvent(island.getAPIWrapper(), island.getAPIWrapper().getLevel()));
|
||||
}
|
||||
|
||||
private int executions;
|
||||
|
||||
@Override
|
||||
@ -159,54 +125,22 @@ public final class IslandScan extends BukkitRunnable {
|
||||
totalScanned += scanned;
|
||||
|
||||
if (blocks.isEmpty()) {
|
||||
finalizeBlocks();
|
||||
cancel();
|
||||
SkyBlock.getInstance().getLevellingManager().stopScan(island);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) {
|
||||
|
||||
double percent = ((double) totalScanned / (double) blocksSize) * 100;
|
||||
|
||||
if(Double.isNaN(percent)) {
|
||||
percent = 0d;
|
||||
}
|
||||
|
||||
String message = language.getString("Command.Island.Level.Scanning.Progress.Message");
|
||||
message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned));
|
||||
message = message.replace("%max_blocks%", String.valueOf(blocksSize));
|
||||
message = message.replace("%percent_whole%", String.valueOf((int) percent));
|
||||
message = message.replace("%percent%", FORMATTER.format(percent));
|
||||
|
||||
final boolean displayComplete = totalScanned == blocksSize && language.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message");
|
||||
final MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
|
||||
|
||||
for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) {
|
||||
|
||||
messageManager.sendMessage(player, message);
|
||||
if (displayComplete)
|
||||
messageManager.sendMessage(player, language.getString("Command.Island.Level.Scanning.Finished.Message"));
|
||||
|
||||
// Check for level ups
|
||||
island.getLevel().checkLevelUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void populate(Map<World, List<ChunkSnapshot>> snapshots, IslandWorld world, boolean paper, PopulateTask task) {
|
||||
private void populate(Map<World, List<ChunkSnapshot>> snapshots, boolean paper, PopulateTask task) {
|
||||
|
||||
final SkyBlock plugin = SkyBlock.getInstance();
|
||||
|
||||
List<ChunkSnapshot> positions = new LinkedList<>();
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, paper, (chunkCompletableFuture) ->
|
||||
positions.add(chunkCompletableFuture.join().getChunkSnapshot()),
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, world, paper, (chunkCompletableFuture) ->
|
||||
positions.add(chunkCompletableFuture.join().getChunkSnapshot()),
|
||||
value -> {
|
||||
snapshots.put(plugin.getWorldManager().getWorld(world), positions);
|
||||
task.onComplete();
|
||||
});
|
||||
snapshots.put(plugin.getWorldManager().getWorld(world), positions);
|
||||
task.onComplete();
|
||||
});
|
||||
}
|
||||
|
||||
private interface PopulateTask {
|
||||
@ -217,4 +151,19 @@ public final class IslandScan extends BukkitRunnable {
|
||||
return doubleBlocks;
|
||||
}
|
||||
|
||||
public Map<CompatibleMaterial, BlockAmount> getAmounts() {
|
||||
return Collections.unmodifiableMap(amounts);
|
||||
}
|
||||
|
||||
public int getTotalScanned() {
|
||||
return totalScanned;
|
||||
}
|
||||
|
||||
public int getBlocksSize() {
|
||||
return blocksSize;
|
||||
}
|
||||
|
||||
public int getExecutions() {
|
||||
return executions;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public final class LevellingMaterial {
|
||||
|
||||
private CompatibleMaterial materials;
|
||||
private final CompatibleMaterial materials;
|
||||
private double points;
|
||||
|
||||
public LevellingMaterial(CompatibleMaterial materials, double points) {
|
||||
|
@ -0,0 +1,112 @@
|
||||
package com.songoda.skyblock.levelling;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.event.island.IslandLevelChangeEvent;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandLevel;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.levelling.amount.BlockAmount;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class QueuedIslandScan {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final Island island;
|
||||
private IslandScan currentScan = null;
|
||||
private final Queue<IslandWorld> toScan = new LinkedList<>();
|
||||
|
||||
private static final NumberFormat FORMATTER = NumberFormat.getInstance();
|
||||
private final Configuration language;
|
||||
|
||||
private int executions;
|
||||
private final int runEveryX;
|
||||
private final Map<CompatibleMaterial, BlockAmount> amounts = new EnumMap<>(CompatibleMaterial.class);
|
||||
private int totalScanned;
|
||||
private int blocksSize;
|
||||
|
||||
public QueuedIslandScan(SkyBlock plugin, Island island) {
|
||||
this.plugin = plugin;
|
||||
this.island = island;
|
||||
this.language = plugin.getLanguage();
|
||||
this.runEveryX = language.getInt("Command.Island.Level.Scanning.Progress.Display-Every-X-Scan");
|
||||
}
|
||||
|
||||
public void addToScan(IslandWorld world) {
|
||||
toScan.add(world);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.executions += currentScan.getExecutions();
|
||||
this.totalScanned += currentScan.getTotalScanned();
|
||||
this.blocksSize += currentScan.getBlocksSize();
|
||||
this.amounts.putAll(currentScan.getAmounts());
|
||||
}
|
||||
|
||||
public boolean scan() {
|
||||
if (currentScan != null)
|
||||
update();
|
||||
|
||||
if (toScan.isEmpty()) {
|
||||
finalize();
|
||||
return false;
|
||||
}
|
||||
IslandWorld world = toScan.poll();
|
||||
currentScan = new IslandScan(plugin, island, world).start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void finalize() {
|
||||
|
||||
final Map<String, Long> materials = new HashMap<>(amounts.size());
|
||||
|
||||
for (Map.Entry<CompatibleMaterial, BlockAmount> entry : amounts.entrySet()) {
|
||||
materials.put(entry.getKey().name(), entry.getValue().getAmount());
|
||||
}
|
||||
|
||||
final IslandLevel level = island.getLevel();
|
||||
|
||||
level.setMaterials(materials);
|
||||
level.setLastCalculatedLevel(level.getLevel());
|
||||
level.setLastCalculatedPoints(level.getPoints());
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new IslandLevelChangeEvent(island.getAPIWrapper(), island.getAPIWrapper().getLevel()));
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) {
|
||||
|
||||
double percent = ((double) totalScanned / (double) blocksSize) * 100;
|
||||
|
||||
if (Double.isNaN(percent)) {
|
||||
percent = 0d;
|
||||
}
|
||||
|
||||
String message = language.getString("Command.Island.Level.Scanning.Progress.Message");
|
||||
message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned));
|
||||
message = message.replace("%max_blocks%", String.valueOf(blocksSize));
|
||||
message = message.replace("%percent_whole%", String.valueOf((int) percent));
|
||||
message = message.replace("%percent%", FORMATTER.format(percent));
|
||||
|
||||
final boolean displayComplete = totalScanned == blocksSize && language.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message");
|
||||
final MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
|
||||
|
||||
for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) {
|
||||
|
||||
messageManager.sendMessage(player, message);
|
||||
if (displayComplete)
|
||||
messageManager.sendMessage(player, language.getString("Command.Island.Level.Scanning.Finished.Message"));
|
||||
|
||||
// Check for level ups
|
||||
island.getLevel().checkLevelUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -39,10 +39,9 @@ public final class LimitationInstanceHandler {
|
||||
|
||||
public void reloadAll() {
|
||||
final SkyBlock plugin = SkyBlock.getInstance();
|
||||
final Configuration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "limits.yml")).getFileConfiguration();
|
||||
final Configuration config = plugin.getLimits();
|
||||
|
||||
loadChunks = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Limits.LoadChunks");
|
||||
loadChunks = plugin.getConfiguration().getBoolean("Island.Limits.LoadChunks");
|
||||
|
||||
for (Limitation limit : instances.values()) {
|
||||
limit.reload(config.getConfigurationSection(limit.getSectionName()));
|
||||
|
@ -50,7 +50,7 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
|
||||
if (type == null)
|
||||
throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in the Section '" + loadFrom.getCurrentPath() + "'");
|
||||
|
||||
|
||||
getMap().put(type, loadFrom.getLong(key));
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
if (player.hasPermission("fabledskyblock.limit.block.*")) return -1;
|
||||
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (type.toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
@ -75,7 +75,7 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
if (material == null) {
|
||||
material = CompatibleMaterial.getMaterial(type);
|
||||
}
|
||||
|
||||
@ -87,21 +87,21 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
}
|
||||
|
||||
public boolean isBlockLimitExceeded(Block block, long limit) {
|
||||
return this.isBlockLimitExceeded(block.getType(), block.getLocation(), limit);
|
||||
return this.isBlockLimitExceeded(CompatibleMaterial.getMaterial(block), block.getLocation(), limit);
|
||||
}
|
||||
|
||||
public boolean isBlockLimitExceeded(Material type, Location loc, long limit) {
|
||||
public boolean isBlockLimitExceeded(CompatibleMaterial type, Location loc, long limit) {
|
||||
if (limit == -1) return false;
|
||||
|
||||
final IslandManager islandManager = SkyBlock.getInstance().getIslandManager();
|
||||
final Island island = islandManager.getIslandAtLocation(loc);
|
||||
final long totalPlaced;
|
||||
|
||||
if (type == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
|
||||
if (type == CompatibleMaterial.SPAWNER) {
|
||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
|
||||
} else {
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (type.toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
@ -109,9 +109,7 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(type);
|
||||
}
|
||||
if (material == null) material = type;
|
||||
totalPlaced = island.getLevel().getMaterialAmount(material.name());
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,7 @@ public class Block implements Listener {
|
||||
stackableManager.removeStack(stackable);
|
||||
}
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
if (material != null) {
|
||||
@ -138,8 +137,7 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||
|
||||
@ -147,7 +145,7 @@ public class Block implements Listener {
|
||||
|| LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||
if (configLoad.getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message"));
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.SpawnProtection.Break.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
@ -238,13 +236,12 @@ public class Block implements Listener {
|
||||
|
||||
if (islandLevelManager.isScanning(island)) {
|
||||
plugin.getMessageManager().sendMessage(player,
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
|
||||
plugin.getLanguage().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||
|
||||
if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){
|
||||
@ -252,8 +249,7 @@ public class Block implements Listener {
|
||||
for(String s : configLoad.getConfigurationSection("Island.Restrict.NetherBlocks").getKeys(false)){
|
||||
if(s.equalsIgnoreCase(block.getType().toString())){
|
||||
if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){
|
||||
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message")));
|
||||
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getLanguage().getString("Island.Unlock.NetherBlocksPlace.Message")));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -266,8 +262,7 @@ public class Block implements Listener {
|
||||
for(String s : configLoad.getConfigurationSection("Island.Restrict.EndBlocks").getKeys(false)){
|
||||
if(s.equalsIgnoreCase(block.getType().toString())){
|
||||
if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){
|
||||
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message")));
|
||||
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getLanguage().getString("Island.Unlock.EndBlocksPlace.Message")));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -298,7 +293,7 @@ public class Block implements Listener {
|
||||
}
|
||||
|
||||
if (isObstructing) {
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.SpawnProtection.Place.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -310,7 +305,9 @@ public class Block implements Listener {
|
||||
|
||||
long limit = limits.getBlockLimit(player, block.getType());
|
||||
|
||||
if (limits.isBlockLimitExceeded(block, limit)) {
|
||||
ItemStack item = event.getItemInHand();
|
||||
|
||||
if (limits.isBlockLimitExceeded(block, limit) && CompatibleMaterial.getMaterial(item) != CompatibleMaterial.ENDER_EYE) {
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (block.getType().toString().toUpperCase()) {
|
||||
@ -324,7 +321,7 @@ public class Block implements Listener {
|
||||
material = CompatibleMaterial.getMaterial(block);
|
||||
}
|
||||
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Limit.Block.Exceeded.Message")
|
||||
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
@ -337,8 +334,7 @@ public class Block implements Listener {
|
||||
if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial()
|
||||
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
|
||||
|
||||
islandLevelManager.updateLevel(island, blockLoc);
|
||||
|
||||
// Not util used 2 islandLevelManager if condition is true
|
||||
// Sponge level dupe fix
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13) &&
|
||||
block.getType().equals(CompatibleMaterial.SPONGE.getBlockMaterial())) {
|
||||
@ -359,6 +355,8 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
islandLevelManager.updateLevel(island, blockLoc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,8 +372,7 @@ public class Block implements Listener {
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
||||
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (island == null) return;
|
||||
|
||||
@ -548,8 +545,7 @@ public class Block implements Listener {
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
||||
if (island == null) return;
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (performStackCheck(event.getBlock(), event.getBlocks(), event.getDirection())) {
|
||||
event.setCancelled(true);
|
||||
@ -587,7 +583,7 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Extend")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Block.Piston.Connected.Extend")) {
|
||||
if (block.getType() == CompatibleMaterial.PISTON.getMaterial() || block.getType() == CompatibleMaterial.STICKY_PISTON.getMaterial()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -646,8 +642,7 @@ public class Block implements Listener {
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
||||
if (island == null) return;
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (performStackCheck(event.getBlock(), event.getBlocks(), event.getDirection())) {
|
||||
event.setCancelled(true);
|
||||
@ -676,7 +671,7 @@ public class Block implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Retract")) {
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Block.Piston.Connected.Retract")) {
|
||||
if (block.getType() == CompatibleMaterial.PISTON.getMaterial() || block.getType() == CompatibleMaterial.STICKY_PISTON.getMaterial()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -691,7 +686,7 @@ public class Block implements Listener {
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
IslandLevelManager islandLevelManager = plugin.getLevellingManager();
|
||||
|
||||
FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
FileConfiguration config = this.plugin.getConfiguration();
|
||||
|
||||
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
||||
|
||||
@ -710,7 +705,7 @@ public class Block implements Listener {
|
||||
// Check spawn block protection
|
||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -775,7 +770,8 @@ public class Block implements Listener {
|
||||
if(onlineOwner.hasPermission(generator.getPermission())) {
|
||||
applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
event.setCancelled(true);
|
||||
org.bukkit.World finalWorld = event.getBlock().getWorld();
|
||||
this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone()));
|
||||
@ -851,7 +847,7 @@ public class Block implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPortalCreate(PortalCreateEvent event) {
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
return;
|
||||
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
@ -913,7 +909,7 @@ public class Block implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onDispenserDispenseBlock(BlockDispenseEvent event) {
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
return;
|
||||
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
@ -932,4 +928,46 @@ public class Block implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onLiquidDestroyBlock(BlockFromToEvent event) {
|
||||
if (!plugin.getWorldManager().isIslandWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
||||
if (island == null)
|
||||
return;
|
||||
|
||||
CompatibleMaterial destmaterial = CompatibleMaterial.getMaterial(event.getToBlock());
|
||||
if (destmaterial == CompatibleMaterial.AIR)
|
||||
return;
|
||||
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (event.getToBlock().getType().toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
destmaterial = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CompatibleMaterial srcmaterial = CompatibleMaterial.getMaterial(event.getBlock());
|
||||
if (srcmaterial != CompatibleMaterial.WATER
|
||||
&& srcmaterial != CompatibleMaterial.LAVA)
|
||||
return;
|
||||
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
if (!configLoad.getBoolean("Island.Block.Level.Enable"))
|
||||
return;
|
||||
|
||||
IslandLevel level = island.getLevel();
|
||||
if (level.hasMaterial(destmaterial.name())) {
|
||||
long materialAmount = level.getMaterialAmount(destmaterial.name());
|
||||
|
||||
if (materialAmount - 1 <= 0) {
|
||||
level.removeMaterial(destmaterial.name());
|
||||
} else {
|
||||
level.setMaterialAmount(destmaterial.name(), materialAmount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class Bucket implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
@ -72,8 +72,7 @@ public class Bucket implements Listener {
|
||||
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||
event.setCancelled(true);
|
||||
plugin.getMessageManager().sendMessage(player,
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
|
||||
plugin.getLanguage().getString("Island.SpawnProtection.Place.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
@ -49,9 +49,7 @@ public class Chat implements Listener {
|
||||
|
||||
if (playerData.isChat() && island != null) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration languageLoad = language.getFileConfiguration();
|
||||
FileConfiguration languageLoad = plugin.getLanguage();
|
||||
|
||||
PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, island.getAPIWrapper(),
|
||||
event.getMessage(), languageLoad.getString("Island.Chat.Format.Message"));
|
||||
@ -65,13 +63,11 @@ public class Chat implements Listener {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Island island = event.getIsland().getIsland();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration languageLoad = language.getFileConfiguration();
|
||||
|
||||
FileConfiguration languageLoad = plugin.getLanguage();
|
||||
|
||||
String islandRole = null;
|
||||
|
||||
@ -110,7 +106,7 @@ public class Chat implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
|
||||
messageManager.sendMessage(Bukkit.getConsoleSender(), event.getFormat().replace("%role", islandRole).replace("%player", player.getName())
|
||||
.replace("%message", event.getMessage()));
|
||||
}
|
||||
|
@ -25,8 +25,7 @@ public class Death implements Listener {
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (plugin.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
boolean keepInventory = false;
|
||||
|
||||
|
@ -64,8 +64,7 @@ public class Entity implements Listener {
|
||||
if(event.getEntity() instanceof Blaze){
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) &&
|
||||
worldManager.getIslandWorld(event.getEntity().getWorld()).equals(IslandWorld.Nether) &&
|
||||
@ -92,8 +91,7 @@ public class Entity implements Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
org.bukkit.entity.Entity victim = event.getEntity();
|
||||
Island island = islandManager.getIslandAtLocation(victim.getLocation());
|
||||
@ -103,9 +101,10 @@ public class Entity implements Listener {
|
||||
if(attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof org.bukkit.entity.Entity) {
|
||||
attacker = (org.bukkit.entity.Entity) ((Projectile) attacker).getShooter();
|
||||
}
|
||||
|
||||
|
||||
// Rework with better config
|
||||
if(victim instanceof Player && attacker instanceof Player) { // PVP
|
||||
if(configLoad.getBoolean("Island.PvP.Enable")) {
|
||||
if (configLoad.getBoolean("Island.Entity_Damage.PVP")) {
|
||||
if(plugin.getPermissionManager()
|
||||
.processPermission(event, (Player) attacker, island)) {
|
||||
plugin.getPermissionManager()
|
||||
@ -114,15 +113,26 @@ public class Entity implements Listener {
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if(victim instanceof Player) { // EVP
|
||||
plugin.getPermissionManager()
|
||||
.processPermission(event, (Player) victim, island, true);
|
||||
} else if(attacker instanceof Player) { // PVE
|
||||
plugin.getPermissionManager()
|
||||
.processPermission(event, (Player) attacker, island);
|
||||
} else { // EVE
|
||||
plugin.getPermissionManager()
|
||||
.processPermission(event, island);
|
||||
}
|
||||
else if(victim instanceof Player) { // EVP
|
||||
if (configLoad.getBoolean("Island.Entity_Damage.EVP")) {
|
||||
plugin.getPermissionManager()
|
||||
.processPermission(event, (Player) victim, island, true);
|
||||
}
|
||||
|
||||
}
|
||||
else if(attacker instanceof Player) { // PVE
|
||||
if (configLoad.getBoolean("Island.Entity_Damage.PVE")) {
|
||||
plugin.getPermissionManager()
|
||||
.processPermission(event, (Player) attacker, island);
|
||||
}
|
||||
|
||||
}
|
||||
else { // EVE
|
||||
if (configLoad.getBoolean("Island.Entity_Damage.PVE")) {
|
||||
plugin.getPermissionManager()
|
||||
.processPermission(event, island);
|
||||
}
|
||||
}
|
||||
|
||||
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if
|
||||
@ -278,8 +288,7 @@ public class Entity implements Listener {
|
||||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
||||
|
||||
@ -290,7 +299,7 @@ public class Entity implements Listener {
|
||||
if ((LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0, 1, 0))
|
||||
|| LocationUtil.isLocationLocation(block.getLocation(),
|
||||
island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0, 1, 0)))
|
||||
&& plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
&& this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -323,8 +332,7 @@ public class Entity implements Listener {
|
||||
if (entity instanceof FallingBlock) return;
|
||||
|
||||
// Check entities interacting with spawn
|
||||
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -333,7 +341,7 @@ public class Entity implements Listener {
|
||||
plugin.getPermissionManager().processPermission(event, null, island);
|
||||
|
||||
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (!this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Block.Level.Enable"))
|
||||
return;
|
||||
|
||||
@ -342,7 +350,6 @@ public class Entity implements Listener {
|
||||
|
||||
if (event.getTo() != Material.AIR) {
|
||||
materials = CompatibleMaterial.getBlockMaterial(event.getTo());
|
||||
;
|
||||
|
||||
if (materials != null) {
|
||||
long materialAmount = 0;
|
||||
@ -379,8 +386,7 @@ public class Entity implements Listener {
|
||||
while (it.hasNext()){
|
||||
removed = false;
|
||||
org.bukkit.block.Block block = it.next();
|
||||
if (SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Spawn.Protection")) {
|
||||
if (SkyBlock.getInstance().getConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld());
|
||||
if (LocationUtil.isLocationLocation(block.getLocation(),
|
||||
island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))) {
|
||||
@ -408,8 +414,7 @@ public class Entity implements Listener {
|
||||
stackableManager.removeStack(stackable);
|
||||
}
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
removeBlockFromLevel(island, block);
|
||||
@ -425,7 +430,7 @@ public class Entity implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Block.Level.Enable")) {
|
||||
if(!removed){
|
||||
removeBlockFromLevel(island, block);
|
||||
@ -573,9 +578,7 @@ public class Entity implements Listener {
|
||||
EntityType type = entity.getType();
|
||||
|
||||
if (limits.isBeingTracked(type)) {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
boolean isSplit = event.getSpawnReason().equals(SpawnReason.SLIME_SPLIT);
|
||||
boolean splitBypass = configLoad.getBoolean("Island.Challenge.PerIsland", true);
|
||||
|
@ -42,8 +42,7 @@ public class EpicSpawners implements Listener {
|
||||
int amount = event.getSpawner().getFirstStack().getStackSize();
|
||||
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
|
||||
|
||||
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
|
||||
@ -77,8 +76,7 @@ public class EpicSpawners implements Listener {
|
||||
int amount = event.getStackSize() - event.getOldStackSize();
|
||||
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
|
||||
|
||||
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
|
||||
@ -112,8 +110,7 @@ public class EpicSpawners implements Listener {
|
||||
int amount = event.getSpawner().getFirstStack().getStackSize();
|
||||
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
|
||||
|
||||
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
|
||||
|
@ -37,8 +37,7 @@ public class FallBreak implements Listener {
|
||||
int counter = 0;
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
FileConfiguration configLoad = plugin.getConfiguration();
|
||||
Iterator<FallingBlock> iterator = fallingBlocks.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
FallingBlock ent = iterator.next();
|
||||
@ -88,7 +87,7 @@ public class FallBreak implements Listener {
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
if (worldManager.isIslandWorld(event.getEntity().getLocation().getWorld())) {
|
||||
if (!event.getTo().equals(CompatibleMaterial.AIR.getMaterial())){
|
||||
fallingBlocks.remove((FallingBlock) event.getEntity());
|
||||
fallingBlocks.remove(event.getEntity());
|
||||
} else if(!event.isCancelled()) {
|
||||
fallingBlocks.add((FallingBlock) event.getEntity());
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ public class Grow implements Listener {
|
||||
// The structure is growing from one island to another.
|
||||
if (!origin.getIslandUUID().equals(growingTo.getIslandUUID())) {
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,7 +85,7 @@ public class Grow implements Listener {
|
||||
// Check spawn block protection
|
||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -155,7 +154,7 @@ public class Grow implements Listener {
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onStructureCreate(StructureGrowEvent event) {
|
||||
if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return;
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) return;
|
||||
|
||||
List<BlockState> blocks = event.getBlocks();
|
||||
if (blocks.isEmpty()) return;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user