mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21: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.NoSuchElementException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The {@code TAG_List} tag.
|
||||
@ -74,7 +73,6 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return the tag or null
|
||||
*/
|
||||
@Nullable
|
||||
public Tag getIfExists(final int index) {
|
||||
try {
|
||||
return this.value.get(index);
|
||||
|
@ -181,9 +181,11 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : PlotSquared.plots.entrySet()) {
|
||||
if (!entry.getKey().equals(priorityWorld)) {
|
||||
for (Plot plot : entry.getValue().values()) {
|
||||
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||
Collections.sort(worlds);
|
||||
for (String world : worlds) {
|
||||
if (!world.equals(priorityWorld)) {
|
||||
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||
if (plots.contains(plot)) {
|
||||
newPlots.add(plot);
|
||||
}
|
||||
@ -193,6 +195,20 @@ public class PlotSquared {
|
||||
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) {
|
||||
final UUID uuid = UUIDHandler.getUUID(player);
|
||||
return getPlots(world, uuid);
|
||||
|
@ -51,7 +51,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
if (cmd.permission.hasPermission(player)) {
|
||||
if (cmd.cmd.startsWith(arg)) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Home extends SubCommand {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||
return true;
|
||||
|
@ -40,7 +40,7 @@ public class MainCommand {
|
||||
/**
|
||||
* 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>() {
|
||||
{
|
||||
addAll(Arrays.asList(_subCommands));
|
||||
|
@ -55,7 +55,7 @@ public class Visit extends SubCommand {
|
||||
final UUID uuid = UUIDHandler.getUUID(username);
|
||||
List<Plot> plots = null;
|
||||
if (uuid != null) {
|
||||
plots = PlotSquared.sortPlots(getPlots(uuid), plr.getLocation().getWorld());
|
||||
plots = PlotSquared.sortPlotsByWorld(getPlots(uuid));
|
||||
}
|
||||
if ((uuid == null) || plots.isEmpty()) {
|
||||
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
|
@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
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();
|
||||
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
@ -72,6 +72,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
return;
|
||||
}
|
||||
if (chunks.size() == 0) {
|
||||
TaskManager.runTaskLater(ifFailed, 1);
|
||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||
TaskManager.tasks.remove(currentIndex);
|
||||
return;
|
||||
|
@ -21,7 +21,7 @@ public abstract class HybridUtils {
|
||||
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user