Now multi-game support.

This commit is contained in:
tastybento 2018-05-26 18:20:33 -07:00
parent f49d6e9e42
commit a09d974d95
11 changed files with 78 additions and 95 deletions

View File

@ -9,6 +9,7 @@ admin:
description: "calculate the island level for player" description: "calculate the island level for player"
top: top:
description: "show the top ten list" description: "show the top ten list"
unknown-world: "&cUnknown world!"
island: island:
level: level:

View File

@ -12,7 +12,6 @@ import bskyblock.addon.level.commands.IslandLevel;
import bskyblock.addon.level.commands.IslandTop; import bskyblock.addon.level.commands.IslandTop;
import bskyblock.addon.level.config.Settings; import bskyblock.addon.level.config.Settings;
import bskyblock.addon.level.database.object.LevelsData; import bskyblock.addon.level.database.object.LevelsData;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.addons.Addon; import us.tastybento.bskyblock.api.addons.Addon;
import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
@ -47,9 +46,10 @@ public class Level extends Addon {
* @param user * @param user
* @param playerUUID - the player's UUID * @param playerUUID - the player's UUID
* @param b * @param b
* @param permPrefix
*/ */
public void calculateIslandLevel(World world, User user, UUID playerUUID, boolean b) { public void calculateIslandLevel(World world, User user, UUID playerUUID, boolean b, String permPrefix) {
levelCalc.calculateIslandLevel(world, user, playerUUID, b); levelCalc.calculateIslandLevel(world, user, playerUUID, b, permPrefix);
} }
/** /**
@ -84,6 +84,9 @@ public class Level extends Addon {
if (levelsCache != null) { if (levelsCache != null) {
save(false); save(false);
} }
if (topTen != null) {
topTen.saveTopTen();
}
} }
@Override @Override
@ -103,15 +106,28 @@ public class Level extends Addon {
// Initialize the cache // Initialize the cache
levelsCache = new HashMap<>(); levelsCache = new HashMap<>();
// Load the calculator // Load the calculator
levelCalc = new LevelPresenter(this); levelCalc = new LevelPresenter(this, getBSkyBlock());
// Start the top ten and register it for clicks // Start the top ten and register it for clicks
topTen = new TopTen(this); topTen = new TopTen(this);
registerListener(topTen); registerListener(topTen);
// Register commands // Register commands - run one tick later to allow all addons to load
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand(Constants.ISLANDCOMMAND); // AcidIsland hook in
getServer().getScheduler().runTask(getBSkyBlock(), () -> {
this.getBSkyBlock().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
getLogger().info("DEBUG: " + getBSkyBlock().getCommandsManager().listCommands());
CompositeCommand acidIslandCmd = getBSkyBlock().getCommandsManager().getCommand("ai");
new IslandLevel(this, acidIslandCmd);
new IslandTop(this, acidIslandCmd);
CompositeCommand acidCmd = getBSkyBlock().getCommandsManager().getCommand("acid");
new AdminLevel(this, acidCmd);
new AdminTop(this, acidCmd);
});
});
// BSkyBlock hook in
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand("island");
new IslandLevel(this, bsbIslandCmd); new IslandLevel(this, bsbIslandCmd);
new IslandTop(this, bsbIslandCmd); new IslandTop(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand(Constants.ADMINCOMMAND); CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand("bsbadmin");
new AdminLevel(this, bsbAdminCmd); new AdminLevel(this, bsbAdminCmd);
new AdminTop(this, bsbAdminCmd); new AdminTop(this, bsbAdminCmd);
// Done // Done
@ -135,8 +151,9 @@ public class Level extends Addon {
* @param world * @param world
* @param targetPlayer * @param targetPlayer
* @param level * @param level
* @param permPrefix
*/ */
protected void setIslandLevel(World world, UUID targetPlayer, long level) { protected void setIslandLevel(World world, UUID targetPlayer, long level, String permPrefix) {
LevelsData ld = getLevelsData(targetPlayer); LevelsData ld = getLevelsData(targetPlayer);
if (ld == null) { if (ld == null) {
ld = new LevelsData(targetPlayer, level, world); ld = new LevelsData(targetPlayer, level, world);
@ -145,7 +162,7 @@ public class Level extends Addon {
} }
// Add to cache // Add to cache
levelsCache.put(targetPlayer, ld); levelsCache.put(targetPlayer, ld);
topTen.addEntry(world, targetPlayer, level); topTen.addEntry(world, targetPlayer, level, permPrefix);
} }
public BSBDatabase<LevelsData> getHandler() { public BSBDatabase<LevelsData> getHandler() {

View File

@ -25,7 +25,6 @@ import com.google.common.collect.Multisets;
import bskyblock.addon.level.event.IslandPostLevelEvent; import bskyblock.addon.level.event.IslandPostLevelEvent;
import bskyblock.addon.level.event.IslandPreLevelEvent; import bskyblock.addon.level.event.IslandPreLevelEvent;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.util.Pair; import us.tastybento.bskyblock.util.Pair;
@ -51,9 +50,10 @@ public class LevelCalcByChunk {
HashMap<MaterialData, Integer> limitCount; HashMap<MaterialData, Integer> limitCount;
private boolean report; private boolean report;
private long oldLevel; private long oldLevel;
private String permPrefix;
public LevelCalcByChunk(final Level addon, final Island island, final UUID targetPlayer, final User asker, final boolean report) { public LevelCalcByChunk(final Level addon, final Island island, final UUID targetPlayer, final User asker, final boolean report, String permPrefix) {
this.addon = addon; this.addon = addon;
this.island = island; this.island = island;
this.world = island != null ? island.getCenter().getWorld() : null; this.world = island != null ? island.getCenter().getWorld() : null;
@ -62,6 +62,7 @@ public class LevelCalcByChunk {
this.limitCount = new HashMap<>(addon.getSettings().getBlockLimits()); this.limitCount = new HashMap<>(addon.getSettings().getBlockLimits());
this.report = report; this.report = report;
this.oldLevel = addon.getIslandLevel(world, targetPlayer); this.oldLevel = addon.getIslandLevel(world, targetPlayer);
this.permPrefix = permPrefix;
// Results go here // Results go here
result = new Results(); result = new Results();
@ -231,8 +232,8 @@ public class LevelCalcByChunk {
if (player != null) { if (player != null) {
// Get permission multiplier // Get permission multiplier
for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
if (perms.getPermission().startsWith(Constants.PERMPREFIX + "island.multiplier.")) { if (perms.getPermission().startsWith(permPrefix + "island.multiplier.")) {
String spl[] = perms.getPermission().split(Constants.PERMPREFIX + "island.multiplier."); String spl[] = perms.getPermission().split(permPrefix + "island.multiplier.");
if (spl.length > 1) { if (spl.length > 1) {
if (!NumberUtils.isDigits(spl[1])) { if (!NumberUtils.isDigits(spl[1])) {
addon.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring..."); addon.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
@ -301,22 +302,22 @@ public class LevelCalcByChunk {
addon.getServer().getPluginManager().callEvent(event); addon.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
// Save the value // Save the value
addon.setIslandLevel(world, island.getOwner(), event.getLevel()); addon.setIslandLevel(world, island.getOwner(), event.getLevel(), permPrefix);
if (addon.getIslands().inTeam(island.getWorld(), targetPlayer)) { if (addon.getIslands().inTeam(island.getWorld(), targetPlayer)) {
//plugin.getLogger().info("DEBUG: player is in team"); //plugin.getLogger().info("DEBUG: player is in team");
for (UUID member : addon.getIslands().getMembers(island.getWorld(), targetPlayer)) { for (UUID member : addon.getIslands().getMembers(island.getWorld(), targetPlayer)) {
//plugin.getLogger().info("DEBUG: updating team member level too"); //plugin.getLogger().info("DEBUG: updating team member level too");
if (addon.getIslandLevel(world, member) != event.getLevel()) { if (addon.getIslandLevel(world, member) != event.getLevel()) {
addon.setIslandLevel(world, member, event.getLevel()); addon.setIslandLevel(world, member, event.getLevel(), permPrefix);
} }
} }
if (addon.getIslands().inTeam(island.getWorld(), targetPlayer)) { if (addon.getIslands().inTeam(island.getWorld(), targetPlayer)) {
UUID leader = addon.getIslands().getTeamLeader(island.getWorld(), targetPlayer); UUID leader = addon.getIslands().getTeamLeader(island.getWorld(), targetPlayer);
if (leader != null) { if (leader != null) {
addon.getTopTen().addEntry(world, leader, event.getLevel()); addon.getTopTen().addEntry(world, leader, event.getLevel(), permPrefix);
} }
} else { } else {
addon.getTopTen().addEntry(world, targetPlayer, event.getLevel()); addon.getTopTen().addEntry(world, targetPlayer, event.getLevel(), permPrefix);
} }
} }
} }

View File

@ -1,25 +0,0 @@
package bskyblock.addon.level;
import java.util.logging.Logger;
import us.tastybento.bskyblock.BSkyBlock;
/**
* Makes code look nicer
* @author ben
*
*/
public abstract class LevelPlugin {
protected final Level plugin;
protected final BSkyBlock bSkyBlock;
public LevelPlugin(Level plugin) {
this.plugin = plugin;
this.bSkyBlock = BSkyBlock.getInstance();
}
public final Logger getLogger() {
return plugin.getLogger();
}
}

View File

@ -6,31 +6,21 @@ import java.util.UUID;
import org.bukkit.World; import org.bukkit.World;
import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
public class LevelPresenter extends LevelPlugin { public class LevelPresenter {
private int levelWait; private int levelWait;
private final Level plugin;
private final BSkyBlock bSkyBlock;
// Level calc cool down // Level calc cool down
private HashMap<UUID, Long> levelWaitTime = new HashMap<UUID, Long>(); private HashMap<UUID, Long> levelWaitTime = new HashMap<UUID, Long>();
public LevelPresenter(Level plugin) { public LevelPresenter(Level plugin, BSkyBlock bSkyBlock) {
super(plugin); this.plugin = plugin;
} this.bSkyBlock = bSkyBlock;
/**
* Calculates the island level
*
* @param world - world to check
* @param sender
* - Player object of player who is asking
* @param targetPlayer
* - UUID of the player's island that is being requested
* @return - true if successful.
*/
public boolean calculateIslandLevel(World world, final User sender, final UUID targetPlayer) {
return calculateIslandLevel(world, sender, targetPlayer, false);
} }
/** /**
@ -39,9 +29,10 @@ public class LevelPresenter extends LevelPlugin {
* @param sender - asker of the level info * @param sender - asker of the level info
* @param targetPlayer * @param targetPlayer
* @param report - if true, a detailed report will be provided * @param report - if true, a detailed report will be provided
* @param permPrefix - per prefix for this player
* @return - false if this is cannot be done * @return - false if this is cannot be done
*/ */
public boolean calculateIslandLevel(World world, final User sender, UUID targetPlayer, boolean report) { public boolean calculateIslandLevel(World world, final User sender, UUID targetPlayer, boolean report, String permPrefix) {
// Check if sender has island // Check if sender has island
boolean inTeam = false; boolean inTeam = false;
if (!bSkyBlock.getIslands().hasIsland(world, targetPlayer)) { if (!bSkyBlock.getIslands().hasIsland(world, targetPlayer)) {
@ -55,12 +46,12 @@ public class LevelPresenter extends LevelPlugin {
} }
} }
// Player asking for their own island calc // Player asking for their own island calc
if (inTeam || !sender.isPlayer() || sender.getUniqueId().equals(targetPlayer) || sender.isOp() || sender.hasPermission(Constants.PERMPREFIX + "mod.info")) { if (inTeam || !sender.isPlayer() || sender.getUniqueId().equals(targetPlayer) || sender.isOp() || sender.hasPermission(permPrefix + "mod.info")) {
// Newer better system - uses chunks // Newer better system - uses chunks
if (!onLevelWaitTime(sender) || levelWait <= 0 || sender.isOp() || sender.hasPermission(Constants.PERMPREFIX + "mod.info")) { if (!onLevelWaitTime(sender) || levelWait <= 0 || sender.isOp() || sender.hasPermission(permPrefix + "mod.info")) {
sender.sendMessage("island.level.calculating"); sender.sendMessage("island.level.calculating");
setLevelWaitTime(sender); setLevelWaitTime(sender);
new LevelCalcByChunk(plugin, bSkyBlock.getIslands().getIsland(world, targetPlayer), targetPlayer, sender, report); new LevelCalcByChunk(plugin, bSkyBlock.getIslands().getIsland(world, targetPlayer), targetPlayer, sender, report, permPrefix);
} else { } else {
// Cooldown // Cooldown
sender.sendMessage("island.level.cooldown", "[time]", String.valueOf(getLevelWaitTime(sender))); sender.sendMessage("island.level.cooldown", "[time]", String.valueOf(getLevelWaitTime(sender)));

View File

@ -18,7 +18,6 @@ import org.bukkit.event.inventory.ClickType;
import bskyblock.addon.level.database.object.LevelsData; import bskyblock.addon.level.database.object.LevelsData;
import bskyblock.addon.level.database.object.TopTenData; import bskyblock.addon.level.database.object.TopTenData;
import bskyblock.addon.warps.Warp; import bskyblock.addon.warps.Warp;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.panels.PanelItem; import us.tastybento.bskyblock.api.panels.PanelItem;
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder; import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder; import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
@ -36,7 +35,7 @@ public class TopTen implements Listener {
// Top ten list of players // Top ten list of players
private Map<World,TopTenData> topTenList; private Map<World,TopTenData> topTenList;
private final int[] SLOTS = new int[] {4, 12, 14, 19, 20, 21, 22, 23, 24, 25}; private final int[] SLOTS = new int[] {4, 12, 14, 19, 20, 21, 22, 23, 24, 25};
private final boolean DEBUG = true; private final boolean DEBUG = false;
private BSBDatabase<TopTenData> handler; private BSBDatabase<TopTenData> handler;
public TopTen(Level addon) { public TopTen(Level addon) {
@ -53,19 +52,20 @@ public class TopTen implements Listener {
* @param ownerUUID * @param ownerUUID
* @param l * @param l
*/ */
public void addEntry(World world, UUID ownerUUID, long l) { public void addEntry(World world, UUID ownerUUID, long l, String permPrefix) {
// Check if player is an island owner or not // Check if player is an island owner or not
if (!addon.getIslands().isOwner(world, ownerUUID)) { if (!addon.getIslands().isOwner(world, ownerUUID)) {
return; return;
} }
// Set up world data // Set up world data
topTenList.putIfAbsent(world, new TopTenData()); topTenList.putIfAbsent(world, new TopTenData());
topTenList.get(world).setUniqueId(world.getName());
// Try and see if the player is online // Try and see if the player is online
Player player = addon.getServer().getPlayer(ownerUUID); Player player = addon.getServer().getPlayer(ownerUUID);
if (player != null) { if (player != null) {
// Online // Online
if (!player.hasPermission(Constants.PERMPREFIX + "intopten")) { if (!player.hasPermission(permPrefix + "intopten")) {
topTenList.get(world).remove(ownerUUID); topTenList.get(world).remove(ownerUUID);
return; return;
} }
@ -78,7 +78,7 @@ public class TopTen implements Listener {
* takes the level from the player's file. * takes the level from the player's file.
* Runs asynchronously from the main thread. * Runs asynchronously from the main thread.
*/ */
public void create() { public void create(String permPrefix) {
// Obtain all the levels for each known player // Obtain all the levels for each known player
BSBDatabase<LevelsData> levelHandler = addon.getHandler(); BSBDatabase<LevelsData> levelHandler = addon.getHandler();
long index = 0; long index = 0;
@ -89,22 +89,23 @@ public class TopTen implements Listener {
// Convert to UUID // Convert to UUID
UUID playerUUID = UUID.fromString(lv.getUniqueId()); UUID playerUUID = UUID.fromString(lv.getUniqueId());
// Get the world // Get the world
lv.getLevels().forEach((k,v) -> addEntry(Bukkit.getWorld(k), playerUUID, v)); lv.getLevels().forEach((k,v) -> addEntry(Bukkit.getWorld(k), playerUUID, v, permPrefix));
} }
saveTopTen(); saveTopTen();
} }
/** /**
* Displays the Top Ten list * Displays the Top Ten list
* @param world
* *
* @param user * @param user
* - the requesting player * - the requesting player
* @return - true if successful, false if no Top Ten list exists * @return - true if successful, false if no Top Ten list exists
*/ */
public boolean getGUI(final User user) { public boolean getGUI(World world, final User user, String permPrefix) {
// Check world // Check world
topTenList.putIfAbsent(user.getWorld(), new TopTenData()); topTenList.putIfAbsent(world, new TopTenData());
topTenList.get(world).setUniqueId(world.getName());
if (DEBUG) if (DEBUG)
addon.getLogger().info("DEBUG: GUI display"); addon.getLogger().info("DEBUG: GUI display");
@ -113,7 +114,7 @@ public class TopTen implements Listener {
.user(user); .user(user);
int i = 1; int i = 1;
Iterator<Entry<UUID, Long>> it = topTenList.get(user.getWorld()).getTopTen().entrySet().iterator(); Iterator<Entry<UUID, Long>> it = topTenList.get(world).getTopTen().entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<UUID, Long> m = it.next(); Map.Entry<UUID, Long> m = it.next();
UUID topTenUUID = m.getKey(); UUID topTenUUID = m.getKey();
@ -125,7 +126,7 @@ public class TopTen implements Listener {
if (entry != null) { if (entry != null) {
if (DEBUG) if (DEBUG)
addon.getLogger().info("DEBUG: removing from topten"); addon.getLogger().info("DEBUG: removing from topten");
if (!entry.hasPermission(Constants.PERMPREFIX + "intopten")) { if (!entry.hasPermission(permPrefix + "intopten")) {
it.remove(); it.remove();
show = false; show = false;
} }
@ -135,7 +136,7 @@ public class TopTen implements Listener {
} }
if (show) { if (show) {
panel.item(SLOTS[i-1], getHead(i, m.getValue(), topTenUUID, user)); panel.item(SLOTS[i-1], getHead(i, m.getValue(), topTenUUID, user, world));
if (i++ == 10) break; if (i++ == 10) break;
} }
} }
@ -151,15 +152,15 @@ public class TopTen implements Listener {
* @param asker - the asker of the top ten * @param asker - the asker of the top ten
* @return PanelItem * @return PanelItem
*/ */
private PanelItem getHead(int rank, Long level, UUID playerUUID, User asker) { private PanelItem getHead(int rank, Long level, UUID playerUUID, User asker, World world) {
final String name = addon.getPlayers().getName(playerUUID); final String name = addon.getPlayers().getName(playerUUID);
List<String> description = new ArrayList<>(); List<String> description = new ArrayList<>();
if (name != null) { if (name != null) {
description.add(asker.getTranslation("island.top.gui-heading", "[name]", name, "[rank]", String.valueOf(rank))); description.add(asker.getTranslation("island.top.gui-heading", "[name]", name, "[rank]", String.valueOf(rank)));
description.add(asker.getTranslation("island.top.island-level","[level]", String.valueOf(level))); description.add(asker.getTranslation("island.top.island-level","[level]", String.valueOf(level)));
if (addon.getIslands().inTeam(asker.getWorld(), playerUUID)) { if (addon.getIslands().inTeam(world, playerUUID)) {
List<String> memberList = new ArrayList<>(); List<String> memberList = new ArrayList<>();
for (UUID members : addon.getIslands().getMembers(asker.getWorld(), playerUUID)) { for (UUID members : addon.getIslands().getMembers(world, playerUUID)) {
memberList.add(ChatColor.AQUA + addon.getPlayers().getName(members)); memberList.add(ChatColor.AQUA + addon.getPlayers().getName(members));
} }
description.addAll(memberList); description.addAll(memberList);
@ -205,6 +206,7 @@ public class TopTen implements Listener {
*/ */
public void removeEntry(World world, UUID ownerUUID) { public void removeEntry(World world, UUID ownerUUID) {
topTenList.putIfAbsent(world, new TopTenData()); topTenList.putIfAbsent(world, new TopTenData());
topTenList.get(world).setUniqueId(world.getName());
topTenList.get(world).remove(ownerUUID); topTenList.get(world).remove(ownerUUID);
} }

View File

@ -6,7 +6,6 @@ import java.util.UUID;
import org.bukkit.World; import org.bukkit.World;
import bskyblock.addon.level.Level; import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
@ -39,9 +38,9 @@ public class AdminLevel extends CompositeCommand {
return true; return true;
} else { } else {
if (user.isPlayer()) { if (user.isPlayer()) {
levelPlugin.calculateIslandLevel(world, user, playerUUID, false); levelPlugin.calculateIslandLevel(world, user, playerUUID, false, getPermissionPrefix());
} else { } else {
levelPlugin.calculateIslandLevel(world, user, playerUUID, true); levelPlugin.calculateIslandLevel(world, user, playerUUID, true, getPermissionPrefix());
} }
} }
return true; return true;
@ -53,7 +52,7 @@ public class AdminLevel extends CompositeCommand {
@Override @Override
public void setup() { public void setup() {
this.setPermission(Constants.PERMPREFIX + "admin.level"); this.setPermission(getPermissionPrefix() + "admin.level");
this.setOnlyPlayer(false); this.setOnlyPlayer(false);
this.setParameters("admin.level.parameters"); this.setParameters("admin.level.parameters");
this.setDescription("admin.level.description"); this.setDescription("admin.level.description");

View File

@ -7,7 +7,6 @@ import java.util.UUID;
import org.bukkit.World; import org.bukkit.World;
import bskyblock.addon.level.Level; import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.database.objects.Island;
@ -57,7 +56,7 @@ public class AdminTop extends CompositeCommand {
@Override @Override
public void setup() { public void setup() {
this.setPermission(Constants.PERMPREFIX + "admin.top"); this.setPermission(getPermissionPrefix() + "admin.top");
this.setOnlyPlayer(false); this.setOnlyPlayer(false);
this.setDescription("admin.top.description"); this.setDescription("admin.top.description");
} }

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import bskyblock.addon.level.Level; import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
@ -29,21 +28,21 @@ public class IslandLevel extends CompositeCommand {
return true; return true;
} else if (user.getUniqueId().equals(playerUUID) ) { } else if (user.getUniqueId().equals(playerUUID) ) {
// Self level request // Self level request
levelPlugin.calculateIslandLevel(user.getWorld(), user, user.getUniqueId(), false); levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId(), false, this.getPermissionPrefix());
} else { } else {
user.sendMessage("island.level.island-level-is", "[level]", String.valueOf(levelPlugin.getIslandLevel(user.getWorld(), playerUUID))); user.sendMessage("island.level.island-level-is", "[level]", String.valueOf(levelPlugin.getIslandLevel(getWorld(), playerUUID)));
return true; return true;
} }
} else { } else {
// Self level request // Self level request
levelPlugin.calculateIslandLevel(user.getWorld(), user, user.getUniqueId(), false); levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId(), false, this.getPermissionPrefix());
} }
return false; return false;
} }
@Override @Override
public void setup() { public void setup() {
this.setPermission(Constants.PERMPREFIX + "island.level"); this.setPermission(getPermissionPrefix() + "island.level");
this.setParameters("island.level.parameters"); this.setParameters("island.level.parameters");
this.setDescription("island.level.description"); this.setDescription("island.level.description");
this.setOnlyPlayer(true); this.setOnlyPlayer(true);

View File

@ -3,7 +3,6 @@ package bskyblock.addon.level.commands;
import java.util.List; import java.util.List;
import bskyblock.addon.level.Level; import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.Constants;
import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.api.user.User;
@ -18,13 +17,13 @@ public class IslandTop extends CompositeCommand {
@Override @Override
public boolean execute(User user, List<String> list) { public boolean execute(User user, List<String> list) {
plugin.getTopTen().getGUI(user); plugin.getTopTen().getGUI(getWorld(), user, getPermissionPrefix());
return true; return true;
} }
@Override @Override
public void setup() { public void setup() {
this.setPermission(Constants.PERMPREFIX + "island.top"); this.setPermission(getPermissionPrefix() + "island.top");
this.setDescription("island.top.description"); this.setDescription("island.top.description");

View File

@ -29,7 +29,6 @@ public class Settings {
private boolean islandResetDeathReset; private boolean islandResetDeathReset;
private boolean teamJoinDeathReset; private boolean teamJoinDeathReset;
@SuppressWarnings("deprecation")
public Settings(Level level) { public Settings(Level level) {
level.saveDefaultConfig(); level.saveDefaultConfig();
@ -104,6 +103,7 @@ public class Settings {
// All done // All done
} }
@SuppressWarnings("deprecation")
private MaterialData getMaterialData(String material) { private MaterialData getMaterialData(String material) {
String[] split = material.split(":"); String[] split = material.split(":");
byte data = 0; byte data = 0;