mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
Fixed home plot sorting
This commit is contained in:
parent
288b84bd6a
commit
c76536b8b0
@ -6,7 +6,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
@ -74,7 +73,6 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return the tag or null
|
* @return the tag or null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public Tag getIfExists(final int index) {
|
public Tag getIfExists(final int index) {
|
||||||
try {
|
try {
|
||||||
return this.value.get(index);
|
return this.value.get(index);
|
||||||
|
@ -181,9 +181,11 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : PlotSquared.plots.entrySet()) {
|
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||||
if (!entry.getKey().equals(priorityWorld)) {
|
Collections.sort(worlds);
|
||||||
for (Plot plot : entry.getValue().values()) {
|
for (String world : worlds) {
|
||||||
|
if (!world.equals(priorityWorld)) {
|
||||||
|
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||||
if (plots.contains(plot)) {
|
if (plots.contains(plot)) {
|
||||||
newPlots.add(plot);
|
newPlots.add(plot);
|
||||||
}
|
}
|
||||||
@ -193,6 +195,20 @@ public class PlotSquared {
|
|||||||
return newPlots;
|
return newPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||||
|
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||||
|
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||||
|
Collections.sort(worlds);
|
||||||
|
for (String world : worlds) {
|
||||||
|
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||||
|
if (plots.contains(plot)) {
|
||||||
|
newPlots.add(plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newPlots;
|
||||||
|
}
|
||||||
|
|
||||||
public static Set<Plot> getPlots(final String world, final String player) {
|
public static Set<Plot> getPlots(final String world, final String player) {
|
||||||
final UUID uuid = UUIDHandler.getUUID(player);
|
final UUID uuid = UUIDHandler.getUUID(player);
|
||||||
return getPlots(world, uuid);
|
return getPlots(world, uuid);
|
||||||
|
@ -51,7 +51,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (cmd.permission.hasPermission(player)) {
|
if (cmd.permission.hasPermission(player)) {
|
||||||
if (cmd.cmd.startsWith(arg)) {
|
if (cmd.cmd.startsWith(arg)) {
|
||||||
tabOptions.add(cmd.cmd);
|
tabOptions.add(cmd.cmd);
|
||||||
} else if (cmd.alias.get(0).startsWith(arg)) {
|
} else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) {
|
||||||
tabOptions.add(cmd.alias.get(0));
|
tabOptions.add(cmd.alias.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class Home extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, String... args) {
|
public boolean execute(final PlotPlayer plr, String... args) {
|
||||||
final ArrayList<Plot> plots = PlotSquared.sortPlots(PlotSquared.getPlots(plr), plr.getLocation().getWorld());
|
final ArrayList<Plot> plots = PlotSquared.sortPlotsByWorld(PlotSquared.getPlots(plr));
|
||||||
if (plots.size() == 1) {
|
if (plots.size() == 1) {
|
||||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||||
return true;
|
return true;
|
||||||
|
@ -40,7 +40,7 @@ public class MainCommand {
|
|||||||
/**
|
/**
|
||||||
* Main Permission Node
|
* Main Permission Node
|
||||||
*/
|
*/
|
||||||
private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), 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 SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm(), new Copy() };
|
private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), 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 SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm(), new Copy(), new WE_Anywhere() };
|
||||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
addAll(Arrays.asList(_subCommands));
|
addAll(Arrays.asList(_subCommands));
|
||||||
|
@ -55,7 +55,7 @@ public class Visit extends SubCommand {
|
|||||||
final UUID uuid = UUIDHandler.getUUID(username);
|
final UUID uuid = UUIDHandler.getUUID(username);
|
||||||
List<Plot> plots = null;
|
List<Plot> plots = null;
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
plots = PlotSquared.sortPlots(getPlots(uuid), plr.getLocation().getWorld());
|
plots = PlotSquared.sortPlotsByWorld(getPlots(uuid));
|
||||||
}
|
}
|
||||||
if ((uuid == null) || plots.isEmpty()) {
|
if ((uuid == null) || plots.isEmpty()) {
|
||||||
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||||
|
@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
|
|
||||||
public class BukkitHybridUtils extends HybridUtils {
|
public class BukkitHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone) {
|
public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone, final Runnable ifFailed) {
|
||||||
TaskManager.index.increment();
|
TaskManager.index.increment();
|
||||||
|
|
||||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
@ -72,6 +72,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (chunks.size() == 0) {
|
if (chunks.size() == 0) {
|
||||||
|
TaskManager.runTaskLater(ifFailed, 1);
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
return;
|
return;
|
||||||
|
@ -21,7 +21,7 @@ public abstract class HybridUtils {
|
|||||||
|
|
||||||
public static HybridUtils manager;
|
public static HybridUtils manager;
|
||||||
|
|
||||||
public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed);
|
public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed, Runnable ifFailed);
|
||||||
|
|
||||||
public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user