mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-09-11 01:48:59 +02:00
Plot search?
This commit is contained in:
parent
d8561d278f
commit
8166873978
@ -175,9 +175,6 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
|
||||
System.out.print(pos1);
|
||||
System.out.print(pos2);
|
||||
|
||||
setWallFilling(dpw, plot.id, new PlotBlock[] { dpw.WALL_FILLING });
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
|
@ -98,6 +98,85 @@ public class MainUtil {
|
||||
return new Location(plot.world, bot.getX() + (top.getX() - bot.getX()) / 2, 0, bot.getZ() + (top.getZ() - bot.getZ()) / 2);
|
||||
}
|
||||
|
||||
public List<Plot> getPlotsBySearch(String search) {
|
||||
String[] split = search.split(" ");
|
||||
int size = split.length * 2;
|
||||
|
||||
List<UUID> uuids = new ArrayList<>();
|
||||
PlotId id = null;
|
||||
String world = null;
|
||||
String alias = null;
|
||||
|
||||
for (String term : split) {
|
||||
try {
|
||||
UUID uuid = UUIDHandler.getUUID(term);
|
||||
if (uuid == null) {
|
||||
uuid = UUID.fromString(term);
|
||||
}
|
||||
if (uuid != null) {
|
||||
uuids.add(uuid);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
id = PlotId.fromString(term);
|
||||
if (id != null) {
|
||||
continue;
|
||||
}
|
||||
for (String pw : PS.get().getPlotWorlds()) {
|
||||
if (pw.equalsIgnoreCase(term)) {
|
||||
world = pw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (world == null) {
|
||||
alias = term;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ArrayList<Plot>> plotList = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
plotList.add(new ArrayList<Plot>());
|
||||
}
|
||||
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
int count = 0;
|
||||
if (uuids.size() > 0) {
|
||||
for (UUID uuid : uuids) {
|
||||
if (plot.isOwner(uuid)) {
|
||||
count += 2;
|
||||
}
|
||||
else if (plot.isAdded(uuid)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (id != null) {
|
||||
if (plot.id.equals(id)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (world != null && plot.world.equals(world)) {
|
||||
count++;
|
||||
}
|
||||
if (alias != null && alias.equals(plot.settings.getAlias())) {
|
||||
count++;
|
||||
}
|
||||
if (count != 0) {
|
||||
plotList.get(count - 1).add(plot);
|
||||
}
|
||||
}
|
||||
|
||||
List<Plot> plots = new ArrayList<Plot>();
|
||||
for (int i = plotList.size() - 1; i >= 0; i--) {
|
||||
if (plotList.get(i).size() > 0) {
|
||||
plots.addAll(plotList.get(i));
|
||||
}
|
||||
}
|
||||
return plots;
|
||||
}
|
||||
|
||||
public static Plot getPlotFromString(PlotPlayer player, String arg, boolean message) {
|
||||
if (arg == null) {
|
||||
if (player == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user