mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Added plot swapping (untested)
This commit is contained in:
parent
c7a1ad5c17
commit
7f669b4207
@ -16,10 +16,15 @@ import org.bukkit.ChatColor;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public enum C {
|
public enum C {
|
||||||
|
/*
|
||||||
|
* Swap
|
||||||
|
*/
|
||||||
|
SWAP_SYNTAX("&c/plots swap <plot id>"),
|
||||||
|
SWAP_SUCCESS("&6Successfully swapped plots"),
|
||||||
/*
|
/*
|
||||||
* Comment
|
* Comment
|
||||||
*/
|
*/
|
||||||
COMMENT_SYNTAX("&cUse /plot comment <everyone|trusted|helper|owner|admin> <comment>"),
|
COMMENT_SYNTAX("&cUse /plots comment <everyone|trusted|helper|owner|admin> <comment>"),
|
||||||
/*
|
/*
|
||||||
* Console
|
* Console
|
||||||
*/
|
*/
|
||||||
@ -57,13 +62,13 @@ public enum C {
|
|||||||
SETUP_VALID_ARG("&cValue &6%s &cset for step %s"),
|
SETUP_VALID_ARG("&cValue &6%s &cset for step %s"),
|
||||||
SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD the world should have just been created. Otherwise you will need to add the world manually through the bukkit.yml"),
|
SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD the world should have just been created. Otherwise you will need to add the world manually through the bukkit.yml"),
|
||||||
SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"),
|
SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"),
|
||||||
SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup &l{world}&6 {generator}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup &l<world>&6 <generator>&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
||||||
SETUP_MISSING_GENERATOR("&cYou need to specify a generator (&6/p setup {world} &l{generator}&r&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
SETUP_MISSING_GENERATOR("&cYou need to specify a generator (&6/p setup <world> &l<generator>&r&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
||||||
SETUP_INVALID_GENERATOR("&cInvalid generator. Possible options: %s"),
|
SETUP_INVALID_GENERATOR("&cInvalid generator. Possible options: %s"),
|
||||||
/*
|
/*
|
||||||
* Schematic Stuff
|
* Schematic Stuff
|
||||||
*/
|
*/
|
||||||
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test {name}"),
|
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test <name>"),
|
||||||
SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"),
|
SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"),
|
||||||
SCHEMATIC_VALID("&cThat is a valid schematic"),
|
SCHEMATIC_VALID("&cThat is a valid schematic"),
|
||||||
SCHEMATIC_PASTE_FAILED("&cFailed to paste the schematic"),
|
SCHEMATIC_PASTE_FAILED("&cFailed to paste the schematic"),
|
||||||
@ -140,10 +145,10 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* purge
|
* purge
|
||||||
*/
|
*/
|
||||||
PURGE_SYNTAX("&c/plots purge {world|world;x,z}"),
|
PURGE_SYNTAX("&c/plots purge <world|world;x,z>"),
|
||||||
PURGE_SUCCESS("All plots for the specified world have now been purged."),
|
PURGE_SUCCESS("All plots for the specified world have now been purged."),
|
||||||
/*
|
/*
|
||||||
* No {plot}
|
* No <plot>
|
||||||
*/
|
*/
|
||||||
NOT_IN_PLOT("&cYou're not in a plot"),
|
NOT_IN_PLOT("&cYou're not in a plot"),
|
||||||
NOT_IN_PLOT_WORLD("&cYou're not in a plot world"),
|
NOT_IN_PLOT_WORLD("&cYou're not in a plot world"),
|
||||||
@ -204,7 +209,7 @@ public enum C {
|
|||||||
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"),
|
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"),
|
||||||
PLOT_INFO("ID: &6%id%&c, Alias: &6%alias%&c, Owner: &6%owner%&c, Biome: &6%biome%&c, Helpers:&6%helpers%&c, Trusted:&6%trusted%&c, Denied:&6%denied%&c, Rating: &6%rating%&c, Flags: &6%flags%"),
|
PLOT_INFO("ID: &6%id%&c, Alias: &6%alias%&c, Owner: &6%owner%&c, Biome: &6%biome%&c, Helpers:&6%helpers%&c, Trusted:&6%trusted%&c, Denied:&6%denied%&c, Rating: &6%rating%&c, Flags: &6%flags%"),
|
||||||
PLOT_USER_LIST(" &6%user%&c,"),
|
PLOT_USER_LIST(" &6%user%&c,"),
|
||||||
INFO_SYNTAX_CONSOLE("/plot info {world} X;Y"),
|
INFO_SYNTAX_CONSOLE("/plot info <world> X;Y"),
|
||||||
/*
|
/*
|
||||||
* Generating
|
* Generating
|
||||||
*/
|
*/
|
||||||
@ -246,7 +251,7 @@ public enum C {
|
|||||||
*/
|
*/
|
||||||
DENIED_REMOVED("&cYou successfully undenied the player from this plot"),
|
DENIED_REMOVED("&cYou successfully undenied the player from this plot"),
|
||||||
DENIED_ADDED("&cYou successfully denied the player from this plot"),
|
DENIED_ADDED("&cYou successfully denied the player from this plot"),
|
||||||
DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"),
|
DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add <name> &cor &6/plot helpers remove <name>"),
|
||||||
WAS_NOT_DENIED("&cThat player was not denied on this plot"),
|
WAS_NOT_DENIED("&cThat player was not denied on this plot"),
|
||||||
/*
|
/*
|
||||||
* Rain
|
* Rain
|
||||||
@ -269,7 +274,7 @@ public enum C {
|
|||||||
*/
|
*/
|
||||||
HELPER_ADDED("&6You successfully added a helper to the plot"),
|
HELPER_ADDED("&6You successfully added a helper to the plot"),
|
||||||
HELPER_REMOVED("&6You successfully removed a helper from the plot"),
|
HELPER_REMOVED("&6You successfully removed a helper from the plot"),
|
||||||
HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"),
|
HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add <name> &cor &6/plot helpers remove <name>"),
|
||||||
WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"),
|
WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"),
|
||||||
/*
|
/*
|
||||||
* Trusted
|
* Trusted
|
||||||
@ -278,7 +283,7 @@ public enum C {
|
|||||||
ALREADY_ADDED("&cThat user is already added to that category."),
|
ALREADY_ADDED("&cThat user is already added to that category."),
|
||||||
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"),
|
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"),
|
||||||
TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"),
|
TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"),
|
||||||
TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"),
|
TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add <name> &cor &6/plot trusted remove <name>"),
|
||||||
T_WAS_NOT_ADDED("&cThat player was not added as a trusted user on this plot"),
|
T_WAS_NOT_ADDED("&cThat player was not added as a trusted user on this plot"),
|
||||||
/*
|
/*
|
||||||
* Set Owner
|
* Set Owner
|
||||||
|
@ -102,10 +102,10 @@ public class PlotSelection {
|
|||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean swap(World world, Plot plot1, Plot plot2) {
|
public static boolean swap(World world, PlotId id1, PlotId id2) {
|
||||||
|
|
||||||
Location bot2 = PlotHelper.getPlotBottomLocAbs(world, plot2.getId()).add(1, 0, 1);
|
Location bot2 = PlotHelper.getPlotBottomLocAbs(world, id2).add(1, 0, 1);
|
||||||
Location top2 = PlotHelper.getPlotTopLocAbs(world, plot2.getId());
|
Location top2 = PlotHelper.getPlotTopLocAbs(world, id2);
|
||||||
|
|
||||||
ArrayList<BlockState> states2 = new ArrayList<BlockState>();
|
ArrayList<BlockState> states2 = new ArrayList<BlockState>();
|
||||||
|
|
||||||
@ -120,15 +120,15 @@ public class PlotSelection {
|
|||||||
|
|
||||||
for (BlockState tile :chunk.getTileEntities()) {
|
for (BlockState tile :chunk.getTileEntities()) {
|
||||||
PlotId id = PlayerFunctions.getPlot(tile.getLocation());
|
PlotId id = PlayerFunctions.getPlot(tile.getLocation());
|
||||||
if ((id != null) && id.equals(plot2.id)) {
|
if ((id != null) && id.equals(id2)) {
|
||||||
states2.add(tile);
|
states2.add(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Location bot1 = PlotHelper.getPlotBottomLocAbs(world, plot1.getId()).add(1, 0, 1);
|
Location bot1 = PlotHelper.getPlotBottomLocAbs(world, id1).add(1, 0, 1);
|
||||||
Location top1 = PlotHelper.getPlotTopLocAbs(world, plot1.getId());
|
Location top1 = PlotHelper.getPlotTopLocAbs(world, id1);
|
||||||
|
|
||||||
ArrayList<BlockState> states1 = new ArrayList<BlockState>();
|
ArrayList<BlockState> states1 = new ArrayList<BlockState>();
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class PlotSelection {
|
|||||||
|
|
||||||
for (BlockState tile :chunk.getTileEntities()) {
|
for (BlockState tile :chunk.getTileEntities()) {
|
||||||
PlotId id = PlayerFunctions.getPlot(tile.getLocation());
|
PlotId id = PlayerFunctions.getPlot(tile.getLocation());
|
||||||
if ((id != null) && id.equals(plot1.id)) {
|
if ((id != null) && id.equals(id1)) {
|
||||||
states1.add(tile);
|
states1.add(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,10 @@ public enum Command {
|
|||||||
// - /plot rate <number out of 10>
|
// - /plot rate <number out of 10>
|
||||||
// - /plot list <some parameter to list the most popular, and highest rated
|
// - /plot list <some parameter to list the most popular, and highest rated
|
||||||
// plots>
|
// plots>
|
||||||
|
SWAP("swap"),
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
INBOX("inbox"),
|
INBOX("inbox"),
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -33,7 +33,7 @@ public class Copy extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
if (!plot.settings.isMerged()) {
|
||||||
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class MainCommand implements CommandExecutor {
|
|||||||
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(),
|
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(),
|
||||||
new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(),
|
new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(),
|
||||||
new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(),
|
new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(),
|
||||||
new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new DebugClaimTest() };
|
new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new DebugClaimTest(), new Inbox(), new Comment(), new Swap() };
|
||||||
|
|
||||||
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
||||||
|
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
||||||
|
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
|
*
|
||||||
|
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.*;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Citymonstret on 2014-08-01.
|
||||||
|
*/
|
||||||
|
public class Swap extends SubCommand {
|
||||||
|
|
||||||
|
public Swap() {
|
||||||
|
super(Command.SWAP, "Swap two plots", "copy", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player plr, String... args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID);
|
||||||
|
PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
|
||||||
|
&& !PlotMain.hasPermission(plr,"plots.admin")) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (plot!=null && plot.settings.isMerged()) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String id = args[0];
|
||||||
|
PlotId plotid;
|
||||||
|
World world = plr.getWorld();
|
||||||
|
try {
|
||||||
|
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
||||||
|
Plot plot2 = PlotMain.getPlots(world).get(plotid);
|
||||||
|
if ((plot2==null || !plot2.hasOwner() || plot2.owner!=plr.getUniqueId()) && !PlotMain.hasPermission(plr,"plots.admin")) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
|
PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlotSelection.swap(world, plot.id, plotid);
|
||||||
|
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user