mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Upstream and debugging changes.
This commit is contained in:
@ -86,6 +86,27 @@ public final class Closer implements Closeable {
|
||||
return zipFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link #rethrow(Throwable)} with the given exception, but before throwing the exception,
|
||||
* also close this Closer. Exceptions from closing are added to {@code t} as suppressed
|
||||
* exceptions.
|
||||
*
|
||||
* @param t the throwable that should be re-thrown
|
||||
* @throws IOException if {@code t} is an IOException, or one occurs
|
||||
*/
|
||||
public RuntimeException rethrowAndClose(Throwable t) throws IOException {
|
||||
// bit of a hack here
|
||||
try {
|
||||
throw rethrow(t);
|
||||
} finally {
|
||||
try {
|
||||
close();
|
||||
} catch (Throwable closeThrown) {
|
||||
t.addSuppressed(closeThrown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given throwable and rethrows it. It will be rethrown as is if it is an
|
||||
* {@code IOException}, {@code RuntimeException} or {@code Error}. Otherwise, it will be rethrown
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.util.translation;
|
||||
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -26,7 +29,6 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer;
|
||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -76,8 +78,10 @@ public class TranslationManager {
|
||||
}
|
||||
|
||||
private Map<String, String> filterTranslations(Map<String, String> translations) {
|
||||
translations.entrySet().removeIf(entry -> entry.getValue().isEmpty());
|
||||
return translations;
|
||||
return translations.entrySet().stream()
|
||||
.filter(e -> !e.getValue().isEmpty())
|
||||
.map(e -> Maps.immutableEntry(e.getKey(), e.getValue().replace("'", "''")))
|
||||
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
|
||||
private Map<String, String> parseTranslationFile(InputStream inputStream) {
|
||||
@ -156,4 +160,4 @@ public class TranslationManager {
|
||||
public Locale getDefaultLocale() {
|
||||
return defaultLocale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user