Replace RunnableVal with java Consumer

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt 2019-02-19 18:39:43 -05:00
parent 2e22dfe056
commit b7aeeb151d
12 changed files with 174 additions and 234 deletions

View File

@ -2,6 +2,8 @@ package com.github.intellectualsites.plotsquared.commands;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import java.util.stream.Stream;
public abstract class Argument<T> { public abstract class Argument<T> {
public static final Argument<Integer> Integer = new Argument<Integer>("int", 16) { public static final Argument<Integer> Integer = new Argument<Integer>("int", 16) {
@ -17,11 +19,9 @@ public abstract class Argument<T> {
public static final Argument<Boolean> Boolean = new Argument<Boolean>("boolean", true) { public static final Argument<Boolean> Boolean = new Argument<Boolean>("boolean", true) {
@Override public Boolean parse(String in) { @Override public Boolean parse(String in) {
Boolean value = null; Boolean value = null;
if (in.equalsIgnoreCase("true") || in.equalsIgnoreCase("Yes") || in if (Stream.of("true", "Yes", "1").anyMatch(in::equalsIgnoreCase)) {
.equalsIgnoreCase("1")) {
value = true; value = true;
} else if (in.equalsIgnoreCase("false") || in.equalsIgnoreCase("No") || in } else if (Stream.of("false", "No", "0").anyMatch(in::equalsIgnoreCase)) {
.equalsIgnoreCase("0")) {
value = false; value = false;
} }
return value; return value;

View File

@ -30,7 +30,6 @@ import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import lombok.Setter; import lombok.Setter;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.*; import java.io.*;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -342,14 +341,12 @@ import java.util.zip.ZipInputStream;
debug("Starting UUID caching"); debug("Starting UUID caching");
UUIDHandler.startCaching(() -> { UUIDHandler.startCaching(() -> {
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE); UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
foreachPlotRaw(new RunnableVal<Plot>() { forEachPlotRaw(plot -> {
@Override public void run(Plot plot) {
if (plot.hasOwner() && plot.temp != -1) { if (plot.hasOwner() && plot.temp != -1) {
if (UUIDHandler.getName(plot.owner) == null) { if (UUIDHandler.getName(plot.owner) == null) {
UUIDHandler.implementation.unknown.add(plot.owner); UUIDHandler.implementation.unknown.add(plot.owner);
} }
} }
}
}); });
startExpiryTasks(); startExpiryTasks();
}); });
@ -516,15 +513,13 @@ import java.util.zip.ZipInputStream;
public Set<Plot> getBasePlots() { public Set<Plot> getBasePlots() {
int size = getPlotCount(); int size = getPlotCount();
final Set<Plot> result = new HashSet<>(size); final Set<Plot> result = new HashSet<>(size);
foreachPlotArea(new RunnableVal<PlotArea>() { forEachPlotArea(value -> {
@Override public void run(PlotArea value) {
for (Plot plot : value.getPlots()) { for (Plot plot : value.getPlots()) {
if (!plot.isBasePlot()) { if (!plot.isBasePlot()) {
continue; continue;
} }
result.add(plot); result.add(plot);
} }
}
}); });
return Collections.unmodifiableSet(result); return Collections.unmodifiableSet(result);
} }
@ -784,8 +779,7 @@ import java.util.zip.ZipInputStream;
*/ */
public Set<Plot> getPlots(final PlotFilter... filters) { public Set<Plot> getPlots(final PlotFilter... filters) {
final HashSet<Plot> set = new HashSet<>(); final HashSet<Plot> set = new HashSet<>();
foreachPlotArea(new RunnableVal<PlotArea>() { forEachPlotArea(value -> {
@Override public void run(PlotArea value) {
for (PlotFilter filter : filters) { for (PlotFilter filter : filters) {
if (!filter.allowsArea(value)) { if (!filter.allowsArea(value)) {
return; return;
@ -801,7 +795,6 @@ import java.util.zip.ZipInputStream;
} }
set.add(plot); set.add(plot);
} }
}
}); });
return set; return set;
} }
@ -814,11 +807,7 @@ import java.util.zip.ZipInputStream;
public Set<Plot> getPlots() { public Set<Plot> getPlots() {
int size = getPlotCount(); int size = getPlotCount();
final Set<Plot> result = new HashSet<>(size); final Set<Plot> result = new HashSet<>(size);
foreachPlotArea(new RunnableVal<PlotArea>() { forEachPlotArea(value -> result.addAll(value.getPlots()));
@Override public void run(PlotArea value) {
result.addAll(value.getPlots());
}
});
return result; return result;
} }
@ -935,11 +924,7 @@ import java.util.zip.ZipInputStream;
public Collection<Plot> getPlots(String world) { public Collection<Plot> getPlots(String world) {
final Set<Plot> set = new HashSet<>(); final Set<Plot> set = new HashSet<>();
foreachPlotArea(world, new RunnableVal<PlotArea>() { forEachPlotArea(world, value -> set.addAll(value.getPlots()));
@Override public void run(PlotArea value) {
set.addAll(value.getPlots());
}
});
return set; return set;
} }
@ -973,12 +958,10 @@ import java.util.zip.ZipInputStream;
*/ */
public Set<Plot> getPlots(final UUID uuid) { public Set<Plot> getPlots(final UUID uuid) {
final Set<Plot> plots = new HashSet<>(); final Set<Plot> plots = new HashSet<>();
foreachPlot(new RunnableVal<Plot>() { forEachPlot(value -> {
@Override public void run(Plot value) {
if (value.isOwnerAbs(uuid)) { if (value.isOwnerAbs(uuid)) {
plots.add(value); plots.add(value);
} }
}
}); });
return Collections.unmodifiableSet(plots); return Collections.unmodifiableSet(plots);
} }
@ -990,12 +973,10 @@ import java.util.zip.ZipInputStream;
public Set<Plot> getBasePlots(final UUID uuid) { public Set<Plot> getBasePlots(final UUID uuid) {
final Set<Plot> plots = new HashSet<>(); final Set<Plot> plots = new HashSet<>();
foreachBasePlot(new RunnableVal<Plot>() { forEachBasePlot(value -> {
@Override public void run(Plot value) {
if (value.isOwner(uuid)) { if (value.isOwner(uuid)) {
plots.add(value); plots.add(value);
} }
}
}); });
return Collections.unmodifiableSet(plots); return Collections.unmodifiableSet(plots);
} }
@ -1008,12 +989,10 @@ import java.util.zip.ZipInputStream;
*/ */
public Set<Plot> getPlotsAbs(final UUID uuid) { public Set<Plot> getPlotsAbs(final UUID uuid) {
final Set<Plot> plots = new HashSet<>(); final Set<Plot> plots = new HashSet<>();
foreachPlot(new RunnableVal<Plot>() { forEachPlot(value -> {
@Override public void run(Plot value) {
if (value.isOwnerAbs(uuid)) { if (value.isOwnerAbs(uuid)) {
plots.add(value); plots.add(value);
} }
}
}); });
return Collections.unmodifiableSet(plots); return Collections.unmodifiableSet(plots);
} }
@ -1538,11 +1517,7 @@ import java.util.zip.ZipInputStream;
// Validate that all data in the db is correct // Validate that all data in the db is correct
final HashSet<Plot> plots = new HashSet<>(); final HashSet<Plot> plots = new HashSet<>();
try { try {
foreachPlotRaw(new RunnableVal<Plot>() { forEachPlotRaw(plots::add);
@Override public void run(Plot value) {
plots.add(value);
}
});
} catch (final Exception ignored) { } catch (final Exception ignored) {
} }
DBFunc.validatePlots(plots); DBFunc.validatePlots(plots);
@ -1824,43 +1799,36 @@ import java.util.zip.ZipInputStream;
} }
} }
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) { public void forEachPlotArea(@NonNull final String world, Consumer<PlotArea> runnable) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
runnable.run(area);
}
}
public void foreachPlotArea(@NonNull final String world,
@NonNull final RunnableVal<PlotArea> runnable) {
final PlotArea[] array = this.plotAreaManager.getPlotAreas(world, null); final PlotArea[] array = this.plotAreaManager.getPlotAreas(world, null);
if (array == null) { if (array == null) {
return; return;
} }
for (final PlotArea area : array) { for (final PlotArea area : array) {
runnable.run(area); runnable.accept(area);
} }
} }
public void foreachPlot(@NonNull final RunnableVal<Plot> runnable) { public void forEachPlot(Consumer<Plot> runnable) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) { for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
area.getPlots().forEach(runnable::run); area.getPlots().forEach(runnable);
} }
} }
public void foreachPlotRaw(@NonNull final RunnableVal<Plot> runnable) { public void forEachPlotRaw(Consumer<Plot> runnable) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) { for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
area.getPlots().forEach(runnable::run); area.getPlots().forEach(runnable);
} }
if (this.plots_tmp != null) { if (this.plots_tmp != null) {
for (final HashMap<PlotId, Plot> entry : this.plots_tmp.values()) { for (final HashMap<PlotId, Plot> entry : this.plots_tmp.values()) {
entry.values().forEach(runnable::run); entry.values().forEach(runnable);
} }
} }
} }
public void foreachBasePlot(@NonNull final RunnableVal<Plot> run) { public void forEachBasePlot(Consumer<Plot> run) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) { for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
area.foreachBasePlot(run); area.forEachBasePlot(run);
} }
} }

View File

@ -46,9 +46,9 @@ import java.util.Set;
final double price = flag.get(); final double price = flag.get();
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT); checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
player.withdraw(price); player.withdraw(price);
confirm.run(this, new Runnable() { // Failure
@Override // Success // Success
public void run() { confirm.run(this, () -> {
C.REMOVED_BALANCE.send(player, price); C.REMOVED_BALANCE.send(player, price);
EconHandler.manager EconHandler.manager
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price); .depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
@ -60,13 +60,9 @@ import java.util.Set;
plot.setOwner(player.getUUID()); plot.setOwner(player.getUUID());
C.CLAIMED.send(player); C.CLAIMED.send(player);
whenDone.run(Buy.this, CommandResult.SUCCESS); whenDone.run(Buy.this, CommandResult.SUCCESS);
} }, () -> {
}, new Runnable() {
@Override // Failure
public void run() {
player.deposit(price); player.deposit(price);
whenDone.run(Buy.this, CommandResult.FAILURE); whenDone.run(Buy.this, CommandResult.FAILURE);
}
}); });
} }
} }

View File

@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Stream;
@CommandDeclaration(command = "setowner", permission = "plots.set.owner", @CommandDeclaration(command = "setowner", permission = "plots.set.owner",
description = "Set the plot owner", usage = "/plot setowner <player>", description = "Set the plot owner", usage = "/plot setowner <player>",
@ -31,8 +32,7 @@ import java.util.UUID;
name = name == null ? value : name; name = name == null ? value : name;
} }
if (uuid == null || value.equalsIgnoreCase("-")) { if (uuid == null || value.equalsIgnoreCase("-")) {
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value if (Stream.of("none", "null", "-").anyMatch(value::equalsIgnoreCase)) {
.equalsIgnoreCase("-")) {
if (!Permissions if (!Permissions
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) { .hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) {
return false; return false;

View File

@ -6,9 +6,7 @@ import com.github.intellectualsites.plotsquared.configuration.MemorySection;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration; import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.io.IOException; import java.io.IOException;
@ -24,10 +22,9 @@ import java.util.Objects;
// loaded during startup unfortunately. // loaded during startup unfortunately.
PlotSquared.get().setupConfigs(); PlotSquared.get().setupConfigs();
C.load(PlotSquared.get().translationFile); C.load(PlotSquared.get().translationFile);
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() { PlotSquared.get().forEachPlotArea(area -> {
@Override public void run(PlotArea area) { ConfigurationSection worldSection =
ConfigurationSection worldSection = PlotSquared.get().worlds PlotSquared.get().worlds.getConfigurationSection("worlds." + area.worldname);
.getConfigurationSection("worlds." + area.worldname);
if (worldSection == null) { if (worldSection == null) {
return; return;
} }
@ -71,7 +68,6 @@ import java.util.Objects;
} }
area.loadDefaultConfiguration(clone); area.loadDefaultConfiguration(clone);
} }
}
}); });
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile); PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
MainUtil.sendMessage(player, C.RELOADED_CONFIGS); MainUtil.sendMessage(player, C.RELOADED_CONFIGS);

View File

@ -61,9 +61,8 @@ import java.util.UUID;
checkTrue(!uuids.isEmpty(), null); checkTrue(!uuids.isEmpty(), null);
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS); .hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
confirm.run(this, new Runnable() { // Success
@Override // Success confirm.run(this, () -> {
public void run() {
for (UUID uuid : uuids) { for (UUID uuid : uuids) {
if (uuid != DBFunc.EVERYONE) { if (uuid != DBFunc.EVERYONE) {
if (!plot.removeMember(uuid)) { if (!plot.removeMember(uuid)) {
@ -76,7 +75,6 @@ import java.util.UUID;
EventUtil.manager.callTrusted(player, plot, uuid, true); EventUtil.manager.callTrusted(player, plot, uuid, true);
MainUtil.sendMessage(player, C.TRUSTED_ADDED); MainUtil.sendMessage(player, C.TRUSTED_ADDED);
} }
}
}, null); }, null);
} }
} }

View File

@ -1,9 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@ -163,11 +160,9 @@ public final class Flags {
public static void registerFlag(final Flag<?> flag) { public static void registerFlag(final Flag<?> flag) {
final Flag<?> duplicate = flags.put(flag.getName(), flag); final Flag<?> duplicate = flags.put(flag.getName(), flag);
if (duplicate != null) { if (duplicate != null) {
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() { PlotSquared.get().forEachPlotArea(value -> {
@Override public void run(PlotArea value) {
Object remove;
if (value.DEFAULT_FLAGS.containsKey(duplicate)) { if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
remove = value.DEFAULT_FLAGS.remove(duplicate); Object remove = value.DEFAULT_FLAGS.remove(duplicate);
try { try {
if (remove instanceof Collection if (remove instanceof Collection
&& remove.getClass().getMethod("toString").getDeclaringClass() && remove.getClass().getMethod("toString").getDeclaringClass()
@ -181,10 +176,8 @@ public final class Flags {
neverHappens.printStackTrace(); neverHappens.printStackTrace();
} }
} }
}
}); });
PlotSquared.get().foreachPlotRaw(new RunnableVal<Plot>() { PlotSquared.get().forEachPlotRaw(value -> {
@Override public void run(Plot value) {
if (value.getFlags().containsKey(duplicate)) { if (value.getFlags().containsKey(duplicate)) {
Object remove = value.getFlags().remove(duplicate); Object remove = value.getFlags().remove(duplicate);
try { try {
@ -200,7 +193,6 @@ public final class Flags {
neverHappens.printStackTrace(); neverHappens.printStackTrace();
} }
} }
}
}); });
} }
} }

View File

@ -32,6 +32,7 @@ import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
/** /**
* The plot class<br> * The plot class<br>
@ -509,8 +510,7 @@ public class Plot {
* @return is the plot merged or not * @return is the plot merged or not
*/ */
public boolean isMerged() { public boolean isMerged() {
return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings() return IntStream.of(0, 2, 1, 3).anyMatch(i -> getSettings().getMerged(i));
.getMerged(1) || getSettings().getMerged(3);
} }
/** /**

View File

@ -22,6 +22,7 @@ import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
/** /**
* @author Jesse Boyd, Alexander Söderberg * @author Jesse Boyd, Alexander Söderberg
@ -516,12 +517,10 @@ public abstract class PlotArea {
return Collections.emptySet(); return Collections.emptySet();
} }
final HashSet<Plot> myPlots = new HashSet<>(); final HashSet<Plot> myPlots = new HashSet<>();
foreachPlotAbs(new RunnableVal<Plot>() { forEachPlotAbs(value -> {
@Override public void run(Plot value) {
if (uuid.equals(value.owner)) { if (uuid.equals(value.owner)) {
myPlots.add(value); myPlots.add(value);
} }
}
}); });
return myPlots; return myPlots;
} }
@ -664,16 +663,16 @@ public abstract class PlotArea {
return myPlots; return myPlots;
} }
private void foreachPlotAbs(@Nonnull final RunnableVal<Plot> run) { private void forEachPlotAbs(Consumer<Plot> run) {
for (final Entry<PlotId, Plot> entry : this.plots.entrySet()) { for (final Entry<PlotId, Plot> entry : this.plots.entrySet()) {
run.run(entry.getValue()); run.accept(entry.getValue());
} }
} }
public void foreachBasePlot(@Nonnull final RunnableVal<Plot> run) { public void forEachBasePlot(Consumer<Plot> run) {
for (final Plot plot : getPlots()) { for (final Plot plot : getPlots()) {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
run.run(plot); run.accept(plot);
} }
} }
} }

View File

@ -202,8 +202,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
} }
final AtomicInteger count = new AtomicInteger(0); final AtomicInteger count = new AtomicInteger(0);
final UUID uuid = getUUID(); final UUID uuid = getUUID();
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() { PlotSquared.get().forEachPlotArea(value -> {
@Override public void run(PlotArea value) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) { if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
for (Plot plot : value.getPlotsAbs(uuid)) { for (Plot plot : value.getPlotsAbs(uuid)) {
if (!plot.hasFlag(Flags.DONE)) { if (!plot.hasFlag(Flags.DONE)) {
@ -213,7 +212,6 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
} else { } else {
count.addAndGet(value.getPlotsAbs(uuid).size()); count.addAndGet(value.getPlotsAbs(uuid).size());
} }
}
}); });
return count.get(); return count.get();
} }
@ -223,14 +221,12 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
return getClusterCount(getLocation().getWorld()); return getClusterCount(getLocation().getWorld());
} }
final AtomicInteger count = new AtomicInteger(0); final AtomicInteger count = new AtomicInteger(0);
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() { PlotSquared.get().forEachPlotArea(value -> {
@Override public void run(PlotArea value) {
for (PlotCluster cluster : value.getClusters()) { for (PlotCluster cluster : value.getClusters()) {
if (cluster.isOwner(getUUID())) { if (cluster.isOwner(getUUID())) {
count.incrementAndGet(); count.incrementAndGet();
} }
} }
}
}); });
return count.get(); return count.get();
} }
@ -519,11 +515,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/ */
public int getPlayerClusterCount() { public int getPlayerClusterCount() {
final AtomicInteger count = new AtomicInteger(); final AtomicInteger count = new AtomicInteger();
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() { PlotSquared.get().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
@Override public void run(PlotArea value) {
count.addAndGet(value.getClusters().size());
}
});
return count.get(); return count.get();
} }

View File

@ -5,9 +5,7 @@ import java.util.Arrays;
public class ArrayUtil { public class ArrayUtil {
public static final <T> T[] concatAll(T[] first, T[]... rest) { public static final <T> T[] concatAll(T[] first, T[]... rest) {
int totalLength = first.length; int totalLength = first.length;
for (T[] array : rest) { totalLength += Arrays.stream(rest).mapToInt(array -> array.length).sum();
totalLength += array.length;
}
T[] result = Arrays.copyOf(first, totalLength); T[] result = Arrays.copyOf(first, totalLength);
int offset = first.length; int offset = first.length;
for (T[] array : rest) { for (T[] array : rest) {

View File

@ -1,7 +1,10 @@
package com.github.intellectualsites.plotsquared.plot.util; package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
@ -52,15 +55,13 @@ public class UUIDHandler {
public static HashSet<UUID> getAllUUIDS() { public static HashSet<UUID> getAllUUIDS() {
final HashSet<UUID> uuids = new HashSet<>(); final HashSet<UUID> uuids = new HashSet<>();
PlotSquared.get().foreachPlotRaw(new RunnableVal<Plot>() { PlotSquared.get().forEachPlotRaw(plot -> {
@Override public void run(Plot plot) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
uuids.add(plot.owner); uuids.add(plot.owner);
uuids.addAll(plot.getTrusted()); uuids.addAll(plot.getTrusted());
uuids.addAll(plot.getMembers()); uuids.addAll(plot.getMembers());
uuids.addAll(plot.getDenied()); uuids.addAll(plot.getDenied());
} }
}
}); });
return uuids; return uuids;
} }