diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 6712f851a..7b52d578b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -23,15 +23,15 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.UUID; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -51,6 +51,7 @@ public class SetOwner extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { + Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || (plot.owner == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); @@ -64,9 +65,9 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } - final World world = plr.getWorld(); - final PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id; - final PlotId top = MainUtil.getTopPlot(world, plot).id; + final String world = loc.getWorld(); + final PlotId bot = MainUtil.getBottomPlot(plot).id; + final PlotId top = MainUtil.getTopPlot( plot).id; final ArrayList plots = MainUtil.getPlotSelectionIds(bot, top); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); @@ -78,11 +79,8 @@ public class SetOwner extends SubCommand { current.owner = uuid; PlotSquared.updatePlot(current); DBFunc.setOwner(current, current.owner); - if (PlotSquared.worldGuardListener != null) { - PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); - } } - MainUtil.setSign(world, args[0], plot); + MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 47c439242..b0511e266 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -27,12 +27,6 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.WorldCreator; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -41,6 +35,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; public class Setup extends SubCommand { @@ -205,7 +200,7 @@ public class Setup extends SubCommand { MainUtil.sendMessage(plr, "&cYou need to choose a world name!"); return false; } - if (Bukkit.getWorld(args[0]) != null) { + if (BlockManager.manager.isWorld(args[0])) { MainUtil.sendMessage(plr, "&cThat world name is already taken!"); } object.world = args[0]; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 6ce585498..de87982bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -29,7 +29,9 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -64,7 +66,7 @@ public class Swap extends SubCommand { } final String id = args[0]; PlotId plotid; - final World world = plr.getWorld(); + final String world = loc.getWorld(); try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); @@ -83,10 +85,9 @@ public class Swap extends SubCommand { MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } - PlotSelection.swap(world, plot.id, plotid); - // TODO Requires testing!! + AChunkManager.manager.swap(world, plot.id, plotid); + // FIXME Requires testing!! DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid)); - // TODO Requires testing!! MainUtil.sendMessage(plr, C.SWAP_SUCCESS); MainUtil.update(plr.getLocation()); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java index 7755edf82..8ca015391 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -21,9 +21,6 @@ package com.intellectualcrafters.plot.commands; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java index a0c676b44..3890c8555 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import org.bukkit.Location; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotId; @@ -35,7 +33,8 @@ public class Target extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (!PlotSquared.isPlotWorld(plr.getWorld())) { + Location ploc = plr.getLocation(); + if (!PlotSquared.isPlotWorld(ploc.getWorld())) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -45,7 +44,7 @@ public class Target extends SubCommand { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; } - final Location loc = MainUtil.getPlotHome(plr.getWorld(), id); + final Location loc = MainUtil.getPlotHome(loc.getWorld(), id); plr.setCompassTarget(loc); MainUtil.sendMessage(plr, C.COMPASS_TARGET); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 3c408382d..cad1dd87c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -25,9 +25,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.GZIPOutputStream; -import org.bukkit.Bukkit; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index b5c455783..6f25bfc3c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -28,10 +28,6 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashSet; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 1ae3155f5..20bbcf123 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index 3ee36d6a1..49865681d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.commands; import net.milkbowl.vault.economy.Economy; -import org.bukkit.World; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 0fc40c6c4..c349958f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -22,10 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java index 04471e9a0..e9b1b7b54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/AChunkManager.java @@ -6,6 +6,7 @@ import java.util.List; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RegionWrapper; public abstract class AChunkManager { @@ -33,4 +34,6 @@ public abstract class AChunkManager { public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone); public abstract void clearAllEntities(final Plot plot); + + public abstract void swap(String world, PlotId id, PlotId plotid); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 5bfb6c591..e486e57f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -760,4 +760,9 @@ public class ChunkManager extends AChunkManager { public boolean loadChunk(String world, ChunkLoc loc) { return BukkitUtil.getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); } + + @Override + public void swap(String world, PlotId id, PlotId plotid) { + // FIXME swap plots + } }