mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Sync old changes
This commit is contained in:
parent
caf1a98759
commit
270ec615af
4 changed files with 35 additions and 17 deletions
|
@ -9,10 +9,12 @@ import com.google.common.base.Function;
|
|||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.ForwardingLoadingCache;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SoftValuesLoadingCache<K, V> extends ForwardingLoadingCache<K, Optional<V>> {
|
||||
|
||||
private final LoadingCache<K, Optional<V>> cache;
|
||||
private static final Logger logger = Logger.getLogger(SoftValuesLoadingCache.class);
|
||||
|
||||
public SoftValuesLoadingCache(CacheLoader<K, Optional<V>> loader) {
|
||||
cache = newBuilder().softValues().build(loader);
|
||||
|
@ -35,7 +37,14 @@ public class SoftValuesLoadingCache<K, V> extends ForwardingLoadingCache<K, Opti
|
|||
try {
|
||||
return get(key).orElse(null);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (e.getCause() instanceof OutOfMemoryError) {
|
||||
logger.warn("Out of memory error: try to increase free memory in launcher options (-xmx param)");
|
||||
return null;
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1539,6 +1539,10 @@ public class SessionImpl implements Session {
|
|||
|
||||
private void handleThrowable(Throwable t) {
|
||||
logger.fatal("Communication error", t);
|
||||
if (t instanceof InterruptedException) {
|
||||
logger.error("Was interrupted", new Throwable());
|
||||
}
|
||||
|
||||
// Probably this can cause hanging the client under certain circumstances as the disconnect method is synchronized
|
||||
// so check if it's needed
|
||||
// disconnect(true);
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
public class ExportJsonGameplayDataTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ExportJsonGameplayDataTest.class);
|
||||
private static final boolean MTGJSON_WRITE_TO_FILES = false;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
|
@ -116,21 +117,24 @@ public class ExportJsonGameplayDataTest {
|
|||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
String filePath = System.getProperty("user.dir") + "/json/" + set.getCode() + ".json";
|
||||
File outputFile = new File(filePath);
|
||||
final boolean mkdirs = outputFile.getParentFile().mkdirs();
|
||||
|
||||
try (Writer writer =
|
||||
new BufferedWriter(
|
||||
new OutputStreamWriter(
|
||||
new FileOutputStream(outputFile, false), StandardCharsets.UTF_8
|
||||
)
|
||||
)
|
||||
) {
|
||||
writer.write(gson.toJson(res));
|
||||
System.out.println("Wrote " + set.getCode() + " to file");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (MTGJSON_WRITE_TO_FILES) {
|
||||
String filePath = System.getProperty("user.dir") + "/json/" + set.getCode() + ".json";
|
||||
File outputFile = new File(filePath);
|
||||
final boolean mkdirs = outputFile.getParentFile().mkdirs();
|
||||
try (Writer writer =
|
||||
new BufferedWriter(
|
||||
new OutputStreamWriter(
|
||||
new FileOutputStream(outputFile, false), StandardCharsets.UTF_8
|
||||
)
|
||||
)
|
||||
) {
|
||||
writer.write(gson.toJson(res));
|
||||
System.out.println("Wrote " + set.getCode() + " to file");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
//System.out.println(gson.toJson(res));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import mage.constants.CardType;
|
||||
|
@ -24,6 +23,8 @@ public final class Wurm1Token extends TokenImpl {
|
|||
power = new MageInt(3);
|
||||
toughness = new MageInt(3);
|
||||
this.addAbility(DeathtouchAbility.getInstance());
|
||||
|
||||
setTokenType(1); // for image
|
||||
}
|
||||
|
||||
public Wurm1Token(final Wurm1Token token) {
|
||||
|
|
Loading…
Reference in a new issue