mirror of
https://github.com/xoo0524tw/OpenArcadeGames.git
synced 2026-12-06 02:46:01 +02:00
Consolidate engine and games into common module and unify platform APIs
This commit is contained in:
1 parent
76ac0e3acd
commit
fbed884ad9
1353 files changed
+44571
-59600
No files matched your search
@@ -20,73 +20,73 @@ public final class SharedCompression {
|
||||
private SharedCompression() {
|
||||
}
|
||||
|
||||
public static byte[] a(String var0) {
|
||||
ByteArrayOutputStream var1 = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream var2 = new GZIPOutputStream(var1)) {
|
||||
var2.write(var0.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException var7) {
|
||||
public static byte[] a(String text) {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream var2 = new GZIPOutputStream(byteArrayOutputStream)) {
|
||||
var2.write(text.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
return var1.toByteArray();
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
|
||||
public static String a(byte[] var0) {
|
||||
ByteArrayInputStream var1 = new ByteArrayInputStream(var0);
|
||||
try (GZIPInputStream var2 = new GZIPInputStream(var1)) {
|
||||
StringBuilder var3 = new StringBuilder();
|
||||
InputStreamReader var4 = new InputStreamReader(var2, StandardCharsets.UTF_8);
|
||||
char[] var5 = new char[1024];
|
||||
public static String a(byte[] byteVals) {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteVals);
|
||||
try (GZIPInputStream var2 = new GZIPInputStream(byteArrayInputStream)) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(var2, StandardCharsets.UTF_8);
|
||||
char[] chs = new char[1024];
|
||||
while (true) {
|
||||
int var6 = var4.read(var5);
|
||||
if (var6 == -1) {
|
||||
return var3.toString();
|
||||
int index = inputStreamReader.read(chs);
|
||||
if (index == -1) {
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
var3.append(var5, 0, var6);
|
||||
stringBuilder.append(chs, 0, index);
|
||||
}
|
||||
} catch (IOException var9) {
|
||||
} catch (IOException ex) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T a(Gson var0, byte[] var1, Class<T> var2) {
|
||||
ByteArrayInputStream var3 = new ByteArrayInputStream(var1);
|
||||
try (GZIPInputStream var4 = new GZIPInputStream(var3)) {
|
||||
return (T) var0.fromJson(new InputStreamReader(var4, StandardCharsets.UTF_8), var2);
|
||||
} catch (IOException var9) {
|
||||
public static <T> T a(Gson gson, byte[] byteVals, Class<T> clazz) {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteVals);
|
||||
try (GZIPInputStream var4 = new GZIPInputStream(byteArrayInputStream)) {
|
||||
return (T) gson.fromJson(new InputStreamReader(var4, StandardCharsets.UTF_8), clazz);
|
||||
} catch (IOException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] a(ConfigManager var0, GameTemplate<?> var1) throws IOException {
|
||||
ByteArrayOutputStream var2 = new ByteArrayOutputStream();
|
||||
public static byte[] a(ConfigManager configManager, GameTemplate<?> gameTemplate) throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
byte[] var3 = a(re$saveToString(var0, var1.b()));
|
||||
var2.write(ByteBuffer.allocate(4).putInt(var3.length).array());
|
||||
var2.write(var3);
|
||||
} catch (InvalidConfigException var4) {
|
||||
throw new IOException("Error saving template: " + var4.getMessage(), var4);
|
||||
byte[] byteVals = a(re$saveToString(configManager, gameTemplate.getMap()));
|
||||
byteArrayOutputStream.write(ByteBuffer.allocate(4).putInt(byteVals.length).array());
|
||||
byteArrayOutputStream.write(byteVals);
|
||||
} catch (InvalidConfigException ex) {
|
||||
throw new IOException("Error saving template: " + ex.getMessage(), ex);
|
||||
}
|
||||
var2.write(ByteBuffer.allocate(4).putInt(var1.c().length).array());
|
||||
var2.write(var1.c());
|
||||
return var2.toByteArray();
|
||||
byteArrayOutputStream.write(ByteBuffer.allocate(4).putInt(gameTemplate.c().length).array());
|
||||
byteArrayOutputStream.write(gameTemplate.c());
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
|
||||
public static void a(ConfigManager var0, byte[] var1, GameTemplate<?> var2) throws IOException {
|
||||
ByteArrayInputStream var3 = new ByteArrayInputStream(var1);
|
||||
public static void a(ConfigManager configManager, byte[] byteVals, GameTemplate<?> gameTemplate) throws IOException {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteVals);
|
||||
try {
|
||||
int var4 = ByteBuffer.wrap(var3.readNBytes(4)).getInt();
|
||||
re$loadFromString(var0, var2.b(), a(var3.readNBytes(var4)));
|
||||
} catch (InvalidConfigException var5) {
|
||||
throw new IOException("Error loading template: " + var5.getMessage(), var5);
|
||||
int index = ByteBuffer.wrap(byteArrayInputStream.readNBytes(4)).getInt();
|
||||
re$loadFromString(configManager, gameTemplate.getMap(), a(byteArrayInputStream.readNBytes(index)));
|
||||
} catch (InvalidConfigException ex) {
|
||||
throw new IOException("Error loading template: " + ex.getMessage(), ex);
|
||||
}
|
||||
int var6 = ByteBuffer.wrap(var3.readNBytes(4)).getInt();
|
||||
var2.a(var3.readNBytes(var6));
|
||||
int index2 = ByteBuffer.wrap(byteArrayInputStream.readNBytes(4)).getInt();
|
||||
gameTemplate.a(byteArrayInputStream.readNBytes(index2));
|
||||
}
|
||||
|
||||
private static String re$saveToString(ConfigManager var0, ro.fr33styler.arcade.api.engine.config.serialize.Configuration var1) throws InvalidConfigException {
|
||||
return var0.saveToString(var1);
|
||||
private static String re$saveToString(ConfigManager configManager, ro.fr33styler.arcade.api.engine.config.serialize.Configuration configuration) throws InvalidConfigException {
|
||||
return configManager.saveToString(configuration);
|
||||
}
|
||||
|
||||
private static void re$loadFromString(ConfigManager var0, ro.fr33styler.arcade.api.engine.config.serialize.Configuration var1, String var2) throws InvalidConfigException {
|
||||
var0.loadFromString(var1, var2);
|
||||
private static void re$loadFromString(ConfigManager configManager, ro.fr33styler.arcade.api.engine.config.serialize.Configuration configuration, String text) throws InvalidConfigException {
|
||||
configManager.loadFromString(configuration, text);
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -6,9 +6,9 @@ import java.lang.reflect.Method;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ClassPatternMatcher {
|
||||
public static boolean a(Class<?> var0, Predicate<Method> var1) {
|
||||
for (Method var5 : var0.getDeclaredMethods()) {
|
||||
if (var1.test(var5)) {
|
||||
public static boolean a(Class<?> clazz, Predicate<Method> predicate) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (predicate.test(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -16,26 +16,26 @@ public class ClassPatternMatcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean a(InputStream var0, int[] var1) {
|
||||
public static boolean a(InputStream inputStream, int[] indexs) {
|
||||
try {
|
||||
int var2 = 0;
|
||||
int index = 0;
|
||||
|
||||
int var3;
|
||||
while ((var3 = var0.read()) != -1) {
|
||||
if (var2 >= var1.length - 1) {
|
||||
int index2;
|
||||
while ((index2 = inputStream.read()) != -1) {
|
||||
if (index >= indexs.length - 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (var1[var2] == var3) {
|
||||
var2++;
|
||||
if (indexs[index] == index2) {
|
||||
index++;
|
||||
} else {
|
||||
var2 = 0;
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (IOException var4) {
|
||||
var4.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -4,37 +4,37 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ClassResourceReader {
|
||||
public static String a(Class<?> var0) {
|
||||
return var0.getCanonicalName().replace('.', '/') + ".class";
|
||||
public static String a(Class<?> clazz) {
|
||||
return clazz.getCanonicalName().replace('.', '/') + ".class";
|
||||
}
|
||||
|
||||
public static int a(InputStream var0) {
|
||||
public static int a(InputStream inputStream) {
|
||||
try {
|
||||
return b(var0);
|
||||
} catch (IOException var2) {
|
||||
var2.printStackTrace();
|
||||
return b(inputStream);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static int b(InputStream var0) throws IOException {
|
||||
int var1 = 0;
|
||||
boolean var2 = false;
|
||||
private static int b(InputStream inputStream) throws IOException {
|
||||
int index = 0;
|
||||
boolean flag = false;
|
||||
|
||||
int var3;
|
||||
while ((var3 = var0.read()) != -1) {
|
||||
if (var3 == 45) {
|
||||
var2 = true;
|
||||
int index2;
|
||||
while ((index2 = inputStream.read()) != -1) {
|
||||
if (index2 == 45) {
|
||||
flag = true;
|
||||
} else {
|
||||
if (!Character.isDigit(var3)) {
|
||||
if (!Character.isDigit(index2)) {
|
||||
break;
|
||||
}
|
||||
|
||||
var1 *= 10;
|
||||
var1 += Character.getNumericValue(var3);
|
||||
index *= 10;
|
||||
index += Character.getNumericValue(index2);
|
||||
}
|
||||
}
|
||||
|
||||
return var2 ? -var1 : var1;
|
||||
return flag ? -index : index;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ public class LeakMarkerProbe {
|
||||
private static boolean b;
|
||||
private static final int[] c = new int[]{76, 101, 97, 107};
|
||||
|
||||
public static boolean a(Plugin var0) {
|
||||
public static boolean a(Plugin plugin) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -6,10 +6,10 @@ public class MethodSuffixProbe {
|
||||
private static boolean a;
|
||||
private static boolean b;
|
||||
|
||||
public static boolean a(Class<?> var0) {
|
||||
public static boolean a(Class<?> clazz) {
|
||||
if (!b) {
|
||||
b = true;
|
||||
a = ClassPatternMatcher.a(var0, var0x -> var0x.getName().endsWith("g0"));
|
||||
a = ClassPatternMatcher.a(clazz, method -> method.getName().endsWith("g0"));
|
||||
}
|
||||
|
||||
return a;
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package ro.fr33styler.arcade.internal.compatibility.marker;
|
||||
|
||||
import ro.fr33styler.arcade.engine.support.EngineUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class RemoteMarkerRegistry {
|
||||
private static boolean a;
|
||||
private static Set<String> set;
|
||||
|
||||
public static Set<String> getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
private static Set<String> a(InputStream inputStream) {
|
||||
HashSet set2 = new HashSet();
|
||||
Scanner scanner = new Scanner(inputStream);
|
||||
|
||||
while (scanner.hasNextLine()) {
|
||||
set2.add(scanner.nextLine());
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
return set2;
|
||||
}
|
||||
|
||||
private static void b(String text, String text2, String text3) {
|
||||
InputStream inputStream = EngineUtils.a(text, text2, text3, 5000);
|
||||
if (inputStream != null) {
|
||||
set = a(inputStream);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(String text, String text2, String text3) {
|
||||
if (!a) {
|
||||
a = true;
|
||||
CompletableFuture.runAsync(() -> b(text, text2, text3));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class UserNonceMarkerProbe {
|
||||
private static final int[] c = new int[]{117, 115, 101, 114, 95, 105, 100, 61};
|
||||
private static final int[] d = new int[]{110, 111, 110, 99, 101, 61};
|
||||
|
||||
public static boolean a(Plugin var0) {
|
||||
public static boolean a(Plugin plugin) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ public class VendorMarkerProbe {
|
||||
private static final int[] e = new int[]{117, 115, 101, 114, 95, 105, 100, 61};
|
||||
private static final int[] f = new int[]{110, 111, 110, 99, 101, 61};
|
||||
|
||||
public static boolean a(Plugin var0) {
|
||||
public static boolean a(Plugin plugin) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+26
-26
@@ -16,57 +16,57 @@ public final class SharedEngineOperations {
|
||||
private SharedEngineOperations() {
|
||||
}
|
||||
|
||||
public static void sleepQuietly(long var0) {
|
||||
public static void sleepQuietly(long longVal) {
|
||||
try {
|
||||
Thread.sleep(var0);
|
||||
} catch (InterruptedException var3) {
|
||||
Thread.sleep(longVal);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeQuietly(Closeable var0) {
|
||||
public static void closeQuietly(Closeable closeable) {
|
||||
try {
|
||||
var0.close();
|
||||
} catch (IOException var2) {
|
||||
closeable.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T orElse(T var0, T var1) {
|
||||
return (T) (var0 == null ? var1 : var0);
|
||||
public static <T> T orElse(T obj, T obj2) {
|
||||
return (T) (obj == null ? obj2 : obj);
|
||||
}
|
||||
|
||||
public static void swap(Object[] var0, int var1, int var2) {
|
||||
Object var3 = var0[var1];
|
||||
var0[var1] = var0[var2];
|
||||
var0[var2] = var3;
|
||||
public static void swap(Object[] objs, int index, int index2) {
|
||||
Object obj = objs[index];
|
||||
objs[index] = objs[index2];
|
||||
objs[index2] = obj;
|
||||
}
|
||||
|
||||
public static float snapYaw(float var0) {
|
||||
if ((!(var0 > 135.0F) || !(var0 <= 180.0F)) && !(var0 < -135.0F)) {
|
||||
if (var0 >= -135.0F && var0 <= -45.0F) {
|
||||
public static float snapYaw(float floatVal) {
|
||||
if ((!(floatVal > 135.0F) || !(floatVal <= 180.0F)) && !(floatVal < -135.0F)) {
|
||||
if (floatVal >= -135.0F && floatVal <= -45.0F) {
|
||||
return -90.0F;
|
||||
} else {
|
||||
return var0 < 135.0F && var0 >= 45.0F ? 90.0F : 0.0F;
|
||||
return floatVal < 135.0F && floatVal >= 45.0F ? 90.0F : 0.0F;
|
||||
}
|
||||
} else {
|
||||
return 180.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLeftClick(Action var0) {
|
||||
return var0 == Action.LEFT_CLICK_AIR || var0 == Action.LEFT_CLICK_BLOCK;
|
||||
public static boolean isLeftClick(Action action) {
|
||||
return action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK;
|
||||
}
|
||||
|
||||
public static boolean isRightClick(Action var0) {
|
||||
return var0 == Action.RIGHT_CLICK_AIR || var0 == Action.RIGHT_CLICK_BLOCK;
|
||||
public static boolean isRightClick(Action action) {
|
||||
return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
|
||||
}
|
||||
|
||||
public static InputStream openStream(String var0, String var1, String var2, int var3) {
|
||||
public static InputStream openStream(String text, String text2, String text3, int index) {
|
||||
try {
|
||||
URLConnection var4 = new URI(var0, var1, var2, null).toURL().openConnection();
|
||||
var4.setConnectTimeout(1000);
|
||||
var4.setReadTimeout(var3);
|
||||
return var4.getInputStream();
|
||||
} catch (URISyntaxException | IOException var5) {
|
||||
URLConnection uRLConnection = new URI(text, text2, text3, null).toURL().openConnection();
|
||||
uRLConnection.setConnectTimeout(1000);
|
||||
uRLConnection.setReadTimeout(index);
|
||||
return uRLConnection.getInputStream();
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user