From f2602c71db899b86d38900ba051072719f1b74fb Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Sun, 12 Jul 2020 13:10:36 +0200 Subject: [PATCH 01/56] update dependency versions in extensions --- Extensions/AdminOnConnect/pom.xml | 2 +- Extensions/BlockReplacePackets/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Extensions/AdminOnConnect/pom.xml b/Extensions/AdminOnConnect/pom.xml index f7bf8a0..d1fda28 100644 --- a/Extensions/AdminOnConnect/pom.xml +++ b/Extensions/AdminOnConnect/pom.xml @@ -106,7 +106,7 @@ G-Earth G-Earth - 1.0 + 1.1 diff --git a/Extensions/BlockReplacePackets/pom.xml b/Extensions/BlockReplacePackets/pom.xml index 813592d..f374398 100644 --- a/Extensions/BlockReplacePackets/pom.xml +++ b/Extensions/BlockReplacePackets/pom.xml @@ -106,7 +106,7 @@ G-Earth G-Earth - 1.0 + 1.1 From e6a74aa971c5e9c434f7ab4d9907a64645fbf237 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 15 Jul 2020 20:28:52 +0200 Subject: [PATCH 02/56] initialize everything HEntityUpdate --- .../java/gearth/extensions/parsers/HEntityUpdate.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/HEntityUpdate.java b/G-Earth/src/main/java/gearth/extensions/parsers/HEntityUpdate.java index 3aab58a..56d28f7 100644 --- a/G-Earth/src/main/java/gearth/extensions/parsers/HEntityUpdate.java +++ b/G-Earth/src/main/java/gearth/extensions/parsers/HEntityUpdate.java @@ -4,14 +4,14 @@ import gearth.protocol.HPacket; public class HEntityUpdate { private int index; - private boolean isController; + private boolean isController = false; private HPoint tile; - private HPoint movingTo; + private HPoint movingTo = null; - private HSign sign; - private HStance stance; - private HAction action; + private HSign sign = null; + private HStance stance = null; + private HAction action = null; private HDirection headFacing; private HDirection bodyFacing; From 3d59ccbab4ea4dc2cba0e95129d68440ebd9982a Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:05:51 +0200 Subject: [PATCH 03/56] expose primaryStage in ExtensionForm --- G-Earth/src/main/java/gearth/extensions/ExtensionForm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java b/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java index 983ba74..145733c 100644 --- a/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java +++ b/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java @@ -11,7 +11,7 @@ import gearth.protocol.HPacket; public abstract class ExtensionForm implements IExtension { volatile Extension extension; - volatile Stage primaryStage; + protected volatile Stage primaryStage; protected static void runExtensionForm(String[] args, Class extension) { ExtensionFormLauncher launcher = new ExtensionFormLauncher(); From cde38f5f0df1d621c6d8edc46776a6141f2b9a50 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:27:01 +0200 Subject: [PATCH 04/56] HPacket charset argument for string utils (incomplete) --- .../PacketStringUtils.java | 2 +- .../main/java/gearth/protocol/HPacket.java | 80 +++++++++++++------ 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/G-Earth/src/main/java/gearth/misc/packetrepresentation/PacketStringUtils.java b/G-Earth/src/main/java/gearth/misc/packetrepresentation/PacketStringUtils.java index 7814fc3..bbe89cf 100644 --- a/G-Earth/src/main/java/gearth/misc/packetrepresentation/PacketStringUtils.java +++ b/G-Earth/src/main/java/gearth/misc/packetrepresentation/PacketStringUtils.java @@ -196,7 +196,7 @@ public class PacketStringUtils { } else if (c == 'i') builder.append("{i:").append(prevInt = p.readInteger()).append('}'); else if (c == 's') builder.append("{s:\"").append( - new String(p.readString().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8) + p.readString(StandardCharsets.UTF_8) .replace("\\", "\\\\") // \ -> \\ .replace("\"", "\\\"") // " -> \" .replace("\r", "\\r") // CR -> \r diff --git a/G-Earth/src/main/java/gearth/protocol/HPacket.java b/G-Earth/src/main/java/gearth/protocol/HPacket.java index 1cde853..5412bd1 100644 --- a/G-Earth/src/main/java/gearth/protocol/HPacket.java +++ b/G-Earth/src/main/java/gearth/protocol/HPacket.java @@ -8,6 +8,7 @@ import gearth.misc.packetrepresentation.PacketStringUtils; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.security.InvalidParameterException; import java.util.Arrays; @@ -180,34 +181,49 @@ public class HPacket implements StringifyAble { return java.nio.ByteBuffer.wrap(btarray).getLong(); } - public String readString() { - String r = readString(readIndex); - readIndex += (2 + r.length()); + + public String readString(Charset charset) { + String r = readString(readIndex, charset); + readIndex += (2 + readUshort(readIndex)); return r; } - public String readString(int index) { + public String readString(int index, Charset charset) { int length = readUshort(index); index+=2; - - return readString(index, length); + return readString(index, length, charset); } - private String readString(int index, int length) { + public String readString() { + return readString(StandardCharsets.ISO_8859_1); + } + public String readString(int index) { + return readString(index, StandardCharsets.ISO_8859_1); + } + + private String readString(int index, int length, Charset charset) { byte[] x = new byte[length]; for (int i = 0; i < x.length; i++) { x[i] = readByte(index); index++; } - return new String(x, StandardCharsets.ISO_8859_1); + return new String(x, charset); } - public String readLongString() { - String r = readLongString(readIndex); - readIndex += (4 + r.length()); + + public String readLongString(Charset charset) { + String r = readLongString(readIndex, charset); + readIndex += (4 + readInteger(readIndex)); return r; } - public String readLongString(int index) { + public String readLongString(int index, Charset charset) { int length = readInteger(index); index += 4; - return readString(index, length); + return readString(index, length, charset); + } + + public String readLongString() { + return readLongString(StandardCharsets.ISO_8859_1); + } + public String readLongString(int index) { + return readLongString(index, StandardCharsets.ISO_8859_1); } public boolean readBoolean() { @@ -267,10 +283,11 @@ public class HPacket implements StringifyAble { packetInBytes[index + 1] = b.array()[1]; return this; } - public HPacket replaceString(int index, String s) { + + public HPacket replaceString(int index, String s, Charset charset) { isEdited = true; - byte[] sbytes = s.getBytes(StandardCharsets.ISO_8859_1); - int mover = s.length() - readUshort(index); + byte[] sbytes = s.getBytes(charset); + int mover = sbytes.length - readUshort(index); if (mover != 0) { byte[] newPacket = Arrays.copyOf(packetInBytes, packetInBytes.length + mover); @@ -283,7 +300,7 @@ public class HPacket implements StringifyAble { } } else { - int i = index + 2 + s.length(); + int i = index + 2 + sbytes.length; while (i < newPacket.length) { newPacket[i] = packetInBytes[i - mover]; i++; @@ -294,13 +311,17 @@ public class HPacket implements StringifyAble { fixLength(); } - replaceUShort(index, s.length()); - for (int i = 0; i < s.length(); i++) { + replaceUShort(index, sbytes.length); + for (int i = 0; i < sbytes.length; i++) { packetInBytes[index + 2 + i] = sbytes[i]; } return this; } + public HPacket replaceString(int index, String s) { + return replaceString(index, s, StandardCharsets.ISO_8859_1); + } + private boolean canReadString(int index) { if (index < packetInBytes.length - 1) { int l = readUshort(index); @@ -445,18 +466,27 @@ public class HPacket implements StringifyAble { fixLength(); return this; } + public HPacket appendString(String s, Charset charset) { + isEdited = true; + appendUShort(s.getBytes(charset).length); + appendBytes(s.getBytes(charset)); + return this; + } public HPacket appendString(String s) { + return appendString(s, StandardCharsets.ISO_8859_1); + } + + public HPacket appendLongString(String s, Charset charset) { isEdited = true; - appendUShort(s.length()); - appendBytes(s.getBytes(StandardCharsets.ISO_8859_1)); + appendInt(s.getBytes(charset).length); + appendBytes(s.getBytes(charset)); return this; } + public HPacket appendLongString(String s) { - isEdited = true; - appendInt(s.length()); - appendBytes(s.getBytes(StandardCharsets.ISO_8859_1)); - return this; + return appendLongString(s, StandardCharsets.ISO_8859_1); } + public HPacket appendObject(Object o) throws InvalidParameterException { isEdited = true; From 17dc388668d7bc243abfdaf0fd7eb734b5e747bb Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:33:59 +0200 Subject: [PATCH 05/56] sng link -> allseeingeye --- .../src/main/java/gearth/ui/info/InfoController.java | 10 +++++----- G-Earth/src/main/resources/gearth/ui/info/Info.fxml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/G-Earth/src/main/java/gearth/ui/info/InfoController.java b/G-Earth/src/main/java/gearth/ui/info/InfoController.java index 7d06c2b..1472e70 100644 --- a/G-Earth/src/main/java/gearth/ui/info/InfoController.java +++ b/G-Earth/src/main/java/gearth/ui/info/InfoController.java @@ -14,7 +14,7 @@ import javafx.scene.image.ImageView; */ public class InfoController extends SubForm { public ImageView img_logo; - public Hyperlink link_sng; + public Hyperlink link_ase; public Hyperlink link_darkbox; public Hyperlink link_d_harble; public Hyperlink link_g_gearth; @@ -38,16 +38,16 @@ public class InfoController extends SubForm { img_logo.setImage(new Image("/gearth/G-EarthLogo.png")); - link_sng.setTooltip(new Tooltip("https://www.sngforum.info")); + link_ase.setTooltip(new Tooltip("https://allseeingeye.to")); link_darkbox.setTooltip(new Tooltip("https://darkbox.nl")); + link_d_harble.setTooltip(new Tooltip("https://discord.gg/CzRuHvW")); link_g_gearth.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth")); link_g_tanji.setTooltip(new Tooltip("https://github.com/ArachisH/Tanji")); - link_d_harble.setTooltip(new Tooltip("https://discord.gg/CzRuHvW")); + activateHyperlink(link_ase); + activateHyperlink(link_darkbox); activateHyperlink(link_d_harble); activateHyperlink(link_g_gearth); activateHyperlink(link_g_tanji); - activateHyperlink(link_sng); - activateHyperlink(link_darkbox); } } diff --git a/G-Earth/src/main/resources/gearth/ui/info/Info.fxml b/G-Earth/src/main/resources/gearth/ui/info/Info.fxml index d54b951..d1e7256 100644 --- a/G-Earth/src/main/resources/gearth/ui/info/Info.fxml +++ b/G-Earth/src/main/resources/gearth/ui/info/Info.fxml @@ -65,12 +65,12 @@ - - + + From 1d1831cc94adc712776f890fdba51df13b78e24c Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Sat, 3 Oct 2020 21:56:26 +0200 Subject: [PATCH 07/56] Expose packet<->string functionality to (network) extension interface preparation for python extensions --- .../extensionhandler/ExtensionHandler.java | 21 +++++++++++++++++ .../extensions/ExtensionListener.java | 3 +++ .../extensions/GEarthExtension.java | 17 ++++++++++++++ .../network/NetworkExtension.java | 23 +++++++++++++++++++ .../network/NetworkExtensionInfo.java | 7 ++++++ .../simple/ExampleExtension.java | 15 ++++++++++++ 6 files changed, 86 insertions(+) diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java b/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java index 4296bb7..575f93c 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java @@ -212,6 +212,27 @@ public class ExtensionHandler { protected void manipulatedPacket(HMessage hMessage) { onExtensionRespond(extension, hMessage); } + + @Override + protected void packetToStringRequest(HPacket packet) { + String s = ""; + String expression = "s"; + try { + s = packet.toString(); + if (packet.length() > 3000) { + expression = packet.toExpression(); + } + } + finally { + extension.packetToStringResponse(s, expression); + } + } + + @Override + protected void stringToPacketRequest(String string) { + HPacket packet = new HPacket(string); + extension.stringToPacketResponse(packet); + } }; extension.getExtensionObservable().addListener(listener); diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/ExtensionListener.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/ExtensionListener.java index f7120ca..080c7c9 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/ExtensionListener.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/ExtensionListener.java @@ -12,4 +12,7 @@ public abstract class ExtensionListener { protected void log(String text) {} protected void hasClosed() {} + protected void packetToStringRequest(HPacket packet) {} + protected void stringToPacketRequest(String string) {} + } diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/GEarthExtension.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/GEarthExtension.java index c38e428..61bfc32 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/GEarthExtension.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/GEarthExtension.java @@ -8,6 +8,8 @@ import gearth.services.extensionhandler.extensions.listeners.OmRemoveClickListen import gearth.services.extensionhandler.extensions.listeners.OnClickListener; import gearth.services.extensionhandler.extensions.listeners.OnDeleteListener; +import java.util.function.Consumer; + public abstract class GEarthExtension { @@ -40,6 +42,8 @@ public abstract class GEarthExtension { public abstract void connectionEnd(); public abstract void init(); public abstract void close(); + public abstract void packetToStringResponse(String string, String expression); + public abstract void stringToPacketResponse(HPacket packet); // --------------------------------------------------------------- @@ -78,6 +82,19 @@ public abstract class GEarthExtension { protected void hasClosed() { extensionObservable.fireEvent(ExtensionListener::hasClosed); } + + protected void packetToStringRequest(HPacket packet) { + int orgIndex = packet.getReadIndex(); + extensionObservable.fireEvent(listener -> { + packet.setReadIndex(6); + listener.packetToStringRequest(packet); + }); + packet.setReadIndex(orgIndex); + } + protected void stringToPacketRequest(String string) { + extensionObservable.fireEvent(l -> l.stringToPacketRequest(string)); + } + // -------------------------------------------------------------------- diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java index f40b790..2539d1c 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java @@ -88,6 +88,14 @@ public class NetworkExtension extends GEarthExtension { else if (message.headerId() == NetworkExtensionInfo.INCOMING_MESSAGES_IDS.EXTENSIONCONSOLELOG) { log(message.readString()); } + else if (message.headerId() == NetworkExtensionInfo.INCOMING_MESSAGES_IDS.PACKETTOSTRING_REQUEST) { + HPacket p = new HPacket(new byte[0]); + p.constructFromString(message.readLongString()); + packetToStringRequest(p); + } + else if (message.headerId() == NetworkExtensionInfo.INCOMING_MESSAGES_IDS.STRINGTOPACKET_REQUEST) { + stringToPacketRequest(message.readLongString()); + } } @@ -211,4 +219,19 @@ public class NetworkExtension extends GEarthExtension { connection.close(); } catch (IOException ignored) { } } + + @Override + public void packetToStringResponse(String string, String expression) { + HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.PACKETTOSTRING_RESPONSE); + packet.appendLongString(string); + packet.appendLongString(expression); + sendMessage(packet); + } + + @Override + public void stringToPacketResponse(HPacket packetFromString) { + HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.STRINGTOPACKET_RESPONSE); + packet.appendLongString(packet.stringify()); + sendMessage(packet); + } } \ No newline at end of file diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtensionInfo.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtensionInfo.java index 17d9f2e..9ea10e1 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtensionInfo.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtensionInfo.java @@ -87,6 +87,9 @@ public class NetworkExtensionInfo { public static final int CONNECTIONSTART = 5; public static final int CONNECTIONEND = 6; public static final int INIT = 7; + + public static final int PACKETTOSTRING_RESPONSE = 20; + public static final int STRINGTOPACKET_RESPONSE = 21; } @@ -95,6 +98,10 @@ public class NetworkExtensionInfo { public static final int MANIPULATEDPACKET = 2; public static final int REQUESTFLAGS = 3; public static final int SENDMESSAGE = 4; + + public static final int PACKETTOSTRING_REQUEST = 20; + public static final int STRINGTOPACKET_REQUEST = 21; + public static final int EXTENSIONCONSOLELOG = 98; } diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/simple/ExampleExtension.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/simple/ExampleExtension.java index 98752f2..e04b043 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/simple/ExampleExtension.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/simple/ExampleExtension.java @@ -1,6 +1,7 @@ package gearth.services.extensionhandler.extensions.implementations.simple; import gearth.protocol.HMessage; +import gearth.protocol.HPacket; import gearth.services.extensionhandler.extensions.GEarthExtension; public class ExampleExtension extends GEarthExtension { @@ -105,4 +106,18 @@ public class ExampleExtension extends GEarthExtension { // finish up and call "hasClosed()" hasClosed(); } + + + + + // ignore these + @Override + public void packetToStringResponse(String string, String expression) { + + } + + @Override + public void stringToPacketResponse(HPacket packet) { + + } } From 1f58290393a614e0511b27dbc7bd476b39004575 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Sun, 4 Oct 2020 17:28:18 +0200 Subject: [PATCH 08/56] packet expression things --- .../main/java/gearth/protocol/HPacket.java | 33 +++++++++++++++---- .../network/NetworkExtension.java | 3 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/G-Earth/src/main/java/gearth/protocol/HPacket.java b/G-Earth/src/main/java/gearth/protocol/HPacket.java index 5412bd1..40f05e1 100644 --- a/G-Earth/src/main/java/gearth/protocol/HPacket.java +++ b/G-Earth/src/main/java/gearth/protocol/HPacket.java @@ -537,25 +537,44 @@ public class HPacket implements StringifyAble { isEdited = edited; } - public String toExpression(HMessage.Direction direction) { - if (isCorrupted()) return ""; - + private String getHarbleStructure(HMessage.Direction direction) { HarbleAPI.HarbleMessage msg; if (HarbleAPIFetcher.HARBLEAPI != null && ((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(direction, headerId())) != null)) { - if (msg.getStructure() != null) { - return PacketStringUtils.toExpressionFromGivenStructure(this, msg.getStructure()); + if (msg.getStructure() != null && structureEquals(msg.getStructure())) { + return msg.getStructure(); } } - return toExpression(); + + return null; + } + + public String toExpression(HMessage.Direction direction) { + if (isCorrupted()) return ""; + + String structure = getHarbleStructure(direction); + if (structure != null) { + return PacketStringUtils.toExpressionFromGivenStructure(this, structure); + } + + return PacketStringUtils.predictedExpression(this); } /** * returns "" if not found or not sure enough - * dont hate on the coding quality in this function, its pretty effective. */ public String toExpression() { if (isCorrupted()) return ""; + + String structure1 = getHarbleStructure(HMessage.Direction.TOCLIENT); + String structure2 = getHarbleStructure(HMessage.Direction.TOSERVER); + if (structure1 != null && structure2 == null) { + return PacketStringUtils.toExpressionFromGivenStructure(this, structure1); + } + else if (structure1 == null && structure2 != null) { + return PacketStringUtils.toExpressionFromGivenStructure(this, structure2); + } + return PacketStringUtils.predictedExpression(this); } diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java index 2539d1c..af4600c 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java @@ -8,6 +8,7 @@ import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.net.Socket; +import java.nio.charset.StandardCharsets; /** * Created by Jonas on 21/06/18. @@ -224,7 +225,7 @@ public class NetworkExtension extends GEarthExtension { public void packetToStringResponse(String string, String expression) { HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.PACKETTOSTRING_RESPONSE); packet.appendLongString(string); - packet.appendLongString(expression); + packet.appendLongString(expression, StandardCharsets.UTF_8); sendMessage(packet); } From 17a740657810f16aa875f2e65adf484e73cf1fc4 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Tue, 6 Oct 2020 04:07:49 +0200 Subject: [PATCH 09/56] me dumb --- .../gearth/services/extensionhandler/ExtensionHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java b/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java index 575f93c..a7253ee 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java @@ -216,10 +216,10 @@ public class ExtensionHandler { @Override protected void packetToStringRequest(HPacket packet) { String s = ""; - String expression = "s"; + String expression = ""; try { s = packet.toString(); - if (packet.length() > 3000) { + if (packet.length() < 3000) { expression = packet.toExpression(); } } From b31b3d6526a8ccac589bf231b5f26bbcd913e945 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Tue, 6 Oct 2020 23:03:45 +0200 Subject: [PATCH 10/56] corrections --- .../extensions/implementations/network/NetworkExtension.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java index af4600c..209dc4f 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/extensions/implementations/network/NetworkExtension.java @@ -95,7 +95,7 @@ public class NetworkExtension extends GEarthExtension { packetToStringRequest(p); } else if (message.headerId() == NetworkExtensionInfo.INCOMING_MESSAGES_IDS.STRINGTOPACKET_REQUEST) { - stringToPacketRequest(message.readLongString()); + stringToPacketRequest(message.readLongString(StandardCharsets.UTF_8)); } } @@ -232,7 +232,7 @@ public class NetworkExtension extends GEarthExtension { @Override public void stringToPacketResponse(HPacket packetFromString) { HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.STRINGTOPACKET_RESPONSE); - packet.appendLongString(packet.stringify()); + packet.appendLongString(packetFromString.stringify()); sendMessage(packet); } } \ No newline at end of file From cb32a9b44247e8e472cfc0ee2875448d917a57de Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 7 Oct 2020 00:05:09 +0200 Subject: [PATCH 11/56] when you don't test irrelevant code --- G-Earth/src/main/java/gearth/extensions/Extension.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/G-Earth/src/main/java/gearth/extensions/Extension.java b/G-Earth/src/main/java/gearth/extensions/Extension.java index 5078c47..89d668f 100644 --- a/G-Earth/src/main/java/gearth/extensions/Extension.java +++ b/G-Earth/src/main/java/gearth/extensions/Extension.java @@ -298,7 +298,13 @@ public abstract class Extension implements IExtension { public boolean requestFlags(FlagsCheckListener flagRequestCallback) { if (this.flagRequestCallback != null) return false; this.flagRequestCallback = flagRequestCallback; - return true; + try { + writeToStream(new HPacket(NetworkExtensionInfo.INCOMING_MESSAGES_IDS.REQUESTFLAGS).toBytes()); + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } } From bf521458a871826fc8cf4bc79df1b3d4cfa15607 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Sat, 10 Oct 2020 15:58:04 +0200 Subject: [PATCH 12/56] add g-python shell button --- .../ui/extensions/ExtensionsController.java | 6 ++++- .../gearth/ui/extensions/Extensions.fxml | 24 ++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java b/G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java index 9d7f80b..1b66357 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java +++ b/G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java @@ -29,12 +29,12 @@ public class ExtensionsController extends SubForm { public Button btn_install; - public Button btn_remove; public TextField ext_port; public VBox extensioncontainer; public GridPane header_ext; public ScrollPane scroller; public Button btn_viewExtensionConsole; + public Button btn_gpython; private ExtensionRunner extensionRunner = null; private ExtensionHandler extensionHandler; @@ -100,4 +100,8 @@ public class ExtensionsController extends SubForm { } } + + public void gpythonBtnClicked(ActionEvent actionEvent) { + + } } diff --git a/G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml b/G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml index 1b4807b..9a71b89 100644 --- a/G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml +++ b/G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml @@ -4,7 +4,7 @@ - + @@ -19,11 +19,11 @@ - - - - - + + + + + @@ -52,14 +52,16 @@ - + - - + + + +