From 4d4cec4cb1dbbfa82bccf491f6f5a6f376ec712d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Feb 2015 22:37:36 +1100 Subject: [PATCH] merge direction --- .../plot/commands/Merge.java | 2 +- .../plot/commands/Set.java | 18 +++++++++++++----- .../plot/object/BukkitPlayer.java | 5 +++++ .../plot/object/PlotPlayer.java | 2 ++ .../plot/util/bukkit/BukkitUtil.java | 6 ++++++ 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 78874b1a6..19c94715e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -72,7 +72,7 @@ public class Merge extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { - final Location loc = plr.getLocation(); + final Location loc = plr.getLocationFull(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 3f91e7978..7906a6a5d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -20,7 +20,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; +import java.util.List; import org.apache.commons.lang.StringUtils; @@ -49,7 +52,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * @author Citymonstret */ public class Set extends SubCommand { - public final static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "flag" }; + public final static String[] values = new String[] { "biome", "alias", "home", "flag" }; public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" }; public Set() { @@ -73,7 +76,10 @@ public class Set extends SubCommand { return false; } if (args.length < 1) { - MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); + PlotManager manager = PlotSquared.getPlotManager(loc.getWorld()); + List newValues = Arrays.asList(values);; + newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getPlotWorld(loc.getWorld()), plot.id))); + MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues)); return false; } for (int i = 0; i < aliases.length; i++) { @@ -258,7 +264,9 @@ public class Set extends SubCommand { return true; } } - MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values)); + List newValues = Arrays.asList(values);; + newValues.addAll(Arrays.asList(manager.getPlotComponents(plotworld, plot.id))); + MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues)); return false; } @@ -266,9 +274,9 @@ public class Set extends SubCommand { return MainUtil.colorise('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } - private String getArgumentList(final String[] strings) { + private String getArgumentList(final List newValues) { final StringBuilder builder = new StringBuilder(); - for (final String s : strings) { + for (final String s : newValues) { builder.append(getString(s)); } return builder.toString().substring(1, builder.toString().length() - 1); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 8ee274af1..2d32295c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -102,4 +102,9 @@ public class BukkitPlayer implements PlotPlayer { } + @Override + public Location getLocationFull() { + return BukkitUtil.getLocationFull(this.player); + } + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 155d68c4b..7cb9597c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -10,6 +10,8 @@ import java.util.UUID; public interface PlotPlayer { public Location getLocation(); + public Location getLocationFull(); + public UUID getUUID(); public boolean hasPermission(final String perm); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index dcd36902f..1fd49fee2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -159,6 +159,12 @@ public class BukkitUtil extends BlockManager { final String world = loc.getWorld().getName(); return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } + + public static Location getLocationFull(final Entity entity) { + final org.bukkit.Location loc = entity.getLocation(); + final String world = loc.getWorld().getName(); + return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getYaw(), loc.getPitch()); + } @Override public void functionSetBlocks(final String worldname, final int[] x, final int[] y, final int[] z, final int[] id, final byte[] data) {