mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-01 13:14:43 +02:00
@ -26,7 +26,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -299,6 +299,26 @@ public class MainUtil {
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
public static <T> void objectTask(Collection<T> objects, final RunnableVal<T> task, final Runnable whenDone) {
|
||||
final Iterator<T> iter = objects.iterator();
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long start = System.currentTimeMillis();
|
||||
boolean hasNext;
|
||||
while ((hasNext = iter.hasNext()) && System.currentTimeMillis() - start < 5) {
|
||||
task.value = iter.next();
|
||||
task.run();
|
||||
}
|
||||
if (!hasNext) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
} else {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void plotTask(Plot plot, RunnableVal<Plot> run) {
|
||||
if (!plot.isMerged()) {
|
||||
@ -723,7 +743,7 @@ public class MainUtil {
|
||||
BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc));
|
||||
}
|
||||
|
||||
public static void update(final Plot plot) {
|
||||
public static void update(final Plot plot) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -2098,6 +2118,7 @@ public class MainUtil {
|
||||
|
||||
/**
|
||||
* @deprecated raw access is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static HashSet<Plot> connected_cache;
|
||||
public static HashSet<RegionWrapper> regions_cache;
|
||||
|
@ -6,6 +6,7 @@ import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class StringMan {
|
||||
public static String replaceFromMap(final String string, final Map<String, String> replacements) {
|
||||
@ -29,6 +30,16 @@ public class StringMan {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static int intersection(Set<String> options, String[] toCheck) {
|
||||
int count = 0;
|
||||
for (String check : toCheck) {
|
||||
if (options.contains(check)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String getString(final Object obj) {
|
||||
if (obj == null) {
|
||||
return "null";
|
||||
|
Reference in New Issue
Block a user