mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-15 01:08:35 +00:00
Add heightmap web util command
This commit is contained in:
@ -32,6 +32,7 @@ import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.*;
|
||||
import javax.imageio.ImageIO;
|
||||
@ -889,7 +890,7 @@ public class MainUtil {
|
||||
return isInSubDirectory(dir, file.getParentFile());
|
||||
}
|
||||
|
||||
public static void iterateFiles(File directory, RunnableVal<File> task) {
|
||||
public static void iterateFiles(File directory, Consumer<File> task) {
|
||||
if (directory.exists()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (null != files) {
|
||||
@ -897,7 +898,7 @@ public class MainUtil {
|
||||
if (files[i].isDirectory()) {
|
||||
iterateFiles(files[i], task);
|
||||
} else {
|
||||
task.run(files[i]);
|
||||
task.accept(files[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1054,9 +1055,9 @@ public class MainUtil {
|
||||
public static void deleteOlder(File directory, final long timeDiff, boolean printDebug) {
|
||||
final long now = System.currentTimeMillis();
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
iterateFiles(directory, new RunnableVal<File>() {
|
||||
iterateFiles(directory, new Consumer<File>() {
|
||||
@Override
|
||||
public void run(File file) {
|
||||
public void accept(File file) {
|
||||
long age = now - file.lastModified();
|
||||
if (age > timeDiff) {
|
||||
pool.submit(() -> file.delete());
|
||||
|
@ -32,14 +32,14 @@ public class ImageUtil {
|
||||
}
|
||||
int type = (img.getTransparency() == Transparency.OPAQUE) ?
|
||||
BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
|
||||
BufferedImage ret = (BufferedImage)img;
|
||||
BufferedImage ret = img;
|
||||
int w, h;
|
||||
if (higherQuality) {
|
||||
// Use multi-step technique: start with original size, then
|
||||
// scale down in multiple passes with drawImage()
|
||||
// until the target size is reached
|
||||
w = img.getWidth();
|
||||
h = img.getHeight();
|
||||
w = ret.getWidth();
|
||||
h = ret.getHeight();
|
||||
} else {
|
||||
// Use one-step technique: scale directly from original
|
||||
// size to target size with a single drawImage() call
|
||||
@ -53,14 +53,14 @@ public class ImageUtil {
|
||||
if (w < targetWidth) {
|
||||
w = targetWidth;
|
||||
}
|
||||
}
|
||||
} else if (w < targetWidth) w = targetWidth;
|
||||
|
||||
if (higherQuality && h > targetHeight) {
|
||||
h /= 2;
|
||||
if (h < targetHeight) {
|
||||
h = targetHeight;
|
||||
}
|
||||
}
|
||||
} else if (h < targetHeight) h = targetHeight;
|
||||
|
||||
BufferedImage tmp = new BufferedImage(w, h, type);
|
||||
Graphics2D g2 = tmp.createGraphics();
|
||||
|
Reference in New Issue
Block a user