mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 02:35:25 +01:00
Island top exemption setting and permission
This commit is contained in:
parent
da8c162344
commit
c2f670e127
@ -86,6 +86,7 @@ public class SkyBlock extends JavaPlugin {
|
||||
fileManager = new FileManager(this);
|
||||
worldManager = new WorldManager(this);
|
||||
userCacheManager = new UserCacheManager(this);
|
||||
economyManager = new EconomyManager();
|
||||
visitManager = new VisitManager(this);
|
||||
banManager = new BanManager(this);
|
||||
islandManager = new IslandManager(this);
|
||||
@ -126,7 +127,6 @@ public class SkyBlock extends JavaPlugin {
|
||||
placeholderManager.registerPlaceholders();
|
||||
|
||||
messageManager = new MessageManager(this);
|
||||
economyManager = new EconomyManager();
|
||||
hologramManager = new HologramManager(this);
|
||||
|
||||
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
|
@ -7,6 +7,7 @@ import me.goodandevil.skyblock.generator.GeneratorManager;
|
||||
import me.goodandevil.skyblock.hologram.Hologram;
|
||||
import me.goodandevil.skyblock.hologram.HologramManager;
|
||||
import me.goodandevil.skyblock.hologram.HologramType;
|
||||
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
|
||||
@ -34,6 +35,7 @@ public class ReloadCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
@ -86,17 +88,11 @@ public class ReloadCommand extends SubCommand {
|
||||
levellingManager.unregisterMaterials();
|
||||
levellingManager.registerMaterials();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
Hologram hologram = hologramManager.getHologram(hologramTypeList);
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
if (hologram != null) {
|
||||
hologramManager.removeHologram(hologram);
|
||||
}
|
||||
|
||||
hologramManager.spawnHologram(hologramTypeList);
|
||||
}
|
||||
});
|
||||
hologramManager.resetHologram();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
|
@ -2,13 +2,16 @@ package me.goodandevil.skyblock.economy;
|
||||
|
||||
import me.goodandevil.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class EconomyManager {
|
||||
|
||||
private Economy economy;
|
||||
private Economy economy = null;
|
||||
private Permission permission = null;
|
||||
|
||||
public EconomyManager() {
|
||||
setup();
|
||||
@ -16,10 +19,14 @@ public class EconomyManager {
|
||||
|
||||
public void setup() {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Economy> registeredServiceProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
RegisteredServiceProvider<Economy> economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
|
||||
if (registeredServiceProvider != null)
|
||||
economy = registeredServiceProvider.getProvider();
|
||||
if (economyRsp != null)
|
||||
economy = economyRsp.getProvider();
|
||||
|
||||
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionRsp != null)
|
||||
permission = permissionRsp.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +53,17 @@ public class EconomyManager {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||
}
|
||||
|
||||
public boolean hasPermission(String world, OfflinePlayer player, String perm) {
|
||||
if (permission != null)
|
||||
return permission.playerHas(world, player, perm);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEconomy() {
|
||||
return Bukkit.getServer().getPluginManager().getPlugin("Vault") != null;
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
public boolean isPermission() {
|
||||
return permission != null;
|
||||
}
|
||||
}
|
||||
|
@ -41,16 +41,14 @@ public class HologramManager {
|
||||
removeWorldHolograms();
|
||||
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Bank || hologramTypeList == HologramType.Votes) {
|
||||
if (hologramTypeList == HologramType.Votes) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
continue;
|
||||
}
|
||||
if (hologramTypeList == HologramType.Votes) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
spawnHologram(hologramTypeList);
|
||||
}
|
||||
|
||||
spawnHologram(hologramTypeList);
|
||||
}
|
||||
}, 200L);
|
||||
}
|
||||
@ -181,11 +179,9 @@ public class HologramManager {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Bank || hologramTypeList == HologramType.Votes) {
|
||||
if (configLoad.getString("Location.Hologram.Leaderboard." + hologramTypeList.name()) != null) {
|
||||
locations.add(fileManager.getLocation(config,
|
||||
"Location.Hologram.Leaderboard." + hologramTypeList.name(), true));
|
||||
}
|
||||
if (configLoad.getString("Location.Hologram.Leaderboard." + hologramTypeList.name()) != null) {
|
||||
locations.add(fileManager.getLocation(config,
|
||||
"Location.Hologram.Leaderboard." + hologramTypeList.name(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,79 +231,77 @@ public class HologramManager {
|
||||
.getFileConfiguration();
|
||||
|
||||
for (HologramType hologramTypeList : HologramType.values()) {
|
||||
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Bank || hologramTypeList == HologramType.Votes) {
|
||||
if (hologramTypeList == HologramType.Votes) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Vote")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Hologram hologram;
|
||||
|
||||
if (hasHologram(hologramTypeList)) {
|
||||
hologram = getHologram(hologramTypeList);
|
||||
} else {
|
||||
if (hologramTypeList == HologramType.Votes) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Vote")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Leaderboard.Type leaderboardType = null;
|
||||
Hologram hologram;
|
||||
|
||||
switch (hologramTypeList) {
|
||||
case Level:
|
||||
leaderboardType = Leaderboard.Type.Level;
|
||||
break;
|
||||
case Bank:
|
||||
leaderboardType = Leaderboard.Type.Bank;
|
||||
break;
|
||||
case Votes:
|
||||
leaderboardType = Leaderboard.Type.Votes;
|
||||
break;
|
||||
}
|
||||
if (hasHologram(hologramTypeList)) {
|
||||
hologram = getHologram(hologramTypeList);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Leaderboard leaderboard = leaderboardManager.getLeaderboardFromPosition(leaderboardType, i);
|
||||
int hologramLine = 10 - i;
|
||||
Leaderboard.Type leaderboardType = null;
|
||||
|
||||
if (leaderboard == null) {
|
||||
hologram.setLine(hologramLine, messageManager.replaceMessage(null,
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Unclaimed")
|
||||
.replace("%position", "" + (i + 1))));
|
||||
switch (hologramTypeList) {
|
||||
case Level:
|
||||
leaderboardType = Leaderboard.Type.Level;
|
||||
break;
|
||||
case Bank:
|
||||
leaderboardType = Leaderboard.Type.Bank;
|
||||
break;
|
||||
case Votes:
|
||||
leaderboardType = Leaderboard.Type.Votes;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Leaderboard leaderboard = leaderboardManager.getLeaderboardFromPosition(leaderboardType, i);
|
||||
int hologramLine = 10 - i;
|
||||
|
||||
if (leaderboard == null) {
|
||||
hologram.setLine(hologramLine, messageManager.replaceMessage(null,
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Unclaimed")
|
||||
.replace("%position", "" + (i + 1))));
|
||||
} else {
|
||||
Visit visit = leaderboard.getVisit();
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
|
||||
String islandOwnerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
|
||||
} else {
|
||||
Visit visit = leaderboard.getVisit();
|
||||
islandOwnerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
|
||||
String islandOwnerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
|
||||
} else {
|
||||
islandOwnerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (hologramTypeList == HologramType.Level) {
|
||||
IslandLevel level = visit.getLevel();
|
||||
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
|
||||
.replace("%position", "" + (i + 1))
|
||||
.replace("%player", islandOwnerName)
|
||||
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
|
||||
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
|
||||
} else if (hologramTypeList == HologramType.Bank) {
|
||||
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
|
||||
.replace("%position", "" + (i + 1))
|
||||
.replace("%player", islandOwnerName)
|
||||
.replace("%balance",
|
||||
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
|
||||
} else if (hologramTypeList == HologramType.Votes) {
|
||||
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
|
||||
.replace("%position", "" + (i + 1))
|
||||
.replace("%player", islandOwnerName)
|
||||
.replace("%votes",
|
||||
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
|
||||
}
|
||||
if (hologramTypeList == HologramType.Level) {
|
||||
IslandLevel level = visit.getLevel();
|
||||
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
|
||||
.replace("%position", "" + (i + 1))
|
||||
.replace("%player", islandOwnerName)
|
||||
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
|
||||
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
|
||||
} else if (hologramTypeList == HologramType.Bank) {
|
||||
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
|
||||
.replace("%position", "" + (i + 1))
|
||||
.replace("%player", islandOwnerName)
|
||||
.replace("%balance",
|
||||
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
|
||||
} else if (hologramTypeList == HologramType.Votes) {
|
||||
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
|
||||
.replace("%position", "" + (i + 1))
|
||||
.replace("%player", islandOwnerName)
|
||||
.replace("%votes",
|
||||
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ package me.goodandevil.skyblock.hologram;
|
||||
|
||||
public enum HologramType {
|
||||
|
||||
Level, Bank, Votes, Stackable;
|
||||
Level, Bank, Votes
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package me.goodandevil.skyblock.leaderboard;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.economy.EconomyManager;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.leaderboard.leaderheads.TopBank;
|
||||
import me.goodandevil.skyblock.leaderboard.leaderheads.TopLevel;
|
||||
import me.goodandevil.skyblock.leaderboard.leaderheads.TopVotes;
|
||||
import me.goodandevil.skyblock.visit.Visit;
|
||||
import me.goodandevil.skyblock.visit.VisitManager;
|
||||
import me.goodandevil.skyblock.world.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -33,15 +36,28 @@ public class LeaderboardManager {
|
||||
}
|
||||
|
||||
public void resetLeaderboard() {
|
||||
EconomyManager economyManager = skyblock.getEconomyManager();
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
|
||||
visitManager.loadIslands();
|
||||
|
||||
List<LeaderboardPlayer> islandLevels = new ArrayList<>();
|
||||
List<LeaderboardPlayer> islandBanks = new ArrayList<>();
|
||||
List<LeaderboardPlayer> islandVotes = new ArrayList<>();
|
||||
|
||||
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Leaderboard.Exemptions.Enable");
|
||||
|
||||
for (int i = 0; i < visitManager.getIslands().size(); i++) {
|
||||
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
|
||||
|
||||
if (enableExemptions && economyManager.hasPermission(
|
||||
worldManager.getWorld(IslandWorld.Normal).getName(),
|
||||
Bukkit.getOfflinePlayer(ownerUUID),
|
||||
"fabledskyblock.island.top.exempt"))
|
||||
continue;
|
||||
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
islandLevels.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
|
||||
islandBanks.add(new LeaderboardPlayer(ownerUUID, (long)visit.getBankBalance()));
|
||||
|
@ -83,6 +83,9 @@ Island:
|
||||
Reset:
|
||||
# Time until Leaderboard resets
|
||||
Time: 300
|
||||
# If users with the permission should be exempt from /is leaderboard
|
||||
Exemptions:
|
||||
Enable: false
|
||||
Invite:
|
||||
# Time until Island invite expires
|
||||
Time: 300
|
||||
|
Loading…
Reference in New Issue
Block a user