mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +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.CacheLoader;
|
||||||
import com.google.common.cache.ForwardingLoadingCache;
|
import com.google.common.cache.ForwardingLoadingCache;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class SoftValuesLoadingCache<K, V> extends ForwardingLoadingCache<K, Optional<V>> {
|
public class SoftValuesLoadingCache<K, V> extends ForwardingLoadingCache<K, Optional<V>> {
|
||||||
|
|
||||||
private final LoadingCache<K, Optional<V>> cache;
|
private final LoadingCache<K, Optional<V>> cache;
|
||||||
|
private static final Logger logger = Logger.getLogger(SoftValuesLoadingCache.class);
|
||||||
|
|
||||||
public SoftValuesLoadingCache(CacheLoader<K, Optional<V>> loader) {
|
public SoftValuesLoadingCache(CacheLoader<K, Optional<V>> loader) {
|
||||||
cache = newBuilder().softValues().build(loader);
|
cache = newBuilder().softValues().build(loader);
|
||||||
|
@ -35,8 +37,15 @@ public class SoftValuesLoadingCache<K, V> extends ForwardingLoadingCache<K, Opti
|
||||||
try {
|
try {
|
||||||
return get(key).orElse(null);
|
return get(key).orElse(null);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException 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);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public V peekIfPresent(K key) {
|
public V peekIfPresent(K key) {
|
||||||
|
|
|
@ -1539,6 +1539,10 @@ public class SessionImpl implements Session {
|
||||||
|
|
||||||
private void handleThrowable(Throwable t) {
|
private void handleThrowable(Throwable t) {
|
||||||
logger.fatal("Communication error", 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
|
// Probably this can cause hanging the client under certain circumstances as the disconnect method is synchronized
|
||||||
// so check if it's needed
|
// so check if it's needed
|
||||||
// disconnect(true);
|
// disconnect(true);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
public class ExportJsonGameplayDataTest {
|
public class ExportJsonGameplayDataTest {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ExportJsonGameplayDataTest.class);
|
private static final Logger logger = Logger.getLogger(ExportJsonGameplayDataTest.class);
|
||||||
|
private static final boolean MTGJSON_WRITE_TO_FILES = false;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
|
@ -116,10 +117,10 @@ public class ExportJsonGameplayDataTest {
|
||||||
|
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
|
||||||
|
if (MTGJSON_WRITE_TO_FILES) {
|
||||||
String filePath = System.getProperty("user.dir") + "/json/" + set.getCode() + ".json";
|
String filePath = System.getProperty("user.dir") + "/json/" + set.getCode() + ".json";
|
||||||
File outputFile = new File(filePath);
|
File outputFile = new File(filePath);
|
||||||
final boolean mkdirs = outputFile.getParentFile().mkdirs();
|
final boolean mkdirs = outputFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
try (Writer writer =
|
try (Writer writer =
|
||||||
new BufferedWriter(
|
new BufferedWriter(
|
||||||
new OutputStreamWriter(
|
new OutputStreamWriter(
|
||||||
|
@ -132,6 +133,9 @@ public class ExportJsonGameplayDataTest {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//System.out.println(gson.toJson(res));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.game.permanent.token;
|
package mage.game.permanent.token;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
@ -24,6 +23,8 @@ public final class Wurm1Token extends TokenImpl {
|
||||||
power = new MageInt(3);
|
power = new MageInt(3);
|
||||||
toughness = new MageInt(3);
|
toughness = new MageInt(3);
|
||||||
this.addAbility(DeathtouchAbility.getInstance());
|
this.addAbility(DeathtouchAbility.getInstance());
|
||||||
|
|
||||||
|
setTokenType(1); // for image
|
||||||
}
|
}
|
||||||
|
|
||||||
public Wurm1Token(final Wurm1Token token) {
|
public Wurm1Token(final Wurm1Token token) {
|
||||||
|
|
Loading…
Reference in a new issue