mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-23 07:51:31 +01:00
Heavy code style changes and slight refactoring
This commit is contained in:
parent
e1c28007bb
commit
308d8ca7b9
@ -27,7 +27,28 @@ import com.songoda.skyblock.island.reward.RewardManager;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.levelling.IslandLevelManager;
|
||||
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||
import com.songoda.skyblock.listeners.*;
|
||||
import com.songoda.skyblock.listeners.BlockListeners;
|
||||
import com.songoda.skyblock.listeners.BucketListeners;
|
||||
import com.songoda.skyblock.listeners.ChatListeners;
|
||||
import com.songoda.skyblock.listeners.DeathListeners;
|
||||
import com.songoda.skyblock.listeners.EntityListeners;
|
||||
import com.songoda.skyblock.listeners.FallBreakListeners;
|
||||
import com.songoda.skyblock.listeners.FoodListeners;
|
||||
import com.songoda.skyblock.listeners.GrowListeners;
|
||||
import com.songoda.skyblock.listeners.InteractListeners;
|
||||
import com.songoda.skyblock.listeners.InventoryListeners;
|
||||
import com.songoda.skyblock.listeners.ItemListeners;
|
||||
import com.songoda.skyblock.listeners.JoinListeners;
|
||||
import com.songoda.skyblock.listeners.MoveListeners;
|
||||
import com.songoda.skyblock.listeners.PistonListeners;
|
||||
import com.songoda.skyblock.listeners.PortalListeners;
|
||||
import com.songoda.skyblock.listeners.ProjectileListeners;
|
||||
import com.songoda.skyblock.listeners.QuitListeners;
|
||||
import com.songoda.skyblock.listeners.RespawnListeners;
|
||||
import com.songoda.skyblock.listeners.SpawnerListeners;
|
||||
import com.songoda.skyblock.listeners.SpongeListeners;
|
||||
import com.songoda.skyblock.listeners.TeleportListeners;
|
||||
import com.songoda.skyblock.listeners.WorldListeners;
|
||||
import com.songoda.skyblock.listeners.hooks.EpicSpawners;
|
||||
import com.songoda.skyblock.listeners.hooks.UltimateStacker;
|
||||
import com.songoda.skyblock.localization.LocalizationManager;
|
||||
@ -57,14 +78,12 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
private static SkyBlock INSTANCE;
|
||||
|
||||
private FileManager fileManager;
|
||||
private final WorldManager worldManager = new WorldManager(this);
|
||||
private UserCacheManager userCacheManager;
|
||||
@ -103,8 +122,12 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.bukkit.plugin.java.JavaPlugin#getPlugin(Class)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static SkyBlock getInstance() {
|
||||
return INSTANCE;
|
||||
return getPlugin(SkyBlock.class);
|
||||
}
|
||||
|
||||
// Add ymlFiles to cache
|
||||
@ -125,7 +148,6 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -134,17 +156,17 @@ public class SkyBlock extends SongodaPlugin {
|
||||
this.getLogger().warning("This Minecraft version is not officially supported.");
|
||||
}
|
||||
|
||||
if (paper = ServerProject.isServer(ServerProject.PAPER)) {
|
||||
if (this.paper = ServerProject.isServer(ServerProject.PAPER)) {
|
||||
try {
|
||||
Bukkit.spigot().getClass().getMethod("getPaperConfig");
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
||||
paperAsync = true;
|
||||
this.paperAsync = true;
|
||||
} else {
|
||||
paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) &&
|
||||
this.paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) &&
|
||||
Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false);
|
||||
}
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
paperAsync = false;
|
||||
this.paperAsync = false;
|
||||
}
|
||||
this.getLogger().info("Enabling Paper hooks");
|
||||
}
|
||||
@ -153,72 +175,72 @@ public class SkyBlock extends SongodaPlugin {
|
||||
SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK);
|
||||
|
||||
// Load Economy
|
||||
economyManager = new EconomyManager(this);
|
||||
this.economyManager = new EconomyManager(this);
|
||||
|
||||
// Load Holograms
|
||||
HologramManager.load(this);
|
||||
|
||||
fileManager = new FileManager(this);
|
||||
this.fileManager = new FileManager(this);
|
||||
|
||||
if (!loadConfigs()) {
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
permissionManager = new PermissionManager(this);
|
||||
localizationManager = new LocalizationManager();
|
||||
worldManager.loadWorlds();
|
||||
userCacheManager = new UserCacheManager(this);
|
||||
visitManager = new VisitManager(this);
|
||||
banManager = new BanManager(this);
|
||||
islandManager = new IslandManager(this);
|
||||
upgradeManager = new UpgradeManager(this);
|
||||
playerDataManager = new PlayerDataManager(this);
|
||||
cooldownManager = new CooldownManager(this);
|
||||
limitationHandler = new LimitationInstanceHandler();
|
||||
fabledChallenge = new FabledChallenge(this);
|
||||
scoreboardManager = new ScoreboardManager(this);
|
||||
inviteManager = new InviteManager(this);
|
||||
biomeManager = new BiomeManager(this);
|
||||
levellingManager = new IslandLevelManager(this);
|
||||
commandManager = new CommandManager(this);
|
||||
structureManager = new StructureManager(this);
|
||||
soundManager = new SoundManager(this);
|
||||
this.permissionManager = new PermissionManager(this);
|
||||
this.localizationManager = new LocalizationManager();
|
||||
this.worldManager.loadWorlds();
|
||||
this.userCacheManager = new UserCacheManager(this);
|
||||
this.visitManager = new VisitManager(this);
|
||||
this.banManager = new BanManager(this);
|
||||
this.islandManager = new IslandManager(this);
|
||||
this.upgradeManager = new UpgradeManager(this);
|
||||
this.playerDataManager = new PlayerDataManager(this);
|
||||
this.cooldownManager = new CooldownManager(this);
|
||||
this.limitationHandler = new LimitationInstanceHandler();
|
||||
this.fabledChallenge = new FabledChallenge(this);
|
||||
this.scoreboardManager = new ScoreboardManager(this);
|
||||
this.inviteManager = new InviteManager(this);
|
||||
this.biomeManager = new BiomeManager(this);
|
||||
this.levellingManager = new IslandLevelManager(this);
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.structureManager = new StructureManager(this);
|
||||
this.soundManager = new SoundManager(this);
|
||||
|
||||
if (this.config.getBoolean("Island.Generator.Enable")) {
|
||||
generatorManager = new GeneratorManager(this);
|
||||
this.generatorManager = new GeneratorManager(this);
|
||||
}
|
||||
|
||||
if (this.config.getBoolean("Island.Stackable.Enable")) {
|
||||
stackableManager = new StackableManager(this);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> stackableManager.loadSavedStackables(), 5L);
|
||||
this.stackableManager = new StackableManager(this);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> this.stackableManager.loadSavedStackables(), 5L);
|
||||
}
|
||||
|
||||
leaderboardManager = new LeaderboardManager(this);
|
||||
this.leaderboardManager = new LeaderboardManager(this);
|
||||
|
||||
placeholderManager = new PlaceholderManager(this);
|
||||
placeholderManager.registerPlaceholders();
|
||||
this.placeholderManager = new PlaceholderManager(this);
|
||||
this.placeholderManager.registerPlaceholders();
|
||||
|
||||
messageManager = new MessageManager(this);
|
||||
this.messageManager = new MessageManager(this);
|
||||
|
||||
rewardManager = new RewardManager(this);
|
||||
rewardManager.loadRewards();
|
||||
this.rewardManager = new RewardManager(this);
|
||||
this.rewardManager.loadRewards();
|
||||
|
||||
bankManager = new BankManager(this);
|
||||
this.bankManager = new BankManager(this);
|
||||
|
||||
if (this.config.getBoolean("Island.Task.PlaytimeTask")) {
|
||||
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
new PlaytimeTask(this.playerDataManager, this.islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
}
|
||||
|
||||
if (this.config.getBoolean("Island.Task.VisitTask")) {
|
||||
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
new VisitTask(this.playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
}
|
||||
|
||||
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
new ConfirmationTask(this.playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
|
||||
// Start Tasks
|
||||
hologramTask = HologramTask.startTask(this);
|
||||
mobNetherWaterTask = MobNetherWaterTask.startTask(this);
|
||||
this.hologramTask = HologramTask.startTask(this);
|
||||
this.mobNetherWaterTask = MobNetherWaterTask.startTask(this);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new JoinListeners(this), this);
|
||||
@ -247,16 +269,18 @@ public class SkyBlock extends SongodaPlugin {
|
||||
pluginManager.registerEvents(new SpongeListeners(this), this);
|
||||
}
|
||||
|
||||
if (pluginManager.isPluginEnabled("EpicSpawners"))
|
||||
if (pluginManager.isPluginEnabled("EpicSpawners")) {
|
||||
pluginManager.registerEvents(new EpicSpawners(this), this);
|
||||
if (pluginManager.isPluginEnabled("UltimateStacker"))
|
||||
}
|
||||
if (pluginManager.isPluginEnabled("UltimateStacker")) {
|
||||
pluginManager.registerEvents(new UltimateStacker(this), this);
|
||||
}
|
||||
|
||||
pluginManager.registerEvents(new Levelling(), this);
|
||||
pluginManager.registerEvents(new Generator(), this);
|
||||
pluginManager.registerEvents(new Creator(), this);
|
||||
|
||||
this.getCommand("skyblock").setExecutor(new SkyBlockCommand());
|
||||
this.getCommand("skyblock").setExecutor(new SkyBlockCommand(this));
|
||||
|
||||
if (pluginManager.isPluginEnabled("Vault")) {
|
||||
this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
|
||||
@ -278,31 +302,41 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
LogManager.load();
|
||||
|
||||
SkyBlockAPI.setImplementation(INSTANCE);
|
||||
SkyBlockAPI.setImplementation(this);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
@ -313,8 +347,11 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
if (!loadConfigs()) this.getLogger().warning("Config are not reload !");
|
||||
else this.getLogger().info("Configurations Loaded !");
|
||||
if (!loadConfigs()) {
|
||||
this.getLogger().warning("Config are not reload !");
|
||||
} else {
|
||||
this.getLogger().info("Configurations Loaded !");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -324,20 +361,20 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
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();
|
||||
this.biomes = this.getFileManager().getConfig(new File(this.getDataFolder(), "biomes.yml")).getFileConfiguration();
|
||||
this.challenges = this.getFileManager().getConfig(new File(this.getDataFolder(), "challenges.yml")).getFileConfiguration();
|
||||
this.config = this.getFileManager().getConfig(new File(this.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
this.generators = this.getFileManager().getConfig(new File(this.getDataFolder(), "generators.yml")).getFileConfiguration();
|
||||
this.language = this.getFileManager().getConfig(new File(this.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.levelling = this.getFileManager().getConfig(new File(this.getDataFolder(), "levelling.yml")).getFileConfiguration();
|
||||
this.limits = this.getFileManager().getConfig(new File(this.getDataFolder(), "limits.yml")).getFileConfiguration();
|
||||
this.menus = this.getFileManager().getConfig(new File(this.getDataFolder(), "menus.yml")).getFileConfiguration();
|
||||
this.placeholders = this.getFileManager().getConfig(new File(this.getDataFolder(), "placeholders.yml")).getFileConfiguration();
|
||||
this.rewards = this.getFileManager().getConfig(new File(this.getDataFolder(), "rewards.yml")).getFileConfiguration();
|
||||
this.scoreboard = this.getFileManager().getConfig(new File(this.getDataFolder(), "scoreboard.yml")).getFileConfiguration();
|
||||
this.settings = this.getFileManager().getConfig(new File(this.getDataFolder(), "settings.yml")).getFileConfiguration();
|
||||
this.stackables = this.getFileManager().getConfig(new File(this.getDataFolder(), "stackables.yml")).getFileConfiguration();
|
||||
this.upgrades = this.getFileManager().getConfig(new File(this.getDataFolder(), "upgrades.yml")).getFileConfiguration();
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
@ -350,47 +387,47 @@ public class SkyBlock extends SongodaPlugin {
|
||||
}
|
||||
|
||||
public FileManager getFileManager() {
|
||||
return fileManager;
|
||||
return this.fileManager;
|
||||
}
|
||||
|
||||
public WorldManager getWorldManager() {
|
||||
return worldManager;
|
||||
return this.worldManager;
|
||||
}
|
||||
|
||||
public UserCacheManager getUserCacheManager() {
|
||||
return userCacheManager;
|
||||
return this.userCacheManager;
|
||||
}
|
||||
|
||||
public VisitManager getVisitManager() {
|
||||
return visitManager;
|
||||
return this.visitManager;
|
||||
}
|
||||
|
||||
public BanManager getBanManager() {
|
||||
return banManager;
|
||||
return this.banManager;
|
||||
}
|
||||
|
||||
public BankManager getBankManager() {
|
||||
return bankManager;
|
||||
return this.bankManager;
|
||||
}
|
||||
|
||||
public IslandManager getIslandManager() {
|
||||
return islandManager;
|
||||
return this.islandManager;
|
||||
}
|
||||
|
||||
public UpgradeManager getUpgradeManager() {
|
||||
return upgradeManager;
|
||||
return this.upgradeManager;
|
||||
}
|
||||
|
||||
public PlayerDataManager getPlayerDataManager() {
|
||||
return playerDataManager;
|
||||
return this.playerDataManager;
|
||||
}
|
||||
|
||||
public CooldownManager getCooldownManager() {
|
||||
return cooldownManager;
|
||||
return this.cooldownManager;
|
||||
}
|
||||
|
||||
public ScoreboardManager getScoreboardManager() {
|
||||
return scoreboardManager;
|
||||
return this.scoreboardManager;
|
||||
}
|
||||
|
||||
public void setScoreboardManager(ScoreboardManager scoreboardManager) {
|
||||
@ -398,31 +435,31 @@ public class SkyBlock extends SongodaPlugin {
|
||||
}
|
||||
|
||||
public InviteManager getInviteManager() {
|
||||
return inviteManager;
|
||||
return this.inviteManager;
|
||||
}
|
||||
|
||||
public BiomeManager getBiomeManager() {
|
||||
return biomeManager;
|
||||
return this.biomeManager;
|
||||
}
|
||||
|
||||
public IslandLevelManager getLevellingManager() {
|
||||
return levellingManager;
|
||||
return this.levellingManager;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
public StructureManager getStructureManager() {
|
||||
return structureManager;
|
||||
return this.structureManager;
|
||||
}
|
||||
|
||||
public SoundManager getSoundManager() {
|
||||
return soundManager;
|
||||
return this.soundManager;
|
||||
}
|
||||
|
||||
public GeneratorManager getGeneratorManager() {
|
||||
return generatorManager;
|
||||
return this.generatorManager;
|
||||
}
|
||||
|
||||
public void setGeneratorManager(GeneratorManager generatorManager) {
|
||||
@ -430,127 +467,127 @@ public class SkyBlock extends SongodaPlugin {
|
||||
}
|
||||
|
||||
public LeaderboardManager getLeaderboardManager() {
|
||||
return leaderboardManager;
|
||||
return this.leaderboardManager;
|
||||
}
|
||||
|
||||
public PlaceholderManager getPlaceholderManager() {
|
||||
return placeholderManager;
|
||||
return this.placeholderManager;
|
||||
}
|
||||
|
||||
public MessageManager getMessageManager() {
|
||||
return messageManager;
|
||||
return this.messageManager;
|
||||
}
|
||||
|
||||
public HologramTask getHologramTask() {
|
||||
return hologramTask;
|
||||
return this.hologramTask;
|
||||
}
|
||||
|
||||
public MobNetherWaterTask getMobNetherWaterTask() {
|
||||
return mobNetherWaterTask;
|
||||
return this.mobNetherWaterTask;
|
||||
}
|
||||
|
||||
public StackableManager getStackableManager() {
|
||||
return stackableManager;
|
||||
return this.stackableManager;
|
||||
}
|
||||
|
||||
public LimitationInstanceHandler getLimitationHandler() {
|
||||
return limitationHandler;
|
||||
return this.limitationHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
return worldManager.getWorldGeneratorForMapName(worldName);
|
||||
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) {
|
||||
return this.worldManager.getWorldGeneratorForMapName(worldName);
|
||||
}
|
||||
|
||||
public LocalizationManager getLocalizationManager() {
|
||||
return localizationManager;
|
||||
return this.localizationManager;
|
||||
}
|
||||
|
||||
public RewardManager getRewardManager() {
|
||||
return rewardManager;
|
||||
return this.rewardManager;
|
||||
}
|
||||
|
||||
public FabledChallenge getFabledChallenge() {
|
||||
return fabledChallenge;
|
||||
return this.fabledChallenge;
|
||||
}
|
||||
|
||||
public PermissionManager getPermissionManager() {
|
||||
return permissionManager;
|
||||
return this.permissionManager;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
return this.guiManager;
|
||||
}
|
||||
|
||||
public boolean isPaper() {
|
||||
return paper;
|
||||
return this.paper;
|
||||
}
|
||||
|
||||
public boolean isPaperAsync() {
|
||||
return paperAsync;
|
||||
return this.paperAsync;
|
||||
}
|
||||
|
||||
public Permission getVaultPermission() {
|
||||
return vaultPermission;
|
||||
return this.vaultPermission;
|
||||
}
|
||||
|
||||
public EconomyManager getEconomyManager() {
|
||||
return economyManager;
|
||||
return this.economyManager;
|
||||
}
|
||||
|
||||
public FileConfiguration getBiomes() {
|
||||
return biomes;
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
public FileConfiguration getChallenges() {
|
||||
return challenges;
|
||||
return this.challenges;
|
||||
}
|
||||
|
||||
public FileConfiguration getConfiguration() {
|
||||
return config;
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public FileConfiguration getGenerators() {
|
||||
return generators;
|
||||
return this.generators;
|
||||
}
|
||||
|
||||
public FileConfiguration getLanguage() {
|
||||
return language;
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public FileConfiguration getLevelling() {
|
||||
return levelling;
|
||||
return this.levelling;
|
||||
}
|
||||
|
||||
public FileConfiguration getLimits() {
|
||||
return limits;
|
||||
return this.limits;
|
||||
}
|
||||
|
||||
public FileConfiguration getMenus() {
|
||||
return menus;
|
||||
return this.menus;
|
||||
}
|
||||
|
||||
public FileConfiguration getPlaceholders() {
|
||||
return placeholders;
|
||||
return this.placeholders;
|
||||
}
|
||||
|
||||
public FileConfiguration getRewards() {
|
||||
return rewards;
|
||||
return this.rewards;
|
||||
}
|
||||
|
||||
public FileConfiguration getSettings() {
|
||||
return settings;
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public FileConfiguration getStackables() {
|
||||
return stackables;
|
||||
return this.stackables;
|
||||
}
|
||||
|
||||
public FileConfiguration getUpgrades() {
|
||||
return upgrades;
|
||||
return this.upgrades;
|
||||
}
|
||||
|
||||
public FileConfiguration getScoreboard() {
|
||||
return scoreboard;
|
||||
return this.scoreboard;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.songoda.skyblock.api.levelling.LevellingManager;
|
||||
import com.songoda.skyblock.api.structure.StructureManager;
|
||||
|
||||
public class SkyBlockAPI {
|
||||
|
||||
private static SkyBlock implementation;
|
||||
|
||||
private static IslandManager islandManager;
|
||||
|
@ -7,7 +7,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ban {
|
||||
|
||||
private final Island handle;
|
||||
|
||||
public Ban(Island handle) {
|
||||
@ -26,7 +25,7 @@ public class Ban {
|
||||
* @return A Set of players that have banned from the Island
|
||||
*/
|
||||
public Set<UUID> getBans() {
|
||||
return handle.getIsland().getBan().getBans();
|
||||
return this.handle.getIsland().getBan().getBans();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +33,7 @@ public class Ban {
|
||||
*/
|
||||
public void addBan(UUID issuer, UUID banned) {
|
||||
Preconditions.checkArgument(banned != null, "Cannot add ban to null banned uuid");
|
||||
handle.getIsland().getBan().addBan(issuer, banned);
|
||||
this.handle.getIsland().getBan().addBan(issuer, banned);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,13 +41,13 @@ public class Ban {
|
||||
*/
|
||||
public void removeBan(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove ban to null uuid");
|
||||
handle.getIsland().getBan().removeBan(uuid);
|
||||
this.handle.getIsland().getBan().removeBan(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
return this.handle;
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,16 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TransactionLog {
|
||||
|
||||
public BankManager getImplementation() {
|
||||
return SkyBlock.getInstance().getBankManager();
|
||||
return SkyBlock.getPlugin(SkyBlock.class).getBankManager();
|
||||
}
|
||||
|
||||
public List<Transaction> getLogForPlayer(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) return null;
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getImplementation().getTransactionList(player);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.songoda.skyblock.island.IslandWorld;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class BiomeManager {
|
||||
|
||||
private final com.songoda.skyblock.biome.BiomeManager biomeManager;
|
||||
|
||||
public BiomeManager(com.songoda.skyblock.biome.BiomeManager biomeManager) {
|
||||
@ -21,6 +20,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, CompatibleBiome.getBiome(biome), null);
|
||||
this.biomeManager.setBiome(island.getIsland(), IslandWorld.NORMAL, CompatibleBiome.getBiome(biome), null);
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandBanEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final OfflinePlayer issuer, banned;
|
||||
private boolean cancelled = false;
|
||||
@ -22,16 +22,16 @@ public class IslandBanEvent extends IslandEvent implements Cancellable {
|
||||
}
|
||||
|
||||
public OfflinePlayer getIssuer() {
|
||||
return issuer;
|
||||
return this.issuer;
|
||||
}
|
||||
|
||||
public OfflinePlayer getBanned() {
|
||||
return banned;
|
||||
return this.banned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,7 +40,7 @@ public class IslandBanEvent extends IslandEvent implements Cancellable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandBiomeChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private Biome biome;
|
||||
@ -20,7 +20,7 @@ public class IslandBiomeChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public Biome getBiome() {
|
||||
return biome;
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public void setBiome(Biome biome) {
|
||||
@ -28,7 +28,7 @@ public class IslandBiomeChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandCreateEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
@ -20,11 +20,11 @@ public class IslandCreateEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandDeleteEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public IslandDeleteEvent(Island island) {
|
||||
@ -16,7 +16,7 @@ public class IslandDeleteEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,18 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class IslandEvent extends Event {
|
||||
|
||||
private final Island island;
|
||||
|
||||
protected IslandEvent(Island island) {
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
protected IslandEvent(Island island, boolean async) {
|
||||
super(async);
|
||||
protected IslandEvent(Island island, boolean isAsync) {
|
||||
super(isAsync);
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
public Island getIsland() {
|
||||
return island;
|
||||
return this.island;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.invite.IslandInvitation;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandInviteEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final IslandInvitation invite;
|
||||
@ -16,11 +16,11 @@ public class IslandInviteEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public IslandInvitation getInvite() {
|
||||
return invite;
|
||||
return this.invite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ import com.songoda.skyblock.api.island.IslandRole;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandKickEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Player kicker;
|
||||
private final OfflinePlayer kicked;
|
||||
@ -26,19 +26,19 @@ public class IslandKickEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public OfflinePlayer getKicked() {
|
||||
return kicked;
|
||||
return this.kicked;
|
||||
}
|
||||
|
||||
public Player getKicker() {
|
||||
return kicker;
|
||||
return this.kicker;
|
||||
}
|
||||
|
||||
public IslandRole getRole() {
|
||||
return role;
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
@ -46,7 +46,7 @@ public class IslandKickEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandLevel;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandLevelChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final IslandLevel level;
|
||||
@ -20,11 +20,11 @@ public class IslandLevelChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public IslandLevel getLevel() {
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandLoadEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public IslandLoadEvent(Island island) {
|
||||
@ -16,7 +16,7 @@ public class IslandLoadEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandLocation;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandLocationChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final IslandLocation location;
|
||||
@ -20,11 +20,11 @@ public class IslandLocationChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public IslandLocation getLocation() {
|
||||
return location;
|
||||
return this.location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandMessage;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IslandMessageChangeEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final IslandMessage message;
|
||||
private boolean cancelled = false;
|
||||
@ -27,11 +27,11 @@ public class IslandMessageChangeEvent extends IslandEvent implements Cancellable
|
||||
}
|
||||
|
||||
public IslandMessage getMessage() {
|
||||
return message;
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public List<String> getLines() {
|
||||
return lines;
|
||||
return this.lines;
|
||||
}
|
||||
|
||||
public void setLines(List<String> lines) {
|
||||
@ -39,7 +39,7 @@ public class IslandMessageChangeEvent extends IslandEvent implements Cancellable
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
return this.author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
@ -48,7 +48,7 @@ public class IslandMessageChangeEvent extends IslandEvent implements Cancellable
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,7 +57,7 @@ public class IslandMessageChangeEvent extends IslandEvent implements Cancellable
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,28 +3,28 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Deprecated
|
||||
public class IslandOpenEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final boolean open;
|
||||
private boolean cancelled = false;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public IslandOpenEvent(Island island, boolean open) {
|
||||
super(island);
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
return this.open;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,7 +33,7 @@ public class IslandOpenEvent extends IslandEvent implements Cancellable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandOwnershipTransferEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final OfflinePlayer owner;
|
||||
@ -20,11 +20,11 @@ public class IslandOwnershipTransferEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public OfflinePlayer getOwner() {
|
||||
return owner;
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandPasswordChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private String password;
|
||||
@ -19,7 +19,7 @@ public class IslandPasswordChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
@ -27,7 +27,7 @@ public class IslandPasswordChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandRole;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandRoleChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final OfflinePlayer player;
|
||||
@ -23,15 +23,15 @@ public class IslandRoleChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public IslandRole getRole() {
|
||||
return role;
|
||||
return this.role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandStatus;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandStatusChangeEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final IslandStatus status;
|
||||
private boolean cancelled = false;
|
||||
@ -17,12 +17,12 @@ public class IslandStatusChangeEvent extends IslandEvent implements Cancellable
|
||||
}
|
||||
|
||||
public IslandStatus getStatus() {
|
||||
return status;
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,7 +31,7 @@ public class IslandStatusChangeEvent extends IslandEvent implements Cancellable
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandUnbanEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final OfflinePlayer unbanned;
|
||||
@ -20,11 +20,11 @@ public class IslandUnbanEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public OfflinePlayer getUnbanned() {
|
||||
return unbanned;
|
||||
return this.unbanned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandUnloadEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public IslandUnloadEvent(Island island) {
|
||||
@ -16,7 +16,7 @@ public class IslandUnloadEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandUpgrade;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandUpgradeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
@ -23,15 +23,15 @@ public class IslandUpgradeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public IslandUpgrade getUpgrade() {
|
||||
return upgrade;
|
||||
return this.upgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.island;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IslandWeatherChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final boolean sync;
|
||||
private final WeatherType weather;
|
||||
@ -23,19 +23,19 @@ public class IslandWeatherChangeEvent extends IslandEvent {
|
||||
}
|
||||
|
||||
public WeatherType getWeather() {
|
||||
return weather;
|
||||
return this.weather;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public boolean isSync() {
|
||||
return sync;
|
||||
return this.sync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class PlayerEvent extends Event {
|
||||
|
||||
private final Player player;
|
||||
private final Island island;
|
||||
|
||||
@ -14,17 +13,17 @@ public abstract class PlayerEvent extends Event {
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
protected PlayerEvent(Player player, Island island, boolean async) {
|
||||
super(async);
|
||||
protected PlayerEvent(Player player, Island island, boolean isAsync) {
|
||||
super(isAsync);
|
||||
this.player = player;
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public Island getIsland() {
|
||||
return island;
|
||||
return this.island;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
@ -23,7 +23,7 @@ public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
@ -31,7 +31,7 @@ public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
@ -39,7 +39,7 @@ public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
@ -47,7 +47,7 @@ public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.player;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandChatSwitchEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final boolean chat;
|
||||
@ -20,11 +20,11 @@ public class PlayerIslandChatSwitchEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
public boolean isChat() {
|
||||
return chat;
|
||||
return this.chat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.player;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandEnterEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public PlayerIslandEnterEvent(Player player, Island island) {
|
||||
@ -17,7 +17,7 @@ public class PlayerIslandEnterEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.player;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandExitEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public PlayerIslandExitEvent(Player player, Island island) {
|
||||
@ -17,7 +17,7 @@ public class PlayerIslandExitEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.player;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandJoinEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
@ -19,7 +19,7 @@ public class PlayerIslandJoinEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
@ -27,7 +27,7 @@ public class PlayerIslandJoinEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandLeaveEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
@ -16,7 +16,7 @@ public class PlayerIslandLeaveEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public class PlayerIslandLeaveEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.player;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerIslandSwitchEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Island lastIsland;
|
||||
@ -20,11 +20,11 @@ public class PlayerIslandSwitchEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
public Island getLastIsland() {
|
||||
return lastIsland;
|
||||
return this.lastIsland;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerVoteEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
@ -16,7 +16,7 @@ public class PlayerVoteEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public class PlayerVoteEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.skyblock.api.event.player;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerVoteRemoveEvent extends PlayerEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
@ -12,11 +13,11 @@ public class PlayerVoteRemoveEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package com.songoda.skyblock.api.event.player;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerWithdrawMoneyEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
@ -21,15 +21,15 @@ public class PlayerWithdrawMoneyEvent extends Event {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public double getMoney() {
|
||||
return money;
|
||||
return this.money;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.songoda.skyblock.api.invite;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IslandInvitation {
|
||||
|
||||
private final Player invited, inviter;
|
||||
private final int time;
|
||||
|
||||
@ -14,14 +13,14 @@ public class IslandInvitation {
|
||||
}
|
||||
|
||||
public Player getInvited() {
|
||||
return invited;
|
||||
return this.invited;
|
||||
}
|
||||
|
||||
public Player getInviter() {
|
||||
return inviter;
|
||||
return this.inviter;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
return this.time;
|
||||
}
|
||||
}
|
||||
|
@ -21,485 +21,484 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Island {
|
||||
private com.songoda.skyblock.island.Island handle;
|
||||
private OfflinePlayer player;
|
||||
|
||||
private com.songoda.skyblock.island.Island handle;
|
||||
private OfflinePlayer player;
|
||||
|
||||
public Island(com.songoda.skyblock.island.Island handle, OfflinePlayer player) {
|
||||
this.handle = handle;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island UUID
|
||||
*/
|
||||
public UUID getIslandUUID() {
|
||||
return this.handle.getIslandUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island owner UUID
|
||||
*/
|
||||
public UUID getOwnerUUID() {
|
||||
return this.handle.getOwnerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The original Island owner UUID
|
||||
*/
|
||||
public UUID getOriginalOwnerUUID() {
|
||||
return this.handle.getOriginalOwnerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island size
|
||||
*/
|
||||
public int getSize() {
|
||||
return this.handle.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the Island
|
||||
*/
|
||||
public void setSize(int size) {
|
||||
Preconditions.checkArgument(size <= 1000, "Cannot set size to greater than 1000");
|
||||
Preconditions.checkArgument(size >= 20, "Cannot set size to less than 20");
|
||||
this.handle.setSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island radius
|
||||
*/
|
||||
public double getRadius() {
|
||||
return this.handle.getRadius();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if not null, false otherwise
|
||||
*/
|
||||
public boolean hasPassword() {
|
||||
return this.handle.hasPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password for ownership
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
Preconditions.checkArgument(password != null, "Cannot set password to null password");
|
||||
this.handle.setPassword(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Location from the World in island world from World in environment.
|
||||
*
|
||||
* @return Location of Island
|
||||
*/
|
||||
public Location getLocation(IslandWorld world, IslandEnvironment environment) {
|
||||
Preconditions.checkArgument(world != null, "World in island world null does not exist");
|
||||
Preconditions.checkArgument(environment != null, "World in environment null does not exist");
|
||||
|
||||
return handle.getLocation(APIUtil.toImplementation(world), APIUtil.toImplementation(environment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Location from the World in island world from world in environment
|
||||
* followed by position
|
||||
*/
|
||||
public void setLocation(IslandWorld world, IslandEnvironment environment, int x, int y, int z) {
|
||||
Preconditions.checkArgument(world != null, "World in island world null does not exist");
|
||||
Preconditions.checkArgument(environment != null, "World in environment null does not exist");
|
||||
|
||||
World bukkitWorld = getLocation(world, environment).getWorld();
|
||||
this.handle.setLocation(APIUtil.toImplementation(world), APIUtil.toImplementation(environment),
|
||||
new Location(bukkitWorld, x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isBorder() {
|
||||
return this.handle.isBorder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border visible to players for the Island
|
||||
*/
|
||||
public void setBorder(boolean border) {
|
||||
this.handle.setBorder(border);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The color of the Island border
|
||||
*/
|
||||
public IslandBorderColor getBorderColor() {
|
||||
return APIUtil.fromImplementation(this.handle.getBorderColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border color for the Island
|
||||
*/
|
||||
public void setBorderColor(IslandBorderColor color) {
|
||||
Preconditions.checkArgument(color != null, "IslandBorderColor null does not exist");
|
||||
this.handle.setBorderColor(APIUtil.toImplementation(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The biome set for the Island
|
||||
*/
|
||||
public Biome getBiome() {
|
||||
return this.handle.getBiome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome for the Island
|
||||
*/
|
||||
public void setBiome(Biome biome) {
|
||||
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
|
||||
this.handle.setBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isDayCycleSynchronizedSynchronized() {
|
||||
return this.handle.isWeatherSynchronized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Day Cycle of the Island to be Synchronized with the World cycle
|
||||
*/
|
||||
public void setDayCycleSynchronzied(boolean sync) {
|
||||
this.handle.setWeatherSynchronized(sync);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The WeatherType set for the Island
|
||||
*/
|
||||
public WeatherType getWeather() {
|
||||
return this.handle.getWeather();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the weather for the Island
|
||||
*/
|
||||
public void setWeather(WeatherType weatherType) {
|
||||
Preconditions.checkArgument(weatherType != null, "Cannot set weather to null weather");
|
||||
this.handle.setWeather(weatherType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The time set for the Island
|
||||
*/
|
||||
public int getTime() {
|
||||
return this.handle.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time for the Island
|
||||
*/
|
||||
public void setTime(int time) {
|
||||
this.handle.setTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of cooped players
|
||||
*/
|
||||
public Map<UUID, IslandCoop> getCoopPlayers() {
|
||||
return this.handle.getCoopPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the coop players for the Island
|
||||
*/
|
||||
public void addCoopPlayer(UUID uuid, IslandCoop islandCoop) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot add coop player to null uuid");
|
||||
this.handle.addCoopPlayer(uuid, islandCoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the coop players for the Island
|
||||
*/
|
||||
public void addCoopPlayer(OfflinePlayer player, IslandCoop islandCoop) {
|
||||
Preconditions.checkArgument(player != null, "Cannot add coop player to null player");
|
||||
this.handle.addCoopPlayer(player.getUniqueId(), islandCoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the coop players for the Island
|
||||
*/
|
||||
public void removeCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove coop player to null uuid");
|
||||
this.handle.removeCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the coop players for the Island
|
||||
*/
|
||||
public void removeCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove coop player to null player");
|
||||
this.handle.removeCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot return condition to null uuid");
|
||||
return this.handle.isCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot return condition to null player");
|
||||
return this.handle.isCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The IslandRole of a player
|
||||
*/
|
||||
public IslandRole getRole(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot get role for null player");
|
||||
|
||||
for (com.songoda.skyblock.island.IslandRole role : com.songoda.skyblock.island.IslandRole.values()) {
|
||||
if (this.handle.hasRole(role, player.getUniqueId())) {
|
||||
return APIUtil.fromImplementation(role);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of players with IslandRole
|
||||
*/
|
||||
public Set<UUID> getPlayersWithRole(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get players will null role");
|
||||
return this.handle.getRole(APIUtil.toImplementation(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean setRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot set role of null player");
|
||||
return setRole(player.getUniqueId(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean setRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot set role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot set role to null role");
|
||||
|
||||
return this.handle.setRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean removeRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove role of null player");
|
||||
return removeRole(player.getUniqueId(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean removeRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot remove role to null role");
|
||||
|
||||
return this.handle.removeRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check role of null player");
|
||||
return handle.hasRole(APIUtil.toImplementation(role), player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot check role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot check role to null role");
|
||||
|
||||
return handle.hasRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the condition of an IslandUpgrade for the Island
|
||||
*/
|
||||
public void setUpgrade(Player player, IslandUpgrade upgrade, boolean status) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot set upgrade to null upgrade");
|
||||
this.handle.setUpgrade(player, APIUtil.toImplementation(upgrade), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasUpgrade(IslandUpgrade upgrade) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot check upgrade to null upgrade");
|
||||
return this.handle.hasUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isUpgrade(IslandUpgrade upgrade) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot check upgrade to null upgrade");
|
||||
return this.handle.isUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Settings of an IslandRole for the Island
|
||||
*/
|
||||
public List<IslandPermission> getSettings(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get settings to null role");
|
||||
return this.handle.getSettings(APIUtil.toImplementation(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isOpen() {
|
||||
return handle.getStatus().equals(IslandStatus.OPEN);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setOpen(boolean open) {
|
||||
this.handle.setStatus(open ? IslandStatus.OPEN : IslandStatus.CLOSED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List from IslandMessage for the Island
|
||||
*/
|
||||
public List<String> getMessage(IslandMessage message) {
|
||||
Preconditions.checkArgument(message != null, "Cannot get message for null message");
|
||||
return this.handle.getMessage(APIUtil.toImplementation(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The author of an IslandMessage for the Island
|
||||
*/
|
||||
public String getMessageAuthor(IslandMessage message) {
|
||||
Preconditions.checkArgument(message != null, "Cannot get message author for null message");
|
||||
return this.handle.getMessageAuthor(APIUtil.toImplementation(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandMessage for the Island
|
||||
*/
|
||||
public void setMessage(IslandMessage message, String author, List<String> messageLines) {
|
||||
Preconditions.checkArgument(message != null, "Cannot set message for null message");
|
||||
this.handle.setMessage(APIUtil.toImplementation(message), author, messageLines);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasStructure() {
|
||||
return this.handle.hasStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Structure name for the Island
|
||||
*/
|
||||
public String getStructure() {
|
||||
return this.handle.getStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Structure for the Island
|
||||
*/
|
||||
public void setStructure(String structure) {
|
||||
Preconditions.checkArgument(structure != null, "Cannot set structure to null structure");
|
||||
this.handle.setStructure(structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Visit implementation for the Island
|
||||
*/
|
||||
public Visit getVisit() {
|
||||
return new Visit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Ban implementation for the Island
|
||||
*/
|
||||
public Ban getBan() {
|
||||
return new Ban(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Level implementation for the Island
|
||||
*/
|
||||
public IslandLevel getLevel() {
|
||||
return new IslandLevel(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isLoaded() {
|
||||
return this.handle != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the Island if unloaded
|
||||
*/
|
||||
public void load() {
|
||||
if (this.handle == null) {
|
||||
SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
|
||||
this.handle = SkyBlockAPI.getImplementation().getIslandManager().getIsland(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads the Island if loaded
|
||||
*/
|
||||
public void unload() {
|
||||
if (this.handle != null) {
|
||||
SkyBlockAPI.getImplementation().getIslandManager().unloadIsland(getIsland(), null);
|
||||
this.handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player of the Island
|
||||
*/
|
||||
public void setPlayer(OfflinePlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public com.songoda.skyblock.island.Island getIsland() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Island))
|
||||
return false;
|
||||
Island other = (Island) object;
|
||||
return other.getIslandUUID().equals(getIslandUUID());
|
||||
public Island(com.songoda.skyblock.island.Island handle, OfflinePlayer player) {
|
||||
this.handle = handle;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island UUID
|
||||
*/
|
||||
public UUID getIslandUUID() {
|
||||
return this.handle.getIslandUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island owner UUID
|
||||
*/
|
||||
public UUID getOwnerUUID() {
|
||||
return this.handle.getOwnerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The original Island owner UUID
|
||||
*/
|
||||
public UUID getOriginalOwnerUUID() {
|
||||
return this.handle.getOriginalOwnerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island size
|
||||
*/
|
||||
public int getSize() {
|
||||
return this.handle.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the Island
|
||||
*/
|
||||
public void setSize(int size) {
|
||||
Preconditions.checkArgument(size <= 1000, "Cannot set size to greater than 1000");
|
||||
Preconditions.checkArgument(size >= 20, "Cannot set size to less than 20");
|
||||
this.handle.setSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island radius
|
||||
*/
|
||||
public double getRadius() {
|
||||
return this.handle.getRadius();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if not null, false otherwise
|
||||
*/
|
||||
public boolean hasPassword() {
|
||||
return this.handle.hasPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password for ownership
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
Preconditions.checkArgument(password != null, "Cannot set password to null password");
|
||||
this.handle.setPassword(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Location from the World in island world from World in environment.
|
||||
*
|
||||
* @return Location of Island
|
||||
*/
|
||||
public Location getLocation(IslandWorld world, IslandEnvironment environment) {
|
||||
Preconditions.checkArgument(world != null, "World in island world null does not exist");
|
||||
Preconditions.checkArgument(environment != null, "World in environment null does not exist");
|
||||
|
||||
return this.handle.getLocation(APIUtil.toImplementation(world), APIUtil.toImplementation(environment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Location from the World in island world from world in environment
|
||||
* followed by position
|
||||
*/
|
||||
public void setLocation(IslandWorld world, IslandEnvironment environment, int x, int y, int z) {
|
||||
Preconditions.checkArgument(world != null, "World in island world null does not exist");
|
||||
Preconditions.checkArgument(environment != null, "World in environment null does not exist");
|
||||
|
||||
World bukkitWorld = getLocation(world, environment).getWorld();
|
||||
this.handle.setLocation(APIUtil.toImplementation(world), APIUtil.toImplementation(environment), new Location(bukkitWorld, x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isBorder() {
|
||||
return this.handle.isBorder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border visible to players for the Island
|
||||
*/
|
||||
public void setBorder(boolean border) {
|
||||
this.handle.setBorder(border);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The color of the Island border
|
||||
*/
|
||||
public IslandBorderColor getBorderColor() {
|
||||
return APIUtil.fromImplementation(this.handle.getBorderColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border color for the Island
|
||||
*/
|
||||
public void setBorderColor(IslandBorderColor color) {
|
||||
Preconditions.checkArgument(color != null, "IslandBorderColor null does not exist");
|
||||
this.handle.setBorderColor(APIUtil.toImplementation(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The biome set for the Island
|
||||
*/
|
||||
public Biome getBiome() {
|
||||
return this.handle.getBiome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome for the Island
|
||||
*/
|
||||
public void setBiome(Biome biome) {
|
||||
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
|
||||
this.handle.setBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isDayCycleSynchronizedSynchronized() {
|
||||
return this.handle.isWeatherSynchronized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Day Cycle of the Island to be Synchronized with the World cycle
|
||||
*/
|
||||
public void setDayCycleSynchronzied(boolean sync) {
|
||||
this.handle.setWeatherSynchronized(sync);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The WeatherType set for the Island
|
||||
*/
|
||||
public WeatherType getWeather() {
|
||||
return this.handle.getWeather();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the weather for the Island
|
||||
*/
|
||||
public void setWeather(WeatherType weatherType) {
|
||||
Preconditions.checkArgument(weatherType != null, "Cannot set weather to null weather");
|
||||
this.handle.setWeather(weatherType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The time set for the Island
|
||||
*/
|
||||
public int getTime() {
|
||||
return this.handle.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time for the Island
|
||||
*/
|
||||
public void setTime(int time) {
|
||||
this.handle.setTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of cooped players
|
||||
*/
|
||||
public Map<UUID, IslandCoop> getCoopPlayers() {
|
||||
return this.handle.getCoopPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the coop players for the Island
|
||||
*/
|
||||
public void addCoopPlayer(UUID uuid, IslandCoop islandCoop) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot add coop player to null uuid");
|
||||
this.handle.addCoopPlayer(uuid, islandCoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the coop players for the Island
|
||||
*/
|
||||
public void addCoopPlayer(OfflinePlayer player, IslandCoop islandCoop) {
|
||||
Preconditions.checkArgument(player != null, "Cannot add coop player to null player");
|
||||
this.handle.addCoopPlayer(player.getUniqueId(), islandCoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the coop players for the Island
|
||||
*/
|
||||
public void removeCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove coop player to null uuid");
|
||||
this.handle.removeCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the coop players for the Island
|
||||
*/
|
||||
public void removeCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove coop player to null player");
|
||||
this.handle.removeCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot return condition to null uuid");
|
||||
return this.handle.isCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot return condition to null player");
|
||||
return this.handle.isCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The IslandRole of a player
|
||||
*/
|
||||
public IslandRole getRole(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot get role for null player");
|
||||
|
||||
for (com.songoda.skyblock.island.IslandRole role : com.songoda.skyblock.island.IslandRole.values()) {
|
||||
if (this.handle.hasRole(role, player.getUniqueId())) {
|
||||
return APIUtil.fromImplementation(role);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of players with IslandRole
|
||||
*/
|
||||
public Set<UUID> getPlayersWithRole(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get players will null role");
|
||||
return this.handle.getRole(APIUtil.toImplementation(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean setRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot set role of null player");
|
||||
return setRole(player.getUniqueId(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean setRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot set role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot set role to null role");
|
||||
|
||||
return this.handle.setRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean removeRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove role of null player");
|
||||
return removeRole(player.getUniqueId(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean removeRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot remove role to null role");
|
||||
|
||||
return this.handle.removeRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check role of null player");
|
||||
return this.handle.hasRole(APIUtil.toImplementation(role), player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot check role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot check role to null role");
|
||||
|
||||
return this.handle.hasRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the condition of an IslandUpgrade for the Island
|
||||
*/
|
||||
public void setUpgrade(Player player, IslandUpgrade upgrade, boolean status) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot set upgrade to null upgrade");
|
||||
this.handle.setUpgrade(player, APIUtil.toImplementation(upgrade), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasUpgrade(IslandUpgrade upgrade) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot check upgrade to null upgrade");
|
||||
return this.handle.hasUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isUpgrade(IslandUpgrade upgrade) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot check upgrade to null upgrade");
|
||||
return this.handle.isUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Settings of an IslandRole for the Island
|
||||
*/
|
||||
public List<IslandPermission> getSettings(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get settings to null role");
|
||||
return this.handle.getSettings(APIUtil.toImplementation(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isOpen() {
|
||||
return this.handle.getStatus() == IslandStatus.OPEN;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setOpen(boolean open) {
|
||||
this.handle.setStatus(open ? IslandStatus.OPEN : IslandStatus.CLOSED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List from IslandMessage for the Island
|
||||
*/
|
||||
public List<String> getMessage(IslandMessage message) {
|
||||
Preconditions.checkArgument(message != null, "Cannot get message for null message");
|
||||
return this.handle.getMessage(APIUtil.toImplementation(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The author of an IslandMessage for the Island
|
||||
*/
|
||||
public String getMessageAuthor(IslandMessage message) {
|
||||
Preconditions.checkArgument(message != null, "Cannot get message author for null message");
|
||||
return this.handle.getMessageAuthor(APIUtil.toImplementation(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandMessage for the Island
|
||||
*/
|
||||
public void setMessage(IslandMessage message, String author, List<String> messageLines) {
|
||||
Preconditions.checkArgument(message != null, "Cannot set message for null message");
|
||||
this.handle.setMessage(APIUtil.toImplementation(message), author, messageLines);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasStructure() {
|
||||
return this.handle.hasStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Structure name for the Island
|
||||
*/
|
||||
public String getStructure() {
|
||||
return this.handle.getStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Structure for the Island
|
||||
*/
|
||||
public void setStructure(String structure) {
|
||||
Preconditions.checkArgument(structure != null, "Cannot set structure to null structure");
|
||||
this.handle.setStructure(structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Visit implementation for the Island
|
||||
*/
|
||||
public Visit getVisit() {
|
||||
return new Visit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Ban implementation for the Island
|
||||
*/
|
||||
public Ban getBan() {
|
||||
return new Ban(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Level implementation for the Island
|
||||
*/
|
||||
public IslandLevel getLevel() {
|
||||
return new IslandLevel(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isLoaded() {
|
||||
return this.handle != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the Island if unloaded
|
||||
*/
|
||||
public void load() {
|
||||
if (this.handle == null) {
|
||||
SkyBlockAPI.getImplementation().getIslandManager().loadIsland(this.player);
|
||||
this.handle = SkyBlockAPI.getImplementation().getIslandManager().getIsland(this.player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads the Island if loaded
|
||||
*/
|
||||
public void unload() {
|
||||
if (this.handle != null) {
|
||||
SkyBlockAPI.getImplementation().getIslandManager().unloadIsland(getIsland(), null);
|
||||
this.handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player of the Island
|
||||
*/
|
||||
public void setPlayer(OfflinePlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public com.songoda.skyblock.island.Island getIsland() {
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Island)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Island other = (Island) obj;
|
||||
return other.getIslandUUID().equals(getIslandUUID());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandBorderColor {
|
||||
|
||||
Blue, Green, Red
|
||||
|
||||
BLUE, GREEN, RED
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandEnvironment {
|
||||
|
||||
ISLAND, VISITOR, MAIN
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class IslandLevel {
|
||||
|
||||
private final Island handle;
|
||||
|
||||
public IslandLevel(Island handle) {
|
||||
@ -115,15 +114,14 @@ public class IslandLevel {
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the island level for a determined location
|
||||
* @param location
|
||||
*/
|
||||
public void updateLevel(Location location){
|
||||
public void updateLevel(Location location) {
|
||||
Preconditions.checkArgument(location != null, "Cannot update level of a null island");
|
||||
SkyBlock.getInstance().getLevellingManager().updateLevel(this.handle.getIsland(), location);
|
||||
SkyBlock.getPlugin(SkyBlock.class).getLevellingManager().updateLevel(this.handle.getIsland(), location);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class IslandLocation {
|
||||
|
||||
private final IslandEnvironment environment;
|
||||
private final IslandWorld world;
|
||||
private final Location location;
|
||||
@ -16,30 +15,30 @@ public class IslandLocation {
|
||||
}
|
||||
|
||||
public IslandEnvironment getEnvironment() {
|
||||
return environment;
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
public IslandWorld getWorld() {
|
||||
return world;
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public World getBukkitWorld() {
|
||||
return location.getWorld();
|
||||
return this.location.getWorld();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return location.getBlockX();
|
||||
return this.location.getBlockX();
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return location.getBlockY();
|
||||
return this.location.getBlockY();
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return location.getBlockZ();
|
||||
return this.location.getBlockZ();
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,12 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class IslandManager {
|
||||
|
||||
private final com.songoda.skyblock.island.IslandManager islandManager;
|
||||
private final PermissionManager permissionManager;
|
||||
|
||||
public IslandManager(com.songoda.skyblock.island.IslandManager islandManager) {
|
||||
this.islandManager = islandManager;
|
||||
this.permissionManager = SkyBlock.getInstance().getPermissionManager();
|
||||
this.permissionManager = SkyBlock.getPlugin(SkyBlock.class).getPermissionManager();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +44,7 @@ public class IslandManager {
|
||||
* Gives Island ownership to a player of their Island
|
||||
*/
|
||||
public void giveOwnership(Island island, OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot give ownership to null island");
|
||||
Preconditions.checkArgument(island != null, "Cannot give ownership to null island");
|
||||
Preconditions.checkArgument(player != null, "Cannot give ownership to null player");
|
||||
|
||||
this.islandManager.giveOwnership(island.getIsland(), player);
|
||||
@ -190,7 +189,7 @@ public class IslandManager {
|
||||
Preconditions.checkArgument(structure != null, "Cannot create island to null structure");
|
||||
|
||||
if (!hasIsland(player)) {
|
||||
return islandManager.createIsland(player, (com.songoda.skyblock.structure.Structure) structure);
|
||||
return this.islandManager.createIsland(player, (com.songoda.skyblock.structure.Structure) structure);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -207,7 +206,7 @@ public class IslandManager {
|
||||
|
||||
this.islandManager.deleteIsland(island.getIsland(), true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If force is set to true, the island will be deleted and no conditions will be
|
||||
* checked, else it will only delete the island if the island deletion
|
||||
@ -349,12 +348,9 @@ public class IslandManager {
|
||||
*/
|
||||
public List<Island> getIslands() {
|
||||
List<Island> islands = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < this.islandManager.getIslands().size(); i++) {
|
||||
islands.add(this.islandManager.getIslands().get(this.islandManager.getIslands().keySet().toArray()[i])
|
||||
.getAPIWrapper());
|
||||
islands.add(this.islandManager.getIslands().get(this.islandManager.getIslands().keySet().toArray()[i]).getAPIWrapper());
|
||||
}
|
||||
|
||||
return islands;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandMessage {
|
||||
|
||||
WELCOME, SIGNATURE, SIGN
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandRole {
|
||||
|
||||
COOP, VISITOR, MEMBER, OPERATOR, OWNER
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandStatus {
|
||||
OPEN,
|
||||
CLOSED,
|
||||
WHITELISTED
|
||||
OPEN, CLOSED, WHITELISTED
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandUpgrade {
|
||||
|
||||
CROP, SPAWNER, FLY, DROPS, SIZE, SPEED, JUMP
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandWorld {
|
||||
|
||||
OVERWORLD, NETHER, END
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.songoda.skyblock.levelling.calculator.CalculatorRegistry;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class LevellingManager {
|
||||
|
||||
private final IslandLevelManager levellingManager;
|
||||
|
||||
public LevellingManager(IslandLevelManager levellingManager) {
|
||||
@ -23,13 +22,11 @@ public class LevellingManager {
|
||||
Preconditions.checkArgument(island != null, "Cannot calculate points to null island");
|
||||
this.levellingManager.startScan(null, island.getIsland());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a new material calculator for a determined material
|
||||
* @param calculator
|
||||
* @param material
|
||||
*/
|
||||
public void registerCalculator(Calculator calculator, Material material){
|
||||
public void registerCalculator(Calculator calculator, Material material) {
|
||||
Preconditions.checkArgument(calculator != null, "Cannot use a null calculator");
|
||||
Preconditions.checkArgument(material != null, "Cannot use a null material");
|
||||
CalculatorRegistry.registerCalculator(calculator, CompatibleMaterial.getMaterial(material));
|
||||
|
@ -5,7 +5,6 @@ import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import java.util.List;
|
||||
|
||||
public interface Structure {
|
||||
|
||||
String getName();
|
||||
|
||||
CompatibleMaterial getMaterial();
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StructureManager {
|
||||
|
||||
private final com.songoda.skyblock.structure.StructureManager structureManager;
|
||||
|
||||
public StructureManager(com.songoda.skyblock.structure.StructureManager structureManager) {
|
||||
@ -22,13 +21,13 @@ public class StructureManager {
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasStructure(String structure) {
|
||||
return structureManager.containsStructure(structure);
|
||||
return this.structureManager.containsStructure(structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Structures for an Island
|
||||
*/
|
||||
public List<Structure> getStructures() {
|
||||
return new ArrayList<>(structureManager.getStructures());
|
||||
return new ArrayList<>(this.structureManager.getStructures());
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,14 @@ import com.songoda.skyblock.api.island.IslandWorld;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
|
||||
public final class APIUtil {
|
||||
|
||||
public static com.songoda.skyblock.island.IslandWorld toImplementation(IslandWorld world) {
|
||||
switch (world) {
|
||||
case NETHER:
|
||||
return com.songoda.skyblock.island.IslandWorld.Nether;
|
||||
return com.songoda.skyblock.island.IslandWorld.NETHER;
|
||||
case OVERWORLD:
|
||||
return com.songoda.skyblock.island.IslandWorld.Normal;
|
||||
return com.songoda.skyblock.island.IslandWorld.NORMAL;
|
||||
case END:
|
||||
return com.songoda.skyblock.island.IslandWorld.End;
|
||||
return com.songoda.skyblock.island.IslandWorld.END;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -27,11 +26,11 @@ public final class APIUtil {
|
||||
|
||||
public static IslandWorld fromImplementation(com.songoda.skyblock.island.IslandWorld world) {
|
||||
switch (world) {
|
||||
case Nether:
|
||||
case NETHER:
|
||||
return IslandWorld.NETHER;
|
||||
case Normal:
|
||||
case NORMAL:
|
||||
return IslandWorld.OVERWORLD;
|
||||
case End:
|
||||
case END:
|
||||
return IslandWorld.END;
|
||||
}
|
||||
|
||||
@ -41,11 +40,11 @@ public final class APIUtil {
|
||||
public static com.songoda.skyblock.island.IslandEnvironment toImplementation(IslandEnvironment environment) {
|
||||
switch (environment) {
|
||||
case ISLAND:
|
||||
return com.songoda.skyblock.island.IslandEnvironment.Island;
|
||||
return com.songoda.skyblock.island.IslandEnvironment.ISLAND;
|
||||
case MAIN:
|
||||
return com.songoda.skyblock.island.IslandEnvironment.Main;
|
||||
return com.songoda.skyblock.island.IslandEnvironment.MAIN;
|
||||
case VISITOR:
|
||||
return com.songoda.skyblock.island.IslandEnvironment.Visitor;
|
||||
return com.songoda.skyblock.island.IslandEnvironment.VISITOR;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -53,11 +52,11 @@ public final class APIUtil {
|
||||
|
||||
public static IslandEnvironment fromImplementation(com.songoda.skyblock.island.IslandEnvironment environment) {
|
||||
switch (environment) {
|
||||
case Island:
|
||||
case ISLAND:
|
||||
return IslandEnvironment.ISLAND;
|
||||
case Main:
|
||||
case MAIN:
|
||||
return IslandEnvironment.MAIN;
|
||||
case Visitor:
|
||||
case VISITOR:
|
||||
return IslandEnvironment.VISITOR;
|
||||
}
|
||||
|
||||
@ -93,15 +92,15 @@ public final class APIUtil {
|
||||
public static com.songoda.skyblock.island.IslandRole toImplementation(IslandRole role) {
|
||||
switch (role) {
|
||||
case VISITOR:
|
||||
return com.songoda.skyblock.island.IslandRole.Visitor;
|
||||
return com.songoda.skyblock.island.IslandRole.VISITOR;
|
||||
case COOP:
|
||||
return com.songoda.skyblock.island.IslandRole.Coop;
|
||||
return com.songoda.skyblock.island.IslandRole.COOP;
|
||||
case MEMBER:
|
||||
return com.songoda.skyblock.island.IslandRole.Member;
|
||||
return com.songoda.skyblock.island.IslandRole.MEMBER;
|
||||
case OPERATOR:
|
||||
return com.songoda.skyblock.island.IslandRole.Operator;
|
||||
return com.songoda.skyblock.island.IslandRole.OPERATOR;
|
||||
case OWNER:
|
||||
return com.songoda.skyblock.island.IslandRole.Owner;
|
||||
return com.songoda.skyblock.island.IslandRole.OWNER;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -109,15 +108,15 @@ public final class APIUtil {
|
||||
|
||||
public static IslandRole fromImplementation(com.songoda.skyblock.island.IslandRole role) {
|
||||
switch (role) {
|
||||
case Visitor:
|
||||
case VISITOR:
|
||||
return IslandRole.VISITOR;
|
||||
case Coop:
|
||||
case COOP:
|
||||
return IslandRole.COOP;
|
||||
case Member:
|
||||
case MEMBER:
|
||||
return IslandRole.MEMBER;
|
||||
case Operator:
|
||||
case OPERATOR:
|
||||
return IslandRole.OPERATOR;
|
||||
case Owner:
|
||||
case OWNER:
|
||||
return IslandRole.OWNER;
|
||||
}
|
||||
|
||||
@ -127,19 +126,19 @@ public final class APIUtil {
|
||||
public static Upgrade.Type toImplementation(IslandUpgrade upgrade) {
|
||||
switch (upgrade) {
|
||||
case CROP:
|
||||
return Upgrade.Type.Crop;
|
||||
return Upgrade.Type.CROP;
|
||||
case DROPS:
|
||||
return Upgrade.Type.Drops;
|
||||
return Upgrade.Type.DROPS;
|
||||
case FLY:
|
||||
return Upgrade.Type.Fly;
|
||||
return Upgrade.Type.FLY;
|
||||
case JUMP:
|
||||
return Upgrade.Type.Jump;
|
||||
return Upgrade.Type.JUMP;
|
||||
case SIZE:
|
||||
return Upgrade.Type.Size;
|
||||
return Upgrade.Type.SIZE;
|
||||
case SPAWNER:
|
||||
return Upgrade.Type.Spawner;
|
||||
return Upgrade.Type.SPAWNER;
|
||||
case SPEED:
|
||||
return Upgrade.Type.Speed;
|
||||
return Upgrade.Type.SPEED;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -147,19 +146,19 @@ public final class APIUtil {
|
||||
|
||||
public static IslandUpgrade fromImplementation(Upgrade.Type upgrade) {
|
||||
switch (upgrade) {
|
||||
case Crop:
|
||||
case CROP:
|
||||
return IslandUpgrade.CROP;
|
||||
case Drops:
|
||||
case DROPS:
|
||||
return IslandUpgrade.DROPS;
|
||||
case Fly:
|
||||
case FLY:
|
||||
return IslandUpgrade.FLY;
|
||||
case Jump:
|
||||
case JUMP:
|
||||
return IslandUpgrade.JUMP;
|
||||
case Size:
|
||||
case SIZE:
|
||||
return IslandUpgrade.SIZE;
|
||||
case Spawner:
|
||||
case SPAWNER:
|
||||
return IslandUpgrade.SPAWNER;
|
||||
case Speed:
|
||||
case SPEED:
|
||||
return IslandUpgrade.SPEED;
|
||||
}
|
||||
|
||||
@ -169,11 +168,11 @@ public final class APIUtil {
|
||||
public static com.songoda.skyblock.island.IslandMessage toImplementation(IslandMessage message) {
|
||||
switch (message) {
|
||||
case SIGN:
|
||||
return com.songoda.skyblock.island.IslandMessage.Sign;
|
||||
return com.songoda.skyblock.island.IslandMessage.SIGN;
|
||||
case SIGNATURE:
|
||||
return com.songoda.skyblock.island.IslandMessage.Signature;
|
||||
return com.songoda.skyblock.island.IslandMessage.SIGNATURE;
|
||||
case WELCOME:
|
||||
return com.songoda.skyblock.island.IslandMessage.Welcome;
|
||||
return com.songoda.skyblock.island.IslandMessage.WELCOME;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -181,11 +180,11 @@ public final class APIUtil {
|
||||
|
||||
public static IslandMessage fromImplementation(com.songoda.skyblock.island.IslandMessage message) {
|
||||
switch (message) {
|
||||
case Sign:
|
||||
case SIGN:
|
||||
return IslandMessage.SIGN;
|
||||
case Signature:
|
||||
case SIGNATURE:
|
||||
return IslandMessage.SIGNATURE;
|
||||
case Welcome:
|
||||
case WELCOME:
|
||||
return IslandMessage.WELCOME;
|
||||
}
|
||||
|
||||
@ -194,11 +193,11 @@ public final class APIUtil {
|
||||
|
||||
public static SWorldBorder.Color toImplementation(IslandBorderColor color) {
|
||||
switch (color) {
|
||||
case Blue:
|
||||
case BLUE:
|
||||
return SWorldBorder.Color.Blue;
|
||||
case Green:
|
||||
case GREEN:
|
||||
return SWorldBorder.Color.Green;
|
||||
case Red:
|
||||
case RED:
|
||||
return SWorldBorder.Color.Red;
|
||||
}
|
||||
|
||||
@ -208,11 +207,11 @@ public final class APIUtil {
|
||||
public static IslandBorderColor fromImplementation(SWorldBorder.Color color) {
|
||||
switch (color) {
|
||||
case Blue:
|
||||
return IslandBorderColor.Blue;
|
||||
return IslandBorderColor.BLUE;
|
||||
case Green:
|
||||
return IslandBorderColor.Green;
|
||||
return IslandBorderColor.GREEN;
|
||||
case Red:
|
||||
return IslandBorderColor.Red;
|
||||
return IslandBorderColor.RED;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -7,7 +7,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Visit {
|
||||
|
||||
private final Island handle;
|
||||
|
||||
public Visit(Island handle) {
|
||||
@ -94,6 +93,6 @@ public class Visit {
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
return this.handle;
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,13 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ban {
|
||||
|
||||
private UUID islandOwnerUUID;
|
||||
|
||||
public Ban(UUID islandOwnerUUID) {
|
||||
@ -21,7 +24,7 @@ public class Ban {
|
||||
}
|
||||
|
||||
public UUID getOwnerUUID() {
|
||||
return islandOwnerUUID;
|
||||
return this.islandOwnerUUID;
|
||||
}
|
||||
|
||||
public void setOwnerUUID(UUID islandOwnerUUID) {
|
||||
@ -33,18 +36,18 @@ public class Ban {
|
||||
}
|
||||
|
||||
public Set<UUID> getBans() {
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getPlugin(SkyBlock.class);
|
||||
|
||||
Set<UUID> islandBans = new HashSet<>();
|
||||
|
||||
for (String islandBanList : plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml"))
|
||||
.getConfig(new File(new File(plugin.getDataFolder(), "ban-data"), FastUUID.toString(this.islandOwnerUUID) + ".yml"))
|
||||
.getFileConfiguration().getStringList("Bans")) {
|
||||
|
||||
UUID uuid = FastUUID.parseUUID(islandBanList);
|
||||
if (!Bukkit.getOfflinePlayer(uuid).hasPlayedBefore())
|
||||
if (!Bukkit.getOfflinePlayer(uuid).hasPlayedBefore()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
islandBans.add(uuid);
|
||||
}
|
||||
@ -53,10 +56,10 @@ public class Ban {
|
||||
}
|
||||
|
||||
public void addBan(UUID issuer, UUID banned) {
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getPlugin(SkyBlock.class);
|
||||
|
||||
IslandBanEvent islandBanEvent = new IslandBanEvent(
|
||||
plugin.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
|
||||
plugin.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(this.islandOwnerUUID))
|
||||
.getAPIWrapper(),
|
||||
Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
|
||||
@ -64,7 +67,7 @@ public class Ban {
|
||||
if (!islandBanEvent.isCancelled()) {
|
||||
FileConfiguration configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml"))
|
||||
FastUUID.toString(this.islandOwnerUUID) + ".yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
List<String> islandBans = new ArrayList<>(configLoad.getStringList("Bans"));
|
||||
@ -75,12 +78,12 @@ public class Ban {
|
||||
}
|
||||
|
||||
public void removeBan(UUID uuid) {
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getPlugin(SkyBlock.class);
|
||||
|
||||
List<String> islandBans = new ArrayList<>();
|
||||
FileConfiguration configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"))
|
||||
this.islandOwnerUUID.toString() + ".yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
for (String islandBanList : configLoad.getStringList("Bans")) {
|
||||
@ -93,20 +96,20 @@ public class Ban {
|
||||
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new IslandUnbanEvent(plugin.getIslandManager()
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).getAPIWrapper(),
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(this.islandOwnerUUID)).getAPIWrapper(),
|
||||
Bukkit.getServer().getOfflinePlayer(uuid)));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getPlugin(SkyBlock.class);
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(
|
||||
new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
|
||||
new File(plugin.getDataFolder(), "ban-data"), this.islandOwnerUUID.toString() + ".yml"));
|
||||
|
||||
try {
|
||||
config.getFileConfiguration().save(config.getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.eatthepath.uuid.FastUUID;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -19,7 +18,6 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BanManager {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final Map<UUID, Ban> banStorage = new HashMap<>();
|
||||
|
||||
@ -38,11 +36,8 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public void loadIslands() {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
if (!this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Visitor.Unload")) {
|
||||
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
|
||||
if (!this.plugin.getConfiguration().getBoolean("Island.Visitor.Unload")) {
|
||||
File configFile = new File(this.plugin.getDataFolder(), "island-data");
|
||||
|
||||
if (configFile.exists()) {
|
||||
for (File fileList : configFile.listFiles()) {
|
||||
@ -54,15 +49,13 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public void transfer(UUID uuid1, UUID uuid2) {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Ban ban = getIsland(uuid1);
|
||||
ban.save();
|
||||
|
||||
File oldBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(uuid1) + ".yml");
|
||||
File newBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(uuid2) + ".yml");
|
||||
File oldBanDataFile = new File(new File(this.plugin.getDataFolder(), "ban-data"), FastUUID.toString(uuid1) + ".yml");
|
||||
File newBanDataFile = new File(new File(this.plugin.getDataFolder(), "ban-data"), FastUUID.toString(uuid2) + ".yml");
|
||||
|
||||
fileManager.unloadConfig(oldBanDataFile);
|
||||
fileManager.unloadConfig(newBanDataFile);
|
||||
@ -74,12 +67,12 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public void removeVisitor(Island island) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
|
||||
FileConfiguration configLoad = this.plugin.getLanguage();
|
||||
|
||||
for (UUID visitorList : plugin.getIslandManager().getVisitorsAtIsland(island)) {
|
||||
for (UUID visitorList : this.plugin.getIslandManager().getVisitorsAtIsland(island)) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
@ -90,42 +83,40 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public boolean hasIsland(UUID islandOwnerUUID) {
|
||||
return banStorage.containsKey(islandOwnerUUID);
|
||||
return this.banStorage.containsKey(islandOwnerUUID);
|
||||
}
|
||||
|
||||
public Ban getIsland(UUID islandOwnerUUID) {
|
||||
return banStorage.get(islandOwnerUUID);
|
||||
return this.banStorage.get(islandOwnerUUID);
|
||||
}
|
||||
|
||||
public Map<UUID, Ban> getIslands() {
|
||||
return banStorage;
|
||||
return this.banStorage;
|
||||
}
|
||||
|
||||
public void createIsland(UUID islandOwnerUUID) {
|
||||
banStorage.put(islandOwnerUUID, new Ban(islandOwnerUUID));
|
||||
this.banStorage.put(islandOwnerUUID, new Ban(islandOwnerUUID));
|
||||
}
|
||||
|
||||
public void addIsland(UUID islandOwnerUUID, Ban ban) {
|
||||
banStorage.put(islandOwnerUUID, ban);
|
||||
this.banStorage.put(islandOwnerUUID, ban);
|
||||
}
|
||||
|
||||
public void removeIsland(UUID islandOwnerUUID) {
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
this.banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
|
||||
public void unloadIsland(UUID islandOwnerUUID) {
|
||||
if (hasIsland(islandOwnerUUID)) {
|
||||
plugin.getFileManager().unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"));
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
this.plugin.getFileManager().unloadConfig(new File(new File(this.plugin.getDataFolder(), "ban-data"), islandOwnerUUID.toString() + ".yml"));
|
||||
this.banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteIsland(UUID islandOwnerUUID) {
|
||||
if (hasIsland(islandOwnerUUID)) {
|
||||
plugin.getFileManager().deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"));
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
this.plugin.getFileManager().deleteConfig(new File(new File(this.plugin.getDataFolder(), "ban-data"), islandOwnerUUID.toString() + ".yml"));
|
||||
this.banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,21 +8,23 @@ import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BankManager {
|
||||
|
||||
private final HashMap<UUID, List<Transaction>> log;
|
||||
|
||||
|
||||
private final SkyBlock plugin;
|
||||
|
||||
public FileConfiguration lang;
|
||||
|
||||
public BankManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
lang = this.plugin.getLanguage();
|
||||
log = new HashMap<>();
|
||||
this.lang = this.plugin.getLanguage();
|
||||
this.log = new HashMap<>();
|
||||
loadTransactions();
|
||||
}
|
||||
|
||||
@ -49,42 +51,43 @@ public class BankManager {
|
||||
}
|
||||
|
||||
public List<Transaction> getTransactions(UUID uuid) {
|
||||
if (log.containsKey(uuid)
|
||||
&& log.get(uuid) != null
|
||||
&& !log.get(uuid).isEmpty()) {
|
||||
return new ArrayList<>(log.get(uuid));
|
||||
}else {
|
||||
if (this.log.containsKey(uuid)
|
||||
&& this.log.get(uuid) != null
|
||||
&& !this.log.get(uuid).isEmpty()) {
|
||||
return new ArrayList<>(this.log.get(uuid));
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public void addTransaction(Player p, Transaction transaction) {
|
||||
if (log.containsKey(p.getUniqueId())) {
|
||||
log.get(p.getUniqueId()).add(transaction);
|
||||
}else {
|
||||
if (this.log.containsKey(p.getUniqueId())) {
|
||||
this.log.get(p.getUniqueId()).add(transaction);
|
||||
} else {
|
||||
List<Transaction> t = new ArrayList<>();
|
||||
t.add(transaction);
|
||||
log.put(p.getUniqueId(),t);
|
||||
this.log.put(p.getUniqueId(), t);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTransactions() {
|
||||
for (UUID uid:SkyBlock.getInstance().getPlayerDataManager().getPlayerData().keySet()) {
|
||||
log.put(uid,SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(uid).getTransactions());
|
||||
for (UUID uid : SkyBlock.getInstance().getPlayerDataManager().getPlayerData().keySet()) {
|
||||
this.log.put(uid, SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(uid).getTransactions());
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getBalanceLore(Player player) {;
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
|
||||
public List<String> getBalanceLore(Player player) {
|
||||
;
|
||||
Economy economy = this.plugin.getEconomyManager().getEconomy();
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add("Some error occurred while loading your balance!");
|
||||
Island island = SkyBlock.getInstance().getIslandManager().getIsland(player);
|
||||
result.add("If this is null then its a easy to fix bug: "+island.toString());
|
||||
Island island = SkyBlock.getPlugin(SkyBlock.class).getIslandManager().getIsland(player);
|
||||
result.add("If this is null then its a easy to fix bug: " + island.toString());
|
||||
if (island != null) {
|
||||
result.clear();
|
||||
result.add(player.getDisplayName()+"'s balance is "+ EconomyManager.formatEconomy(economy.getBalance(player)));
|
||||
result.add(player.getDisplayName()+"'s island has "+ EconomyManager.formatEconomy(island.getBankBalance()));
|
||||
result.add(player.getDisplayName() + "'s balance is " + EconomyManager.formatEconomy(economy.getBalance(player)));
|
||||
result.add(player.getDisplayName() + "'s island has " + EconomyManager.formatEconomy(island.getBankBalance()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -94,12 +97,12 @@ public class BankManager {
|
||||
}
|
||||
|
||||
public List<Transaction> getTransactionList(UUID uuid) {
|
||||
return log.get(uuid);
|
||||
return this.log.get(uuid);
|
||||
}
|
||||
|
||||
public BankResponse deposit(Player player, Island island, double amt, boolean admin) {
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
Economy economy = this.plugin.getEconomyManager().getEconomy();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
// Make sure the amount is positive
|
||||
if (amt <= 0) {
|
||||
@ -114,11 +117,11 @@ public class BankManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(!admin) {
|
||||
if (!admin) {
|
||||
if (!economy.hasBalance(player, amt)) {
|
||||
return BankResponse.NOT_ENOUGH_MONEY;
|
||||
}
|
||||
|
||||
|
||||
economy.withdrawBalance(player, amt);
|
||||
}
|
||||
|
||||
@ -134,7 +137,7 @@ public class BankManager {
|
||||
}
|
||||
|
||||
public BankResponse withdraw(Player player, Island island, double amt, boolean admin) {
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
Economy economy = this.plugin.getEconomyManager().getEconomy();
|
||||
|
||||
// Make sure the amount is positive
|
||||
if (amt <= 0) {
|
||||
@ -149,11 +152,11 @@ public class BankManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(!admin){
|
||||
if (!admin) {
|
||||
if (amt > island.getBankBalance()) {
|
||||
return BankResponse.NOT_ENOUGH_MONEY;
|
||||
}
|
||||
|
||||
|
||||
economy.deposit(player, amt);
|
||||
}
|
||||
|
||||
@ -168,7 +171,7 @@ public class BankManager {
|
||||
return BankResponse.SUCCESS;
|
||||
}
|
||||
|
||||
public enum BankResponse{
|
||||
public enum BankResponse {
|
||||
NOT_ENOUGH_MONEY,
|
||||
DECIMALS_NOT_ALLOWED,
|
||||
NEGATIVE_AMOUNT,
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.OfflinePlayer;
|
||||
import java.util.Date;
|
||||
|
||||
public class Transaction {
|
||||
|
||||
public OfflinePlayer player;
|
||||
public float amount;
|
||||
public Date timestamp;
|
||||
@ -21,4 +20,4 @@ public class Transaction {
|
||||
ADMIN,
|
||||
USER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,14 @@
|
||||
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;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -21,7 +16,6 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class BiomeManager {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final List<Island> updatingIslands;
|
||||
private final FileConfiguration language;
|
||||
@ -30,61 +24,64 @@ public class BiomeManager {
|
||||
public BiomeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.updatingIslands = new ArrayList<>();
|
||||
this.language = SkyBlock.getInstance().getLanguage();
|
||||
this.runEveryX = language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates");
|
||||
this.language = SkyBlock.getPlugin(SkyBlock.class).getLanguage();
|
||||
this.runEveryX = this.language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates");
|
||||
}
|
||||
|
||||
|
||||
public boolean isUpdating(Island island) {
|
||||
return updatingIslands.contains(island);
|
||||
return this.updatingIslands.contains(island);
|
||||
}
|
||||
|
||||
|
||||
public void addUpdatingIsland(Island island) {
|
||||
updatingIslands.add(island);
|
||||
this.updatingIslands.add(island);
|
||||
}
|
||||
|
||||
|
||||
public void removeUpdatingIsland(Island island) {
|
||||
updatingIslands.remove(island);
|
||||
this.updatingIslands.remove(island);
|
||||
}
|
||||
|
||||
public void setBiome(Island island, IslandWorld world, CompatibleBiome biome, CompleteTask task) {
|
||||
addUpdatingIsland(island);
|
||||
|
||||
if (island.getLocation(world, IslandEnvironment.Island) == null) return;
|
||||
|
||||
if (island.getLocation(world, IslandEnvironment.ISLAND) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We keep it sequentially in order to use less RAM
|
||||
int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d));
|
||||
int chunkAmount = (int) Math.ceil(Math.pow(island.getSize() / 16d, 2d));
|
||||
AtomicInteger progress = new AtomicInteger();
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (cachedChunk) -> {
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, world, this.plugin.isPaperAsync(), (cachedChunk) -> {
|
||||
// I don't like this. But CompletableFuture#join causes a crash on some setups.
|
||||
cachedChunk.getChunk().thenAccept(chunk -> {
|
||||
try {
|
||||
if (chunk != null)
|
||||
if (chunk != null) {
|
||||
biome.setBiome(chunk);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
progress.getAndIncrement();
|
||||
|
||||
if (language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") &&
|
||||
progress.get() == 1 || progress.get() == chunkAmount || progress.get() % runEveryX == 0) {
|
||||
if (this.language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") &&
|
||||
progress.get() == 1 || progress.get() == chunkAmount || progress.get() % this.runEveryX == 0) {
|
||||
final double percent = ((double) progress.get() / (double) chunkAmount) * 100;
|
||||
|
||||
String message = language.getString("Command.Island.Biome.Progress.Message");
|
||||
String message = this.language.getString("Command.Island.Biome.Progress.Message");
|
||||
message = message.replace("%current_updated_chunks%", String.valueOf(progress.get()));
|
||||
message = message.replace("%max_chunks%", String.valueOf(chunkAmount));
|
||||
message = message.replace("%percent_whole%", String.valueOf((int) percent));
|
||||
message = message.replace("%percent%", NumberFormat.getInstance().format(percent));
|
||||
|
||||
for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) {
|
||||
plugin.getMessageManager().sendMessage(player, message);
|
||||
for (Player player : SkyBlock.getPlugin(SkyBlock.class).getIslandManager().getPlayersAtIsland(island)) {
|
||||
this.plugin.getMessageManager().sendMessage(player, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, (island1 -> {
|
||||
removeUpdatingIsland(island1);
|
||||
if(task != null) {
|
||||
if (task != null) {
|
||||
task.onCompleteUpdate();
|
||||
}
|
||||
}));
|
||||
|
@ -3,7 +3,6 @@ package com.songoda.skyblock.blockscanner;
|
||||
import org.bukkit.World;
|
||||
|
||||
public final class BlockInfo {
|
||||
|
||||
private final World world;
|
||||
|
||||
private final int x;
|
||||
@ -18,19 +17,18 @@ public final class BlockInfo {
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
return this.world;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public final class BlockScanner extends BukkitRunnable {
|
||||
|
||||
private static final Method ID_FIELD;
|
||||
private static final int MAX_CHUNKS_PER_ITERATION = 2;
|
||||
private static final int MAX_EMPTY_ITERATIONS = 20;
|
||||
@ -53,8 +52,8 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
|
||||
try {
|
||||
id = (Integer) ID_FIELD.invoke(chunk.getSnapshot(), x, y, z);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return id;
|
||||
@ -85,7 +84,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
this.completedNum = new AtomicInteger();
|
||||
this.island = island;
|
||||
|
||||
FileConfiguration config = SkyBlock.getInstance().getConfiguration();
|
||||
FileConfiguration config = SkyBlock.getPlugin(SkyBlock.class).getConfiguration();
|
||||
|
||||
int threadCount = 0;
|
||||
|
||||
@ -128,7 +127,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
}
|
||||
|
||||
private void queueWork(World world, int scanY, List<CachedChunk> subList) {
|
||||
WorldManager worldManager = SkyBlock.getInstance().getWorldManager();
|
||||
WorldManager worldManager = SkyBlock.getPlugin(SkyBlock.class).getWorldManager();
|
||||
|
||||
// The chunks that couldn't be taken snapshot async
|
||||
List<CachedChunk> pendingChunks = new ArrayList<>();
|
||||
@ -142,16 +141,16 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
// This is the actual object that we will use to wait
|
||||
Condition emptyCondition = lock.newCondition();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> {
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getPlugin(SkyBlock.class), () -> {
|
||||
// We need to hold the lock on the thread calling the await
|
||||
lock.lock();
|
||||
|
||||
LocationBounds bounds = null;
|
||||
if (island != null) {
|
||||
Location islandLocation = island.getLocation(worldManager.getIslandWorld(world), IslandEnvironment.Island);
|
||||
if (this.island != null) {
|
||||
Location islandLocation = this.island.getLocation(worldManager.getIslandWorld(world), IslandEnvironment.ISLAND);
|
||||
|
||||
Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius());
|
||||
Location minLocation = new Location(world, islandLocation.getBlockX() - this.island.getRadius(), 0, islandLocation.getBlockZ() - this.island.getRadius());
|
||||
Location maxLocation = new Location(world, islandLocation.getBlockX() + this.island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + this.island.getRadius());
|
||||
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
@ -235,7 +234,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
}
|
||||
|
||||
if (pendingChunks.isEmpty()) {
|
||||
if (emptyIterations >= MAX_EMPTY_ITERATIONS) {
|
||||
if (this.emptyIterations >= MAX_EMPTY_ITERATIONS) {
|
||||
// Send the signal to unlock the async thread and continue with the processing
|
||||
emptyCondition.signalAll();
|
||||
this.cancel();
|
||||
@ -243,13 +242,13 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
emptyIterations++;
|
||||
this.emptyIterations++;
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(SkyBlock.getInstance(), 1, 1);
|
||||
}.runTaskTimer(SkyBlock.getPlugin(SkyBlock.class), 1, 1);
|
||||
}
|
||||
|
||||
private void processCachedChunk(World world, int scanY, CachedChunk shot, LocationBounds bounds) {
|
||||
@ -279,48 +278,50 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
|
||||
if (type == null) {
|
||||
continue;
|
||||
} else if (type.equals(CompatibleMaterial.AIR) && ignoreAir) {
|
||||
} else if (type == CompatibleMaterial.AIR && this.ignoreAir) {
|
||||
continue;
|
||||
} else if (type.equals(CompatibleMaterial.WATER) && ignoreLiquids) {
|
||||
} else if (type == CompatibleMaterial.WATER && this.ignoreLiquids) {
|
||||
continue;
|
||||
}
|
||||
|
||||
blocks.add(new BlockInfo(world, x + (cX), y, z + (cZ)));
|
||||
this.blocks.add(new BlockInfo(world, x + (cX), y, z + (cZ)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized int increment() {
|
||||
return completedNum.getAndIncrement();
|
||||
return this.completedNum.getAndIncrement();
|
||||
}
|
||||
|
||||
private synchronized int get() {
|
||||
return completedNum.get();
|
||||
return this.completedNum.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (get() != threadCount) return;
|
||||
if (get() != this.threadCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
tasks.onComplete(blocks);
|
||||
this.tasks.onComplete(this.blocks);
|
||||
cancel();
|
||||
}
|
||||
|
||||
public static void startScanner(Map<World, List<CachedChunk>> snapshots, Island island, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) {
|
||||
|
||||
if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null");
|
||||
if (tasks == null) throw new IllegalArgumentException("tasks cannot be null");
|
||||
if (snapshots == null) {
|
||||
throw new IllegalArgumentException("snapshots cannot be null");
|
||||
}
|
||||
if (tasks == null) {
|
||||
throw new IllegalArgumentException("tasks cannot be null");
|
||||
}
|
||||
|
||||
final BlockScanner scanner = new BlockScanner(snapshots, island, ignoreLiquids, ignoreLiquidsY, ignoreAir, ignoreY, tasks);
|
||||
|
||||
scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5);
|
||||
scanner.runTaskTimer(SkyBlock.getPlugin(SkyBlock.class), 5, 5);
|
||||
}
|
||||
|
||||
public interface ScannerTasks {
|
||||
|
||||
void onComplete(Queue<BlockInfo> blocks);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CachedChunk {
|
||||
|
||||
private final String world;
|
||||
private final int x;
|
||||
private final int z;
|
||||
@ -44,19 +43,21 @@ public class CachedChunk {
|
||||
|
||||
public CompletableFuture<Chunk> getChunk() {
|
||||
World world = Bukkit.getWorld(this.world);
|
||||
if (world == null)
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
return PaperLib.getChunkAtAsync(world, this.x, this.z);
|
||||
}
|
||||
|
||||
public boolean isSnapshotAvailable() {
|
||||
return latestSnapshot != null;
|
||||
return this.latestSnapshot != null;
|
||||
}
|
||||
|
||||
public ChunkSnapshot getSnapshot() {
|
||||
if (latestSnapshot == null)
|
||||
if (this.latestSnapshot == null) {
|
||||
return takeSnapshot();
|
||||
return latestSnapshot;
|
||||
}
|
||||
return this.latestSnapshot;
|
||||
}
|
||||
|
||||
public ChunkSnapshot takeSnapshot() {
|
||||
@ -64,15 +65,19 @@ public class CachedChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Chunk) {
|
||||
Chunk other = (Chunk) o;
|
||||
return this.world.equals(other.getWorld().getName()) && this.x == other.getX() && this.z == other.getZ();
|
||||
} else return false;
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Chunk)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Chunk other = (Chunk) obj;
|
||||
return this.world.equals(other.getWorld().getName()) &&
|
||||
this.x == other.getX() &&
|
||||
this.z == other.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.world, this.x, this.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,35 +34,37 @@ public class ChunkLoader extends BukkitRunnable {
|
||||
boolean chunkForChunk,
|
||||
ChunkForChunkScannerTask chunkTask,
|
||||
CompleteTask complete) {
|
||||
chunkPerTick = SkyBlock.getInstance().getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
this.chunkPerTick = SkyBlock.getPlugin(SkyBlock.class).getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
|
||||
this.completeTask = complete;
|
||||
this.chunkTask = chunkTask;
|
||||
this.chunkForChunk = chunkForChunk;
|
||||
this.paper = paper;
|
||||
this.island = island;
|
||||
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island);
|
||||
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.ISLAND);
|
||||
|
||||
if (islandLocation == null) return;
|
||||
if (islandLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
world = islandLocation.getWorld();
|
||||
this.world = islandLocation.getWorld();
|
||||
|
||||
Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius());
|
||||
Location minLocation = new Location(this.world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(this.world, islandLocation.getBlockX() + island.getRadius(), this.world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius());
|
||||
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4;
|
||||
minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4;
|
||||
this.minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4;
|
||||
|
||||
maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15;
|
||||
maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15;
|
||||
this.maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15;
|
||||
this.maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15;
|
||||
|
||||
x = minX;
|
||||
z = minZ;
|
||||
this.x = minX;
|
||||
this.z = this.minZ;
|
||||
|
||||
if (paper) {
|
||||
this.runTaskAsynchronously(SkyBlock.getInstance());
|
||||
this.runTaskAsynchronously(SkyBlock.getPlugin(SkyBlock.class));
|
||||
} else {
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L);
|
||||
this.runTaskTimer(SkyBlock.getPlugin(SkyBlock.class), 1L, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,70 +74,71 @@ public class ChunkLoader extends BukkitRunnable {
|
||||
boolean chunkForChunk,
|
||||
ChunkScannerTask generalTask,
|
||||
CompleteTask complete) {
|
||||
chunkPerTick = SkyBlock.getInstance().getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
this.chunkPerTick = SkyBlock.getPlugin(SkyBlock.class).getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
|
||||
this.completeTask = complete;
|
||||
this.generalTask = generalTask;
|
||||
this.chunkForChunk = chunkForChunk;
|
||||
this.paper = paper;
|
||||
this.island = island;
|
||||
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island);
|
||||
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.ISLAND);
|
||||
if (islandLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (islandLocation == null) return;
|
||||
|
||||
world = islandLocation.getWorld();
|
||||
this.world = islandLocation.getWorld();
|
||||
|
||||
Location minLocation = new Location(
|
||||
world,
|
||||
this.world,
|
||||
islandLocation.getBlockX() - island.getRadius(),
|
||||
0,
|
||||
islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(
|
||||
world,
|
||||
this.world,
|
||||
islandLocation.getBlockX() + island.getRadius(),
|
||||
world.getMaxHeight(),
|
||||
this.world.getMaxHeight(),
|
||||
islandLocation.getBlockZ() + island.getRadius());
|
||||
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4;
|
||||
minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4;
|
||||
this.minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4;
|
||||
|
||||
maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15;
|
||||
maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15;
|
||||
this.maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15;
|
||||
this.maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15;
|
||||
|
||||
x = minX;
|
||||
z = minZ;
|
||||
this.x = minX;
|
||||
this.z = this.minZ;
|
||||
|
||||
if (paper) {
|
||||
this.runTaskAsynchronously(SkyBlock.getInstance());
|
||||
this.runTaskAsynchronously(SkyBlock.getPlugin(SkyBlock.class));
|
||||
} else {
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L);
|
||||
this.runTaskTimer(SkyBlock.getPlugin(SkyBlock.class), 1L, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() { // TODO New algorithm that start from the center of the island
|
||||
for (int i = 0; i < chunkPerTick || paper; i++) {
|
||||
if (x <= maxX) {
|
||||
if (z <= maxZ) {
|
||||
if (!chunkForChunk) {
|
||||
positions.add(new CachedChunk(world, x >> 4, z >> 4));
|
||||
for (int i = 0; i < this.chunkPerTick || this.paper; i++) {
|
||||
if (this.x <= this.maxX) {
|
||||
if (this.z <= this.maxZ) {
|
||||
if (!this.chunkForChunk) {
|
||||
this.positions.add(new CachedChunk(this.world, this.x >> 4, this.z >> 4));
|
||||
} else {
|
||||
if (chunkTask != null) {
|
||||
chunkTask.onChunkComplete(new CachedChunk(world, x >> 4, z >> 4));
|
||||
if (this.chunkTask != null) {
|
||||
this.chunkTask.onChunkComplete(new CachedChunk(this.world, this.x >> 4, this.z >> 4));
|
||||
}
|
||||
}
|
||||
|
||||
z += 16;
|
||||
this.z += 16;
|
||||
} else {
|
||||
z = minZ;
|
||||
x += 16;
|
||||
this.z = this.minZ;
|
||||
this.x += 16;
|
||||
}
|
||||
} else {
|
||||
if (generalTask != null) {
|
||||
generalTask.onComplete(positions);
|
||||
if (this.generalTask != null) {
|
||||
this.generalTask.onComplete(this.positions);
|
||||
}
|
||||
if (completeTask != null) {
|
||||
completeTask.onComplete(island);
|
||||
if (this.completeTask != null) {
|
||||
this.completeTask.onComplete(this.island);
|
||||
}
|
||||
this.cancel();
|
||||
return;
|
||||
|
@ -2,27 +2,27 @@ package com.songoda.skyblock.blockscanner;
|
||||
|
||||
public class LocationBounds {
|
||||
private final int minX, minZ, maxX, maxZ;
|
||||
|
||||
|
||||
public LocationBounds(int minX, int minZ, int maxX, int maxZ) {
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
|
||||
public int getMinX() {
|
||||
return minX;
|
||||
return this.minX;
|
||||
}
|
||||
|
||||
|
||||
public int getMinZ() {
|
||||
return minZ;
|
||||
return this.minZ;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxX() {
|
||||
return maxX;
|
||||
return this.maxX;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxZ() {
|
||||
return maxZ;
|
||||
return this.maxZ;
|
||||
}
|
||||
}
|
||||
|
@ -6,19 +6,20 @@ import org.bukkit.Material;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class MaterialIDHelper {
|
||||
private MaterialIDHelper() {
|
||||
}
|
||||
|
||||
private MaterialIDHelper() {}
|
||||
|
||||
private final static Map<Integer, Material> MATERIALS;
|
||||
private static final Map<Integer, Material> MATERIALS;
|
||||
|
||||
static {
|
||||
MATERIALS = new HashMap<>();
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
for (Material type : Material.values()) {
|
||||
if (type.isLegacy()) MATERIALS.put(type.getId(), type);
|
||||
if (type.isLegacy()) {
|
||||
MATERIALS.put(type.getId(), type);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Material type : Material.values()) {
|
||||
|
@ -11,53 +11,55 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FabledChallenge {
|
||||
private final SkyBlock plugin;
|
||||
private final ChallengeManager challengeManager;
|
||||
private final PlayerManager playerManager;
|
||||
// I use my own inventory api bc it's hard to implement inventories with the
|
||||
private final InventoryManager inventoryManager;
|
||||
private final DefaultInventory defaultInventory;
|
||||
private final ChallengeInventory challengeInventory;
|
||||
private final SkyBlock plugin;
|
||||
private final ChallengeManager challengeManager;
|
||||
private final PlayerManager playerManager;
|
||||
// I use my own inventory api bc it's hard to implement inventories with the
|
||||
private final InventoryManager inventoryManager;
|
||||
private final DefaultInventory defaultInventory;
|
||||
private final ChallengeInventory challengeInventory;
|
||||
|
||||
public FabledChallenge(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.defaultInventory = new DefaultInventory(plugin);
|
||||
this.challengeManager = new ChallengeManager(plugin);
|
||||
this.playerManager = new PlayerManager(plugin);
|
||||
this.challengeInventory = new ChallengeInventory(this);
|
||||
this.inventoryManager = new InventoryManager(plugin);
|
||||
this.inventoryManager.init();
|
||||
}
|
||||
public FabledChallenge(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.defaultInventory = new DefaultInventory(plugin);
|
||||
this.challengeManager = new ChallengeManager(plugin);
|
||||
this.playerManager = new PlayerManager(plugin);
|
||||
this.challengeInventory = new ChallengeInventory(this);
|
||||
this.inventoryManager = new InventoryManager(plugin);
|
||||
this.inventoryManager.init();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
this.inventoryManager.closeInventories();
|
||||
}
|
||||
public void onDisable() {
|
||||
this.inventoryManager.closeInventories();
|
||||
}
|
||||
|
||||
public void openChallengeInventory(Player p, ChallengeCategory category) {
|
||||
if (category == null)
|
||||
return;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
inventoryManager.openInventory(challengeInventory, p, params -> {
|
||||
params.put(ChallengeInventory.CATEGORY, category);
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
public void openChallengeInventory(Player p, ChallengeCategory category) {
|
||||
if (category == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
|
||||
this.inventoryManager.openInventory(this.challengeInventory, p, params -> {
|
||||
params.put(ChallengeInventory.CATEGORY, category);
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
||||
public ChallengeManager getChallengeManager() {
|
||||
return challengeManager;
|
||||
}
|
||||
// GETTERS
|
||||
|
||||
public PlayerManager getPlayerManager() {
|
||||
return playerManager;
|
||||
}
|
||||
public ChallengeManager getChallengeManager() {
|
||||
return this.challengeManager;
|
||||
}
|
||||
|
||||
public InventoryManager getInventoryManager() {
|
||||
return inventoryManager;
|
||||
}
|
||||
public PlayerManager getPlayerManager() {
|
||||
return this.playerManager;
|
||||
}
|
||||
|
||||
public DefaultInventory getDefaultInventory() {
|
||||
return defaultInventory;
|
||||
}
|
||||
public InventoryManager getInventoryManager() {
|
||||
return this.inventoryManager;
|
||||
}
|
||||
|
||||
public DefaultInventory getDefaultInventory() {
|
||||
return this.defaultInventory;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Challenge {
|
||||
|
||||
private final ChallengeCategory category;
|
||||
private final int id;
|
||||
private final String name;
|
||||
@ -56,8 +55,10 @@ public class Challenge {
|
||||
// Requires
|
||||
for (String str : requires) {
|
||||
int idx = str.indexOf(':');
|
||||
if (idx == -1)
|
||||
if (idx == -1) {
|
||||
throw new IllegalArgumentException("Line \"" + str + "\" isn't a correct line");
|
||||
}
|
||||
|
||||
String arg0 = str.substring(0, idx);
|
||||
String arg1 = str.substring(idx + 1);
|
||||
try {
|
||||
@ -72,8 +73,10 @@ public class Challenge {
|
||||
// Rewards
|
||||
for (String str : rewards) {
|
||||
int idx = str.indexOf(':');
|
||||
if (idx == -1)
|
||||
if (idx == -1) {
|
||||
throw new IllegalArgumentException("Line " + str + " isn't a correct line");
|
||||
}
|
||||
|
||||
String arg0 = str.substring(0, idx);
|
||||
String arg1 = str.substring(idx + 1);
|
||||
try {
|
||||
@ -90,35 +93,35 @@ public class Challenge {
|
||||
// GETTERS
|
||||
|
||||
public ChallengeCategory getCategory() {
|
||||
return category;
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getMaxTimes() {
|
||||
return maxTimes;
|
||||
return this.maxTimes;
|
||||
}
|
||||
|
||||
public boolean isShowInChat() {
|
||||
return showInChat;
|
||||
return this.showInChat;
|
||||
}
|
||||
|
||||
public List<Peer<Type, Object>> getRequires() {
|
||||
return requires;
|
||||
return this.requires;
|
||||
}
|
||||
|
||||
public List<Peer<Type, Object>> getRewards() {
|
||||
return rewards;
|
||||
return this.rewards;
|
||||
}
|
||||
|
||||
public ItemChallenge getItem() {
|
||||
return item;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
@ -149,14 +152,14 @@ public class Challenge {
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
List<Integer> is = (List<Integer>) obj;
|
||||
SkyBlock instance = SkyBlock.getInstance();
|
||||
SkyBlock instance = SkyBlock.getPlugin(SkyBlock.class);
|
||||
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);
|
||||
ChallengeCategory cc = SkyBlock.getPlugin(SkyBlock.class).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))) {
|
||||
@ -186,17 +189,18 @@ public class Challenge {
|
||||
*/
|
||||
@Override
|
||||
public ItemStack convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value.trim()))
|
||||
if (value == null || "".equalsIgnoreCase(value.trim())) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
int index = value.indexOf(' ');
|
||||
// The id
|
||||
String id = index == -1 ? value : value.substring(0, index);
|
||||
// Check if it's a Minecraft item
|
||||
CompatibleMaterial m = CompatibleMaterial.getMaterial(id);
|
||||
//Material m = Material.matchMaterial(id);
|
||||
if (m == null)
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + id + "\" isn't a correct Minecraft Material (value = \"" + value + "\")");
|
||||
if (m == null) {
|
||||
throw new IllegalArgumentException("\"" + id + "\" isn't a correct Minecraft Material (value = \"" + value + "\")");
|
||||
}
|
||||
int amount = 1;
|
||||
if (index != -1) {
|
||||
String strAmount = value.substring(index + 1);
|
||||
@ -214,13 +218,14 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
boolean ignoreLore = SkyBlock.getInstance().getConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
boolean ignoreLore = SkyBlock.getPlugin(SkyBlock.class).getConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
if (obj instanceof ItemStack) {
|
||||
// Check if player has specific item in his inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(is);
|
||||
if (ignoreLore)
|
||||
if (ignoreLore) {
|
||||
return findSimilar(p, material) >= is.getAmount();
|
||||
}
|
||||
return p.getInventory().containsAtLeast(is, is.getAmount());
|
||||
}
|
||||
return false;
|
||||
@ -228,22 +233,26 @@ public class Challenge {
|
||||
|
||||
private int findSimilar(Player p, CompatibleMaterial material) {
|
||||
int amountFound = 0;
|
||||
for (ItemStack item : p.getInventory().getContents())
|
||||
if (CompatibleMaterial.getMaterial(item) == material)
|
||||
for (ItemStack item : p.getInventory().getContents()) {
|
||||
if (CompatibleMaterial.getMaterial(item) == material) {
|
||||
amountFound += item.getAmount();
|
||||
}
|
||||
}
|
||||
return amountFound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
boolean ignoreLore = SkyBlock.getInstance().getConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
boolean ignoreLore = SkyBlock.getPlugin(SkyBlock.class).getConfiguration().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 (jis == null) {
|
||||
continue;
|
||||
}
|
||||
if (ignoreLore ? CompatibleMaterial.getMaterial(jis) == CompatibleMaterial.getMaterial(is) : jis.isSimilar(is)) {
|
||||
if (jis.getAmount() <= toRemove) {
|
||||
toRemove -= jis.getAmount();
|
||||
@ -266,8 +275,9 @@ public class Challenge {
|
||||
// Give specific item to player
|
||||
ItemStack is = (ItemStack) obj;
|
||||
HashMap<Integer, ItemStack> rest = p.getInventory().addItem(is.clone());
|
||||
for (ItemStack restIs : rest.values())
|
||||
for (ItemStack restIs : rest.values()) {
|
||||
p.getWorld().dropItem(p.getLocation(), restIs);
|
||||
}
|
||||
}
|
||||
},
|
||||
CMD {
|
||||
@ -276,8 +286,9 @@ public class Challenge {
|
||||
@Override
|
||||
public String convert(String value) throws IllegalArgumentException {
|
||||
// Here we don't have to convert the value because the value is the command
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -306,8 +317,9 @@ public class Challenge {
|
||||
public Integer convert(String value) throws IllegalArgumentException {
|
||||
// Convert the value to an Integer representing the minimum level of island
|
||||
// required
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -320,7 +332,7 @@ public class Challenge {
|
||||
public boolean has(Player p, Object obj) {
|
||||
// Check if the level of player's island is greater or equals to the required
|
||||
// level
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
Island is = SkyBlock.getPlugin(SkyBlock.class).getIslandManager().getIsland(p);
|
||||
// Player doesn't have an island
|
||||
if (is != null && obj instanceof Number) {
|
||||
return is.getLevel().getLevel() >= ((Number) obj).longValue();
|
||||
@ -342,8 +354,9 @@ public class Challenge {
|
||||
@Override
|
||||
public Peer<EntityType, Integer> convert(String value) throws IllegalArgumentException {
|
||||
// We returns the entity type and the number of entity required
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
int index = value.indexOf(' ');
|
||||
// The id
|
||||
String id = index == -1 ? value : value.substring(0, index);
|
||||
@ -352,8 +365,7 @@ public class Challenge {
|
||||
try {
|
||||
et = EntityType.valueOf(id.toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + id + "\" isn't a correct Minecraft EntityType (value = \"" + value + "\")");
|
||||
throw new IllegalArgumentException("\"" + id + "\" isn't a correct Minecraft EntityType (value = \"" + value + "\")");
|
||||
}
|
||||
int amount = 1;
|
||||
if (index != -1) {
|
||||
@ -361,11 +373,10 @@ public class Challenge {
|
||||
try {
|
||||
amount = Integer.parseInt(strAmount);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + strAmount + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
throw new IllegalArgumentException("\"" + strAmount + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
}
|
||||
}
|
||||
return new Peer<EntityType, Integer>(et, amount);
|
||||
return new Peer<>(et, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -375,10 +386,12 @@ public class Challenge {
|
||||
List<Entity> entities = p.getNearbyEntities(60, 60, 60);
|
||||
int count = 0;
|
||||
for (Entity e : entities) {
|
||||
if (e.getType() == peer.getKey())
|
||||
if (e.getType() == peer.getKey()) {
|
||||
count++;
|
||||
if (count == peer.getValue())
|
||||
}
|
||||
if (count == peer.getValue()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -400,30 +413,31 @@ public class Challenge {
|
||||
@Override
|
||||
public Peer<PotionType, Peer<Integer, Integer>> convert(String value) throws IllegalArgumentException {
|
||||
// We returns the potion required
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
String[] split = space.split(value);
|
||||
if (split.length != 3)
|
||||
}
|
||||
String[] split = this.space.split(value);
|
||||
if (split.length != 3) {
|
||||
throw new IllegalArgumentException("Incorrect value : \"" + value + "\"");
|
||||
}
|
||||
// The id
|
||||
// Check if it's a Minecraft item
|
||||
PotionType pt;
|
||||
try {
|
||||
pt = PotionType.valueOf(split[0].toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + split[0] + "\" isn't a correct Minecraft PotionType (value = \"" + value + "\")");
|
||||
throw new IllegalArgumentException("\"" + split[0] + "\" isn't a correct Minecraft PotionType (value = \"" + value + "\")");
|
||||
}
|
||||
// The data
|
||||
int data;
|
||||
try {
|
||||
data = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + split[1] + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
throw new IllegalArgumentException("\"" + split[1] + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
}
|
||||
if (data < 0 || data > 8)
|
||||
if (data < 0 || data > 8) {
|
||||
throw new IllegalArgumentException("Data must be between 0 and 8, but is \"" + split[1] + "\"");
|
||||
}
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(split[2]);
|
||||
@ -444,8 +458,9 @@ public class Challenge {
|
||||
&& isSame(is, peer.getKey(), peer.getValue().getKey())) {
|
||||
// Same potion
|
||||
count += is.getAmount();
|
||||
if (count >= peer.getValue().getValue())
|
||||
if (count >= peer.getValue().getValue()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -479,12 +494,13 @@ public class Challenge {
|
||||
Peer<PotionType, Peer<Integer, Integer>> peer = (Peer<PotionType, Peer<Integer, Integer>>) obj;
|
||||
ItemStack is = null;
|
||||
int data = peer.getValue().getKey();
|
||||
if (data <= 2)
|
||||
if (data <= 2) {
|
||||
is = new ItemStack(Material.POTION, peer.getValue().getValue());
|
||||
else if (data <= 5)
|
||||
} else if (data <= 5) {
|
||||
is = new ItemStack(Material.LINGERING_POTION, peer.getValue().getValue());
|
||||
else if (data <= 8)
|
||||
} else if (data <= 8) {
|
||||
is = new ItemStack(Material.SPLASH_POTION, peer.getValue().getValue());
|
||||
}
|
||||
PotionMeta pm = (PotionMeta) is.getItemMeta();
|
||||
pm.setBasePotionData(new PotionData(peer.getKey(), data == 1 || data == 4 || data == 7,
|
||||
data == 2 || data == 5 || data == 8));
|
||||
@ -492,8 +508,9 @@ public class Challenge {
|
||||
|
||||
// Add item or drop if inventory is full
|
||||
HashMap<Integer, ItemStack> rest = p.getInventory().addItem(is);
|
||||
for (ItemStack restIs : rest.values())
|
||||
for (ItemStack restIs : rest.values()) {
|
||||
p.getWorld().dropItem(p.getLocation(), restIs);
|
||||
}
|
||||
|
||||
// TODO LOG
|
||||
}
|
||||
@ -518,28 +535,32 @@ public class Challenge {
|
||||
* </ul>
|
||||
*/
|
||||
private boolean isSame(ItemStack is, PotionType type, int data) {
|
||||
if (data <= 2 && is.getType() != Material.POTION)
|
||||
if (data <= 2 && is.getType() != Material.POTION) {
|
||||
return false;
|
||||
else if (data >= 3 && data <= 5 && is.getType() != Material.LINGERING_POTION)
|
||||
} else if (data >= 3 && data <= 5 && is.getType() != Material.LINGERING_POTION) {
|
||||
return false;
|
||||
else if (data >= 6 && data <= 8 && is.getType() != Material.SPLASH_POTION)
|
||||
} else if (data >= 6 && data <= 8 && is.getType() != Material.SPLASH_POTION) {
|
||||
return false;
|
||||
}
|
||||
PotionMeta pm = (PotionMeta) is.getItemMeta();
|
||||
PotionData pd = pm.getBasePotionData();
|
||||
if (pd.getType() != type)
|
||||
if (pd.getType() != type) {
|
||||
return false;
|
||||
else if ((data == 0 || data == 3 || data == 6) && (pd.isExtended() || pd.isUpgraded()))
|
||||
} else if ((data == 0 || data == 3 || data == 6) && (pd.isExtended() || pd.isUpgraded())) {
|
||||
return false;
|
||||
else if ((data == 1 || data == 4 || data == 7) && !pd.isExtended())
|
||||
} else if ((data == 1 || data == 4 || data == 7) && !pd.isExtended()) {
|
||||
return false;
|
||||
else return (data != 2 && data != 5 && data != 8) || pd.isUpgraded();
|
||||
} else {
|
||||
return (data != 2 && data != 5 && data != 8) || pd.isUpgraded();
|
||||
}
|
||||
}
|
||||
},
|
||||
ECO {
|
||||
@Override
|
||||
public Double convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -550,7 +571,7 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy();
|
||||
Economy economy = SkyBlock.getPlugin(SkyBlock.class).getEconomyManager().getEconomy();
|
||||
if (obj instanceof Number) {
|
||||
return economy.getBalance(p) >= ((Number) obj).doubleValue();
|
||||
}
|
||||
@ -559,7 +580,7 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy();
|
||||
Economy economy = SkyBlock.getPlugin(SkyBlock.class).getEconomyManager().getEconomy();
|
||||
if (obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
economy.withdrawBalance(p, ((Number) obj).doubleValue());
|
||||
}
|
||||
@ -567,7 +588,7 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public void executeReward(Player p, Object obj) {
|
||||
Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy();
|
||||
Economy economy = SkyBlock.getPlugin(SkyBlock.class).getEconomyManager().getEconomy();
|
||||
if (obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
economy.deposit(p, ((Number) obj).doubleValue());
|
||||
}
|
||||
@ -576,8 +597,9 @@ public class Challenge {
|
||||
BANK {
|
||||
@Override
|
||||
public Double convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
if (value == null || "".equalsIgnoreCase(value)) {
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -588,7 +610,7 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
Island is = SkyBlock.getPlugin(SkyBlock.class).getIslandManager().getIsland(p);
|
||||
|
||||
if (is != null && obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
return is.getBankBalance() >= ((Number) obj).doubleValue();
|
||||
@ -598,8 +620,8 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
BankManager bankManager = SkyBlock.getInstance().getBankManager();
|
||||
Island is = SkyBlock.getPlugin(SkyBlock.class).getIslandManager().getIsland(p);
|
||||
BankManager bankManager = SkyBlock.getPlugin(SkyBlock.class).getBankManager();
|
||||
|
||||
if (is != null && obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
bankManager.withdraw(p, is, ((Number) obj).doubleValue(), false);
|
||||
@ -608,8 +630,8 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public void executeReward(Player p, Object obj) {
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
BankManager bankManager = SkyBlock.getInstance().getBankManager();
|
||||
Island is = SkyBlock.getPlugin(SkyBlock.class).getIslandManager().getIsland(p);
|
||||
BankManager bankManager = SkyBlock.getPlugin(SkyBlock.class).getBankManager();
|
||||
|
||||
if (is != null && obj instanceof Number) {
|
||||
bankManager.deposit(p, is, ((Number) obj).doubleValue(), false);
|
||||
|
@ -12,94 +12,97 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChallengeCategory {
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final 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;
|
||||
this.name = name;
|
||||
challenges = new HashMap<>();
|
||||
loadChallenges(config);
|
||||
}
|
||||
public ChallengeCategory(int id, String name, FileConfiguration config) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.challenges = new HashMap<>();
|
||||
loadChallenges(config);
|
||||
}
|
||||
|
||||
private void loadChallenges(FileConfiguration config) {
|
||||
ConfigurationSection section = config.getConfigurationSection("challenges." + id + ".challenges");
|
||||
if (section == null)
|
||||
// No challenge here
|
||||
return;
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String k : keys) {
|
||||
String key = "challenges." + id + ".challenges." + k;
|
||||
int id = config.getInt(key + ".id");
|
||||
if (id == 0)
|
||||
throw new IllegalArgumentException("Invalid id at category " + this.name + "(" + this.id
|
||||
+ ") at challenge " + name + "(" + id + ")");
|
||||
String name = ChatColor.translateAlternateColorCodes('&', config.getString(key + ".name"));
|
||||
List<String> require = toColor(config.getStringList(key + ".require"));
|
||||
List<String> reward = toColor(config.getStringList(key + ".reward"));
|
||||
int maxTimes = 0;
|
||||
try {
|
||||
Integer.parseInt(config.getString(key + ".maxtimes", "unlimited"));
|
||||
maxTimes = config.getInt(key + ".maxtimes");
|
||||
} catch(NumberFormatException ignored) {
|
||||
if(config.getString(key + ".maxtimes", "unlimited").equalsIgnoreCase("unlimited")) {
|
||||
maxTimes = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
boolean showInChat = config.getBoolean(key + ".showInChat");
|
||||
// Item
|
||||
boolean show = config.getBoolean(key + ".item.show");
|
||||
int row = show ? config.getInt(key + ".item.row") : 0;
|
||||
int col = show ? config.getInt(key + ".item.col") : 0;
|
||||
String strItem = show ? config.getString(key + ".item.item") : "AIR";
|
||||
if (strItem == null)
|
||||
strItem = "AIR";
|
||||
int amount = show ? config.getInt(key + ".item.amount") : 0;
|
||||
List<String> lore = show ? toColor(config.getStringList(key + ".item.lore")) : new ArrayList<>();
|
||||
if (lore == null)
|
||||
lore = new ArrayList<>();
|
||||
try {
|
||||
// If an Exception occurs, we don't handle it here but in parent class
|
||||
CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(strItem);
|
||||
if (compatibleMaterial == null)
|
||||
throw new IllegalArgumentException("Item " + strItem + " isn't a correct material");
|
||||
ItemChallenge ic = new ItemChallenge(show, row, col, compatibleMaterial, amount, lore);
|
||||
Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic);
|
||||
challenges.put(id, c);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Exception at category " + this.name.replace("&", "") + "(" + this.id
|
||||
+ ") at challenge " + name.replace("&", "") + "(" + id + "): " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN
|
||||
+ " loaded with " + ChatColor.GOLD + challenges.size() + ChatColor.GREEN + " challenges");
|
||||
}
|
||||
private void loadChallenges(FileConfiguration config) {
|
||||
ConfigurationSection section = config.getConfigurationSection("challenges." + this.id + ".challenges");
|
||||
if (section == null) {
|
||||
return; // No challenge here
|
||||
}
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String k : keys) {
|
||||
String key = "challenges." + this.id + ".challenges." + k;
|
||||
int id = config.getInt(key + ".id");
|
||||
if (id == 0) {
|
||||
throw new IllegalArgumentException("Invalid id at category " + this.name + "(" + this.id
|
||||
+ ") at challenge " + this.name + "(" + id + ")");
|
||||
}
|
||||
String name = ChatColor.translateAlternateColorCodes('&', config.getString(key + ".name"));
|
||||
List<String> require = toColor(config.getStringList(key + ".require"));
|
||||
List<String> reward = toColor(config.getStringList(key + ".reward"));
|
||||
int maxTimes = 0;
|
||||
try {
|
||||
Integer.parseInt(config.getString(key + ".maxtimes", "unlimited"));
|
||||
maxTimes = config.getInt(key + ".maxtimes");
|
||||
} catch (NumberFormatException ignored) {
|
||||
if (config.getString(key + ".maxtimes", "unlimited").equalsIgnoreCase("unlimited")) {
|
||||
maxTimes = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
boolean showInChat = config.getBoolean(key + ".showInChat");
|
||||
// Item
|
||||
boolean show = config.getBoolean(key + ".item.show");
|
||||
int row = show ? config.getInt(key + ".item.row") : 0;
|
||||
int col = show ? config.getInt(key + ".item.col") : 0;
|
||||
String strItem = show ? config.getString(key + ".item.item") : "AIR";
|
||||
if (strItem == null) {
|
||||
strItem = "AIR";
|
||||
}
|
||||
int amount = show ? config.getInt(key + ".item.amount") : 0;
|
||||
List<String> lore = show ? toColor(config.getStringList(key + ".item.lore")) : new ArrayList<>();
|
||||
try {
|
||||
// If an Exception occurs, we don't handle it here but in parent class
|
||||
CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(strItem);
|
||||
if (compatibleMaterial == null) {
|
||||
throw new IllegalArgumentException("Item " + strItem + " isn't a correct material");
|
||||
}
|
||||
ItemChallenge ic = new ItemChallenge(show, row, col, compatibleMaterial, amount, lore);
|
||||
Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic);
|
||||
this.challenges.put(id, c);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Exception at category " + this.name.replace("&", "") + "(" + this.id
|
||||
+ ") at challenge " + name.replace("&", "") + "(" + id + "): " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + this.name + ChatColor.GREEN
|
||||
+ " loaded with " + ChatColor.GOLD + this.challenges.size() + ChatColor.GREEN + " challenges");
|
||||
}
|
||||
|
||||
private List<String> toColor(List<String> list) {
|
||||
List<String> copy = new ArrayList<>();
|
||||
if (list == null)
|
||||
return copy;
|
||||
for (String str : list)
|
||||
copy.add(ChatColor.translateAlternateColorCodes('&', str));
|
||||
return copy;
|
||||
}
|
||||
private List<String> toColor(List<String> list) {
|
||||
List<String> copy = new ArrayList<>();
|
||||
if (list == null) {
|
||||
return copy;
|
||||
}
|
||||
for (String str : list) {
|
||||
copy.add(ChatColor.translateAlternateColorCodes('&', str));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
// GETTERS
|
||||
|
||||
public Challenge getChallenge(int id) {
|
||||
return challenges.get(id);
|
||||
}
|
||||
public Challenge getChallenge(int id) {
|
||||
return this.challenges.get(id);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Challenge> getChallenges() {
|
||||
return challenges;
|
||||
}
|
||||
public HashMap<Integer, Challenge> getChallenges() {
|
||||
return this.challenges;
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,45 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChallengeManager {
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<Integer, ChallengeCategory> categories;
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<Integer, ChallengeCategory> categories;
|
||||
|
||||
public ChallengeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
categories = new HashMap<>();
|
||||
loadChallenges();
|
||||
}
|
||||
public ChallengeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.categories = new HashMap<>();
|
||||
loadChallenges();
|
||||
}
|
||||
|
||||
private void loadChallenges() {
|
||||
FileConfiguration configLoad = this.plugin.getChallenges();
|
||||
private void loadChallenges() {
|
||||
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 = plugin.formatText(configLoad.getString("challenges." + k + ".name"));
|
||||
ChallengeCategory cc = new ChallengeCategory(id, name, configLoad);
|
||||
categories.put(id, cc);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error while loading challenges:", ex);
|
||||
return;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + " challenges loaded with " + ChatColor.GOLD
|
||||
+ categories.size() + ChatColor.GREEN + " categories");
|
||||
}
|
||||
try {
|
||||
ConfigurationSection section = configLoad.getConfigurationSection("challenges");
|
||||
if (section != null) {
|
||||
for (String k : section.getKeys(false)) {
|
||||
int id = configLoad.getInt("challenges." + k + ".id");
|
||||
String name = this.plugin.formatText(configLoad.getString("challenges." + k + ".name"));
|
||||
ChallengeCategory cc = new ChallengeCategory(id, name, configLoad);
|
||||
this.categories.put(id, cc);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error while loading challenges:", ex);
|
||||
return;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + " challenges loaded with " + ChatColor.GOLD + this.categories.size() + ChatColor.GREEN + " categories");
|
||||
}
|
||||
|
||||
public ChallengeCategory getChallenge(int id) {
|
||||
return categories.get(id);
|
||||
}
|
||||
public ChallengeCategory getChallenge(int id) {
|
||||
return this.categories.get(id);
|
||||
}
|
||||
}
|
||||
|
@ -2,90 +2,86 @@ package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemChallenge {
|
||||
private Challenge challenge;
|
||||
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 Challenge challenge;
|
||||
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 final String itemTitle;
|
||||
private final String itemTitle;
|
||||
|
||||
public ItemChallenge(boolean show, int row, int col, CompatibleMaterial type, int amount, List<String> lore) {
|
||||
this.show = show;
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
this.lore = lore;
|
||||
FileConfiguration langConfigLoad = SkyBlock.getInstance().getLanguage();
|
||||
itemTitle = langConfigLoad.getString("Challenge.Inventory.Item.Title");
|
||||
}
|
||||
public ItemChallenge(boolean show, int row, int col, CompatibleMaterial type, int amount, List<String> lore) {
|
||||
this.show = show;
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
this.lore = lore;
|
||||
FileConfiguration langConfigLoad = SkyBlock.getPlugin(SkyBlock.class).getLanguage();
|
||||
this.itemTitle = langConfigLoad.getString("Challenge.Inventory.Item.Title");
|
||||
}
|
||||
|
||||
public ItemStack createItem(UUID player, int amount) {
|
||||
FileConfiguration langConfigLoad = SkyBlock.getInstance().getLanguage();
|
||||
|
||||
ItemStack is = type.getItem();
|
||||
is.setAmount(this.amount);
|
||||
// Air
|
||||
ItemMeta im = is.getItemMeta();
|
||||
if (im != null) {
|
||||
String maxAmount;
|
||||
if(challenge.getMaxTimes() == Integer.MAX_VALUE) {
|
||||
maxAmount = langConfigLoad.getString("Challenge.Inventory.Unlimited.Message");
|
||||
} else {
|
||||
maxAmount = String.valueOf(challenge.getMaxTimes());
|
||||
}
|
||||
im.setDisplayName(SkyBlock.getInstance().formatText( challenge.getName()).replace("%amount", Integer.toString(amount))
|
||||
.replace("%max", maxAmount));
|
||||
im.setLore(lore);
|
||||
is.setItemMeta(im);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
public ItemStack createItem(UUID player, int amount) {
|
||||
FileConfiguration langConfigLoad = SkyBlock.getPlugin(SkyBlock.class).getLanguage();
|
||||
|
||||
// GETTERS & SETTERS
|
||||
public Challenge getChallenge() {
|
||||
return challenge;
|
||||
}
|
||||
ItemStack is = this.type.getItem();
|
||||
is.setAmount(this.amount);
|
||||
// Air
|
||||
ItemMeta im = is.getItemMeta();
|
||||
if (im != null) {
|
||||
String maxAmount;
|
||||
if (this.challenge.getMaxTimes() == Integer.MAX_VALUE) {
|
||||
maxAmount = langConfigLoad.getString("Challenge.Inventory.Unlimited.Message");
|
||||
} else {
|
||||
maxAmount = String.valueOf(this.challenge.getMaxTimes());
|
||||
}
|
||||
im.setDisplayName(SkyBlock.getPlugin(SkyBlock.class).formatText(this.challenge.getName()).replace("%amount", Integer.toString(amount)).replace("%max", maxAmount));
|
||||
im.setLore(this.lore);
|
||||
is.setItemMeta(im);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public void setChallenge(Challenge challenge) {
|
||||
this.challenge = challenge;
|
||||
}
|
||||
// GETTERS & SETTERS
|
||||
public Challenge getChallenge() {
|
||||
return this.challenge;
|
||||
}
|
||||
|
||||
public boolean isShow() {
|
||||
return show;
|
||||
}
|
||||
public void setChallenge(Challenge challenge) {
|
||||
this.challenge = challenge;
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return row;
|
||||
}
|
||||
public boolean isShow() {
|
||||
return this.show;
|
||||
}
|
||||
|
||||
public int getCol() {
|
||||
return col;
|
||||
}
|
||||
public int getRow() {
|
||||
return this.row;
|
||||
}
|
||||
|
||||
public CompatibleMaterial getType() {
|
||||
return type;
|
||||
}
|
||||
public int getCol() {
|
||||
return this.col;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
public CompatibleMaterial getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return lore;
|
||||
}
|
||||
public int getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return this.lore;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
public class Peer<E, F> {
|
||||
private final E key;
|
||||
private final F value;
|
||||
private final E key;
|
||||
private final F value;
|
||||
|
||||
public Peer(E key, F value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
public Peer(E key, F value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public E getKey() {
|
||||
return key;
|
||||
}
|
||||
public E getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public F getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
public F getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.songoda.skyblock.challenge.defaultinv;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -11,66 +10,70 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultInventory {
|
||||
private final Item defaultItem = new Item(new ItemStack(Material.AIR));
|
||||
private final int size;
|
||||
private final Item[][] items;
|
||||
private final Item defaultItem = new Item(new ItemStack(Material.AIR));
|
||||
private final int size;
|
||||
private final Item[][] items;
|
||||
|
||||
public DefaultInventory(SkyBlock plugin) {
|
||||
FileConfiguration configLoad = plugin.getChallenges();
|
||||
size = configLoad.getInt("inventory.size");
|
||||
items = new Item[9][size];
|
||||
ConfigurationSection section = configLoad.getConfigurationSection("inventory.items");
|
||||
if (section == null)
|
||||
// No items
|
||||
return;
|
||||
for (String key : section.getKeys(false)) {
|
||||
String k = "inventory.items." + key;
|
||||
int row = configLoad.getInt(k + ".row");
|
||||
int col = configLoad.getInt(k + ".col");
|
||||
String strItem = configLoad.getString(k + ".item");
|
||||
int amount = configLoad.getInt(k + ".amount");
|
||||
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);
|
||||
if (material == null || material == CompatibleMaterial.AIR) {
|
||||
Bukkit.getLogger().warning("Item " + strItem + " is not a Material");
|
||||
continue;
|
||||
}
|
||||
public DefaultInventory(SkyBlock plugin) {
|
||||
FileConfiguration configLoad = plugin.getChallenges();
|
||||
this.size = configLoad.getInt("inventory.size");
|
||||
this.items = new Item[9][this.size];
|
||||
ConfigurationSection section = configLoad.getConfigurationSection("inventory.items");
|
||||
if (section == null)
|
||||
// No items
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (String key : section.getKeys(false)) {
|
||||
String k = "inventory.items." + key;
|
||||
int row = configLoad.getInt(k + ".row");
|
||||
int col = configLoad.getInt(k + ".col");
|
||||
String strItem = configLoad.getString(k + ".item");
|
||||
int amount = configLoad.getInt(k + ".amount");
|
||||
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);
|
||||
if (material == null || material == CompatibleMaterial.AIR) {
|
||||
Bukkit.getLogger().warning("Item " + strItem + " is not a Material");
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack is = material.getItem();
|
||||
is.setAmount(amount);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(name);
|
||||
im.setLore(lore);
|
||||
is.setItemMeta(im);
|
||||
items[col - 1][row - 1] = new Item(is, redirect);
|
||||
}
|
||||
}
|
||||
ItemStack is = material.getItem();
|
||||
is.setAmount(amount);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(name);
|
||||
im.setLore(lore);
|
||||
is.setItemMeta(im);
|
||||
this.items[col - 1][row - 1] = new Item(is, redirect);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> toColor(List<String> list) {
|
||||
List<String> copy = new ArrayList<>();
|
||||
if (list == null)
|
||||
return copy;
|
||||
for (String str : list)
|
||||
copy.add(ChatColor.translateAlternateColorCodes('&', str));
|
||||
return copy;
|
||||
}
|
||||
private List<String> toColor(List<String> list) {
|
||||
List<String> copy = new ArrayList<>();
|
||||
if (list == null) {
|
||||
return copy;
|
||||
}
|
||||
for (String str : list) {
|
||||
copy.add(ChatColor.translateAlternateColorCodes('&', str));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
public Item get(int row, int col) {
|
||||
Item is = items[col][row];
|
||||
if (is == null)
|
||||
is = defaultItem;
|
||||
// Clone it
|
||||
return new Item(is.getItemStack().clone(), is.getRedirect());
|
||||
}
|
||||
public Item get(int row, int col) {
|
||||
Item is = this.items[col][row];
|
||||
if (is == null) {
|
||||
is = this.defaultItem;
|
||||
}
|
||||
// Clone it
|
||||
return new Item(is.getItemStack().clone(), is.getRedirect());
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
|
@ -3,23 +3,23 @@ package com.songoda.skyblock.challenge.defaultinv;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Item {
|
||||
private final ItemStack itemStack;
|
||||
private final int redirect;
|
||||
private final ItemStack itemStack;
|
||||
private final int redirect;
|
||||
|
||||
public Item(ItemStack itemStack) {
|
||||
this(itemStack, 0);
|
||||
}
|
||||
public Item(ItemStack itemStack) {
|
||||
this(itemStack, 0);
|
||||
}
|
||||
|
||||
public Item(ItemStack itemStack, int redirect) {
|
||||
this.itemStack = itemStack;
|
||||
this.redirect = redirect;
|
||||
}
|
||||
public Item(ItemStack itemStack, int redirect) {
|
||||
this.itemStack = itemStack;
|
||||
this.redirect = redirect;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
public int getRedirect() {
|
||||
return redirect;
|
||||
}
|
||||
public int getRedirect() {
|
||||
return this.redirect;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
@ -9,32 +9,32 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClickableItem {
|
||||
private final ItemStack item;
|
||||
private final Consumer<InventoryClickEvent> event;
|
||||
private final ItemStack item;
|
||||
private final Consumer<InventoryClickEvent> event;
|
||||
|
||||
private ClickableItem(ItemStack item, Consumer<InventoryClickEvent> event) {
|
||||
this.item = item;
|
||||
this.event = event;
|
||||
}
|
||||
private ClickableItem(ItemStack item, Consumer<InventoryClickEvent> event) {
|
||||
this.item = item;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public void run(InventoryClickEvent e) {
|
||||
event.accept(e);
|
||||
}
|
||||
public void run(InventoryClickEvent e) {
|
||||
this.event.accept(e);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Consumer<InventoryClickEvent> getEvent() {
|
||||
return event;
|
||||
}
|
||||
public ItemStack getItemStack() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public static ClickableItem of(ItemStack is) {
|
||||
return new ClickableItem(is, e -> {
|
||||
});
|
||||
}
|
||||
public Consumer<InventoryClickEvent> getEvent() {
|
||||
return this.event;
|
||||
}
|
||||
|
||||
public static ClickableItem of(ItemStack is, Consumer<InventoryClickEvent> event) {
|
||||
return new ClickableItem(is, event);
|
||||
}
|
||||
public static ClickableItem of(ItemStack is) {
|
||||
return new ClickableItem(is, e -> {
|
||||
});
|
||||
}
|
||||
|
||||
public static ClickableItem of(ItemStack is, Consumer<InventoryClickEvent> event) {
|
||||
return new ClickableItem(is, event);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
@ -13,195 +13,231 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Inventory {
|
||||
public static final String TICK = "tick";
|
||||
private final HashMap<String, Object> values;
|
||||
private final Player player;
|
||||
private final InventoryProvider inventoryProvider;
|
||||
private final int size;
|
||||
public static final String TICK = "tick";
|
||||
private final HashMap<String, Object> values;
|
||||
private final Player player;
|
||||
private final InventoryProvider inventoryProvider;
|
||||
private final int size;
|
||||
|
||||
private final List<Integer> excluseCases;
|
||||
private final ClickableItem[] items;
|
||||
private final 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<>();
|
||||
this.player = player;
|
||||
this.inventoryProvider = inventoryProvider;
|
||||
params.accept(this);
|
||||
this.excluseCases = inventoryProvider.excluseCases(this);
|
||||
this.size = inventoryProvider.rows(this);
|
||||
this.items = new ClickableItem[9 * size];
|
||||
this.bukkitInventory = Bukkit.createInventory(player, size * 9, inventoryProvider.title(this));
|
||||
put(TICK, 0);
|
||||
}
|
||||
public Inventory(Player player, InventoryProvider inventoryProvider, Consumer<Inventory> params) {
|
||||
this.values = new HashMap<>();
|
||||
this.player = player;
|
||||
this.inventoryProvider = inventoryProvider;
|
||||
params.accept(this);
|
||||
this.excluseCases = inventoryProvider.excluseCases(this);
|
||||
this.size = inventoryProvider.rows(this);
|
||||
this.items = new ClickableItem[9 * this.size];
|
||||
this.bukkitInventory = Bukkit.createInventory(player, this.size * 9, inventoryProvider.title(this));
|
||||
put(TICK, 0);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public InventoryProvider getInventoryProvider() {
|
||||
return inventoryProvider;
|
||||
}
|
||||
public InventoryProvider getInventoryProvider() {
|
||||
return this.inventoryProvider;
|
||||
}
|
||||
|
||||
public org.bukkit.inventory.Inventory getBukkitInventory() {
|
||||
return bukkitInventory;
|
||||
}
|
||||
public org.bukkit.inventory.Inventory getBukkitInventory() {
|
||||
return this.bukkitInventory;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
return size;
|
||||
}
|
||||
public int getRows() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public List<Integer> getExcludeCases() {
|
||||
return excluseCases;
|
||||
}
|
||||
public List<Integer> getExcludeCases() {
|
||||
return this.excluseCases;
|
||||
}
|
||||
|
||||
public void set(int col, int row, ClickableItem item) {
|
||||
if (col < 1 || col > 9)
|
||||
throw new IllegalArgumentException("col must be between 1 and 9 but is " + col);
|
||||
if (row < 1 || row > getRows())
|
||||
throw new IllegalArgumentException("row must be between 1 and " + getRows());
|
||||
set(locToPos(col, row), item);
|
||||
}
|
||||
public void set(int col, int row, ClickableItem item) {
|
||||
if (col < 1 || col > 9) {
|
||||
throw new IllegalArgumentException("col must be between 1 and 9 but is " + col);
|
||||
}
|
||||
if (row < 1 || row > getRows()) {
|
||||
throw new IllegalArgumentException("row must be between 1 and " + getRows());
|
||||
}
|
||||
|
||||
public void set(int pos, ClickableItem item) {
|
||||
if (pos < 0 || pos > size * 9 - 1)
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (size * 9 - 1) + ", but is " + pos);
|
||||
items[pos] = item;
|
||||
bukkitInventory.setItem(pos, item == null ? null : item.getItemStack());
|
||||
}
|
||||
set(locToPos(col, row), item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the item but keep the old event
|
||||
*/
|
||||
public void updateItem(int col, int row, ItemStack is) {
|
||||
if (col < 1 || col > 9)
|
||||
throw new IllegalArgumentException("col must be between 1 and 9 but is " + col);
|
||||
if (row < 1 || row > getRows())
|
||||
throw new IllegalArgumentException("row must be between 1 and " + getRows());
|
||||
updateItem(locToPos(col, row), is);
|
||||
}
|
||||
public void set(int pos, ClickableItem item) {
|
||||
if (pos < 0 || pos > this.size * 9 - 1) {
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (this.size * 9 - 1) + ", but is " + pos);
|
||||
}
|
||||
this.items[pos] = item;
|
||||
this.bukkitInventory.setItem(pos, item == null ? null : item.getItemStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the item but keep the old event
|
||||
*/
|
||||
public void updateItem(int pos, ItemStack is) {
|
||||
if (pos < 0 || pos > size * 9 - 1)
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (size * 9 - 1) + ", but is " + pos);
|
||||
ClickableItem item = items[pos];
|
||||
if (item == null)
|
||||
item = ClickableItem.of(is);
|
||||
else
|
||||
item = ClickableItem.of(is, item.getEvent());
|
||||
set(pos, item);
|
||||
}
|
||||
/**
|
||||
* Update the item but keep the old event
|
||||
*/
|
||||
public void updateItem(int col, int row, ItemStack is) {
|
||||
if (col < 1 || col > 9) {
|
||||
throw new IllegalArgumentException("col must be between 1 and 9 but is " + col);
|
||||
}
|
||||
if (row < 1 || row > getRows()) {
|
||||
throw new IllegalArgumentException("row must be between 1 and " + getRows());
|
||||
}
|
||||
updateItem(locToPos(col, row), is);
|
||||
}
|
||||
|
||||
public void fill(ClickableItem item) {
|
||||
for (int row = 0; row < size; row++)
|
||||
for (int col = 0; col < 9; col++)
|
||||
set(row * 9 + col, item);
|
||||
}
|
||||
/**
|
||||
* Update the item but keep the old event
|
||||
*/
|
||||
public void updateItem(int pos, ItemStack is) {
|
||||
if (pos < 0 || pos > this.size * 9 - 1) {
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (this.size * 9 - 1) + ", but is " + pos);
|
||||
}
|
||||
ClickableItem item = this.items[pos];
|
||||
if (item == null) {
|
||||
item = ClickableItem.of(is);
|
||||
} else {
|
||||
item = ClickableItem.of(is, item.getEvent());
|
||||
}
|
||||
set(pos, item);
|
||||
}
|
||||
|
||||
public void rectangle(int col, int row, int width, int height, ClickableItem item) {
|
||||
if (col < 1 || col > 9)
|
||||
throw new IllegalArgumentException("col must be between 1 and 9");
|
||||
if (row < 1 || row > getRows())
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col)
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
if (height < 1 || height > getRows() + 1 - row)
|
||||
throw new IllegalArgumentException("The height must be between 1 and " + (getRows() + 1 - row));
|
||||
rectangle(locToPos(col, row), width, height, item);
|
||||
}
|
||||
public void fill(ClickableItem item) {
|
||||
for (int row = 0; row < this.size; row++) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
set(row * 9 + col, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rectangle(int pos, int width, int height, ClickableItem item) {
|
||||
if (pos < 0 || pos > size * 9)
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (size * 9) + ", but is " + pos);
|
||||
int[] colRow = posToLoc(pos);
|
||||
int row = colRow[0];
|
||||
int col = colRow[1];
|
||||
if (col < 1 || col > 9)
|
||||
throw new IllegalArgumentException("col must be between 1 and 9, but is " + col);
|
||||
if (row < 1 || row > 6)
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col)
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
if (height < 1 || height > getRows() + 1 - row)
|
||||
throw new IllegalArgumentException(
|
||||
"The height must be between 1 and " + (getRows() + 1 - row) + ", but is " + height);
|
||||
for (int i = col; i < col + width; i++)
|
||||
for (int j = row; j < row + height; j++)
|
||||
// Around
|
||||
if (i == col || i == col + width - 1 || j == row || j == row + height - 1)
|
||||
set(i, j, item);
|
||||
}
|
||||
public void rectangle(int col, int row, int width, int height, ClickableItem item) {
|
||||
if (col < 1 || col > 9) {
|
||||
throw new IllegalArgumentException("col must be between 1 and 9");
|
||||
}
|
||||
if (row < 1 || row > getRows()) {
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
}
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col) {
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
}
|
||||
if (height < 1 || height > getRows() + 1 - row) {
|
||||
throw new IllegalArgumentException("The height must be between 1 and " + (getRows() + 1 - row));
|
||||
}
|
||||
rectangle(locToPos(col, row), width, height, item);
|
||||
}
|
||||
|
||||
public void fillRectangle(int col, int row, int width, int height, ClickableItem item) {
|
||||
if (col < 1 || col > 9)
|
||||
throw new IllegalArgumentException("col must be between 1 and 9, but is " + col);
|
||||
if (row < 1 || row > 6)
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col)
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
if (height < 1 || height > getRows() + 1 - row)
|
||||
throw new IllegalArgumentException(
|
||||
"The height must be between 1 and " + (getRows() + 1 - row) + ", but is " + height);
|
||||
fillRectangle(locToPos(col, row), width, height, item);
|
||||
}
|
||||
public void rectangle(int pos, int width, int height, ClickableItem item) {
|
||||
if (pos < 0 || pos > this.size * 9) {
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (this.size * 9) + ", but is " + pos);
|
||||
}
|
||||
int[] colRow = posToLoc(pos);
|
||||
int row = colRow[0];
|
||||
int col = colRow[1];
|
||||
if (col < 1 || col > 9) {
|
||||
throw new IllegalArgumentException("col must be between 1 and 9, but is " + col);
|
||||
}
|
||||
if (row < 1 || row > 6) {
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
}
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col) {
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
}
|
||||
if (height < 1 || height > getRows() + 1 - row) {
|
||||
throw new IllegalArgumentException(
|
||||
"The height must be between 1 and " + (getRows() + 1 - row) + ", but is " + height);
|
||||
}
|
||||
for (int i = col; i < col + width; i++) {
|
||||
for (int j = row; j < row + height; j++)
|
||||
// Around
|
||||
{
|
||||
if (i == col || i == col + width - 1 || j == row || j == row + height - 1) {
|
||||
set(i, j, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fillRectangle(int pos, int width, int height, ClickableItem item) {
|
||||
if (pos < 0 || pos > size * 9)
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (size * 9) + ", but is " + pos);
|
||||
int[] colRow = posToLoc(pos);
|
||||
int row = colRow[0];
|
||||
int col = colRow[1];
|
||||
public void fillRectangle(int col, int row, int width, int height, ClickableItem item) {
|
||||
if (col < 1 || col > 9) {
|
||||
throw new IllegalArgumentException("col must be between 1 and 9, but is " + col);
|
||||
}
|
||||
if (row < 1 || row > 6) {
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
}
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col) {
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
}
|
||||
if (height < 1 || height > getRows() + 1 - row) {
|
||||
throw new IllegalArgumentException(
|
||||
"The height must be between 1 and " + (getRows() + 1 - row) + ", but is " + height);
|
||||
}
|
||||
|
||||
if (col < 1 || col > 9)
|
||||
throw new IllegalArgumentException("col must be between 1 and 9, but is " + col);
|
||||
if (row < 1 || row > 6)
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col)
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
if (height < 1 || height > getRows() + 1 - row)
|
||||
throw new IllegalArgumentException(
|
||||
"The height must be between 1 and " + (getRows() + 1 - row) + ", but is " + height);
|
||||
for (int i = col; i < col + width; i++)
|
||||
for (int j = row; j < row + height; j++)
|
||||
set(i, j, item);
|
||||
}
|
||||
fillRectangle(locToPos(col, row), width, height, item);
|
||||
}
|
||||
|
||||
public void open() {
|
||||
player.openInventory(bukkitInventory);
|
||||
}
|
||||
public void fillRectangle(int pos, int width, int height, ClickableItem item) {
|
||||
if (pos < 0 || pos > this.size * 9) {
|
||||
throw new IllegalArgumentException("pos must be between 0 and " + (this.size * 9) + ", but is " + pos);
|
||||
}
|
||||
int[] colRow = posToLoc(pos);
|
||||
int row = colRow[0];
|
||||
int col = colRow[1];
|
||||
|
||||
public void handler(InventoryClickEvent e) {
|
||||
int pos = e.getSlot();
|
||||
if (pos < 0 || pos > items.length)
|
||||
return;
|
||||
ClickableItem item = items[pos];
|
||||
if (item == null) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
item.run(e);
|
||||
}
|
||||
if (col < 1 || col > 9) {
|
||||
throw new IllegalArgumentException("col must be between 1 and 9, but is " + col);
|
||||
}
|
||||
if (row < 1 || row > 6) {
|
||||
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows, but is " + row);
|
||||
}
|
||||
// 10 - col because width starts with 1 and not 0
|
||||
if (width < 1 || width > 10 - col) {
|
||||
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col) + ", but is " + width);
|
||||
}
|
||||
if (height < 1 || height > getRows() + 1 - row) {
|
||||
throw new IllegalArgumentException(
|
||||
"The height must be between 1 and " + (getRows() + 1 - row) + ", but is " + height);
|
||||
}
|
||||
for (int i = col; i < col + width; i++) {
|
||||
for (int j = row; j < row + height; j++) {
|
||||
set(i, j, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String key, Object value) {
|
||||
values.put(key, value);
|
||||
}
|
||||
public void open() {
|
||||
this.player.openInventory(this.bukkitInventory);
|
||||
}
|
||||
|
||||
public Object get(String key) {
|
||||
return values.get(key);
|
||||
}
|
||||
public void handler(InventoryClickEvent e) {
|
||||
int pos = e.getSlot();
|
||||
if (pos < 0 || pos > this.items.length) {
|
||||
return;
|
||||
}
|
||||
ClickableItem item = this.items[pos];
|
||||
if (item == null) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
item.run(e);
|
||||
}
|
||||
|
||||
public int[] posToLoc(int pos) {
|
||||
return new int[] { (pos / 9) + 1, (pos % 9) + 1 };
|
||||
}
|
||||
public void put(String key, Object value) {
|
||||
this.values.put(key, value);
|
||||
}
|
||||
|
||||
public int locToPos(int col, int row) {
|
||||
return (row - 1) * 9 + (col - 1);
|
||||
}
|
||||
public Object get(String key) {
|
||||
return this.values.get(key);
|
||||
}
|
||||
|
||||
public int[] posToLoc(int pos) {
|
||||
return new int[]{(pos / 9) + 1, (pos % 9) + 1};
|
||||
}
|
||||
|
||||
public int locToPos(int col, int row) {
|
||||
return (row - 1) * 9 + (col - 1);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
@ -20,104 +20,114 @@ import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class InventoryManager implements Listener {
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<UUID, Inventory> inventories;
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<UUID, Inventory> inventories;
|
||||
|
||||
public InventoryManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.inventories = new HashMap<>();
|
||||
}
|
||||
public InventoryManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.inventories = new HashMap<>();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
if (inventories.size() == 0)
|
||||
return;
|
||||
for (Inventory inv : inventories.values()) {
|
||||
int tick = 0;
|
||||
Object currentTick = inv.get(Inventory.TICK);
|
||||
if (currentTick != null && currentTick instanceof Integer)
|
||||
tick = Integer.parseInt(currentTick.toString());
|
||||
inv.put(Inventory.TICK, tick + 1);
|
||||
inv.getInventoryProvider().update(inv);
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
public void init() {
|
||||
Bukkit.getPluginManager().registerEvents(this, this.plugin);
|
||||
int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, () -> {
|
||||
if (this.inventories.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (Inventory inv : this.inventories.values()) {
|
||||
int tick = 0;
|
||||
Object currentTick = inv.get(Inventory.TICK);
|
||||
if (currentTick instanceof Integer) {
|
||||
tick = Integer.parseInt(currentTick.toString());
|
||||
}
|
||||
inv.put(Inventory.TICK, tick + 1);
|
||||
inv.getInventoryProvider().update(inv);
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public Inventory openInventory(InventoryProvider provider, Player p) {
|
||||
return openInventory(provider, p, null);
|
||||
}
|
||||
public Inventory openInventory(InventoryProvider provider, Player p) {
|
||||
return openInventory(provider, p, null);
|
||||
}
|
||||
|
||||
public Inventory openInventory(InventoryProvider provider, Player p, Consumer<Inventory> params) {
|
||||
Inventory inv = new Inventory(p, provider, params);
|
||||
inv.getInventoryProvider().init(inv);
|
||||
inventories.put(inv.getPlayer().getUniqueId(), inv);
|
||||
inv.open();
|
||||
return inv;
|
||||
}
|
||||
public Inventory openInventory(InventoryProvider provider, Player p, Consumer<Inventory> params) {
|
||||
Inventory inv = new Inventory(p, provider, params);
|
||||
inv.getInventoryProvider().init(inv);
|
||||
this.inventories.put(inv.getPlayer().getUniqueId(), inv);
|
||||
inv.open();
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory getInventory(Player p) {
|
||||
return inventories.get(p.getUniqueId());
|
||||
}
|
||||
public Inventory getInventory(Player p) {
|
||||
return this.inventories.get(p.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean hasInventoryOpened(Player p) {
|
||||
return inventories.containsKey(p.getUniqueId());
|
||||
}
|
||||
public boolean hasInventoryOpened(Player p) {
|
||||
return this.inventories.containsKey(p.getUniqueId());
|
||||
}
|
||||
|
||||
public void closeInventory(Player p) {
|
||||
p.closeInventory();
|
||||
}
|
||||
public void closeInventory(Player p) {
|
||||
p.closeInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all inventories
|
||||
*/
|
||||
public void closeInventories() {
|
||||
// New ArrayList to prevent CurrentModificationException
|
||||
for (Inventory inv : new ArrayList<>(inventories.values()))
|
||||
closeInventory(inv.getPlayer());
|
||||
inventories.clear();
|
||||
}
|
||||
/**
|
||||
* Close all inventories
|
||||
*/
|
||||
public void closeInventories() {
|
||||
// New ArrayList to prevent CurrentModificationException
|
||||
for (Inventory inv : new ArrayList<>(this.inventories.values())) {
|
||||
closeInventory(inv.getPlayer());
|
||||
}
|
||||
this.inventories.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInventoryClick(InventoryClickEvent e) {
|
||||
org.bukkit.inventory.Inventory clickedInventory = e.getClickedInventory();
|
||||
if (clickedInventory == null)
|
||||
return;
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
Inventory inv = getInventory(p);
|
||||
if (inv == null)
|
||||
return;
|
||||
if (e.getAction() == InventoryAction.COLLECT_TO_CURSOR) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (e.getRawSlot() >= e.getInventory().getSize() && !e.isShiftClick())
|
||||
return;
|
||||
if (inv.getExcludeCases() == null || !inv.getExcludeCases().contains(e.getSlot()))
|
||||
e.setCancelled(true);
|
||||
if (!inv.getBukkitInventory().equals(clickedInventory)) {
|
||||
// The player doesn't click on the correct inventory
|
||||
return;
|
||||
}
|
||||
inv.handler(e);
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerInventoryClick(InventoryClickEvent e) {
|
||||
org.bukkit.inventory.Inventory clickedInventory = e.getClickedInventory();
|
||||
if (clickedInventory == null) {
|
||||
return;
|
||||
}
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
Inventory inv = getInventory(p);
|
||||
if (inv == null) {
|
||||
return;
|
||||
}
|
||||
if (e.getAction() == InventoryAction.COLLECT_TO_CURSOR) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (e.getRawSlot() >= e.getInventory().getSize() && !e.isShiftClick()) {
|
||||
return;
|
||||
}
|
||||
if (inv.getExcludeCases() == null || !inv.getExcludeCases().contains(e.getSlot())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (!inv.getBukkitInventory().equals(clickedInventory)) {
|
||||
// The player doesn't click on the correct inventory
|
||||
return;
|
||||
}
|
||||
inv.handler(e);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInventoryDrag(InventoryDragEvent e) {
|
||||
if (!inventories.containsKey(e.getWhoClicked().getUniqueId()))
|
||||
return;
|
||||
e.setCancelled(false);
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerInventoryDrag(InventoryDragEvent e) {
|
||||
if (!this.inventories.containsKey(e.getWhoClicked().getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInventoryClose(InventoryCloseEvent e) {
|
||||
if (!inventories.containsKey(e.getPlayer().getUniqueId()))
|
||||
return;
|
||||
org.bukkit.inventory.Inventory invopen = e.getInventory();
|
||||
Inventory inv = inventories.get(e.getPlayer().getUniqueId());
|
||||
if (!inv.getBukkitInventory().equals(invopen))
|
||||
return;
|
||||
inv.getInventoryProvider().onClose(e, inv);
|
||||
inventories.remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInventoryClose(InventoryCloseEvent e) {
|
||||
if (!this.inventories.containsKey(e.getPlayer().getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
org.bukkit.inventory.Inventory invopen = e.getInventory();
|
||||
Inventory inv = this.inventories.get(e.getPlayer().getUniqueId());
|
||||
if (!inv.getBukkitInventory().equals(invopen)) {
|
||||
return;
|
||||
}
|
||||
inv.getInventoryProvider().onClose(e, inv);
|
||||
this.inventories.remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
@ -9,19 +9,18 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public interface InventoryProvider {
|
||||
String title(Inventory inv);
|
||||
|
||||
String title(Inventory inv);
|
||||
int rows(Inventory inv);
|
||||
|
||||
int rows(Inventory inv);
|
||||
void init(Inventory inv);
|
||||
|
||||
void init(Inventory inv);
|
||||
void update(Inventory inv);
|
||||
|
||||
void update(Inventory inv);
|
||||
default List<Integer> excluseCases(Inventory inv) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
default List<Integer> excluseCases(Inventory inv) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
default void onClose(InventoryCloseEvent e, Inventory inv) {
|
||||
}
|
||||
default void onClose(InventoryCloseEvent e, Inventory inv) {
|
||||
}
|
||||
}
|
||||
|
@ -23,101 +23,107 @@ import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChallengeInventory implements InventoryProvider {
|
||||
public static final String CATEGORY = "ChallengeCategory";
|
||||
private final FabledChallenge fc;
|
||||
|
||||
public ChallengeInventory(FabledChallenge fc) {
|
||||
this.fc = fc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String title(Inventory inv) {
|
||||
ChallengeCategory category = (ChallengeCategory) inv.get(CATEGORY);
|
||||
return category.getName();
|
||||
}
|
||||
public static final String CATEGORY = "ChallengeCategory";
|
||||
private final FabledChallenge fc;
|
||||
|
||||
@Override
|
||||
public int rows(Inventory inv) {
|
||||
return fc.getDefaultInventory().getSize();
|
||||
}
|
||||
public ChallengeInventory(FabledChallenge fc) {
|
||||
this.fc = fc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Inventory inv) {
|
||||
try {
|
||||
// Initialize the inventory
|
||||
ChallengeCategory category = (ChallengeCategory) inv.get(CATEGORY);
|
||||
HashMap<Challenge, Integer> done = fc.getPlayerManager()
|
||||
.getPlayer(inv.getPlayer().getUniqueId());
|
||||
if (done == null) {
|
||||
// How is that possible
|
||||
return;
|
||||
}
|
||||
// Set background
|
||||
DefaultInventory di = fc.getDefaultInventory();
|
||||
for (int row = 0; row < di.getSize(); row++)
|
||||
for (int col = 0; col < 9; col++) {
|
||||
Item item = di.get(row, col);
|
||||
inv.set(col + 1, row + 1, ClickableItem.of(item.getItemStack(), e -> {
|
||||
if (item.getRedirect() != 0) {
|
||||
ChallengeCategory cat = fc.getChallengeManager()
|
||||
.getChallenge(item.getRedirect());
|
||||
if (cat != null) {
|
||||
// Open inventory
|
||||
fc.openChallengeInventory(inv.getPlayer(), cat);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
// Set challenges
|
||||
for (Challenge c : category.getChallenges().values()) {
|
||||
ItemChallenge ic = c.getItem();
|
||||
if (!ic.isShow())
|
||||
continue;
|
||||
int count = done.getOrDefault(c, 0);
|
||||
ItemStack is = ic.createItem(inv.getPlayer().getUniqueId(), count);
|
||||
// If challenge is done, add enchantment to show to player that it's done
|
||||
if (count >= c.getMaxTimes())
|
||||
is.addUnsafeEnchantment(Enchantment.OXYGEN, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
is.setItemMeta(im);
|
||||
@Override
|
||||
public String title(Inventory inv) {
|
||||
ChallengeCategory category = (ChallengeCategory) inv.get(CATEGORY);
|
||||
return category.getName();
|
||||
}
|
||||
|
||||
Consumer<InventoryClickEvent> consumer = e -> {
|
||||
// Count the new value
|
||||
int count2 = done.getOrDefault(c, 0);
|
||||
if (count2 >= c.getMaxTimes()) {
|
||||
// Do not continue if maxtimes has been reached
|
||||
return;
|
||||
}
|
||||
Player p = inv.getPlayer();
|
||||
if (fc.getPlayerManager().doChallenge(p, c)) {
|
||||
// Ok
|
||||
// Update count
|
||||
count2 = done.getOrDefault(c, 0);
|
||||
// Play sound
|
||||
p.playSound(p.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1, 1);
|
||||
// Update item
|
||||
ItemStack is2 = ic.createItem(inv.getPlayer().getUniqueId(), count2);
|
||||
// If challenge is done, add enchantment to show to player that it's done
|
||||
if (count2 >= c.getMaxTimes())
|
||||
is2.addUnsafeEnchantment(Enchantment.OXYGEN, 1);
|
||||
ItemMeta im2 = is2.getItemMeta();
|
||||
im2.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
is2.setItemMeta(im2);
|
||||
// Update
|
||||
inv.updateItem(ic.getCol(), ic.getRow(), is2);
|
||||
} else
|
||||
p.playSound(p.getLocation(), CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1, 1);
|
||||
};
|
||||
inv.set(ic.getCol(), ic.getRow(), ClickableItem.of(is, consumer));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "", ex);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int rows(Inventory inv) {
|
||||
return this.fc.getDefaultInventory().getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Inventory inv) {
|
||||
// Nothing to update here
|
||||
}
|
||||
@Override
|
||||
public void init(Inventory inv) {
|
||||
try {
|
||||
// Initialize the inventory
|
||||
ChallengeCategory category = (ChallengeCategory) inv.get(CATEGORY);
|
||||
HashMap<Challenge, Integer> done = this.fc.getPlayerManager()
|
||||
.getPlayer(inv.getPlayer().getUniqueId());
|
||||
if (done == null) {
|
||||
// How is that possible
|
||||
return;
|
||||
}
|
||||
// Set background
|
||||
DefaultInventory di = this.fc.getDefaultInventory();
|
||||
for (int row = 0; row < di.getSize(); row++) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
Item item = di.get(row, col);
|
||||
inv.set(col + 1, row + 1, ClickableItem.of(item.getItemStack(), e -> {
|
||||
if (item.getRedirect() != 0) {
|
||||
ChallengeCategory cat = this.fc.getChallengeManager()
|
||||
.getChallenge(item.getRedirect());
|
||||
if (cat != null) {
|
||||
// Open inventory
|
||||
this.fc.openChallengeInventory(inv.getPlayer(), cat);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// Set challenges
|
||||
for (Challenge c : category.getChallenges().values()) {
|
||||
ItemChallenge ic = c.getItem();
|
||||
if (!ic.isShow()) {
|
||||
continue;
|
||||
}
|
||||
int count = done.getOrDefault(c, 0);
|
||||
ItemStack is = ic.createItem(inv.getPlayer().getUniqueId(), count);
|
||||
// If challenge is done, add enchantment to show to player that it's done
|
||||
if (count >= c.getMaxTimes()) {
|
||||
is.addUnsafeEnchantment(Enchantment.OXYGEN, 1);
|
||||
}
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
is.setItemMeta(im);
|
||||
|
||||
Consumer<InventoryClickEvent> consumer = e -> {
|
||||
// Count the new value
|
||||
int count2 = done.getOrDefault(c, 0);
|
||||
if (count2 >= c.getMaxTimes()) {
|
||||
// Do not continue if maxtimes has been reached
|
||||
return;
|
||||
}
|
||||
Player p = inv.getPlayer();
|
||||
if (this.fc.getPlayerManager().doChallenge(p, c)) {
|
||||
// Ok
|
||||
// Update count
|
||||
count2 = done.getOrDefault(c, 0);
|
||||
// Play sound
|
||||
p.playSound(p.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1, 1);
|
||||
// Update item
|
||||
ItemStack is2 = ic.createItem(inv.getPlayer().getUniqueId(), count2);
|
||||
// If challenge is done, add enchantment to show to player that it's done
|
||||
if (count2 >= c.getMaxTimes()) {
|
||||
is2.addUnsafeEnchantment(Enchantment.OXYGEN, 1);
|
||||
}
|
||||
ItemMeta im2 = is2.getItemMeta();
|
||||
im2.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
is2.setItemMeta(im2);
|
||||
// Update
|
||||
inv.updateItem(ic.getCol(), ic.getRow(), is2);
|
||||
} else {
|
||||
p.playSound(p.getLocation(), CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1, 1);
|
||||
}
|
||||
};
|
||||
inv.set(ic.getCol(), ic.getRow(), ClickableItem.of(is, consumer));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Inventory inv) {
|
||||
// Nothing to update here
|
||||
}
|
||||
}
|
||||
|
@ -6,19 +6,19 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerChallenge {
|
||||
private final UUID uuid;
|
||||
private final 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;
|
||||
this.challenges = challenges;
|
||||
}
|
||||
public PlayerChallenge(UUID uuid, HashMap<Challenge, Integer> challenges) {
|
||||
this.uuid = uuid;
|
||||
this.challenges = challenges;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public HashMap<Challenge, Integer> getChallenges() {
|
||||
return challenges;
|
||||
}
|
||||
public HashMap<Challenge, Integer> getChallenges() {
|
||||
return this.challenges;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.songoda.skyblock.challenge.challenge.Peer;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -24,240 +23,235 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerManager {
|
||||
private final SkyBlock plugin;
|
||||
private final HashMap<UUID, HashMap<Challenge, Integer>> islands;
|
||||
private final 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;
|
||||
islands = new HashMap<>();
|
||||
playersDirectory = new File(plugin.getDataFolder(), "challenge-data");
|
||||
if (!playersDirectory.exists())
|
||||
playersDirectory.mkdirs();
|
||||
public PlayerManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.islands = new HashMap<>();
|
||||
this.playersDirectory = new File(plugin.getDataFolder(), "challenge-data");
|
||||
if (!this.playersDirectory.exists()) {
|
||||
this.playersDirectory.mkdirs();
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
Bukkit.getServer().getOnlinePlayers().stream().map(Entity::getUniqueId).forEach(this::loadPlayer);
|
||||
});
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
Bukkit.getServer().getOnlinePlayers().stream().map(Entity::getUniqueId).forEach(this::loadPlayer);
|
||||
});
|
||||
}
|
||||
|
||||
public HashMap<Challenge, Integer> getPlayer(UUID uuid) {
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
player = Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
Island is = plugin.getIslandManager().getIsland(player);
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
return islands.get(uuid);
|
||||
}
|
||||
public HashMap<Challenge, Integer> getPlayer(UUID uuid) {
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) {
|
||||
player = Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
Island is = this.plugin.getIslandManager().getIsland(player);
|
||||
if (is != null) {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
return this.islands.get(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load specific player
|
||||
*
|
||||
* @param uuid
|
||||
* The uuid of specific player
|
||||
*/
|
||||
public void loadPlayer(UUID uuid) {
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = plugin.getFileManager().getConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
HashMap<Challenge, Integer> challenges = new HashMap<>();
|
||||
ConfigurationSection section = fileConfig.getConfigurationSection("challenges");
|
||||
Set<String> strs = (section != null) ? section.getKeys(false) : new HashSet<>();
|
||||
for (String k : strs) {
|
||||
int id = fileConfig.getInt("challenges." + k + ".id");
|
||||
ChallengeCategory cc = plugin.getFabledChallenge().getChallengeManager().getChallenge(id);
|
||||
// WTF
|
||||
if (cc == null)
|
||||
continue;
|
||||
ConfigurationSection section2 = fileConfig.getConfigurationSection("challenges." + k + ".challenges");
|
||||
if (section2 != null)
|
||||
for (String d : section2.getKeys(false)) {
|
||||
String key = "challenges." + k + ".challenges." + d;
|
||||
int cId = fileConfig.getInt(key + ".id");
|
||||
int count = fileConfig.getInt(key + ".count");
|
||||
Challenge c = cc.getChallenge(cId);
|
||||
if (c == null)
|
||||
continue;
|
||||
challenges.put(c, count);
|
||||
}
|
||||
}
|
||||
islands.put(uuid, challenges);
|
||||
}
|
||||
/**
|
||||
* Load specific player
|
||||
*
|
||||
* @param uuid The uuid of specific player
|
||||
*/
|
||||
public void loadPlayer(UUID uuid) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = this.plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (is != null) {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = this.plugin.getFileManager().getConfig(new File(this.playersDirectory, FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
HashMap<Challenge, Integer> challenges = new HashMap<>();
|
||||
ConfigurationSection section = fileConfig.getConfigurationSection("challenges");
|
||||
Set<String> strs = (section != null) ? section.getKeys(false) : new HashSet<>();
|
||||
for (String k : strs) {
|
||||
int id = fileConfig.getInt("challenges." + k + ".id");
|
||||
ChallengeCategory cc = this.plugin.getFabledChallenge().getChallengeManager().getChallenge(id);
|
||||
// WTF
|
||||
if (cc == null) {
|
||||
continue;
|
||||
}
|
||||
ConfigurationSection section2 = fileConfig.getConfigurationSection("challenges." + k + ".challenges");
|
||||
if (section2 != null) {
|
||||
for (String d : section2.getKeys(false)) {
|
||||
String key = "challenges." + k + ".challenges." + d;
|
||||
int cId = fileConfig.getInt(key + ".id");
|
||||
int count = fileConfig.getInt(key + ".count");
|
||||
Challenge c = cc.getChallenge(cId);
|
||||
if (c == null) {
|
||||
continue;
|
||||
}
|
||||
challenges.put(c, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.islands.put(uuid, challenges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload specific player
|
||||
*
|
||||
* @param uuid
|
||||
* The uuid of specific player
|
||||
*/
|
||||
public void unloadPlayer(UUID uuid) {
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
player = Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
Island is = plugin.getIslandManager().getIsland(player);
|
||||
if(is != null){
|
||||
if (!plugin.getIslandManager().getMembersOnline(is).isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
islands.remove(uuid);
|
||||
plugin.getFileManager().unloadConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
/**
|
||||
* Unload specific player
|
||||
*
|
||||
* @param uuid The uuid of specific player
|
||||
*/
|
||||
public void unloadPlayer(UUID uuid) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) {
|
||||
player = Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
Island is = this.plugin.getIslandManager().getIsland(player);
|
||||
if (is != null) {
|
||||
if (!this.plugin.getIslandManager().getMembersOnline(is).isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.islands.remove(uuid);
|
||||
this.plugin.getFileManager().unloadConfig(new File(this.playersDirectory, FastUUID.toString(uuid) + ".yml"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if specific player can do specific challenge
|
||||
*
|
||||
* @param p
|
||||
* The player
|
||||
* @param c
|
||||
* The challenge
|
||||
* @return true if specific player can execute specific challenge
|
||||
*/
|
||||
public boolean canDoChallenge(Player p, Challenge c) {
|
||||
if (c == null)
|
||||
return false;
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
HashMap<Challenge, Integer> done = islands.get(uuid);
|
||||
if (done == null) {
|
||||
// Wtf ?
|
||||
loadPlayer(uuid);
|
||||
done = islands.get(uuid);
|
||||
}
|
||||
int count = done.getOrDefault(c, 0);
|
||||
if (c.getMaxTimes() != 0 && count >= c.getMaxTimes())
|
||||
return false;
|
||||
// Check if player has required items
|
||||
for (Peer<Type, Object> peer : c.getRequires())
|
||||
if (!peer.getKey().has(p, peer.getValue()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Check if a specific player can do a specific challenge
|
||||
*
|
||||
* @param p The player
|
||||
* @param c The challenge
|
||||
* @return true if a specific player can execute a specific challenge
|
||||
*/
|
||||
public boolean canDoChallenge(Player p, Challenge c) {
|
||||
if (c == null) {
|
||||
return false;
|
||||
}
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = this.plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (is != null) {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
HashMap<Challenge, Integer> done = this.islands.get(uuid);
|
||||
if (done == null) {
|
||||
// Wtf ?
|
||||
loadPlayer(uuid);
|
||||
done = this.islands.get(uuid);
|
||||
}
|
||||
int count = done.getOrDefault(c, 0);
|
||||
if (c.getMaxTimes() != 0 && count >= c.getMaxTimes()) {
|
||||
return false;
|
||||
}
|
||||
// Check if player has required items
|
||||
for (Peer<Type, Object> peer : c.getRequires()) {
|
||||
if (!peer.getKey().has(p, peer.getValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform specific challenge for specific player
|
||||
*
|
||||
* @param p
|
||||
* Specific player
|
||||
* @param c
|
||||
* Specific challenge
|
||||
* @return true if all is good
|
||||
*/
|
||||
public boolean doChallenge(Player p, Challenge c) {
|
||||
if (!canDoChallenge(p, c))
|
||||
return false;
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
HashMap<Challenge, Integer> done = islands.get(uuid);
|
||||
int count = done.getOrDefault(c, 0);
|
||||
done.put(c, count + 1);
|
||||
addChallenge(uuid, c);
|
||||
// Take items
|
||||
for (Peer<Type, Object> peer : c.getRequires()) {
|
||||
peer.getKey().executeRequire(p, peer.getValue());
|
||||
}
|
||||
for (Peer<Type, Object> peer : c.getRewards()) {
|
||||
peer.getKey().executeReward(p, peer.getValue());
|
||||
}
|
||||
// Ok, send message
|
||||
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))
|
||||
.replace("%max", Integer.toString(c.getMaxTimes())));
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Perform specific challenge for specific player
|
||||
*
|
||||
* @param p Specific player
|
||||
* @param c Specific challenge
|
||||
* @return true if all is good
|
||||
*/
|
||||
public boolean doChallenge(Player p, Challenge c) {
|
||||
if (!canDoChallenge(p, c)) {
|
||||
return false;
|
||||
}
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = this.plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (is != null) {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
HashMap<Challenge, Integer> done = this.islands.get(uuid);
|
||||
int count = done.getOrDefault(c, 0);
|
||||
done.put(c, count + 1);
|
||||
addChallenge(uuid, c);
|
||||
// Take items
|
||||
for (Peer<Type, Object> peer : c.getRequires()) {
|
||||
peer.getKey().executeRequire(p, peer.getValue());
|
||||
}
|
||||
for (Peer<Type, Object> peer : c.getRewards()) {
|
||||
peer.getKey().executeReward(p, peer.getValue());
|
||||
}
|
||||
// Ok, send message
|
||||
String broadcast = this.plugin.formatText(this.plugin.getLanguage().getString("Challenge.Broadcast"));
|
||||
if (c.isShowInChat()) {
|
||||
Bukkit.broadcastMessage(broadcast.replace("%player", p.getName()).replace("%challenge", c.getName())
|
||||
.replace("%amount", Integer.toString(count + 1))
|
||||
.replace("%max", Integer.toString(c.getMaxTimes())));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addChallenge(UUID uuid, Challenge c) {
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = plugin.getFileManager().getConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
int ccId = c.getCategory().getId();
|
||||
int cId = c.getId();
|
||||
int count = 1;
|
||||
if (fileConfig.contains("challenges." + ccId + ".challenges." + cId + ".count"))
|
||||
count = fileConfig.getInt("challenges." + ccId + ".challenges." + cId + ".count") + 1;
|
||||
fileConfig.set("challenges." + ccId + ".id", ccId);
|
||||
fileConfig.set("challenges." + ccId + ".challenges." + cId + ".id", cId);
|
||||
fileConfig.set("challenges." + ccId + ".challenges." + cId + ".count", count);
|
||||
try {
|
||||
fileConfig.save(new File(playersDirectory, FastUUID.toString(uuid) + ".yml"));
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void addChallenge(UUID uuid, Challenge c) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = this.plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (is != null) {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = this.plugin.getFileManager().getConfig(new File(this.playersDirectory, FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
int ccId = c.getCategory().getId();
|
||||
int cId = c.getId();
|
||||
int count = 1;
|
||||
if (fileConfig.contains("challenges." + ccId + ".challenges." + cId + ".count")) {
|
||||
count = fileConfig.getInt("challenges." + ccId + ".challenges." + cId + ".count") + 1;
|
||||
}
|
||||
fileConfig.set("challenges." + ccId + ".id", ccId);
|
||||
fileConfig.set("challenges." + ccId + ".challenges." + cId + ".id", cId);
|
||||
fileConfig.set("challenges." + ccId + ".challenges." + cId + ".count", count);
|
||||
try {
|
||||
fileConfig.save(new File(this.playersDirectory, FastUUID.toString(uuid) + ".yml"));
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of time specific player has done specific challenge
|
||||
*
|
||||
* @param uuid
|
||||
* The player's uuid
|
||||
* @param c
|
||||
* The challenge
|
||||
* @return The number of time specific challenge has been done by player
|
||||
*/
|
||||
public int getChallengeCount(UUID uuid, Challenge c) {
|
||||
HashMap<Challenge, Integer> challenges = islands.get(uuid);
|
||||
if (challenges != null) {
|
||||
return challenges.getOrDefault(c, 0);
|
||||
} else {
|
||||
if (this.plugin.getConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return the number of time specific player has done a specific challenge
|
||||
*
|
||||
* @param uuid The player's uuid
|
||||
* @param c The challenge
|
||||
* @return The number of time specific challenge has been done by player
|
||||
*/
|
||||
public int getChallengeCount(UUID uuid, Challenge c) {
|
||||
HashMap<Challenge, Integer> challenges = this.islands.get(uuid);
|
||||
if (challenges != null) {
|
||||
return challenges.getOrDefault(c, 0);
|
||||
} else {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = this.plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (is != null) {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
|
||||
// Not connected, check in file
|
||||
Config config = plugin.getFileManager().getConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
int ccId = c.getCategory().getId();
|
||||
int cId = c.getId();
|
||||
if (!fileConfig.contains("challenges." + ccId + ".challenges." + cId + ".count"))
|
||||
return 0;
|
||||
return fileConfig.getInt("challenges." + ccId + ".challenges." + cId + ".count");
|
||||
}
|
||||
}
|
||||
// Not connected, check in file
|
||||
Config config = this.plugin.getFileManager().getConfig(new File(this.playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
int ccId = c.getCategory().getId();
|
||||
int cId = c.getId();
|
||||
if (!fileConfig.contains("challenges." + ccId + ".challenges." + cId + ".count")) {
|
||||
return 0;
|
||||
}
|
||||
return fileConfig.getInt("challenges." + ccId + ".challenges." + cId + ".count");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,68 @@ package com.songoda.skyblock.command;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.commands.admin.*;
|
||||
import com.songoda.skyblock.command.commands.admin.AddUpgradeCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.AdminBank;
|
||||
import com.songoda.skyblock.command.commands.admin.ChatSpyCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.GeneratorCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.LevelScanCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.ProxyCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.RefreshHologramsCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.ReloadCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.RemoveHologramCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.RemoveUpgradeCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.SetAlwaysLoadedCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.SetBiomeCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.SetHologramCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.SetMaxMembers;
|
||||
import com.songoda.skyblock.command.commands.admin.SetSizeCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.StackableCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.StructureCommand;
|
||||
import com.songoda.skyblock.command.commands.admin.UpdateAllIslandsCommand;
|
||||
import com.songoda.skyblock.command.commands.island.AcceptCommand;
|
||||
import com.songoda.skyblock.command.commands.island.BanCommand;
|
||||
import com.songoda.skyblock.command.commands.island.BankCommand;
|
||||
import com.songoda.skyblock.command.commands.island.BansCommand;
|
||||
import com.songoda.skyblock.command.commands.island.BiomeCommand;
|
||||
import com.songoda.skyblock.command.commands.island.BorderCommand;
|
||||
import com.songoda.skyblock.command.commands.island.CancelCommand;
|
||||
import com.songoda.skyblock.command.commands.island.ChallengeCommand;
|
||||
import com.songoda.skyblock.command.commands.island.ChatCommand;
|
||||
import com.songoda.skyblock.command.commands.island.CloseCommand;
|
||||
import com.songoda.skyblock.command.commands.island.ConfirmCommand;
|
||||
import com.songoda.skyblock.command.commands.island.ControlPanelCommand;
|
||||
import com.songoda.skyblock.command.commands.island.CoopCommand;
|
||||
import com.songoda.skyblock.command.commands.island.CreateCommand;
|
||||
import com.songoda.skyblock.command.commands.island.CurrentCommand;
|
||||
import com.songoda.skyblock.command.commands.island.DeleteCommand;
|
||||
import com.songoda.skyblock.command.commands.island.DemoteCommand;
|
||||
import com.songoda.skyblock.command.commands.island.DenyCommand;
|
||||
import com.songoda.skyblock.command.commands.island.InformationCommand;
|
||||
import com.songoda.skyblock.command.commands.island.InviteCommand;
|
||||
import com.songoda.skyblock.command.commands.island.KickAllCommand;
|
||||
import com.songoda.skyblock.command.commands.island.KickCommand;
|
||||
import com.songoda.skyblock.command.commands.island.LeaderboardCommand;
|
||||
import com.songoda.skyblock.command.commands.island.LeaveCommand;
|
||||
import com.songoda.skyblock.command.commands.island.LevelCommand;
|
||||
import com.songoda.skyblock.command.commands.island.MembersCommand;
|
||||
import com.songoda.skyblock.command.commands.island.OpenCommand;
|
||||
import com.songoda.skyblock.command.commands.island.OwnerCommand;
|
||||
import com.songoda.skyblock.command.commands.island.PreviewCommand;
|
||||
import com.songoda.skyblock.command.commands.island.PromoteCommand;
|
||||
import com.songoda.skyblock.command.commands.island.PublicCommand;
|
||||
import com.songoda.skyblock.command.commands.island.ScoreboardCommand;
|
||||
import com.songoda.skyblock.command.commands.island.SetSpawnCommand;
|
||||
import com.songoda.skyblock.command.commands.island.SettingsCommand;
|
||||
import com.songoda.skyblock.command.commands.island.TeleportCommand;
|
||||
import com.songoda.skyblock.command.commands.island.UnbanCommand;
|
||||
import com.songoda.skyblock.command.commands.island.UnlockCommand;
|
||||
import com.songoda.skyblock.command.commands.island.UpgradeCommand;
|
||||
import com.songoda.skyblock.command.commands.island.*;
|
||||
import com.songoda.skyblock.command.commands.island.ValueCommand;
|
||||
import com.songoda.skyblock.command.commands.island.VisitCommand;
|
||||
import com.songoda.skyblock.command.commands.island.VisitorsCommand;
|
||||
import com.songoda.skyblock.command.commands.island.VoteCommand;
|
||||
import com.songoda.skyblock.command.commands.island.WeatherCommand;
|
||||
import com.songoda.skyblock.command.commands.island.WhitelistCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
@ -29,6 +82,7 @@ import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -36,7 +90,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private List<SubCommand> islandCommands;
|
||||
private List<SubCommand> adminCommands;
|
||||
@ -54,90 +107,90 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
public void registerSubCommands() {
|
||||
islandCommands = Arrays.asList(
|
||||
new AcceptCommand(),
|
||||
new BanCommand(),
|
||||
new BankCommand(),
|
||||
new BansCommand(),
|
||||
new BiomeCommand(),
|
||||
new BorderCommand(),
|
||||
new CancelCommand(),
|
||||
new ChallengeCommand(),
|
||||
new ChatCommand(),
|
||||
new CloseCommand(),
|
||||
new ConfirmCommand(),
|
||||
new ControlPanelCommand(),
|
||||
new CoopCommand(),
|
||||
new CreateCommand(),
|
||||
new CurrentCommand(),
|
||||
new DeleteCommand(),
|
||||
new DemoteCommand(),
|
||||
new DenyCommand(),
|
||||
new InformationCommand(),
|
||||
new InviteCommand(),
|
||||
new KickAllCommand(),
|
||||
new KickCommand(),
|
||||
new LeaderboardCommand(),
|
||||
new LeaveCommand(),
|
||||
new LevelCommand(),
|
||||
new MembersCommand(),
|
||||
new OpenCommand(),
|
||||
new OwnerCommand(),
|
||||
new PreviewCommand(),
|
||||
new PromoteCommand(),
|
||||
new PublicCommand(),
|
||||
new SetSpawnCommand(),
|
||||
new SettingsCommand(),
|
||||
new TeleportCommand(),
|
||||
new UnbanCommand(),
|
||||
new UnlockCommand(),
|
||||
new UpgradeCommand(),
|
||||
new ValueCommand(),
|
||||
new VisitCommand(),
|
||||
new VisitorsCommand(),
|
||||
new VoteCommand(),
|
||||
new ScoreboardCommand(),
|
||||
new WeatherCommand(),
|
||||
new WhitelistCommand()
|
||||
this.islandCommands = Arrays.asList(
|
||||
new AcceptCommand(this.plugin),
|
||||
new BanCommand(this.plugin),
|
||||
new BankCommand(this.plugin),
|
||||
new BansCommand(this.plugin),
|
||||
new BiomeCommand(this.plugin),
|
||||
new BorderCommand(this.plugin),
|
||||
new CancelCommand(this.plugin),
|
||||
new ChallengeCommand(this.plugin),
|
||||
new ChatCommand(this.plugin),
|
||||
new CloseCommand(this.plugin),
|
||||
new ConfirmCommand(this.plugin),
|
||||
new ControlPanelCommand(this.plugin),
|
||||
new CoopCommand(this.plugin),
|
||||
new CreateCommand(this.plugin),
|
||||
new CurrentCommand(this.plugin),
|
||||
new DeleteCommand(this.plugin),
|
||||
new DemoteCommand(this.plugin),
|
||||
new DenyCommand(this.plugin),
|
||||
new InformationCommand(this.plugin),
|
||||
new InviteCommand(this.plugin),
|
||||
new KickAllCommand(this.plugin),
|
||||
new KickCommand(this.plugin),
|
||||
new LeaderboardCommand(this.plugin),
|
||||
new LeaveCommand(this.plugin),
|
||||
new LevelCommand(this.plugin),
|
||||
new MembersCommand(this.plugin),
|
||||
new OpenCommand(this.plugin),
|
||||
new OwnerCommand(this.plugin),
|
||||
new PreviewCommand(this.plugin),
|
||||
new PromoteCommand(this.plugin),
|
||||
new PublicCommand(this.plugin),
|
||||
new SetSpawnCommand(this.plugin),
|
||||
new SettingsCommand(this.plugin),
|
||||
new TeleportCommand(this.plugin),
|
||||
new UnbanCommand(this.plugin),
|
||||
new UnlockCommand(this.plugin),
|
||||
new UpgradeCommand(this.plugin),
|
||||
new ValueCommand(this.plugin),
|
||||
new VisitCommand(this.plugin),
|
||||
new VisitorsCommand(this.plugin),
|
||||
new VoteCommand(this.plugin),
|
||||
new ScoreboardCommand(this.plugin),
|
||||
new WeatherCommand(this.plugin),
|
||||
new WhitelistCommand(this.plugin)
|
||||
);
|
||||
|
||||
adminCommands = Arrays.asList(
|
||||
new AddUpgradeCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.CreateCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.DeleteCommand(),
|
||||
new GeneratorCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.LevelCommand(),
|
||||
new LevelScanCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.OwnerCommand(),
|
||||
new RefreshHologramsCommand(),
|
||||
new ReloadCommand(),
|
||||
new RemoveHologramCommand(),
|
||||
new RemoveUpgradeCommand(),
|
||||
new SetBiomeCommand(),
|
||||
new SetAlwaysLoadedCommand(),
|
||||
new ProxyCommand(),
|
||||
new SetHologramCommand(),
|
||||
new SetSizeCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.SetSpawnCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.SettingsCommand(),
|
||||
new StructureCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.UpgradeCommand(),
|
||||
new StackableCommand(),
|
||||
new AdminBank(),
|
||||
new SetMaxMembers(),
|
||||
new ChatSpyCommand(),
|
||||
new UpdateAllIslandsCommand()
|
||||
this.adminCommands = Arrays.asList(
|
||||
new AddUpgradeCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.CreateCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.DeleteCommand(this.plugin),
|
||||
new GeneratorCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.LevelCommand(this.plugin),
|
||||
new LevelScanCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.OwnerCommand(this.plugin),
|
||||
new RefreshHologramsCommand(this.plugin),
|
||||
new ReloadCommand(this.plugin),
|
||||
new RemoveHologramCommand(this.plugin),
|
||||
new RemoveUpgradeCommand(this.plugin),
|
||||
new SetBiomeCommand(this.plugin),
|
||||
new SetAlwaysLoadedCommand(this.plugin),
|
||||
new ProxyCommand(this.plugin),
|
||||
new SetHologramCommand(this.plugin),
|
||||
new SetSizeCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.SetSpawnCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.SettingsCommand(this.plugin),
|
||||
new StructureCommand(this.plugin),
|
||||
new com.songoda.skyblock.command.commands.admin.UpgradeCommand(this.plugin),
|
||||
new StackableCommand(this.plugin),
|
||||
new AdminBank(this.plugin),
|
||||
new SetMaxMembers(this.plugin),
|
||||
new ChatSpyCommand(this.plugin),
|
||||
new UpdateAllIslandsCommand(this.plugin)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNull String s, String[] args) {
|
||||
if (command.getName().equalsIgnoreCase("island")) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
|
||||
FileConfiguration languageConfigLoad = plugin.getLanguage();
|
||||
FileConfiguration mainConfig = plugin.getConfiguration();
|
||||
FileConfiguration languageConfigLoad = this.plugin.getLanguage();
|
||||
FileConfiguration mainConfig = this.plugin.getConfiguration();
|
||||
|
||||
Player player = null;
|
||||
|
||||
@ -151,7 +204,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
} else {
|
||||
String commandToExecute;
|
||||
String defaultCommand;
|
||||
if (plugin.getIslandManager().getIsland(player) == null) {
|
||||
if (this.plugin.getIslandManager().getIsland(player) == null) {
|
||||
defaultCommand = "island create";
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", defaultCommand);
|
||||
} else {
|
||||
@ -169,9 +222,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
String finalCommandToExecute = commandToExecute;
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () ->
|
||||
Bukkit.getServer().dispatchCommand(sender,
|
||||
finalCommandToExecute));
|
||||
Bukkit.getServer().getScheduler().runTask(this.plugin, () -> Bukkit.getServer().dispatchCommand(sender, finalCommandToExecute));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -278,7 +329,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
List<String> arguments = new ArrayList<>(Arrays.asList(args));
|
||||
arguments.remove(args[0]);
|
||||
|
||||
if (adminCommands.contains(subCommand)) {
|
||||
if (this.adminCommands.contains(subCommand)) {
|
||||
arguments.remove(args[1]);
|
||||
}
|
||||
|
||||
@ -294,7 +345,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
@ -308,7 +359,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
if (args[0] == null || args[0].isEmpty()) {
|
||||
commandAliases.add("admin");
|
||||
|
||||
for (SubCommand subCommandList : islandCommands) {
|
||||
for (SubCommand subCommandList : this.islandCommands) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
} else {
|
||||
@ -318,7 +369,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
for (SubCommand subCommandList : islandCommands) {
|
||||
for (SubCommand subCommandList : this.islandCommands) {
|
||||
if (subCommandList.getName().toLowerCase().contains(args[0].toLowerCase())) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
@ -328,11 +379,11 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
if (isAdmin) {
|
||||
if (args[0].equalsIgnoreCase("admin")) {
|
||||
if (args[1] == null || args[1].isEmpty()) {
|
||||
for (SubCommand subCommandList : adminCommands) {
|
||||
for (SubCommand subCommandList : this.adminCommands) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
} else {
|
||||
for (SubCommand subCommandList : adminCommands) {
|
||||
for (SubCommand subCommandList : this.adminCommands) {
|
||||
if (subCommandList.getName().toLowerCase().contains(args[1].toLowerCase())) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
@ -343,7 +394,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
List<String> arguments = getIslandArguments(args[0], args[1]);
|
||||
|
||||
if (arguments.size() != 0) {
|
||||
if (!arguments.isEmpty()) {
|
||||
commandAliases.addAll(arguments);
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
@ -351,14 +402,14 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
if (args[0].equalsIgnoreCase("admin")) {
|
||||
List<String> arguments = getAdminArguments(args[1], args[2]);
|
||||
|
||||
if (arguments.size() != 0) {
|
||||
if (!arguments.isEmpty()) {
|
||||
commandAliases.addAll(arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commandAliases.size() != 0) {
|
||||
if (!commandAliases.isEmpty()) {
|
||||
return commandAliases;
|
||||
}
|
||||
}
|
||||
@ -367,11 +418,11 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
public List<String> getIslandArguments(String arg1, String arg2) {
|
||||
return this.getArguments(islandCommands, arg1, arg2);
|
||||
return this.getArguments(this.islandCommands, arg1, arg2);
|
||||
}
|
||||
|
||||
public List<String> getAdminArguments(String arg1, String arg2) {
|
||||
return this.getArguments(adminCommands, arg1, arg2);
|
||||
return this.getArguments(this.adminCommands, arg1, arg2);
|
||||
}
|
||||
|
||||
public List<String> getArguments(List<SubCommand> subCommands, String arg1, String arg2) {
|
||||
@ -399,29 +450,29 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
public void sendPlayerIslandHelpCommands(Player player, int page) {
|
||||
this.sendPlayerHelpCommands(player, islandCommands, page, false);
|
||||
this.sendPlayerHelpCommands(player, this.islandCommands, page, false);
|
||||
}
|
||||
|
||||
public void sendPlayerAdminHelpCommands(Player player, int page) {
|
||||
this.sendPlayerHelpCommands(player, adminCommands, page, true);
|
||||
this.sendPlayerHelpCommands(player, this.adminCommands, page, true);
|
||||
}
|
||||
|
||||
public void sendPlayerHelpCommands(Player player, List<SubCommand> subCommands, int page, boolean isAdmin) {
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
int pageSize = 7;
|
||||
|
||||
int nextEndIndex = subCommands.size() - page * pageSize, index = page * pageSize - pageSize,
|
||||
endIndex = index >= subCommands.size() ? subCommands.size() - 1 : index + pageSize;
|
||||
boolean showAlises = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
boolean showAliases = fileManager.getConfig(new File(this.plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Command.Help.Aliases.Enable");
|
||||
|
||||
if (nextEndIndex <= -7) {
|
||||
plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
this.plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message"));
|
||||
this.plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -453,7 +504,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
for (SubCommand subCommand : subCommands) {
|
||||
StringBuilder commandAliases = new StringBuilder();
|
||||
|
||||
if (showAlises) {
|
||||
if (showAliases) {
|
||||
for (int i = 0; i < subCommand.getAliases().length; i++) {
|
||||
commandAliases.append("/").append(subCommand.getAliases()[i]);
|
||||
}
|
||||
@ -475,7 +526,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
SubCommand subCommandFromIndex = subCommands.get(index);
|
||||
StringBuilder commandAliases = new StringBuilder();
|
||||
|
||||
if (showAlises) {
|
||||
if (showAliases) {
|
||||
for (int i = 0; i < subCommandFromIndex.getAliases().length; i++) {
|
||||
commandAliases.append("/").append(subCommandFromIndex.getAliases()[i]);
|
||||
}
|
||||
@ -494,7 +545,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.getMessageManager().sendMessage(player, helpLines);
|
||||
this.plugin.getMessageManager().sendMessage(player, helpLines);
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,7 +555,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
player.spigot()
|
||||
.sendMessage(
|
||||
new ChatComponent(
|
||||
plugin.formatText(configLoad.getString("Command.Island.Help.Word.Next")),
|
||||
this.plugin.formatText(configLoad.getString("Command.Island.Help.Word.Next")),
|
||||
false, null,
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/island " + subCommandText + "help " + (page + 1)),
|
||||
@ -513,16 +564,16 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
player.spigot()
|
||||
.sendMessage(
|
||||
new ChatComponent(
|
||||
plugin.formatText(configLoad.getString("Command.Island.Help.Word.Previous")),
|
||||
this.plugin.formatText(configLoad.getString("Command.Island.Help.Word.Previous")),
|
||||
false, null,
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/island " + subCommandText + "help " + (page - 1)),
|
||||
null).addExtraChatComponent(
|
||||
new ChatComponent(" "
|
||||
+ ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad
|
||||
.getString("Command.Island.Help.Word.Pipe"))
|
||||
+ " ", false, null, null, null))
|
||||
new ChatComponent(" "
|
||||
+ ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad
|
||||
.getString("Command.Island.Help.Word.Pipe"))
|
||||
+ " ", false, null, null, null))
|
||||
.addExtraChatComponent(new ChatComponent(
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString(
|
||||
@ -547,7 +598,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
|
||||
this.plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void sendConsoleHelpCommands(CommandSender sender) {
|
||||
@ -562,21 +613,24 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
public SubCommand getIslandSubCommand(String cmdName) {
|
||||
return this.getSubCommand(islandCommands, cmdName);
|
||||
return this.getSubCommand(this.islandCommands, cmdName);
|
||||
}
|
||||
|
||||
public SubCommand getAdminSubCommand(String cmdName) {
|
||||
return this.getSubCommand(adminCommands, cmdName);
|
||||
return this.getSubCommand(this.adminCommands, cmdName);
|
||||
}
|
||||
|
||||
public SubCommand getSubCommand(List<SubCommand> subCommands, String cmdName) {
|
||||
for (SubCommand command : subCommands) {
|
||||
if (command.getName().equalsIgnoreCase(cmdName))
|
||||
if (command.getName().equalsIgnoreCase(cmdName)) {
|
||||
return command;
|
||||
}
|
||||
|
||||
for (String argList : command.getAliases())
|
||||
if (argList.equalsIgnoreCase(cmdName))
|
||||
for (String argList : command.getAliases()) {
|
||||
if (argList.equalsIgnoreCase(cmdName)) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,20 +1,16 @@
|
||||
package com.songoda.skyblock.command;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class SubCommand {
|
||||
|
||||
protected final SkyBlock plugin;
|
||||
protected final String info;
|
||||
|
||||
public SubCommand() {
|
||||
this.plugin = SkyBlock.getInstance();
|
||||
public SubCommand(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.info = this.plugin.formatText(this.plugin.getLanguage().getString(this.getInfoMessagePath()));
|
||||
}
|
||||
|
||||
@ -35,12 +31,12 @@ public abstract class SubCommand {
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permissible toCheck, boolean isAdmin) {
|
||||
if (toCheck.hasPermission("fabledskyblock.*"))
|
||||
if (toCheck.hasPermission("fabledskyblock.*")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isAdmin
|
||||
? toCheck.hasPermission("fabledskyblock.admin.*") || toCheck.hasPermission("fabledskyblock.admin." + this.getName())
|
||||
: toCheck.hasPermission("fabledskyblock.island.*") || toCheck.hasPermission("fabledskyblock.island." + this.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,13 +5,19 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SkyBlockCommand implements CommandExecutor {
|
||||
private final SkyBlock plugin;
|
||||
|
||||
public SkyBlockCommand(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
public boolean onCommand(CommandSender sender, @NotNull Command command, @NotNull String s, String[] strings) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(formatText("FabledSkyBlock &7Version " + SkyBlock.getInstance().getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
sender.sendMessage(formatText("FabledSkyBlock &7Version " + this.plugin.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
sender.sendMessage(formatText("&8 - &a/island help &7 - The default help command."));
|
||||
sender.sendMessage("");
|
||||
return true;
|
||||
|
@ -2,6 +2,7 @@ package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.eatthepath.uuid.FastUUID;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -24,6 +25,9 @@ import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AddUpgradeCommand extends SubCommand {
|
||||
public AddUpgradeCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -36,13 +40,13 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -58,30 +62,27 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
|
||||
Upgrade.Type upgrade = null;
|
||||
for(Upgrade.Type type : Upgrade.Type.values()) {
|
||||
if(type.name().toUpperCase().equals(args[1].toUpperCase())) {
|
||||
for (Upgrade.Type type : Upgrade.Type.values()) {
|
||||
if (type.name().equalsIgnoreCase(args[1])) {
|
||||
upgrade = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.AddUpgrade.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (upgrade == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Exist.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Exist.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
if (island.hasUpgrade(upgrade)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
@ -89,8 +90,7 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
|
||||
island.setUpgrade(null, upgrade, true);
|
||||
} else {
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml");
|
||||
File islandDataFile = new File(this.plugin.getDataFolder() + "/island-data", FastUUID.toString(islandOwnerUUID) + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
@ -114,8 +114,8 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.skyblock.command.commands.admin;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.gui.bank.GuiBank;
|
||||
@ -21,18 +22,20 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminBank extends SubCommand {
|
||||
|
||||
public AdminBank(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
Economy economy = this.plugin.getEconomyManager().getEconomy();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileManager.Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
@ -44,8 +47,8 @@ public class AdminBank extends SubCommand {
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
if (island != null){
|
||||
plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true));
|
||||
if (island != null) {
|
||||
this.plugin.getGuiManager().showGUI(player, new GuiBank(this.plugin, island, null, true));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
@ -54,43 +57,43 @@ public class AdminBank extends SubCommand {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "balance":
|
||||
if (args.length >= 3) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
}
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
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%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%", args[1]).replace("%ammount%", EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
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%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%", args[1]).replace("%ammount%", EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "open":
|
||||
if(args.length == 2){
|
||||
if (args.length == 2) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[1]);
|
||||
UUID islandOwnerUUID;
|
||||
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[1]);
|
||||
islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
}
|
||||
|
||||
|
||||
island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
}
|
||||
if (island != null){
|
||||
plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true));
|
||||
if (island != null) {
|
||||
this.plugin.getGuiManager().showGUI(player, new GuiBank(this.plugin, island, null, true));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
@ -105,12 +108,12 @@ public class AdminBank extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
Economy economy = this.plugin.getEconomyManager().getEconomy();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileManager.Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length < 2) {
|
||||
@ -119,21 +122,21 @@ public class AdminBank extends SubCommand {
|
||||
}
|
||||
switch (args[0]) {
|
||||
case "balance":
|
||||
messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
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%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%", args[1]).replace("%ammount%", EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
} else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
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%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%", args[1]).replace("%ammount%", EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
} else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
@ -19,20 +20,23 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatSpyCommand extends SubCommand {
|
||||
|
||||
public ChatSpyCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
FileManager.Config language = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
|
||||
FileManager.Config language = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration languageLoad = language.getFileConfiguration();
|
||||
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
|
||||
if (args.length < 1) {
|
||||
toggleSpy(player, messageManager, languageLoad, playerData);
|
||||
} else {
|
||||
@ -41,7 +45,7 @@ public class ChatSpyCommand extends SubCommand {
|
||||
toggleSpy(player, messageManager, languageLoad, playerData);
|
||||
break;
|
||||
case "global":
|
||||
if(!playerData.isGlobalChatSpy()){
|
||||
if (!playerData.isGlobalChatSpy()) {
|
||||
playerData.enableGlobalChatSpy();
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.GlobalEnabled.Message"));
|
||||
} else {
|
||||
@ -50,10 +54,10 @@ public class ChatSpyCommand extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "add":
|
||||
if(args.length == 2){
|
||||
if (args.length == 2) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
|
||||
Island island = islandManager.getIslandByOwner(offlinePlayer.getBukkitOfflinePlayer());
|
||||
if(island != null) {
|
||||
if (island != null) {
|
||||
playerData.addChatSpyIsland(island);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message")
|
||||
.replace("%owner", new OfflinePlayer(island.getOwnerUUID()).getName()));
|
||||
@ -66,10 +70,10 @@ public class ChatSpyCommand extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if(args.length == 2){
|
||||
if (args.length == 2) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
|
||||
Island island = islandManager.getIslandByOwner(offlinePlayer.getBukkitOfflinePlayer());
|
||||
if(island != null) {
|
||||
if (island != null) {
|
||||
playerData.removeChatSpyIsland(island);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message")
|
||||
.replace("%owner", new OfflinePlayer(island.getOwnerUUID()).getName()));
|
||||
@ -83,9 +87,9 @@ public class ChatSpyCommand extends SubCommand {
|
||||
break;
|
||||
case "list":
|
||||
Set<UUID> uuidSet = playerData.getChatSpyIslands();
|
||||
if(!uuidSet.isEmpty()){
|
||||
if (!uuidSet.isEmpty()) {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.Start.Message"));
|
||||
for(UUID uuid : uuidSet) {
|
||||
for (UUID uuid : uuidSet) {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.List.Message")
|
||||
.replace("%owner", new OfflinePlayer(uuid).getName()));
|
||||
}
|
||||
@ -101,10 +105,10 @@ public class ChatSpyCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void toggleSpy(Player player, MessageManager messageManager, FileConfiguration languageLoad, PlayerData playerData) {
|
||||
if(playerData != null) {
|
||||
if(playerData.isChatSpy()){
|
||||
if (playerData != null) {
|
||||
if (playerData.isChatSpy()) {
|
||||
playerData.setChatSpy(false);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Disabled.Message"));
|
||||
} else {
|
||||
@ -113,27 +117,27 @@ public class ChatSpyCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "chatspy";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.ChatSpy.Info.Message";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"spychat", "spy"};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"toggle", "global", "add", "remove", "list"};
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.admin.Creator;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
@ -9,11 +10,14 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CreateCommand extends SubCommand {
|
||||
public CreateCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
playerDataManager.getPlayerData(player).setViewer(null);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -23,6 +24,9 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DeleteCommand extends SubCommand {
|
||||
public DeleteCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -35,12 +39,12 @@ public class DeleteCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Player player = null;
|
||||
@ -64,8 +68,7 @@ public class DeleteCommand extends SubCommand {
|
||||
}
|
||||
|
||||
if (targetPlayerUUID == null || !islandManager.isIslandExist(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
@ -83,8 +86,8 @@ public class DeleteCommand extends SubCommand {
|
||||
}
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, all.getUniqueId())) {
|
||||
if (island.hasRole(IslandRole.MEMBER, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.OPERATOR, all.getUniqueId())) {
|
||||
all.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Command.Island.Confirmation.Deletion.Broadcast.Message")));
|
||||
soundManager.playSound(all, CompatibleSound.ENTITY_GENERIC_EXPLODE.getSound(), 10.0F, 10.0F);
|
||||
@ -94,9 +97,7 @@ public class DeleteCommand extends SubCommand {
|
||||
island.setDeleted(true);
|
||||
islandManager.deleteIsland(island, true);
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player",
|
||||
targetPlayerName));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -15,18 +16,21 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
|
||||
public class GeneratorCommand extends SubCommand {
|
||||
public GeneratorCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (plugin.getGeneratorManager() == null) {
|
||||
if (this.plugin.getGeneratorManager() == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Generator.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.admin.Levelling;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -8,10 +9,13 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LevelCommand extends SubCommand {
|
||||
public LevelCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
|
||||
Levelling.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
@ -18,6 +19,9 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
|
||||
public class LevelScanCommand extends SubCommand {
|
||||
public LevelScanCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -30,13 +34,13 @@ public class LevelScanCommand extends SubCommand {
|
||||
}
|
||||
|
||||
private void onCommand(CommandSender sender, String[] args) {
|
||||
IslandLevelManager levellingManager = plugin.getLevellingManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
IslandLevelManager levellingManager = this.plugin.getLevellingManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileManager.Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 0) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -18,6 +19,9 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OwnerCommand extends SubCommand {
|
||||
public OwnerCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -30,12 +34,12 @@ public class OwnerCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -57,7 +61,7 @@ public class OwnerCommand extends SubCommand {
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Owner.Island.None.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (islandOwnerUUID.equals(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Owner.Island.Owner.Message").replace("%player",
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -18,6 +19,9 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProxyCommand extends SubCommand {
|
||||
public ProxyCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -30,12 +34,12 @@ public class ProxyCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -44,29 +48,29 @@ public class ProxyCommand extends SubCommand {
|
||||
UUID userUUID = targetPlayerOffline.getUUID();
|
||||
|
||||
if (islandManager.getIsland(Bukkit.getOfflinePlayer(userUUID)) != null) {
|
||||
if (islandManager.isPlayerProxyingAnotherPlayer(((Player)sender).getUniqueId())) {
|
||||
if (islandManager.isPlayerProxyingAnotherPlayer(((Player) sender).getUniqueId())) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Proxy.IsOffPlayer.Message")
|
||||
.replace("%player", targetPlayerOffline.getName()));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
islandManager.removeProxyingPlayer(((Player)sender).getUniqueId());
|
||||
islandManager.removeProxyingPlayer(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Proxy.IsOn.Message")
|
||||
.replace("%player", targetPlayerOffline.getName()));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
islandManager.addProxiedPlayer(((Player)sender).getUniqueId(), userUUID);
|
||||
islandManager.addProxiedPlayer(((Player) sender).getUniqueId(), userUUID);
|
||||
}
|
||||
}
|
||||
} else if (args.length == 0){
|
||||
} else if (args.length == 0) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Proxy.IsOff.Message")
|
||||
.replace("%player", ""));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
islandManager.removeProxyingPlayer(((Player)sender).getUniqueId());
|
||||
islandManager.removeProxyingPlayer(((Player) sender).getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -16,6 +17,9 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
|
||||
public class RefreshHologramsCommand extends SubCommand {
|
||||
public RefreshHologramsCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -28,20 +32,20 @@ public class RefreshHologramsCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
LeaderboardManager leaderboardManager = this.plugin.getLeaderboardManager();
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> plugin.getHologramTask().updateHologram());
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.plugin.getHologramTask().updateHologram());
|
||||
});
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message"));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -23,6 +24,9 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReloadCommand extends SubCommand {
|
||||
public ReloadCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -35,68 +39,68 @@ public class ReloadCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender) {
|
||||
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
LimitationInstanceHandler limitHandler = plugin.getLimitationHandler();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
LeaderboardManager leaderboardManager = this.plugin.getLeaderboardManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
LimitationInstanceHandler limitHandler = this.plugin.getLimitationHandler();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
"&cPlease note that this command is not supported and may " + "cause issues that could put the plugin in an unstable state. " + "If you encounter any issues please stop your server, edit the configuration files, "
|
||||
+ "and then start your server again. This command does NOT reload all the plugin files, only " + "the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Map<String, Config> configs = fileManager.getConfigs();
|
||||
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
for (int i = 0; i < configs.size(); ++i) {
|
||||
String configFileName = (String) configs.keySet().toArray()[i];
|
||||
Config configFileConfig = configs.get(configFileName);
|
||||
String configFilePath = configFileName.replace(configFileConfig.getFile().getName(), "");
|
||||
|
||||
if (configFilePath.equals(plugin.getDataFolder().toString() + "\\") || configFilePath.equals(plugin.getDataFolder().toString() + "/")) {
|
||||
if (configFilePath.equals(this.plugin.getDataFolder() + "\\") || configFilePath.equals(this.plugin.getDataFolder() + "/")) {
|
||||
configFileConfig.loadFile();
|
||||
}
|
||||
}
|
||||
|
||||
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
Config mainConfig = fileManager.getConfig(new File(this.plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
|
||||
|
||||
if (plugin.getScoreboardManager() == null) {
|
||||
if (this.plugin.getScoreboardManager() == null) {
|
||||
if (mainConfigLoad.getBoolean("Island.Scoreboard.Enable")) {
|
||||
plugin.setScoreboardManager(new ScoreboardManager(plugin));
|
||||
this.plugin.setScoreboardManager(new ScoreboardManager(this.plugin));
|
||||
}
|
||||
} else {
|
||||
plugin.getScoreboardManager().reload();
|
||||
this.plugin.getScoreboardManager().reload();
|
||||
}
|
||||
|
||||
if (plugin.getGeneratorManager() == null) {
|
||||
if (this.plugin.getGeneratorManager() == null) {
|
||||
if (mainConfigLoad.getBoolean("Island.Generator.Enable")) {
|
||||
plugin.setGeneratorManager(new GeneratorManager(plugin));
|
||||
this.plugin.setGeneratorManager(new GeneratorManager(this.plugin));
|
||||
}
|
||||
} else {
|
||||
GeneratorManager generatorManager = plugin.getGeneratorManager();
|
||||
GeneratorManager generatorManager = this.plugin.getGeneratorManager();
|
||||
generatorManager.unregisterGenerators();
|
||||
generatorManager.registerGenerators();
|
||||
}
|
||||
|
||||
IslandLevelManager levellingManager = plugin.getLevellingManager();
|
||||
IslandLevelManager levellingManager = this.plugin.getLevellingManager();
|
||||
levellingManager.reloadWorth();
|
||||
|
||||
RewardManager rewardManager = plugin.getRewardManager();
|
||||
RewardManager rewardManager = this.plugin.getRewardManager();
|
||||
rewardManager.loadRewards();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> plugin.getHologramTask().updateHologram());
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.plugin.getHologramTask().updateHologram());
|
||||
});
|
||||
|
||||
limitHandler.reloadAll();
|
||||
plugin.getLocalizationManager().reloadAll();
|
||||
this.plugin.getLocalizationManager().reloadAll();
|
||||
MenuClickRegistry.getInstance().reloadAll();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -20,6 +21,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class RemoveHologramCommand extends SubCommand {
|
||||
public RemoveHologramCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -32,31 +36,31 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
HologramTask hologramManager = plugin.getHologramTask();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
HologramTask hologramManager = this.plugin.getHologramTask();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
HologramType hologramType = null;
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "level":
|
||||
hologramType = HologramType.Level;
|
||||
break;
|
||||
case "bank":
|
||||
hologramType = HologramType.Bank;
|
||||
break;
|
||||
case "votes":
|
||||
hologramType = HologramType.Votes;
|
||||
break;
|
||||
case "level":
|
||||
hologramType = HologramType.LEVEL;
|
||||
break;
|
||||
case "bank":
|
||||
hologramType = HologramType.BANK;
|
||||
break;
|
||||
case "votes":
|
||||
hologramType = HologramType.VOTES;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hologramType != null) {
|
||||
Config locationsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml"));
|
||||
Config locationsConfig = fileManager.getConfig(new File(this.plugin.getDataFolder(), "locations.yml"));
|
||||
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
|
||||
|
||||
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.name()) == null) {
|
||||
@ -67,16 +71,17 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
|
||||
try {
|
||||
locationsConfigLoad.save(locationsConfig.getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
Bukkit.getServer().getScheduler().runTask(this.plugin, () -> {
|
||||
HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
if (hologram != null)
|
||||
if (hologram != null) {
|
||||
hologramManager.removeHologram(hologram);
|
||||
}
|
||||
});
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name()));
|
||||
@ -108,6 +113,6 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[] { "level", "bank", "votes" };
|
||||
return new String[]{"level", "bank", "votes"};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -23,6 +24,9 @@ import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RemoveUpgradeCommand extends SubCommand {
|
||||
public RemoveUpgradeCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -35,13 +39,13 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -57,10 +61,10 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
|
||||
Upgrade.Type upgrade = null;
|
||||
for(Upgrade.Type type : Upgrade.Type.values()) {
|
||||
if(type.name().toUpperCase().equals(args[1].toUpperCase())) {
|
||||
for (Upgrade.Type type : Upgrade.Type.values()) {
|
||||
if (type.name().equalsIgnoreCase(args[1])) {
|
||||
upgrade = type;
|
||||
break;
|
||||
}
|
||||
@ -69,11 +73,11 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (upgrade == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Exist.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
@ -88,7 +92,7 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
|
||||
island.removeUpgrade(upgrade);
|
||||
} else {
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
File islandDataFile = new File(this.plugin.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
@ -113,8 +117,8 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -20,6 +21,9 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetAlwaysLoadedCommand extends SubCommand {
|
||||
public SetAlwaysLoadedCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -32,21 +36,19 @@ public class SetAlwaysLoadedCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
|
||||
if (args.length == 0) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetAlwaysLoaded.No-Player-Input.Message"));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.SetAlwaysLoaded.No-Player-Input.Message"));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
|
||||
if (args.length == 1) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
@ -2,6 +2,7 @@ package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleBiome;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.biome.BiomeManager;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
@ -24,6 +25,9 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetBiomeCommand extends SubCommand {
|
||||
public SetBiomeCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -36,14 +40,14 @@ public class SetBiomeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
BiomeManager biomeManager = plugin.getBiomeManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
BiomeManager biomeManager = this.plugin.getBiomeManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length >= 2) {
|
||||
@ -60,7 +64,7 @@ public class SetBiomeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
world = IslandWorld.Normal;
|
||||
world = IslandWorld.NORMAL;
|
||||
}
|
||||
|
||||
CompatibleBiome biome = null;
|
||||
@ -86,14 +90,13 @@ public class SetBiomeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetBiome.Island.Owner.Message"));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.SetBiome.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
biomeManager.setBiome(island, world, biome, null);
|
||||
if (world.equals(IslandWorld.Normal)) {
|
||||
if (world == IslandWorld.NORMAL) {
|
||||
island.setBiome(biome.getBiome());
|
||||
}
|
||||
} else {
|
||||
@ -107,7 +110,7 @@ public class SetBiomeCommand extends SubCommand {
|
||||
CompatibleBiome finalBiome = biome;
|
||||
IslandWorld finalWorld = world;
|
||||
biomeManager.setBiome(island, world, biome, () -> {
|
||||
if (finalWorld.equals(IslandWorld.Normal)) {
|
||||
if (finalWorld == IslandWorld.NORMAL) {
|
||||
island.setBiome(finalBiome.getBiome());
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -18,15 +19,18 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
|
||||
public class SetHologramCommand extends SubCommand {
|
||||
public SetHologramCommand(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
HologramTask hologramManager = plugin.getHologramTask();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
HologramTask hologramManager = this.plugin.getHologramTask();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -34,43 +38,41 @@ public class SetHologramCommand extends SubCommand {
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "level":
|
||||
hologramType = HologramType.Level;
|
||||
hologramType = HologramType.LEVEL;
|
||||
break;
|
||||
case "bank":
|
||||
hologramType = HologramType.Bank;
|
||||
hologramType = HologramType.BANK;
|
||||
break;
|
||||
case "votes":
|
||||
hologramType = HologramType.Votes;
|
||||
hologramType = HologramType.VOTES;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hologramType != null) {
|
||||
fileManager.setLocation(
|
||||
fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")),
|
||||
fileManager.getConfig(new File(this.plugin.getDataFolder(), "locations.yml")),
|
||||
"Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true);
|
||||
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
Bukkit.getServer().getScheduler().runTask(this.plugin, () -> {
|
||||
HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
if (hologram != null)
|
||||
if (hologram != null) {
|
||||
hologramManager.removeHologram(hologram);
|
||||
|
||||
}
|
||||
hologramManager.spawnHologram(hologramType1);
|
||||
});
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type",
|
||||
hologramType.name()));
|
||||
configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type", hologramType.name()));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.SetHologram.Invalid.Message"));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetHologram.Invalid.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.utils.NumberUtils;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -9,7 +11,6 @@ import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.core.utils.NumberUtils;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -23,6 +24,9 @@ import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetMaxMembers extends SubCommand {
|
||||
public SetMaxMembers(SkyBlock plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
@ -35,13 +39,13 @@ public class SetMaxMembers extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PlayerDataManager playerDataManager = this.plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = this.plugin.getMessageManager();
|
||||
IslandManager islandManager = this.plugin.getIslandManager();
|
||||
SoundManager soundManager = this.plugin.getSoundManager();
|
||||
FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(this.plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -59,32 +63,30 @@ public class SetMaxMembers extends SubCommand {
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
int maxMembers = Integer.valueOf(args[1]);
|
||||
int maxMembers = Integer.parseInt(args[1]);
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (maxMembers <= 0) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Members.Greater.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (maxMembers > 100000) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Members.Less.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
island.setMaxMembers(maxMembers);
|
||||
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable") && island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
} else {
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
File islandDataFile = new File(this.plugin.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
@ -101,8 +103,8 @@ public class SetMaxMembers extends SubCommand {
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user