mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-07 11:10:04 +01:00
Added base for level ups.
This commit is contained in:
parent
85f1b051fc
commit
032f17d51c
@ -18,6 +18,7 @@ import com.songoda.skyblock.generator.GeneratorManager;
|
|||||||
import com.songoda.skyblock.hologram.HologramManager;
|
import com.songoda.skyblock.hologram.HologramManager;
|
||||||
import com.songoda.skyblock.invite.InviteManager;
|
import com.songoda.skyblock.invite.InviteManager;
|
||||||
import com.songoda.skyblock.island.IslandManager;
|
import com.songoda.skyblock.island.IslandManager;
|
||||||
|
import com.songoda.skyblock.island.reward.RewardManager;
|
||||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||||
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
|
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
|
||||||
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||||
@ -79,6 +80,7 @@ public class SkyBlock extends SongodaPlugin {
|
|||||||
private HologramManager hologramManager;
|
private HologramManager hologramManager;
|
||||||
private LimitationInstanceHandler limitationHandler;
|
private LimitationInstanceHandler limitationHandler;
|
||||||
private LocalizationManager localizationManager;
|
private LocalizationManager localizationManager;
|
||||||
|
private RewardManager rewardManager;
|
||||||
private FabledChallenge fabledChallenge;
|
private FabledChallenge fabledChallenge;
|
||||||
|
|
||||||
public static SkyBlock getInstance() {
|
public static SkyBlock getInstance() {
|
||||||
@ -139,6 +141,9 @@ public class SkyBlock extends SongodaPlugin {
|
|||||||
messageManager = new MessageManager(this);
|
messageManager = new MessageManager(this);
|
||||||
hologramManager = new HologramManager(this);
|
hologramManager = new HologramManager(this);
|
||||||
|
|
||||||
|
rewardManager = new RewardManager(this);
|
||||||
|
rewardManager.loadRewards();
|
||||||
|
|
||||||
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||||
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||||
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||||
@ -344,6 +349,10 @@ public class SkyBlock extends SongodaPlugin {
|
|||||||
return localizationManager;
|
return localizationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RewardManager getRewardManager() {
|
||||||
|
return rewardManager;
|
||||||
|
}
|
||||||
|
|
||||||
public FabledChallenge getFabledChallenge() {
|
public FabledChallenge getFabledChallenge() {
|
||||||
return fabledChallenge;
|
return fabledChallenge;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.songoda.skyblock.command.commands.admin;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.songoda.skyblock.island.reward.RewardManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
@ -84,6 +85,9 @@ public class ReloadCommand extends SubCommand {
|
|||||||
IslandLevelManager levellingManager = skyblock.getLevellingManager();
|
IslandLevelManager levellingManager = skyblock.getLevellingManager();
|
||||||
levellingManager.reloadWorth();
|
levellingManager.reloadWorth();
|
||||||
|
|
||||||
|
RewardManager rewardManager = skyblock.getRewardManager();
|
||||||
|
rewardManager.loadRewards();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||||
leaderboardManager.clearLeaderboard();
|
leaderboardManager.clearLeaderboard();
|
||||||
leaderboardManager.resetLeaderboard();
|
leaderboardManager.resetLeaderboard();
|
||||||
|
@ -70,6 +70,7 @@ public class FileManager {
|
|||||||
configFiles.put("generators.yml", new File(skyblock.getDataFolder(), "generators.yml"));
|
configFiles.put("generators.yml", new File(skyblock.getDataFolder(), "generators.yml"));
|
||||||
configFiles.put("stackables.yml", new File(skyblock.getDataFolder(), "stackables.yml"));
|
configFiles.put("stackables.yml", new File(skyblock.getDataFolder(), "stackables.yml"));
|
||||||
configFiles.put("structures.yml", new File(skyblock.getDataFolder(), "structures.yml"));
|
configFiles.put("structures.yml", new File(skyblock.getDataFolder(), "structures.yml"));
|
||||||
|
configFiles.put("rewards.yml", new File(skyblock.getDataFolder(), "rewards.yml"));
|
||||||
configFiles.put("structures/default.structure", new File(skyblock.getDataFolder().toString() + "/structures", "default.structure"));
|
configFiles.put("structures/default.structure", new File(skyblock.getDataFolder().toString() + "/structures", "default.structure"));
|
||||||
configFiles.put("challenges.yml", new File(skyblock.getDataFolder(), "challenges.yml"));
|
configFiles.put("challenges.yml", new File(skyblock.getDataFolder(), "challenges.yml"));
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.songoda.skyblock.island;
|
package com.songoda.skyblock.island;
|
||||||
|
|
||||||
|
import com.songoda.core.locale.Message;
|
||||||
import com.songoda.skyblock.SkyBlock;
|
import com.songoda.skyblock.SkyBlock;
|
||||||
import com.songoda.skyblock.config.FileManager.Config;
|
import com.songoda.skyblock.config.FileManager.Config;
|
||||||
|
import com.songoda.skyblock.island.reward.LevelReward;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
@ -25,6 +28,9 @@ public class IslandLevel {
|
|||||||
|
|
||||||
private Map<String, Long> materials;
|
private Map<String, Long> materials;
|
||||||
|
|
||||||
|
// Highest level achieved, to prevent reward farming (since is level can decrease)
|
||||||
|
private long highestLevel;
|
||||||
|
|
||||||
public IslandLevel(UUID ownerUUID, SkyBlock skyblock) {
|
public IslandLevel(UUID ownerUUID, SkyBlock skyblock) {
|
||||||
this.skyblock = skyblock;
|
this.skyblock = skyblock;
|
||||||
this.ownerUUID = ownerUUID;
|
this.ownerUUID = ownerUUID;
|
||||||
@ -44,14 +50,17 @@ public class IslandLevel {
|
|||||||
ConfigurationSection current = section.getConfigurationSection(material);
|
ConfigurationSection current = section.getConfigurationSection(material);
|
||||||
|
|
||||||
if (current.isSet("Amount")) materials.put(material, current.getLong("Amount"));
|
if (current.isSet("Amount")) materials.put(material, current.getLong("Amount"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
materials = new HashMap<>();
|
materials = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.materials = materials;
|
this.materials = materials;
|
||||||
|
|
||||||
|
if (configLoad.contains("Levelling.Highest-Level"))
|
||||||
|
this.highestLevel = configLoad.getLong("Levelling.Highest-Level");
|
||||||
|
else
|
||||||
|
this.highestLevel = getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwnerUUID(UUID ownerUUID) {
|
public void setOwnerUUID(UUID ownerUUID) {
|
||||||
@ -113,6 +122,33 @@ public class IslandLevel {
|
|||||||
return getPoints() / division;
|
return getPoints() / division;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkLevelUp() {
|
||||||
|
|
||||||
|
long level = getLevel();
|
||||||
|
|
||||||
|
// Island Level increased above highest
|
||||||
|
if (level > highestLevel) {
|
||||||
|
|
||||||
|
OfflinePlayer offlinePlayer = Bukkit.getPlayer(ownerUUID);
|
||||||
|
|
||||||
|
// Reward the player for each level reached
|
||||||
|
if (offlinePlayer != null && offlinePlayer.isOnline()) {
|
||||||
|
for (int i = (int) highestLevel; i <= level; i++) {
|
||||||
|
LevelReward levelReward = skyblock.getRewardManager().getReward(i);
|
||||||
|
|
||||||
|
if (levelReward == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
levelReward.give(offlinePlayer.getPlayer(), skyblock);
|
||||||
|
}
|
||||||
|
|
||||||
|
new Message("You have reached island level " + level).sendMessage(offlinePlayer.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
setHighestLevel(level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setMaterialAmount(String material, long amount) {
|
public void setMaterialAmount(String material, long amount) {
|
||||||
skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration()
|
skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration()
|
||||||
.set("Levelling.Materials." + material + ".Amount", amount);
|
.set("Levelling.Materials." + material + ".Amount", amount);
|
||||||
@ -183,4 +219,17 @@ public class IslandLevel {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getHighestLevel() {
|
||||||
|
return highestLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHighestLevel(long highestLevel) {
|
||||||
|
Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
configLoad.set("Levelling.Highest-Level", highestLevel);
|
||||||
|
|
||||||
|
this.highestLevel = highestLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.songoda.skyblock.island.reward;
|
||||||
|
|
||||||
|
import com.songoda.core.hooks.EconomyManager;
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LevelReward {
|
||||||
|
|
||||||
|
private List<String> commands;
|
||||||
|
|
||||||
|
private double money;
|
||||||
|
|
||||||
|
public LevelReward(List<String> commands, double money) {
|
||||||
|
this.commands = commands;
|
||||||
|
this.money = money;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void give(Player player, SkyBlock skyblock) {
|
||||||
|
if (money > 0)
|
||||||
|
EconomyManager.deposit(player, money);
|
||||||
|
|
||||||
|
if (!commands.isEmpty()) {
|
||||||
|
for (String cmd : commands) {
|
||||||
|
cmd = skyblock.getMessageManager().replaceMessage(player, cmd);
|
||||||
|
skyblock.getServer().dispatchCommand(skyblock.getConsole(), cmd.replace("%player%", player.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommands(List<String> commands) {
|
||||||
|
this.commands = commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMoney() {
|
||||||
|
return money;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoney(double money) {
|
||||||
|
this.money = money;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.songoda.skyblock.island.reward;
|
||||||
|
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
import com.songoda.skyblock.config.FileManager.Config;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class RewardManager {
|
||||||
|
|
||||||
|
private final SkyBlock skyBlock;
|
||||||
|
|
||||||
|
private final Map<Long, LevelReward> registeredRewards = new HashMap<>();
|
||||||
|
|
||||||
|
public RewardManager(SkyBlock skyBlock) {
|
||||||
|
this.skyBlock = skyBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadRewards() {
|
||||||
|
final Config config = skyBlock.getFileManager().getConfig(new File(skyBlock.getDataFolder(), "rewards.yml"));
|
||||||
|
final FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
this.registeredRewards.clear();
|
||||||
|
|
||||||
|
for (String key : configLoad.getKeys(false)) {
|
||||||
|
long level;
|
||||||
|
try {
|
||||||
|
level = Long.parseLong(key);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurationSection section = configLoad.getConfigurationSection(key);
|
||||||
|
|
||||||
|
double money = section.getDouble("money", 0);
|
||||||
|
|
||||||
|
List<String> commands = section.contains("commands") ? section.getStringList("commands") : new ArrayList<>();
|
||||||
|
|
||||||
|
LevelReward levelReward = new LevelReward(commands, money);
|
||||||
|
|
||||||
|
this.registeredRewards.put(level, levelReward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LevelReward getReward(long level) {
|
||||||
|
return this.registeredRewards.getOrDefault(level, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, LevelReward> getRegisteredRewards() {
|
||||||
|
return Collections.unmodifiableMap(this.registeredRewards);
|
||||||
|
}
|
||||||
|
}
|
@ -63,7 +63,9 @@ public class Levelling {
|
|||||||
SoundManager soundManager = skyblock.getSoundManager();
|
SoundManager soundManager = skyblock.getSoundManager();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
if (playerDataManager.hasPlayerData(player)) {
|
if (!playerDataManager.hasPlayerData(player))
|
||||||
|
return;
|
||||||
|
|
||||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||||
|
|
||||||
@ -72,11 +74,12 @@ public class Levelling {
|
|||||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Message"));
|
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Message"));
|
||||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerDataManager.hasPlayerData(player)) {
|
if (!playerDataManager.hasPlayerData(player))
|
||||||
|
return;
|
||||||
|
|
||||||
ItemStack is = event.getItem();
|
ItemStack is = event.getItem();
|
||||||
|
|
||||||
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta())
|
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta())
|
||||||
@ -88,22 +91,19 @@ public class Levelling {
|
|||||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta())
|
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta())
|
||||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Exit.Displayname"))))) {
|
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Exit.Displayname"))))) {
|
||||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||||
} else
|
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
|
||||||
if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
|
|
||||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"))))) {
|
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"))))) {
|
||||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
|
||||||
event.setWillClose(false);
|
event.setWillClose(false);
|
||||||
event.setWillDestroy(false);
|
event.setWillDestroy(false);
|
||||||
} else
|
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta())
|
||||||
if ((is.getType() == Material.BARRIER) && (is.hasItemMeta())
|
|
||||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Nothing.Displayname"))))) {
|
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Nothing.Displayname"))))) {
|
||||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
|
||||||
event.setWillClose(false);
|
event.setWillClose(false);
|
||||||
event.setWillDestroy(false);
|
event.setWillDestroy(false);
|
||||||
} else
|
} else if ((is.getType() == Materials.FIREWORK_STAR.parseMaterial()) && (is.hasItemMeta())
|
||||||
if ((is.getType() == Materials.FIREWORK_STAR.parseMaterial()) && (is.hasItemMeta())
|
|
||||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"))))) {
|
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"))))) {
|
||||||
Island island = islandManager.getIsland(player);
|
Island island = islandManager.getIsland(player);
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
||||||
@ -143,8 +143,7 @@ public class Levelling {
|
|||||||
cooldownManager.createPlayer(CooldownType.Levelling, Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()));
|
cooldownManager.createPlayer(CooldownType.Levelling, Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()));
|
||||||
levellingManager.startScan(player, island);
|
levellingManager.startScan(player, island);
|
||||||
});
|
});
|
||||||
} else
|
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||||
if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
|
||||||
PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player);
|
PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||||
|
|
||||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) {
|
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) {
|
||||||
@ -169,7 +168,6 @@ public class Levelling {
|
|||||||
event.setWillClose(false);
|
event.setWillClose(false);
|
||||||
event.setWillDestroy(false);
|
event.setWillDestroy(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Island island = islandManager.getIsland(player);
|
Island island = islandManager.getIsland(player);
|
||||||
@ -184,9 +182,12 @@ public class Levelling {
|
|||||||
|
|
||||||
// Filter out ItemStacks that can't be displayed in the inventory
|
// Filter out ItemStacks that can't be displayed in the inventory
|
||||||
Inventory testInventory = Bukkit.createInventory(null, 9);
|
Inventory testInventory = Bukkit.createInventory(null, 9);
|
||||||
|
|
||||||
for (String materialName : testIslandMaterialKeysOrdered) {
|
for (String materialName : testIslandMaterialKeysOrdered) {
|
||||||
if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null) continue;
|
if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null ||
|
||||||
if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") && mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0) continue;
|
!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") &&
|
||||||
|
mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
long value = testIslandMaterials.get(materialName);
|
long value = testIslandMaterials.get(materialName);
|
||||||
Materials materials = Materials.fromString(materialName);
|
Materials materials = Materials.fromString(materialName);
|
||||||
@ -199,6 +200,7 @@ public class Levelling {
|
|||||||
|
|
||||||
testInventory.clear();
|
testInventory.clear();
|
||||||
testInventory.setItem(0, is);
|
testInventory.setItem(0, is);
|
||||||
|
|
||||||
if (testInventory.getItem(0) != null) {
|
if (testInventory.getItem(0) != null) {
|
||||||
islandMaterials.put(materialName, value);
|
islandMaterials.put(materialName, value);
|
||||||
}
|
}
|
||||||
@ -208,10 +210,10 @@ public class Levelling {
|
|||||||
|
|
||||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||||
nInv.addItem(nInv.createItem(Materials.FIREWORK_STAR.parseItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null,
|
nInv.addItem(nInv.createItem(Materials.FIREWORK_STAR.parseItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null,
|
||||||
new ItemFlag[] { ItemFlag.HIDE_POTION_EFFECTS }), 3, 5);
|
new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 3, 5);
|
||||||
nInv.addItem(
|
nInv.addItem(
|
||||||
nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Statistics.Lore"),
|
nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Statistics.Lore"),
|
||||||
new Placeholder[] { new Placeholder("%level_points", NumberUtil.formatNumberByDecimal(level.getPoints())), new Placeholder("%level", NumberUtil.formatNumberByDecimal(level.getLevel())) }, null, null),
|
new Placeholder[]{new Placeholder("%level_points", NumberUtil.formatNumberByDecimal(level.getPoints())), new Placeholder("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))}, null, null),
|
||||||
4);
|
4);
|
||||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||||
|
|
||||||
@ -235,24 +237,33 @@ public class Levelling {
|
|||||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandMaterials.size() ? islandMaterials.size() - 1 : index + 36, inventorySlot = 17;
|
int index = playerMenuPage * 36 - 36, endIndex = index >= islandMaterials.size() ? islandMaterials.size() - 1 : index + 36, inventorySlot = 17;
|
||||||
|
|
||||||
for (; index < endIndex; index++) {
|
for (; index < endIndex; index++) {
|
||||||
if (islandMaterials.size() > index) {
|
if (islandMaterials.size() <= index)
|
||||||
|
break;
|
||||||
|
|
||||||
String material = (String) islandMaterials.keySet().toArray()[index];
|
String material = (String) islandMaterials.keySet().toArray()[index];
|
||||||
Materials materials = Materials.fromString(material);
|
Materials materials = Materials.fromString(material);
|
||||||
|
|
||||||
if (materials != null) {
|
if (materials == null)
|
||||||
|
break;
|
||||||
|
|
||||||
long materialAmount = islandMaterials.get(material);
|
long materialAmount = islandMaterials.get(material);
|
||||||
|
|
||||||
if (mainConfig.getFileConfiguration().getString("Materials." + material + ".Points") != null) {
|
if (mainConfig.getFileConfiguration().getString("Materials." + material + ".Points") == null)
|
||||||
|
break;
|
||||||
|
|
||||||
int pointsMultiplier = mainConfig.getFileConfiguration().getInt("Materials." + material + ".Points");
|
int pointsMultiplier = mainConfig.getFileConfiguration().getInt("Materials." + material + ".Points");
|
||||||
|
|
||||||
if (settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") || pointsMultiplier != 0) {
|
if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") && pointsMultiplier == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
inventorySlot++;
|
inventorySlot++;
|
||||||
|
|
||||||
long pointsEarned = materialAmount * pointsMultiplier;
|
long pointsEarned = materialAmount * pointsMultiplier;
|
||||||
|
|
||||||
String name = skyblock.getLocalizationManager().getLocalizationFor(Materials.class).getLocale(materials);
|
String name = skyblock.getLocalizationManager().getLocalizationFor(Materials.class).getLocale(materials);
|
||||||
|
|
||||||
if (materials == Materials.FARMLAND && NMSUtil.getVersionNumber() < 9) materials = Materials.DIRT;
|
if (materials == Materials.FARMLAND && NMSUtil.getVersionNumber() < 9)
|
||||||
|
materials = Materials.DIRT;
|
||||||
|
|
||||||
ItemStack is = materials.parseItem();
|
ItemStack is = materials.parseItem();
|
||||||
is.setAmount(Math.min(Math.toIntExact(materialAmount), 64));
|
is.setAmount(Math.min(Math.toIntExact(materialAmount), 64));
|
||||||
@ -265,15 +276,10 @@ public class Levelling {
|
|||||||
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name), lore, null, null, null), inventorySlot);
|
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name), lore, null, null, null), inventorySlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")));
|
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")));
|
||||||
nInv.setRows(6);
|
nInv.setRows(6);
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open());
|
Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
11
src/main/resources/rewards.yml
Normal file
11
src/main/resources/rewards.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# FabledSkyblock Island level rewards
|
||||||
|
1:
|
||||||
|
# Vault balance
|
||||||
|
money: 100
|
||||||
|
# Commands ran by console
|
||||||
|
commands:
|
||||||
|
- 'say %player% reached level 1!'
|
||||||
|
2:
|
||||||
|
money: 100
|
||||||
|
commands:
|
||||||
|
- 'say %player% reached level 1!'
|
Loading…
Reference in New Issue
Block a user