more cmds

This commit is contained in:
boy0001 2015-02-22 23:40:36 +11:00
parent 1d969e439c
commit b3a5f0aff2
12 changed files with 25 additions and 42 deletions

View File

@ -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<PlotId> 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;
}

View File

@ -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];

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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
}
}