mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-27 20:56:05 +01:00
more things including island stuff.
This commit is contained in:
parent
46308e328f
commit
38a2e83391
@ -15,7 +15,7 @@ import com.songoda.skyblock.invite.InviteManager;
|
|||||||
import com.songoda.skyblock.island.IslandManager;
|
import com.songoda.skyblock.island.IslandManager;
|
||||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||||
import com.songoda.skyblock.levelling.LevellingManager;
|
import com.songoda.skyblock.levelling.LevellingManager;
|
||||||
import com.songoda.skyblock.limit.LimitManager;
|
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||||
import com.songoda.skyblock.listeners.*;
|
import com.songoda.skyblock.listeners.*;
|
||||||
import com.songoda.skyblock.menus.Rollback;
|
import com.songoda.skyblock.menus.Rollback;
|
||||||
import com.songoda.skyblock.menus.admin.Creator;
|
import com.songoda.skyblock.menus.admin.Creator;
|
||||||
@ -61,7 +61,6 @@ public class SkyBlock extends JavaPlugin {
|
|||||||
private UpgradeManager upgradeManager;
|
private UpgradeManager upgradeManager;
|
||||||
private PlayerDataManager playerDataManager;
|
private PlayerDataManager playerDataManager;
|
||||||
private CooldownManager cooldownManager;
|
private CooldownManager cooldownManager;
|
||||||
private LimitManager limitManager;
|
|
||||||
private ScoreboardManager scoreboardManager;
|
private ScoreboardManager scoreboardManager;
|
||||||
private InviteManager inviteManager;
|
private InviteManager inviteManager;
|
||||||
private BiomeManager biomeManager;
|
private BiomeManager biomeManager;
|
||||||
@ -76,6 +75,7 @@ public class SkyBlock extends JavaPlugin {
|
|||||||
private MessageManager messageManager;
|
private MessageManager messageManager;
|
||||||
private EconomyManager economyManager;
|
private EconomyManager economyManager;
|
||||||
private HologramManager hologramManager;
|
private HologramManager hologramManager;
|
||||||
|
private LimitationInstanceHandler limitationHandler;
|
||||||
|
|
||||||
public static SkyBlock getInstance() {
|
public static SkyBlock getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
@ -101,7 +101,7 @@ public class SkyBlock extends JavaPlugin {
|
|||||||
upgradeManager = new UpgradeManager(this);
|
upgradeManager = new UpgradeManager(this);
|
||||||
playerDataManager = new PlayerDataManager(this);
|
playerDataManager = new PlayerDataManager(this);
|
||||||
cooldownManager = new CooldownManager(this);
|
cooldownManager = new CooldownManager(this);
|
||||||
limitManager = new LimitManager(this);
|
limitationHandler = new LimitationInstanceHandler();
|
||||||
|
|
||||||
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
|
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
|
||||||
.getBoolean("Island.Scoreboard.Enable")) {
|
.getBoolean("Island.Scoreboard.Enable")) {
|
||||||
@ -261,10 +261,6 @@ public class SkyBlock extends JavaPlugin {
|
|||||||
return cooldownManager;
|
return cooldownManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimitManager getLimitManager() {
|
|
||||||
return limitManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScoreboardManager getScoreboardManager() {
|
public ScoreboardManager getScoreboardManager() {
|
||||||
return scoreboardManager;
|
return scoreboardManager;
|
||||||
}
|
}
|
||||||
@ -329,6 +325,10 @@ public class SkyBlock extends JavaPlugin {
|
|||||||
return stackableManager;
|
return stackableManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LimitationInstanceHandler getLimitationHandler() {
|
||||||
|
return limitationHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||||
return new VoidGenerator();
|
return new VoidGenerator();
|
||||||
|
@ -31,8 +31,7 @@ public class BanManager {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Map<UUID, Ban> banIslands = getIslands();
|
Map<UUID, Ban> banIslands = getIslands();
|
||||||
|
|
||||||
for (UUID banIslandList : banIslands.keySet()) {
|
for (Ban ban : banIslands.values()) {
|
||||||
Ban ban = banIslands.get(banIslandList);
|
|
||||||
ban.save();
|
ban.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,11 +95,7 @@ public class BanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Ban getIsland(UUID islandOwnerUUID) {
|
public Ban getIsland(UUID islandOwnerUUID) {
|
||||||
if (hasIsland(islandOwnerUUID)) {
|
return banStorage.get(islandOwnerUUID);
|
||||||
return banStorage.get(islandOwnerUUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID, Ban> getIslands() {
|
public Map<UUID, Ban> getIslands() {
|
||||||
@ -116,9 +111,7 @@ public class BanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeIsland(UUID islandOwnerUUID) {
|
public void removeIsland(UUID islandOwnerUUID) {
|
||||||
if (hasIsland(islandOwnerUUID)) {
|
banStorage.remove(islandOwnerUUID);
|
||||||
banStorage.remove(islandOwnerUUID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadIsland(UUID islandOwnerUUID) {
|
public void unloadIsland(UUID islandOwnerUUID) {
|
||||||
|
@ -11,8 +11,8 @@ import org.bukkit.block.Biome;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BiomeManager {
|
public class BiomeManager {
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ public class BiomeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBiome(Island island, Biome biome) {
|
public void setBiome(Island island, Biome biome) {
|
||||||
List<Chunk> chunks = new ArrayList<>();
|
Set<Chunk> chunks = new HashSet<>();
|
||||||
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
|
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
|
||||||
int radius = (int) Math.ceil(island.getRadius());
|
int radius = (int) Math.ceil(island.getRadius());
|
||||||
|
|
||||||
@ -31,8 +31,7 @@ public class BiomeManager {
|
|||||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
|
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
|
||||||
location.getWorld().setBiome(x, z, biome);
|
location.getWorld().setBiome(x, z, biome);
|
||||||
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
||||||
if (!chunks.contains(chunk))
|
chunks.add(chunk);
|
||||||
chunks.add(chunk);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
package com.songoda.skyblock.command.commands.admin;
|
package com.songoda.skyblock.command.commands.admin;
|
||||||
|
|
||||||
import com.songoda.skyblock.command.SubCommand;
|
import java.io.File;
|
||||||
import com.songoda.skyblock.config.FileManager;
|
import java.util.Map;
|
||||||
import com.songoda.skyblock.config.FileManager.Config;
|
|
||||||
import com.songoda.skyblock.generator.GeneratorManager;
|
|
||||||
import com.songoda.skyblock.hologram.HologramManager;
|
|
||||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
|
||||||
import com.songoda.skyblock.levelling.LevellingManager;
|
|
||||||
import com.songoda.skyblock.limit.LimitManager;
|
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
|
||||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
|
||||||
import com.songoda.skyblock.sound.SoundManager;
|
|
||||||
import com.songoda.skyblock.utils.version.Sounds;
|
|
||||||
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;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import com.songoda.skyblock.command.SubCommand;
|
||||||
import java.util.Map;
|
import com.songoda.skyblock.config.FileManager;
|
||||||
|
import com.songoda.skyblock.config.FileManager.Config;
|
||||||
|
import com.songoda.skyblock.generator.GeneratorManager;
|
||||||
|
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||||
|
import com.songoda.skyblock.levelling.LevellingManager;
|
||||||
|
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||||
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
|
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||||
|
import com.songoda.skyblock.sound.SoundManager;
|
||||||
|
import com.songoda.skyblock.utils.version.Sounds;
|
||||||
|
|
||||||
public class ReloadCommand extends SubCommand {
|
public class ReloadCommand extends SubCommand {
|
||||||
|
|
||||||
@ -35,10 +35,9 @@ public class ReloadCommand extends SubCommand {
|
|||||||
|
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||||
HologramManager hologramManager = skyblock.getHologramManager();
|
|
||||||
MessageManager messageManager = skyblock.getMessageManager();
|
MessageManager messageManager = skyblock.getMessageManager();
|
||||||
SoundManager soundManager = skyblock.getSoundManager();
|
SoundManager soundManager = skyblock.getSoundManager();
|
||||||
LimitManager limitManager = skyblock.getLimitManager();
|
LimitationInstanceHandler limitHandler = skyblock.getLimitationHandler();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
|
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
|
||||||
@ -96,7 +95,7 @@ public class ReloadCommand extends SubCommand {
|
|||||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
|
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
|
||||||
});
|
});
|
||||||
|
|
||||||
limitManager.reload();
|
limitHandler.reloadAll();
|
||||||
|
|
||||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||||
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
package com.songoda.skyblock.command.commands.admin;
|
package com.songoda.skyblock.command.commands.admin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.songoda.skyblock.command.SubCommand;
|
import com.songoda.skyblock.command.SubCommand;
|
||||||
import com.songoda.skyblock.config.FileManager;
|
import com.songoda.skyblock.config.FileManager;
|
||||||
import com.songoda.skyblock.config.FileManager.Config;
|
import com.songoda.skyblock.config.FileManager.Config;
|
||||||
@ -10,16 +19,6 @@ import com.songoda.skyblock.playerdata.PlayerDataManager;
|
|||||||
import com.songoda.skyblock.sound.SoundManager;
|
import com.songoda.skyblock.sound.SoundManager;
|
||||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||||
import com.songoda.skyblock.utils.version.Sounds;
|
import com.songoda.skyblock.utils.version.Sounds;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class SetAlwaysLoadedCommand extends SubCommand {
|
public class SetAlwaysLoadedCommand extends SubCommand {
|
||||||
|
|
||||||
@ -34,14 +33,21 @@ public class SetAlwaysLoadedCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
|
||||||
MessageManager messageManager = skyblock.getMessageManager();
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
|
||||||
SoundManager soundManager = skyblock.getSoundManager();
|
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
|
||||||
|
|
||||||
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
MessageManager messageManager = skyblock.getMessageManager();
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
messageManager.sendMessage(sender,
|
||||||
|
configLoad.getString("Command.Island.Admin.SetAlwaysLoaded.No-Player-Input.Message"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||||
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
|
SoundManager soundManager = skyblock.getSoundManager();
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.songoda.skyblock.confirmation;
|
package com.songoda.skyblock.confirmation;
|
||||||
|
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.songoda.skyblock.playerdata.PlayerData;
|
import com.songoda.skyblock.playerdata.PlayerData;
|
||||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
public class ConfirmationTask extends BukkitRunnable {
|
public class ConfirmationTask extends BukkitRunnable {
|
||||||
|
|
||||||
@ -16,13 +15,9 @@ public class ConfirmationTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
for (PlayerData playerData : playerDataManager.getPlayerData().values()) {
|
||||||
if (playerDataManager.hasPlayerData(all)) {
|
if (playerData.getConfirmationTime() > 0) {
|
||||||
PlayerData playerData = playerDataManager.getPlayerData(all);
|
playerData.setConfirmationTime(playerData.getConfirmationTime() - 1);
|
||||||
|
|
||||||
if (playerData.getConfirmationTime() > 0) {
|
|
||||||
playerData.setConfirmationTime(playerData.getConfirmationTime() - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,9 @@ import org.bukkit.entity.Player;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -21,14 +23,14 @@ public class CooldownManager {
|
|||||||
|
|
||||||
private final SkyBlock skyblock;
|
private final SkyBlock skyblock;
|
||||||
|
|
||||||
private Map<CooldownType, List<CooldownPlayer>> cooldownStorage = new HashMap<>();
|
private Map<CooldownType, List<CooldownPlayer>> cooldownStorage = new EnumMap<>(CooldownType.class);
|
||||||
|
|
||||||
public CooldownManager(SkyBlock skyblock) {
|
public CooldownManager(SkyBlock skyblock) {
|
||||||
this.skyblock = skyblock;
|
this.skyblock = skyblock;
|
||||||
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
|
|
||||||
for (CooldownType cooldownTypeList : CooldownType.values()) {
|
for (CooldownType cooldownTypeList : CooldownType.getTypes()) {
|
||||||
List<CooldownPlayer> cooldownPlayers = new ArrayList<>();
|
List<CooldownPlayer> cooldownPlayers = new ArrayList<>();
|
||||||
|
|
||||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||||
@ -60,7 +62,7 @@ public class CooldownManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for (CooldownType cooldownTypeList : CooldownType.values()) {
|
for (CooldownType cooldownTypeList : CooldownType.getTypes()) {
|
||||||
setCooldownPlayer(cooldownTypeList);
|
setCooldownPlayer(cooldownTypeList);
|
||||||
saveCooldownPlayer(cooldownTypeList);
|
saveCooldownPlayer(cooldownTypeList);
|
||||||
}
|
}
|
||||||
@ -69,23 +71,19 @@ public class CooldownManager {
|
|||||||
public CooldownPlayer loadCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public CooldownPlayer loadCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||||
Config config = skyblock.getFileManager()
|
Config config = skyblock.getFileManager()
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
|
||||||
player.getUniqueId().toString() + ".yml"));
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
if (configLoad.getString("Island." + cooldownType.name() + ".Cooldown") != null) {
|
if (configLoad.getString("Island." + cooldownType.name() + ".Cooldown") != null) {
|
||||||
return new CooldownPlayer(player.getUniqueId(),
|
return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt("Island." + cooldownType.name() + ".Cooldown")));
|
||||||
new Cooldown(configLoad.getInt("Island." + cooldownType.name() + ".Cooldown")));
|
|
||||||
}
|
}
|
||||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||||
Config config = skyblock.getFileManager()
|
Config config = skyblock.getFileManager()
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"));
|
||||||
player.getUniqueId().toString() + ".yml"));
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
if (configLoad.getString(cooldownType.name() + ".Cooldown") != null) {
|
if (configLoad.getString(cooldownType.name() + ".Cooldown") != null) {
|
||||||
return new CooldownPlayer(player.getUniqueId(),
|
return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt(cooldownType.name() + ".Cooldown")));
|
||||||
new Cooldown(configLoad.getInt(cooldownType.name() + ".Cooldown")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,79 +93,73 @@ public class CooldownManager {
|
|||||||
public void createPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public void createPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
List<CooldownPlayer> cooldowns = cooldownStorage.get(cooldownType);
|
||||||
int time = 0;
|
|
||||||
|
|
||||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
if (cooldowns == null) return;
|
||||||
time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
|
||||||
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
|
||||||
|
|
||||||
Config config = fileManager
|
int time = 0;
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
|
||||||
player.getUniqueId().toString() + ".yml"));
|
|
||||||
File configFile = config.getFile();
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
|
||||||
|
|
||||||
configLoad.set("Island." + cooldownType.name() + ".Cooldown", time);
|
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||||
|
time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||||
|
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
||||||
|
|
||||||
try {
|
Config config = fileManager
|
||||||
configLoad.save(configFile);
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
|
||||||
} catch (IOException e) {
|
File configFile = config.getFile();
|
||||||
e.printStackTrace();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
}
|
|
||||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
|
||||||
time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
|
||||||
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
|
||||||
|
|
||||||
Config config = skyblock.getFileManager()
|
configLoad.set("Island." + cooldownType.name() + ".Cooldown", time);
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
|
||||||
player.getUniqueId().toString() + ".yml"));
|
|
||||||
File configFile = config.getFile();
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
|
||||||
|
|
||||||
configLoad.set(cooldownType.name() + ".Cooldown", time);
|
try {
|
||||||
|
configLoad.save(configFile);
|
||||||
try {
|
} catch (IOException e) {
|
||||||
configLoad.save(configFile);
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||||
|
time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||||
|
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
||||||
|
|
||||||
cooldownStorage.get(cooldownType).add(new CooldownPlayer(player.getUniqueId(), new Cooldown(time)));
|
Config config = skyblock.getFileManager()
|
||||||
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"));
|
||||||
|
File configFile = config.getFile();
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
configLoad.set(cooldownType.name() + ".Cooldown", time);
|
||||||
|
|
||||||
|
try {
|
||||||
|
configLoad.save(configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cooldowns.add(new CooldownPlayer(player.getUniqueId(), new Cooldown(time)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deletePlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public void deletePlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (Iterator<CooldownPlayer> it = getCooldownPlayersOrEmptyList(cooldownType).iterator(); it.hasNext();) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
if (it.next().getUUID().equals(player.getUniqueId())) {
|
||||||
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
skyblock.getFileManager()
|
||||||
skyblock.getFileManager()
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
player.getUniqueId().toString() + ".yml"))
|
||||||
player.getUniqueId().toString() + ".yml"))
|
.getFileConfiguration().set("Island." + cooldownType.name() + ".Cooldown", null);
|
||||||
.getFileConfiguration().set("Island." + cooldownType.name() + ".Cooldown", null);
|
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
skyblock.getFileManager().getConfig(
|
||||||
skyblock.getFileManager()
|
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"))
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
.getFileConfiguration().set(cooldownType.name() + ".Cooldown", null);
|
||||||
player.getUniqueId().toString() + ".yml"))
|
|
||||||
.getFileConfiguration().set(cooldownType.name() + ".Cooldown", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
cooldownStorage.get(cooldownType).remove(cooldownPlayerList);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
it.remove();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public boolean hasPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||||
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,72 +167,55 @@ public class CooldownManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void transferPlayer(CooldownType cooldownType, OfflinePlayer player1, OfflinePlayer player2) {
|
public void transferPlayer(CooldownType cooldownType, OfflinePlayer player1, OfflinePlayer player2) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
if (cooldownPlayerList.getUUID().equals(player1.getUniqueId())) {
|
||||||
if (cooldownPlayerList.getUUID().equals(player1.getUniqueId())) {
|
cooldownPlayerList.setUUID(player2.getUniqueId());
|
||||||
cooldownPlayerList.setUUID(player2.getUniqueId());
|
break;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCooldownPlayer(CooldownType cooldownType, CooldownPlayer cooldownPlayer) {
|
public void removeCooldownPlayer(CooldownType cooldownType, CooldownPlayer cooldownPlayer) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
getCooldownPlayersOrEmptyList(cooldownType).remove(cooldownPlayer);
|
||||||
cooldownStorage.get(cooldownType).remove(cooldownPlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public void removeCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (Iterator<CooldownPlayer> it = getCooldownPlayersOrEmptyList(cooldownType).iterator(); it.hasNext();) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
if (it.next().getUUID().equals(player.getUniqueId())) {
|
||||||
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
it.remove();
|
||||||
cooldownStorage.get(cooldownType).remove(cooldownPlayerList);
|
break;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCooldownPlayer(CooldownType cooldownType) {
|
public void setCooldownPlayer(CooldownType cooldownType) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
setCooldownPlayer(cooldownType, Bukkit.getServer().getOfflinePlayer(cooldownPlayerList.getUUID()));
|
||||||
setCooldownPlayer(cooldownType, Bukkit.getServer().getOfflinePlayer(cooldownPlayerList.getUUID()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public void setCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
||||||
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
skyblock.getFileManager()
|
||||||
skyblock.getFileManager()
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
player.getUniqueId().toString() + ".yml"))
|
||||||
player.getUniqueId().toString() + ".yml"))
|
.getFileConfiguration().set("Island." + cooldownType + ".Cooldown", cooldownPlayerList.getCooldown().getTime());
|
||||||
.getFileConfiguration().set("Island." + cooldownType + ".Cooldown",
|
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||||
cooldownPlayerList.getCooldown().getTime());
|
skyblock.getFileManager()
|
||||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
||||||
skyblock.getFileManager()
|
player.getUniqueId().toString() + ".yml"))
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
.getFileConfiguration().set(cooldownType.name() + ".Cooldown", cooldownPlayerList.getCooldown().getTime());
|
||||||
player.getUniqueId().toString() + ".yml"))
|
|
||||||
.getFileConfiguration()
|
|
||||||
.set(cooldownType.name() + ".Cooldown", cooldownPlayerList.getCooldown().getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCooldownPlayer(CooldownType cooldownType) {
|
public void saveCooldownPlayer(CooldownType cooldownType) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
saveCooldownPlayer(cooldownType, Bukkit.getServer().getOfflinePlayer(cooldownPlayerList.getUUID()));
|
||||||
saveCooldownPlayer(cooldownType, Bukkit.getServer().getOfflinePlayer(cooldownPlayerList.getUUID()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,12 +224,10 @@ public class CooldownManager {
|
|||||||
|
|
||||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||||
config = skyblock.getFileManager()
|
config = skyblock.getFileManager()
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
|
||||||
player.getUniqueId().toString() + ".yml"));
|
|
||||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||||
config = skyblock.getFileManager()
|
config = skyblock.getFileManager()
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"));
|
||||||
player.getUniqueId().toString() + ".yml"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
@ -267,19 +240,20 @@ public class CooldownManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addCooldownPlayer(CooldownType cooldownType, CooldownPlayer cooldownPlayer) {
|
public void addCooldownPlayer(CooldownType cooldownType, CooldownPlayer cooldownPlayer) {
|
||||||
if (cooldownType != null && cooldownPlayer != null) {
|
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
if (cooldownType == null || cooldownPlayer == null) return;
|
||||||
cooldownStorage.get(cooldownType).add(cooldownPlayer);
|
|
||||||
}
|
List<CooldownPlayer> cooldowns = cooldownStorage.get(cooldownType);
|
||||||
}
|
|
||||||
|
if (cooldowns == null) return;
|
||||||
|
|
||||||
|
cooldowns.add(cooldownPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CooldownPlayer getCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
public CooldownPlayer getCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||||
for (CooldownPlayer cooldownPlayerList : cooldownStorage.get(cooldownType)) {
|
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
||||||
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
return cooldownPlayerList;
|
||||||
return cooldownPlayerList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,14 +261,21 @@ public class CooldownManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<CooldownPlayer> getCooldownPlayers(CooldownType cooldownType) {
|
public List<CooldownPlayer> getCooldownPlayers(CooldownType cooldownType) {
|
||||||
if (cooldownStorage.containsKey(cooldownType)) {
|
return cooldownStorage.get(cooldownType);
|
||||||
return cooldownStorage.get(cooldownType);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
/**
|
||||||
|
* Convenience method. This method functions the same as
|
||||||
|
* {@link CooldownManager#getCooldownPlayers(CooldownType)} but returns a
|
||||||
|
* {@link Collections#emptyList()} when no value is present in the map under the
|
||||||
|
* key, cooldownType.
|
||||||
|
*/
|
||||||
|
public List<CooldownPlayer> getCooldownPlayersOrEmptyList(CooldownType cooldownType) {
|
||||||
|
return cooldownStorage.getOrDefault(cooldownType, Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCooldownType(CooldownType cooldownType) {
|
public boolean hasCooldownType(CooldownType cooldownType) {
|
||||||
return cooldownStorage.containsKey(cooldownType);
|
return cooldownStorage.containsKey(cooldownType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,22 +15,22 @@ public class CooldownTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (CooldownType cooldownTypeList : CooldownType.values()) {
|
for (CooldownType cooldownType : CooldownType.getTypes()) {
|
||||||
if (cooldownManager.hasCooldownType(cooldownTypeList)) {
|
List<CooldownPlayer> cooldownPlayers = cooldownManager.getCooldownPlayers(cooldownType);
|
||||||
List<CooldownPlayer> cooldownPlayers = cooldownManager.getCooldownPlayers(cooldownTypeList);
|
|
||||||
|
|
||||||
for (int i = 0; i < cooldownPlayers.size(); i++) {
|
if (cooldownPlayers == null) return;
|
||||||
CooldownPlayer cooldownPlayer = cooldownPlayers.get(i);
|
|
||||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
|
||||||
|
|
||||||
cooldown.setTime(cooldown.getTime() - 1);
|
for (int i = 0; i < cooldownPlayers.size(); i++) {
|
||||||
|
CooldownPlayer cooldownPlayer = cooldownPlayers.get(i);
|
||||||
|
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||||
|
|
||||||
if (cooldown.getTime() <= 0) {
|
cooldown.setTime(cooldown.getTime() - 1);
|
||||||
cooldownManager.deletePlayer(cooldownTypeList,
|
|
||||||
Bukkit.getServer().getOfflinePlayer(cooldownPlayer.getUUID()));
|
if (cooldown.getTime() <= 0) {
|
||||||
}
|
cooldownManager.deletePlayer(cooldownType, Bukkit.getServer().getOfflinePlayer(cooldownPlayer.getUUID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
package com.songoda.skyblock.cooldown;
|
package com.songoda.skyblock.cooldown;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public enum CooldownType {
|
public enum CooldownType {
|
||||||
|
|
||||||
Biome, Creation, Levelling, Ownership, Teleport
|
Biome,
|
||||||
|
Creation,
|
||||||
|
Levelling,
|
||||||
|
Ownership,
|
||||||
|
Teleport;
|
||||||
|
|
||||||
|
private static final Set<CooldownType> types = Collections.unmodifiableSet(EnumSet.allOf(CooldownType.class));
|
||||||
|
|
||||||
|
public static Set<CooldownType> getTypes() {
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,22 +18,17 @@ public class InviteManager {
|
|||||||
public Invite createInvite(Player player, Player sender, UUID owner, int time) {
|
public Invite createInvite(Player player, Player sender, UUID owner, int time) {
|
||||||
Invite invite = new Invite(player, sender, owner, time);
|
Invite invite = new Invite(player, sender, owner, time);
|
||||||
inviteStorage.put(player.getUniqueId(), invite);
|
inviteStorage.put(player.getUniqueId(), invite);
|
||||||
|
|
||||||
return invite;
|
return invite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeInvite(UUID uuid) {
|
public void removeInvite(UUID uuid) {
|
||||||
if (hasInvite(uuid)) {
|
inviteStorage.remove(uuid);
|
||||||
inviteStorage.remove(uuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tranfer(UUID uuid1, UUID uuid2) {
|
public void tranfer(UUID uuid1, UUID uuid2) {
|
||||||
Map<UUID, Invite> islandInvites = getInvites();
|
Map<UUID, Invite> islandInvites = getInvites();
|
||||||
|
|
||||||
for (UUID islandInviteList : islandInvites.keySet()) {
|
for (Invite invite : islandInvites.values()) {
|
||||||
Invite invite = islandInvites.get(islandInviteList);
|
|
||||||
|
|
||||||
if (invite.getOwnerUUID().equals(uuid1)) {
|
if (invite.getOwnerUUID().equals(uuid1)) {
|
||||||
invite.setOwnerUUID(uuid2);
|
invite.setOwnerUUID(uuid2);
|
||||||
}
|
}
|
||||||
@ -45,11 +40,7 @@ public class InviteManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Invite getInvite(UUID uuid) {
|
public Invite getInvite(UUID uuid) {
|
||||||
if (hasInvite(uuid)) {
|
return inviteStorage.get(uuid);
|
||||||
return inviteStorage.get(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasInvite(UUID uuid) {
|
public boolean hasInvite(UUID uuid) {
|
||||||
|
@ -27,6 +27,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class Island {
|
public class Island {
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ public class Island {
|
|||||||
|
|
||||||
if (playerDataConfigLoad.getString("Island.Owner") == null
|
if (playerDataConfigLoad.getString("Island.Owner") == null
|
||||||
|| !playerDataConfigLoad.getString("Island.Owner").equals(ownerUUID.toString())) {
|
|| !playerDataConfigLoad.getString("Island.Owner").equals(ownerUUID.toString())) {
|
||||||
members.remove(member);
|
members.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ public class Island {
|
|||||||
|
|
||||||
if (playerDataConfigLoad.getString("Island.Owner") == null
|
if (playerDataConfigLoad.getString("Island.Owner") == null
|
||||||
|| !playerDataConfigLoad.getString("Island.Owner").equals(ownerUUID.toString())) {
|
|| !playerDataConfigLoad.getString("Island.Owner").equals(ownerUUID.toString())) {
|
||||||
operators.remove(operator);
|
operators.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,24 +132,21 @@ public class Island {
|
|||||||
|
|
||||||
Config settingsDataConfig = null;
|
Config settingsDataConfig = null;
|
||||||
|
|
||||||
if (fileManager.isFileExist(new File(skyblock.getDataFolder().toString() + "/setting-data",
|
File settingDataFile = new File(skyblock.getDataFolder().toString() + "/setting-data", getOwnerUUID().toString() + ".yml");
|
||||||
getOwnerUUID().toString() + ".yml"))) {
|
|
||||||
settingsDataConfig = fileManager.getConfig(new File(
|
if (fileManager.isFileExist(settingDataFile)) {
|
||||||
skyblock.getDataFolder().toString() + "/setting-data", getOwnerUUID().toString() + ".yml"));
|
settingsDataConfig = fileManager.getConfig(settingDataFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IslandRole roleList : IslandRole.values()) {
|
for (IslandRole roleList : IslandRole.getRoles()) {
|
||||||
List<IslandSetting> settings = new ArrayList<>();
|
List<IslandSetting> settings = new ArrayList<>();
|
||||||
|
|
||||||
for (String settingList : defaultSettingsConfig.getFileConfiguration()
|
for (String settingList : defaultSettingsConfig.getFileConfiguration().getConfigurationSection("Settings." + roleList.name()).getKeys(false)) {
|
||||||
.getConfigurationSection("Settings." + roleList.name()).getKeys(false)) {
|
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration().getString("Settings." + roleList.name() + "." + settingList) == null) {
|
||||||
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
|
settings.add(
|
||||||
.getString("Settings." + roleList.name() + "." + settingList) == null) {
|
new IslandSetting(settingList, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + settingList)));
|
||||||
settings.add(new IslandSetting(settingList, defaultSettingsConfig.getFileConfiguration()
|
|
||||||
.getBoolean("Settings." + roleList.name() + "." + settingList)));
|
|
||||||
} else {
|
} else {
|
||||||
settings.add(new IslandSetting(settingList, settingsDataConfig.getFileConfiguration()
|
settings.add(new IslandSetting(settingList, settingsDataConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + settingList)));
|
||||||
.getBoolean("Settings." + roleList.name() + "." + settingList)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +165,13 @@ public class Island {
|
|||||||
configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase());
|
configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase());
|
||||||
configLoad.set("Ownership.Original", ownerUUID.toString());
|
configLoad.set("Ownership.Original", ownerUUID.toString());
|
||||||
|
|
||||||
for (IslandRole roleList : IslandRole.values()) {
|
for (IslandRole roleList : IslandRole.getRoles()) {
|
||||||
List<IslandSetting> settings = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String settingList : defaultSettingsConfig.getFileConfiguration()
|
Set<String> keys = defaultSettingsConfig.getFileConfiguration().getConfigurationSection("Settings." + roleList.name()).getKeys(false);
|
||||||
.getConfigurationSection("Settings." + roleList.name()).getKeys(false)) {
|
List<IslandSetting> settings = new ArrayList<>(keys.size());
|
||||||
settings.add(new IslandSetting(settingList, defaultSettingsConfig.getFileConfiguration()
|
|
||||||
.getBoolean("Settings." + roleList.name() + "." + settingList)));
|
for (String settingList : keys) {
|
||||||
|
settings.add(new IslandSetting(settingList, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + settingList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
islandSettings.put(roleList, settings);
|
islandSettings.put(roleList, settings);
|
||||||
@ -227,12 +225,8 @@ public class Island {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UUID getOriginalOwnerUUID() {
|
public UUID getOriginalOwnerUUID() {
|
||||||
return UUID
|
return UUID.fromString(skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
|
||||||
.fromString(
|
.getFileConfiguration().getString("Ownership.Original"));
|
||||||
skyblock.getFileManager()
|
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
|
||||||
ownerUUID.toString() + ".yml"))
|
|
||||||
.getFileConfiguration().getString("Ownership.Original"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
@ -772,9 +766,9 @@ public class Island {
|
|||||||
.getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml"));
|
.getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
for (IslandRole roleList : islandSettings.keySet()) {
|
for (Entry<IslandRole, List<IslandSetting>> entry : islandSettings.entrySet()) {
|
||||||
for (IslandSetting settingList : islandSettings.get(roleList)) {
|
for (IslandSetting setting : entry.getValue()) {
|
||||||
configLoad.set("Settings." + roleList + "." + settingList.getName(), settingList.getStatus());
|
configLoad.set("Settings." + entry.getKey() + "." + setting.getName(), setting.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,7 +784,7 @@ public class Island {
|
|||||||
.getConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml"));
|
.getConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml"));
|
||||||
configLoad = config.getFileConfiguration();
|
configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
List<String> coopPlayersAsString = new ArrayList<>();
|
List<String> coopPlayersAsString = new ArrayList<>(coopPlayers.size());
|
||||||
|
|
||||||
for (Map.Entry<UUID, IslandCoop> entry : coopPlayers.entrySet()) {
|
for (Map.Entry<UUID, IslandCoop> entry : coopPlayers.entrySet()) {
|
||||||
if (entry.getValue() == IslandCoop.TEMP) continue;
|
if (entry.getValue() == IslandCoop.TEMP) continue;
|
||||||
|
@ -2,12 +2,16 @@ package com.songoda.skyblock.island;
|
|||||||
|
|
||||||
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 org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class IslandLevel {
|
public class IslandLevel {
|
||||||
@ -25,18 +29,25 @@ public class IslandLevel {
|
|||||||
this.skyblock = skyblock;
|
this.skyblock = skyblock;
|
||||||
this.ownerUUID = ownerUUID;
|
this.ownerUUID = ownerUUID;
|
||||||
|
|
||||||
Config config = skyblock.getFileManager().getConfig(
|
Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
||||||
new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
Map<String, Long> materials = new HashMap<>();
|
Map<String, Long> materials;
|
||||||
|
|
||||||
if (configLoad.getString("Levelling.Materials") != null) {
|
ConfigurationSection materialSection = configLoad.getConfigurationSection("Leveling.Materials");
|
||||||
for (String materialList : configLoad.getConfigurationSection("Levelling.Materials").getKeys(false)) {
|
|
||||||
if (configLoad.getString("Levelling.Materials." + materialList + ".Amount") != null) {
|
if (materialSection != null) {
|
||||||
materials.put(materialList, configLoad.getLong("Levelling.Materials." + materialList + ".Amount"));
|
Set<String> keys = materialSection.getKeys(false);
|
||||||
}
|
materials = new HashMap<>(keys.size() * 2);
|
||||||
|
|
||||||
|
for (String material : materialSection.getKeys(false)) {
|
||||||
|
|
||||||
|
final ConfigurationSection current = materialSection.getConfigurationSection(material);
|
||||||
|
|
||||||
|
if (current.isSet("Amount")) materials.put(material, current.getLong("Amount"));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
materials = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.materials = materials;
|
this.materials = materials;
|
||||||
@ -50,18 +61,18 @@ public class IslandLevel {
|
|||||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
|
||||||
|
|
||||||
|
if (materialSection == null) return 0;
|
||||||
|
|
||||||
long pointsEarned = 0;
|
long pointsEarned = 0;
|
||||||
|
|
||||||
for (String materialList : this.materials.keySet()) {
|
for (Entry<String, Long> entry : this.materials.entrySet()) {
|
||||||
long materialAmount = this.materials.get(materialList);
|
ConfigurationSection current = materialSection.getConfigurationSection(entry.getKey());
|
||||||
|
|
||||||
if (configLoad.getString("Materials." + materialList + ".Points") != null) {
|
long pointsRequired = current.getLong("Points", 0);
|
||||||
long pointsRequired = config.getFileConfiguration().getLong("Materials." + materialList + ".Points");
|
|
||||||
|
|
||||||
if (pointsRequired != 0) {
|
if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired);
|
||||||
pointsEarned = pointsEarned + (materialAmount * pointsRequired);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pointsEarned;
|
return pointsEarned;
|
||||||
@ -71,26 +82,25 @@ public class IslandLevel {
|
|||||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
long pointsEarned = 0;
|
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
|
||||||
|
|
||||||
if (this.materials.containsKey(material)) {
|
if (materialSection == null) return 0;
|
||||||
long materialAmount = this.materials.get(material);
|
|
||||||
|
|
||||||
if (configLoad.getString("Materials." + material + ".Points") != null) {
|
ConfigurationSection current = materialSection.getConfigurationSection(material);
|
||||||
long pointsRequired = configLoad.getLong("Materials." + material + ".Points");
|
|
||||||
|
|
||||||
if (pointsRequired != 0) {
|
if (current == null) return 0;
|
||||||
pointsEarned = materialAmount * pointsRequired;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pointsEarned;
|
Long boxedAmount = this.materials.get(material);
|
||||||
|
|
||||||
|
if (boxedAmount == null) return 0;
|
||||||
|
|
||||||
|
long pointsRequired = current.getLong("Points");
|
||||||
|
|
||||||
|
return pointsRequired == 0 ? 0 : boxedAmount * pointsRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLevel() {
|
public long getLevel() {
|
||||||
long division = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
long division = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Division");
|
||||||
.getFileConfiguration().getLong("Island.Levelling.Division");
|
|
||||||
|
|
||||||
if (division == 0) {
|
if (division == 0) {
|
||||||
division = 1;
|
division = 1;
|
||||||
@ -100,27 +110,19 @@ public class IslandLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMaterialAmount(String material, long amount) {
|
public void setMaterialAmount(String material, long amount) {
|
||||||
skyblock.getFileManager()
|
skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration()
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"),
|
.set("Levelling.Materials." + material + ".Amount", amount);
|
||||||
ownerUUID.toString() + ".yml"))
|
|
||||||
.getFileConfiguration().set("Levelling.Materials." + material + ".Amount", amount);
|
|
||||||
|
|
||||||
this.materials.put(material, amount);
|
this.materials.put(material, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMaterialAmount(String material) {
|
public long getMaterialAmount(String material) {
|
||||||
if (this.materials.containsKey(material)) {
|
return this.materials.getOrDefault(material, 0l);
|
||||||
return this.materials.get(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMaterial(String material) {
|
public void removeMaterial(String material) {
|
||||||
skyblock.getFileManager()
|
skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration()
|
||||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"),
|
.set("Levelling.Materials." + material, null);
|
||||||
ownerUUID.toString() + ".yml"))
|
|
||||||
.getFileConfiguration().set("Levelling.Materials." + material, null);
|
|
||||||
|
|
||||||
this.materials.remove(material);
|
this.materials.remove(material);
|
||||||
}
|
}
|
||||||
@ -138,8 +140,7 @@ public class IslandLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMaterials(Map<String, Long> materials) {
|
public void setMaterials(Map<String, Long> materials) {
|
||||||
Config config = skyblock.getFileManager().getConfig(
|
Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
||||||
new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
configLoad.set("Levelling.Materials", null);
|
configLoad.set("Levelling.Materials", null);
|
||||||
@ -168,8 +169,7 @@ public class IslandLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
Config config = skyblock.getFileManager().getConfig(
|
Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
||||||
new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
|
|
||||||
File configFile = config.getFile();
|
File configFile = config.getFile();
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
@ -616,6 +616,7 @@ public class IslandManager {
|
|||||||
|
|
||||||
island.save();
|
island.save();
|
||||||
|
|
||||||
|
|
||||||
int islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1,
|
int islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1,
|
||||||
islandVisitors = getVisitorsAtIsland(island).size();
|
islandVisitors = getVisitorsAtIsland(island).size();
|
||||||
boolean unloadIsland = true;
|
boolean unloadIsland = true;
|
||||||
@ -627,7 +628,7 @@ public class IslandManager {
|
|||||||
|
|
||||||
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|
||||||
|| island.hasRole(IslandRole.Operator, all.getUniqueId())
|
|| island.hasRole(IslandRole.Operator, all.getUniqueId())
|
||||||
|| island.hasRole(IslandRole.Owner, all.getUniqueId())) {
|
|| island.hasRole(IslandRole.Owner, all.getUniqueId()) || island.getCoopType(all.getUniqueId()) == IslandCoop.NORMAL) {
|
||||||
if (scoreboardManager != null) {
|
if (scoreboardManager != null) {
|
||||||
try {
|
try {
|
||||||
if (islandMembers == 1 && islandVisitors == 0) {
|
if (islandMembers == 1 && islandVisitors == 0) {
|
||||||
@ -1292,6 +1293,8 @@ public class IslandManager {
|
|||||||
for (UUID coopPlayerAtIslandList : getCoopPlayersAtIsland(island)) {
|
for (UUID coopPlayerAtIslandList : getCoopPlayersAtIsland(island)) {
|
||||||
Player targetPlayer = Bukkit.getServer().getPlayer(coopPlayerAtIslandList);
|
Player targetPlayer = Bukkit.getServer().getPlayer(coopPlayerAtIslandList);
|
||||||
|
|
||||||
|
if(island.getCoopType(coopPlayerAtIslandList) == IslandCoop.NORMAL) continue;
|
||||||
|
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||||
|
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
package com.songoda.skyblock.island;
|
package com.songoda.skyblock.island;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public enum IslandRole {
|
public enum IslandRole {
|
||||||
|
|
||||||
Coop, Visitor, Member, Operator, Owner
|
Coop,
|
||||||
|
Visitor,
|
||||||
|
Member,
|
||||||
|
Operator,
|
||||||
|
Owner;
|
||||||
|
|
||||||
|
private static final Set<IslandRole> roles = Collections.unmodifiableSet(EnumSet.allOf(IslandRole.class));
|
||||||
|
|
||||||
|
public static Set<IslandRole> getRoles() {
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@ public class TopBank extends DataCollector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Entry<?, Double>> requestAll() {
|
public List<Entry<?, Double>> requestAll() {
|
||||||
Map<UUID, Double> topLevels = new HashMap<>();
|
|
||||||
|
|
||||||
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Bank);
|
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Bank);
|
||||||
|
Map<UUID, Double> topLevels = new HashMap<>(leaderboards.size());
|
||||||
|
|
||||||
for (Leaderboard leaderboard : leaderboards) {
|
for (Leaderboard leaderboard : leaderboards) {
|
||||||
Visit visit = leaderboard.getVisit();
|
Visit visit = leaderboard.getVisit();
|
||||||
|
@ -26,9 +26,9 @@ public class TopLevel extends DataCollector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Entry<?, Double>> requestAll() {
|
public List<Entry<?, Double>> requestAll() {
|
||||||
Map<UUID, Double> topLevels = new HashMap<>();
|
|
||||||
|
|
||||||
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Leaderboard.Type.Level);
|
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Leaderboard.Type.Level);
|
||||||
|
Map<UUID, Double> topLevels = new HashMap<>(leaderboards.size());
|
||||||
|
|
||||||
for (int i = 0; i < leaderboards.size(); i++) {
|
for (int i = 0; i < leaderboards.size(); i++) {
|
||||||
Leaderboard leaderboard = leaderboards.get(i);
|
Leaderboard leaderboard = leaderboards.get(i);
|
||||||
|
@ -27,9 +27,9 @@ public class TopVotes extends DataCollector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Entry<?, Double>> requestAll() {
|
public List<Entry<?, Double>> requestAll() {
|
||||||
Map<UUID, Double> topLevels = new HashMap<>();
|
|
||||||
|
|
||||||
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Votes);
|
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Votes);
|
||||||
|
Map<UUID, Double> topLevels = new HashMap<>(leaderboards.size());
|
||||||
|
|
||||||
for (int i = 0; i < leaderboards.size(); i++) {
|
for (int i = 0; i < leaderboards.size(); i++) {
|
||||||
Leaderboard leaderboard = leaderboards.get(i);
|
Leaderboard leaderboard = leaderboards.get(i);
|
||||||
|
77
src/main/java/com/songoda/skyblock/limit/EnumLimitation.java
Normal file
77
src/main/java/com/songoda/skyblock/limit/EnumLimitation.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package com.songoda.skyblock.limit;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public abstract class EnumLimitation<K extends Enum<K>> implements Limitation {
|
||||||
|
|
||||||
|
private long defaultLimit;
|
||||||
|
private final Class<K> type;
|
||||||
|
private final Map<K, Long> map;
|
||||||
|
|
||||||
|
public EnumLimitation(Class<K> type) {
|
||||||
|
this.defaultLimit = -1;
|
||||||
|
this.map = new EnumMap<>(type);
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBeingTracked(Enum<K> type) {
|
||||||
|
return map.containsKey(type) || getDefault() >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Map<K, Long> getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDefault() {
|
||||||
|
return defaultLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasTooMuch(long currentAmount, Enum<K> type) {
|
||||||
|
final long cached = map.getOrDefault(type, getDefault());
|
||||||
|
|
||||||
|
if (cached <= -1) return false;
|
||||||
|
|
||||||
|
return currentAmount > cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload(ConfigurationSection loadFrom) {
|
||||||
|
unload();
|
||||||
|
|
||||||
|
if (loadFrom == null) return;
|
||||||
|
|
||||||
|
final Set<String> keys = loadFrom.getKeys(false);
|
||||||
|
|
||||||
|
removeAndLoadDefaultLimit(loadFrom, keys);
|
||||||
|
|
||||||
|
for (String key : keys) {
|
||||||
|
|
||||||
|
final String enumName = key.toUpperCase(Locale.ENGLISH);
|
||||||
|
|
||||||
|
try {
|
||||||
|
map.put(Enum.valueOf(type, enumName), loadFrom.getLong(key));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new IllegalArgumentException("Incorrect enum constant '" + enumName + "' in " + loadFrom.getCurrentPath(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unload() {
|
||||||
|
map.clear();
|
||||||
|
defaultLimit = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void removeAndLoadDefaultLimit(ConfigurationSection loadFrom, Set<String> keys) {
|
||||||
|
keys.remove("DefaultLimit");
|
||||||
|
defaultLimit = loadFrom.getInt("DefaultLimit", -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,115 +0,0 @@
|
|||||||
package com.songoda.skyblock.limit;
|
|
||||||
|
|
||||||
import com.songoda.skyblock.SkyBlock;
|
|
||||||
import com.songoda.skyblock.island.Island;
|
|
||||||
import com.songoda.skyblock.island.IslandManager;
|
|
||||||
import com.songoda.skyblock.utils.version.Materials;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class LimitManager {
|
|
||||||
|
|
||||||
private final SkyBlock skyblock;
|
|
||||||
private Map<Materials, Long> blockLimits;
|
|
||||||
|
|
||||||
public LimitManager(SkyBlock skyblock) {
|
|
||||||
this.skyblock = skyblock;
|
|
||||||
this.blockLimits = new HashMap<>();
|
|
||||||
|
|
||||||
this.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload() {
|
|
||||||
this.blockLimits.clear();
|
|
||||||
|
|
||||||
FileConfiguration limitsConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "limits.yml")).getFileConfiguration();
|
|
||||||
ConfigurationSection blockLimitSection = limitsConfig.getConfigurationSection("block");
|
|
||||||
|
|
||||||
if (blockLimitSection != null) {
|
|
||||||
for (String materialString : blockLimitSection.getKeys(false)) {
|
|
||||||
Materials material = Materials.fromString(materialString);
|
|
||||||
if (material != null) {
|
|
||||||
long limit = blockLimitSection.getLong(materialString);
|
|
||||||
this.blockLimits.put(material, limit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max number of a type of block a player can place
|
|
||||||
*
|
|
||||||
* @param player The player to check
|
|
||||||
* @param block The block to check
|
|
||||||
* @return The max number of the type of block the player can place
|
|
||||||
*/
|
|
||||||
public long getBlockLimit(Player player, Block block) {
|
|
||||||
if (player == null || block == null)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (player.hasPermission("fabledskyblock.limit.block.*"))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
|
||||||
if (material == null)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
long limit = -1;
|
|
||||||
if (this.blockLimits.containsKey(material))
|
|
||||||
limit = Math.max(limit, this.blockLimits.get(material));
|
|
||||||
|
|
||||||
Set<PermissionAttachmentInfo> permissions = player.getEffectivePermissions()
|
|
||||||
.stream()
|
|
||||||
.filter(x -> x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block." + material.name().toLowerCase()))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
for (PermissionAttachmentInfo permission : permissions) {
|
|
||||||
try {
|
|
||||||
String permString = permission.getPermission();
|
|
||||||
String numberString = permString.substring(permString.lastIndexOf(".") + 1);
|
|
||||||
if (numberString.equals("*"))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
limit = Math.max(limit, Integer.parseInt(numberString));
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a player has exceeded the number of blocks they can place
|
|
||||||
*
|
|
||||||
* @param player The player to check
|
|
||||||
* @param block The block to check
|
|
||||||
* @return true if the player has exceeded the block limit, otherwise false
|
|
||||||
*/
|
|
||||||
public boolean isBlockLimitExceeded(Player player, Block block) {
|
|
||||||
IslandManager islandManager = this.skyblock.getIslandManager();
|
|
||||||
|
|
||||||
long limit = this.getBlockLimit(player, block);
|
|
||||||
if (limit == -1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
|
||||||
long totalPlaced;
|
|
||||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
|
||||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
|
|
||||||
} else {
|
|
||||||
totalPlaced = island.getLevel().getMaterialAmount(Materials.getMaterials(block.getType(), block.getData()).name());
|
|
||||||
}
|
|
||||||
|
|
||||||
return limit < totalPlaced + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
13
src/main/java/com/songoda/skyblock/limit/Limitation.java
Normal file
13
src/main/java/com/songoda/skyblock/limit/Limitation.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.songoda.skyblock.limit;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public interface Limitation {
|
||||||
|
|
||||||
|
void unload();
|
||||||
|
|
||||||
|
void reload(ConfigurationSection loadFrom);
|
||||||
|
|
||||||
|
String getSectionName();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.songoda.skyblock.limit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.Configuration;
|
||||||
|
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
import com.songoda.skyblock.limit.impl.BlockLimitation;
|
||||||
|
import com.songoda.skyblock.limit.impl.EntityLimitaton;
|
||||||
|
|
||||||
|
public final class LimitationInstanceHandler {
|
||||||
|
|
||||||
|
private final Map<Class<? extends Limitation>, Limitation> instances;
|
||||||
|
|
||||||
|
public LimitationInstanceHandler() {
|
||||||
|
this.instances = new HashMap<>();
|
||||||
|
registerInstance(new EntityLimitaton());
|
||||||
|
registerInstance(new BlockLimitation());
|
||||||
|
reloadAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Limitation> T getInstance(Class<T> type) {
|
||||||
|
return type.cast(instances.get(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerInstance(Limitation instance) {
|
||||||
|
instances.put(instance.getClass(), instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadAll() {
|
||||||
|
final SkyBlock instance = SkyBlock.getInstance();
|
||||||
|
final Configuration config = instance.getFileManager().getConfig(new File(instance.getDataFolder(), "limits.yml")).getFileConfiguration();
|
||||||
|
|
||||||
|
for (Limitation limit : instances.values()) {
|
||||||
|
limit.reload(config.getConfigurationSection(limit.getSectionName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
package com.songoda.skyblock.limit.impl;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
|
|
||||||
|
import com.songoda.skyblock.SkyBlock;
|
||||||
|
import com.songoda.skyblock.island.Island;
|
||||||
|
import com.songoda.skyblock.island.IslandManager;
|
||||||
|
import com.songoda.skyblock.limit.EnumLimitation;
|
||||||
|
import com.songoda.skyblock.utils.version.Materials;
|
||||||
|
|
||||||
|
public final class BlockLimitation extends EnumLimitation<Materials> {
|
||||||
|
|
||||||
|
public BlockLimitation() {
|
||||||
|
super(Materials.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSectionName() {
|
||||||
|
return "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTooMuch(long currentAmount, Enum<Materials> type) {
|
||||||
|
throw new UnsupportedOperationException("Not implemented. Use getBlockLimit and isBlockLimitExceeded instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload(ConfigurationSection loadFrom) {
|
||||||
|
unload();
|
||||||
|
|
||||||
|
if (loadFrom == null) return;
|
||||||
|
|
||||||
|
final Set<String> keys = loadFrom.getKeys(false);
|
||||||
|
|
||||||
|
removeAndLoadDefaultLimit(loadFrom, keys);
|
||||||
|
|
||||||
|
for (String key : keys) {
|
||||||
|
final String enumName = key.toUpperCase(Locale.ENGLISH);
|
||||||
|
final Materials type = Materials.fromString(enumName);
|
||||||
|
|
||||||
|
if (type == null) throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in " + loadFrom.getCurrentPath());
|
||||||
|
|
||||||
|
getMap().put(type, loadFrom.getLong(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public long getBlockLimit(Player player, Block block) {
|
||||||
|
if (player == null || block == null) return -1;
|
||||||
|
|
||||||
|
if (player.hasPermission("fabledskyblock.limit.block.*")) return -1;
|
||||||
|
|
||||||
|
final Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||||
|
|
||||||
|
if (material == null) return -1;
|
||||||
|
|
||||||
|
long limit = getMap().getOrDefault(material, getDefault());
|
||||||
|
|
||||||
|
final String name = material.name().toLowerCase();
|
||||||
|
|
||||||
|
Set<PermissionAttachmentInfo> permissions = player.getEffectivePermissions().stream()
|
||||||
|
.filter(x -> x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block." + name)).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
for (PermissionAttachmentInfo permission : permissions) {
|
||||||
|
try {
|
||||||
|
String permString = permission.getPermission();
|
||||||
|
String numberString = permString.substring(permString.lastIndexOf(".") + 1);
|
||||||
|
if (numberString.equals("*")) return -1;
|
||||||
|
|
||||||
|
limit = Math.max(limit, Integer.parseInt(numberString));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public boolean isBlockLimitExceeded(Player player, Block block, long limit) {
|
||||||
|
|
||||||
|
if (limit == -1) return false;
|
||||||
|
|
||||||
|
final IslandManager islandManager = SkyBlock.getInstance().getIslandManager();
|
||||||
|
final Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||||
|
final long totalPlaced;
|
||||||
|
|
||||||
|
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||||
|
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER"))
|
||||||
|
.mapToLong(Map.Entry::getValue).sum();
|
||||||
|
} else {
|
||||||
|
totalPlaced = island.getLevel().getMaterialAmount(Materials.getMaterials(block.getType(), block.getData()).name());
|
||||||
|
}
|
||||||
|
|
||||||
|
return limit < totalPlaced + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.skyblock.limit.impl;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import com.songoda.skyblock.island.Island;
|
||||||
|
import com.songoda.skyblock.island.IslandEnvironment;
|
||||||
|
import com.songoda.skyblock.island.IslandWorld;
|
||||||
|
import com.songoda.skyblock.limit.EnumLimitation;
|
||||||
|
|
||||||
|
public final class EntityLimitaton extends EnumLimitation<EntityType> {
|
||||||
|
|
||||||
|
public EntityLimitaton() {
|
||||||
|
super(EntityType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEntityCount(Island island, IslandWorld islandWorld, EntityType type) {
|
||||||
|
final Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island);
|
||||||
|
final World world = islandLocation.getWorld();
|
||||||
|
|
||||||
|
final Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0,
|
||||||
|
islandLocation.getBlockZ() - island.getRadius());
|
||||||
|
final Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(),
|
||||||
|
islandLocation.getBlockZ() + island.getRadius());
|
||||||
|
|
||||||
|
final int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||||
|
final int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||||
|
|
||||||
|
final int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||||
|
final int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for (int x = minX; x < maxX + 16; x += 16) {
|
||||||
|
for (int z = minZ; z < maxZ + 16; z += 16) {
|
||||||
|
final Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
|
||||||
|
|
||||||
|
for (Entity ent : chunk.getEntities()) {
|
||||||
|
if (ent.getType() == type) count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSectionName() {
|
||||||
|
return "entity";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -43,7 +43,7 @@ import com.songoda.skyblock.island.IslandManager;
|
|||||||
import com.songoda.skyblock.island.IslandRole;
|
import com.songoda.skyblock.island.IslandRole;
|
||||||
import com.songoda.skyblock.island.IslandWorld;
|
import com.songoda.skyblock.island.IslandWorld;
|
||||||
import com.songoda.skyblock.levelling.LevellingManager;
|
import com.songoda.skyblock.levelling.LevellingManager;
|
||||||
import com.songoda.skyblock.limit.LimitManager;
|
import com.songoda.skyblock.limit.impl.BlockLimitation;
|
||||||
import com.songoda.skyblock.stackable.Stackable;
|
import com.songoda.skyblock.stackable.Stackable;
|
||||||
import com.songoda.skyblock.stackable.StackableManager;
|
import com.songoda.skyblock.stackable.StackableManager;
|
||||||
import com.songoda.skyblock.utils.NumberUtil;
|
import com.songoda.skyblock.utils.NumberUtil;
|
||||||
@ -74,14 +74,17 @@ public class Block implements Listener {
|
|||||||
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
||||||
|
|
||||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
|
||||||
|
Location blockLocation = block.getLocation();
|
||||||
|
|
||||||
|
Island island = islandManager.getIslandAtLocation(blockLocation);
|
||||||
|
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
if (!islandManager.hasPermission(player, blockLocation, "Destroy")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
skyblock.getMessageManager().sendMessage(player,
|
skyblock.getMessageManager().sendMessage(player,
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
@ -91,7 +94,7 @@ public class Block implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stackableManager != null
|
if (stackableManager != null
|
||||||
&& stackableManager.isStacked(block.getLocation())) {
|
&& stackableManager.isStacked(blockLocation)) {
|
||||||
Stackable stackable = stackableManager.getStack(block.getLocation(), block.getType());
|
Stackable stackable = stackableManager.getStack(block.getLocation(), block.getType());
|
||||||
if (stackable != null) {
|
if (stackable != null) {
|
||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
@ -99,7 +102,7 @@ public class Block implements Listener {
|
|||||||
|
|
||||||
int droppedAmount = 0;
|
int droppedAmount = 0;
|
||||||
if (event.getPlayer().isSneaking()) {
|
if (event.getPlayer().isSneaking()) {
|
||||||
Location dropLoc = event.getBlock().getLocation().add(0.5, 0.5, 0.5);
|
Location dropLoc = blockLocation.clone().add(0.5, 0.5, 0.5);
|
||||||
int count = stackable.getSize();
|
int count = stackable.getSize();
|
||||||
droppedAmount = count;
|
droppedAmount = count;
|
||||||
while (count > 64) {
|
while (count > 64) {
|
||||||
@ -110,7 +113,7 @@ public class Block implements Listener {
|
|||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
stackable.setSize(0);
|
stackable.setSize(0);
|
||||||
} else {
|
} else {
|
||||||
block.getWorld().dropItemNaturally(block.getLocation().add(.5, 1, .5), new ItemStack(material, 1, data));
|
block.getWorld().dropItemNaturally(blockLocation.clone().add(.5, 1, .5), new ItemStack(material, 1, data));
|
||||||
stackable.takeOne();
|
stackable.takeOne();
|
||||||
droppedAmount = 1;
|
droppedAmount = 1;
|
||||||
}
|
}
|
||||||
@ -247,15 +250,18 @@ public class Block implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitManager limitManager = skyblock.getLimitManager();
|
BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class);
|
||||||
if (limitManager.isBlockLimitExceeded(player, block)) {
|
|
||||||
|
long limit = limits.getBlockLimit(player, block);
|
||||||
|
|
||||||
|
if (limits.isBlockLimitExceeded(player, block, limit)) {
|
||||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||||
|
|
||||||
skyblock.getMessageManager().sendMessage(player,
|
skyblock.getMessageManager().sendMessage(player,
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
.getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
.getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
||||||
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " ")))
|
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " ")))
|
||||||
.replace("%limit", NumberUtil.formatNumber(limitManager.getBlockLimit(player, block))));
|
.replace("%limit", NumberUtil.formatNumber(limit)));
|
||||||
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ import com.songoda.skyblock.island.IslandLevel;
|
|||||||
import com.songoda.skyblock.island.IslandManager;
|
import com.songoda.skyblock.island.IslandManager;
|
||||||
import com.songoda.skyblock.island.IslandWorld;
|
import com.songoda.skyblock.island.IslandWorld;
|
||||||
import com.songoda.skyblock.levelling.LevellingManager;
|
import com.songoda.skyblock.levelling.LevellingManager;
|
||||||
import com.songoda.skyblock.limit.LimitManager;
|
import com.songoda.skyblock.limit.impl.BlockLimitation;
|
||||||
import com.songoda.skyblock.message.MessageManager;
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
import com.songoda.skyblock.sound.SoundManager;
|
import com.songoda.skyblock.sound.SoundManager;
|
||||||
import com.songoda.skyblock.stackable.Stackable;
|
import com.songoda.skyblock.stackable.Stackable;
|
||||||
@ -157,19 +157,22 @@ public class Interact implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitManager limitManager = skyblock.getLimitManager();
|
BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class);
|
||||||
if (limitManager.isBlockLimitExceeded(player, block)) {
|
|
||||||
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
|
||||||
|
|
||||||
skyblock.getMessageManager().sendMessage(player,
|
long limit = limits.getBlockLimit(player, block);
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
|
||||||
.getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
|
||||||
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " ")))
|
|
||||||
.replace("%limit", NumberUtil.formatNumber(limitManager.getBlockLimit(player, block))));
|
|
||||||
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
if (limits.isBlockLimitExceeded(player, block, limit)) {
|
||||||
return;
|
Materials material = Materials.getMaterials(block.getType(), block.getData());
|
||||||
|
|
||||||
|
skyblock.getMessageManager().sendMessage(player,
|
||||||
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
|
.getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
||||||
|
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " ")))
|
||||||
|
.replace("%limit", NumberUtil.formatNumber(limit)));
|
||||||
|
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = event.getClickedBlock().getLocation();
|
Location location = event.getClickedBlock().getLocation();
|
||||||
|
@ -14,11 +14,7 @@ public class Area {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Location getPosition(int position) {
|
public Location getPosition(int position) {
|
||||||
if (positions.containsKey(position)) {
|
return positions.get(position);
|
||||||
return positions.get(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int position, Location location) {
|
public void setPosition(int position, Location location) {
|
||||||
|
@ -40,14 +40,14 @@ public class SchematicUtil {
|
|||||||
// TODO: Cache this later
|
// TODO: Cache this later
|
||||||
try {
|
try {
|
||||||
Class<?> bukkitWorldClass = Class.forName("com.sk89q.worldedit.bukkit.BukkitWorld");
|
Class<?> bukkitWorldClass = Class.forName("com.sk89q.worldedit.bukkit.BukkitWorld");
|
||||||
Constructor bukkitWorldConstructor = bukkitWorldClass.getConstructor(World.class);
|
Constructor<?> bukkitWorldConstructor = bukkitWorldClass.getConstructor(World.class);
|
||||||
Class<?> editSessionClass = Class.forName("com.sk89q.worldedit.EditSession");
|
Class<?> editSessionClass = Class.forName("com.sk89q.worldedit.EditSession");
|
||||||
Class<?> localWorldClass = Class.forName("com.sk89q.worldedit.LocalWorld");
|
Class<?> localWorldClass = Class.forName("com.sk89q.worldedit.LocalWorld");
|
||||||
Constructor editSessionConstructor = editSessionClass.getConstructor(localWorldClass, int.class);
|
Constructor<?> editSessionConstructor = editSessionClass.getConstructor(localWorldClass, int.class);
|
||||||
Class<?> cuboidClipboardClass = Class.forName("com.sk89q.worldedit.CuboidClipboard");
|
Class<?> cuboidClipboardClass = Class.forName("com.sk89q.worldedit.CuboidClipboard");
|
||||||
Method loadSchematicMethod = cuboidClipboardClass.getMethod("loadSchematic", File.class);
|
Method loadSchematicMethod = cuboidClipboardClass.getMethod("loadSchematic", File.class);
|
||||||
Class<?> vectorClass = Class.forName("com.sk89q.worldedit.Vector");
|
Class<?> vectorClass = Class.forName("com.sk89q.worldedit.Vector");
|
||||||
Constructor vectorConstructor = vectorClass.getConstructor(double.class, double.class, double.class);
|
Constructor<?> vectorConstructor = vectorClass.getConstructor(double.class, double.class, double.class);
|
||||||
Method pasteMethod = cuboidClipboardClass.getMethod("paste", editSessionClass, vectorClass, boolean.class);
|
Method pasteMethod = cuboidClipboardClass.getMethod("paste", editSessionClass, vectorClass, boolean.class);
|
||||||
|
|
||||||
Object editSessionObj = editSessionConstructor.newInstance(bukkitWorldConstructor.newInstance(location.getWorld()), 999999999);
|
Object editSessionObj = editSessionConstructor.newInstance(bukkitWorldConstructor.newInstance(location.getWorld()), 999999999);
|
||||||
|
@ -6,7 +6,6 @@ import com.google.gson.JsonSyntaxException;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.songoda.skyblock.SkyBlock;
|
import com.songoda.skyblock.SkyBlock;
|
||||||
import com.songoda.skyblock.config.FileManager;
|
import com.songoda.skyblock.config.FileManager;
|
||||||
import com.songoda.skyblock.utils.Compression;
|
|
||||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||||
import com.songoda.skyblock.utils.world.block.BlockData;
|
import com.songoda.skyblock.utils.world.block.BlockData;
|
||||||
@ -26,7 +25,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -242,6 +242,8 @@ Command:
|
|||||||
Message: '&bSkyBlock &8| &aInfo&8: &eThis island will unload.'
|
Message: '&bSkyBlock &8| &aInfo&8: &eThis island will unload.'
|
||||||
Info:
|
Info:
|
||||||
Message: '&f&oKeeps an island from unloading.'
|
Message: '&f&oKeeps an island from unloading.'
|
||||||
|
No-Player-Input:
|
||||||
|
Message: '&bSkyBlock &8| &cError&8: &ePlease input a player.'
|
||||||
Proxy:
|
Proxy:
|
||||||
IsOn:
|
IsOn:
|
||||||
Message: '&bSkyBlock &8| &aInfo&8: &eYou are now proxying %player.'
|
Message: '&bSkyBlock &8| &aInfo&8: &eYou are now proxying %player.'
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
block:
|
block:
|
||||||
BEDROCK: 0
|
DefaultLimit: -1
|
||||||
END_PORTAL_FRAME: 12
|
BEDROCK: 0
|
||||||
|
END_PORTAL_FRAME: 12
|
||||||
|
entity:
|
||||||
|
DefaultLimit: -1
|
Loading…
Reference in New Issue
Block a user