diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
index 8b02be968..1da734d56 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
@@ -79,6 +79,22 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
return false;
}
+ // TODO restructure this
+ public static int hasPermissionRange(final Player player, final String stub, final int range) {
+ if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) {
+ return Byte.MAX_VALUE;
+ }
+ if (player.hasPermission(stub + ".*")) {
+ return Byte.MAX_VALUE;
+ }
+ for (int i = range; i > 0; i--) {
+ if (player.hasPermission(stub + "." + i)) {
+ return i;
+ }
+ }
+ return 0;
+ }
+
// TODO restructure this
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
Plot bot = PlayerFunctions.getBottomPlot(player.getWorld().getName(), plot);
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java
index 6dd1bffd6..dd46e7a6a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/_PlotMain.java
@@ -1157,30 +1157,6 @@ public class _PlotSquared {
return new HybridGen(world);
}
- /**
- * Check a range of permissions e.g. 'plots.plot.<0-100>'
Returns highest integer in range.
- *
- * @param player to check
- * @param stub to check
- * @param range tp check
- *
- * @return permitted range
- */
- public int hasPermissionRange(final Player player, final String stub, final int range) {
- if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) {
- return Byte.MAX_VALUE;
- }
- if (player.hasPermission(stub + ".*")) {
- return Byte.MAX_VALUE;
- }
- for (int i = range; i > 0; i--) {
- if (player.hasPermission(stub + "." + i)) {
- return i;
- }
- }
- return 0;
- }
-
/**
* Check a player for a permission
- Op has all permissions
- checks for '*' nodes
*
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java
index bb364c63d..c94e5587f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java
@@ -13,6 +13,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
+import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.commands.Unlink;
import com.intellectualcrafters.plot.config.C;
@@ -23,6 +24,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
+import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
public class ExpireManager {
@@ -64,7 +66,7 @@ public class ExpireManager {
}
public static void runTask() {
- ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotSquared.getMain(), new Runnable() {
+ ExpireManager.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, new Runnable() {
@Override
public void run() {
for (String world : PlotSquared.getPlotWorldsString()) {
@@ -109,14 +111,13 @@ public class ExpireManager {
PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString());
}
}
- final World worldobj = Bukkit.getWorld(world);
final PlotManager manager = PlotSquared.getPlotManager(world);
if (plot.settings.isMerged()) {
Unlink.unlinkPlot(Bukkit.getWorld(world), plot);
}
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
- manager.clearPlot(worldobj, plotworld, plot, false, null);
- PlotHelper.removeSign(worldobj, plot);
+ manager.clearPlot(plotworld, plot, false, null);
+ PlotHelper.removeSign(plot);
DBFunc.delete(world, plot);
PlotSquared.removePlot(world, plot.id, true);
expiredPlots.get(world).remove(plot);
@@ -186,7 +187,7 @@ public class ExpireManager {
String worldname = Bukkit.getWorlds().get(0).getName();
String foldername;
String filename = null;
- if (PlotSquared.checkVersion(1, 7, 5)) {
+ if (BukkitMain.checkVersion(1, 7, 5)) {
foldername = "playerdata";
try {
filename = op.getUniqueId() +".dat";
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
deleted file mode 100644
index 95cc0e546..000000000
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.intellectualcrafters.plot.util;
-
-import com.intellectualcrafters.plot.PlotSquared;
-import com.intellectualcrafters.plot.config.C;
-
-public class MainUtil {
- // TODO messages / permission stuff
-
- /**
- * Send a message to the console
- *
- * @param c message
- */
- public static void log(final C c) {
- PlotSquared.MAIN_IMP.log(c.s());
- }
-}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java
index c33eb0fa1..95859cc86 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java
@@ -21,6 +21,7 @@
package com.intellectualcrafters.plot.util;
+import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@@ -29,6 +30,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
+import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import org.bukkit.ChatColor;
import org.bukkit.World;
@@ -127,7 +129,7 @@ import java.util.UUID;
* @return
*/
public static PlotId getPlotAbs(final Location loc) {
- final String world = loc.getWorld().getName();
+ final String world = loc.getWorld();
final PlotManager manager = PlotSquared.getPlotManager(world);
if (manager == null) {
return null;
@@ -145,7 +147,7 @@ import java.util.UUID;
* @return
*/
public static PlotId getPlot(final Location loc) {
- final String world = loc.getWorld().getName();
+ final String world = loc.getWorld();
final PlotManager manager = PlotSquared.getPlotManager(world);
if (manager == null) {
return null;
@@ -169,18 +171,18 @@ import java.util.UUID;
* @return
*/
public static Plot getCurrentPlot(final Player player) {
- if (!PlotSquared.isPlotWorld(player.getWorld())) {
+ if (!PlotSquared.isPlotWorld(player.getWorld().getName())) {
return null;
}
- final PlotId id = getPlot(BukkitUtil.getLocation(entity));
- final World world = player.getWorld();
+ final PlotId id = getPlot(BukkitUtil.getLocation(player));
+ final String world = player.getWorld().getName();
if (id == null) {
return null;
}
if (PlotSquared.getPlots(world).containsKey(id)) {
return PlotSquared.getPlots(world).get(id);
}
- return new Plot(id, null, new ArrayList(), new ArrayList(), world.getName());
+ return new Plot(id, null, new ArrayList(), new ArrayList(), world);
}
@@ -203,8 +205,8 @@ import java.util.UUID;
*
* @return
*/
- public static Set getPlayerPlots(final World world, final Player plr) {
- final Set p = PlotSquared.getPlots(world, plr);
+ public static Set getPlayerPlots(final String world, final Player plr) {
+ final Set p = PlotSquared.getPlots(world, plr.getName());
if (p == null) {
return new HashSet<>();
}
@@ -218,7 +220,7 @@ import java.util.UUID;
*
* @return
*/
- public static int getPlayerPlotCount(final World world, final Player plr) {
+ public static int getPlayerPlotCount(final String world, final Player plr) {
final UUID uuid = UUIDHandler.getUUID(plr);
int count = 0;
for (final Plot plot : PlotSquared.getPlots(world).values()) {
@@ -237,7 +239,7 @@ import java.util.UUID;
* @return
*/
public static int getAllowedPlots(final Player p) {
- return PlotSquared.MAIN_IMP.(p, "plots.plot", Settings.MAX_PLOTS);
+ return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS);
}
/**
@@ -286,7 +288,7 @@ import java.util.UUID;
public static boolean sendMessage(final Player plr, final String msg, final boolean prefix) {
if ((msg.length() > 0) && !msg.equals("")) {
if (plr == null) {
- PlotSquared.MAIN_IMP.log(C.PREFIX.s() + msg);
+ PlotSquared.log(C.PREFIX.s() + msg);
} else {
sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
}