mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 18:55:30 +01:00
Do not open challenge inventory if player doesn't have an island and per-island challenges are enabled
This commit is contained in:
parent
1d5463fed7
commit
66ee4d4f5b
@ -43,7 +43,10 @@ public class PlayerManager {
|
||||
public HashMap<Challenge, Integer> getPlayer(UUID uuid) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
uuid = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)).getOwnerUUID();
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
return islands.get(uuid);
|
||||
}
|
||||
@ -57,7 +60,10 @@ public class PlayerManager {
|
||||
public void loadPlayer(UUID uuid) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
uuid = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)).getOwnerUUID();
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
|
||||
uuid.toString() + ".yml"));
|
||||
@ -121,8 +127,10 @@ public class PlayerManager {
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
uuid = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)).getOwnerUUID();
|
||||
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
HashMap<Challenge, Integer> done = islands.get(uuid);
|
||||
if (done == null) {
|
||||
@ -155,7 +163,10 @@ public class PlayerManager {
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
uuid = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)).getOwnerUUID();
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
HashMap<Challenge, Integer> done = islands.get(uuid);
|
||||
int count = done.getOrDefault(c, 0);
|
||||
@ -181,8 +192,10 @@ public class PlayerManager {
|
||||
public void addChallenge(UUID uuid, Challenge c) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
uuid = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)).getOwnerUUID();
|
||||
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
|
||||
uuid.toString() + ".yml"));
|
||||
@ -218,7 +231,10 @@ public class PlayerManager {
|
||||
} else {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
uuid = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)).getOwnerUUID();
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
|
||||
// Not connected, check in file
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.skyblock.command.commands.island;
|
||||
import java.io.File;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -24,6 +25,7 @@ public class ChallengeCommand extends SubCommand {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FabledChallenge fabledChallenge = skyblock.getFabledChallenge();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
Config langConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
|
||||
@ -36,6 +38,15 @@ public class ChallengeCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland")){
|
||||
if(islandManager.getIsland(player) == null){
|
||||
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Open challenge inventory
|
||||
ChallengeCategory cc = fabledChallenge.getChallengeManager().getChallenge(1);
|
||||
if (cc == null) {
|
||||
|
@ -990,6 +990,8 @@ Command:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eCategory not found.'
|
||||
ChallengeNotFound:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eChallenge not found.'
|
||||
NoIsland:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eYou don''t have an island.'
|
||||
Preview:
|
||||
Info:
|
||||
Message: '&f&oAllows you to preview island before choosing'
|
||||
|
Loading…
Reference in New Issue
Block a user