From 50fc4b41073da4ae4ad86615895fa82f7cfcf438 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Thu, 29 Apr 2021 02:38:27 +0200 Subject: [PATCH] grtgrtgrg --- G-Earth/src/main/java/gearth/extensions/Extension.java | 1 + .../java/gearth/extensions/InternalExtensionBuilder.java | 4 ++-- G-Earth/src/main/java/gearth/protocol/HPacket.java | 6 +++--- .../gearth/services/extensionhandler/ExtensionHandler.java | 2 +- .../extensionhandler/extensions/GEarthExtension.java | 2 +- .../implementations/network/NetworkExtension.java | 4 ++-- .../extensions/implementations/simple/ExampleExtension.java | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/G-Earth/src/main/java/gearth/extensions/Extension.java b/G-Earth/src/main/java/gearth/extensions/Extension.java index bcd67ac..6a97383 100644 --- a/G-Earth/src/main/java/gearth/extensions/Extension.java +++ b/G-Earth/src/main/java/gearth/extensions/Extension.java @@ -155,6 +155,7 @@ public abstract class Extension extends ExtensionBase { flagRequestCallback = null; } else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT) { +// boolean isConnected = packet.readBoolean(); - don't read since not relevant here initExtension(); writeToConsole("green","Extension \"" + getInfoAnnotations().Title() + "\" successfully initialized", false); } diff --git a/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java b/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java index 8f90d79..b1440d9 100644 --- a/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java +++ b/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java @@ -118,9 +118,9 @@ public class InternalExtensionBuilder extends GEarthExtension { } @Override - public void init() { + public void init(boolean isConnected) { extension.initExtension(); - } + } // not implementing isConnected, only relevant for g-python @Override public void close() { diff --git a/G-Earth/src/main/java/gearth/protocol/HPacket.java b/G-Earth/src/main/java/gearth/protocol/HPacket.java index 9805843..2f5cd21 100644 --- a/G-Earth/src/main/java/gearth/protocol/HPacket.java +++ b/G-Earth/src/main/java/gearth/protocol/HPacket.java @@ -37,10 +37,10 @@ public class HPacket implements StringifyAble { packetInBytes = packetFromString.packetInBytes; identifier = packetFromString.identifier; identifierDirection = packetFromString.identifierDirection; - } catch (InvalidPacketException e) { - packetInBytes = new byte[0]; - } + } catch (InvalidPacketException e) { + packetInBytes = new byte[0]; } +} public HPacket(int header) { packetInBytes = new byte[]{0,0,0,2,0,0}; replaceShort(4, (short)header); 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 98e7056..2c48249 100644 --- a/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java +++ b/G-Earth/src/main/java/gearth/services/extensionhandler/ExtensionHandler.java @@ -237,7 +237,7 @@ public class ExtensionHandler { }; extension.getExtensionObservable().addListener(listener); - extension.init(); + extension.init(hConnection.getState() == HState.CONNECTED); if (hConnection.getState() == HState.CONNECTED) { extension.connectionStart( 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 a22d847..ffafecd 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 @@ -40,7 +40,7 @@ public abstract class GEarthExtension { public abstract void provideFlags(String[] flags); public abstract void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager); public abstract void connectionEnd(); - public abstract void init(); + public abstract void init(boolean isConnected); public abstract void close(); public abstract void packetToStringResponse(String string, String expression); public abstract void stringToPacketResponse(HPacket packet); 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 6d6eaf4..7e46460 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 @@ -213,9 +213,9 @@ public class NetworkExtension extends GEarthExtension { } @Override - public void init() { + public void init(boolean isConnected) { sendMessage( - new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT) + new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT, isConnected) ); } 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 a33bf9b..3880c68 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 @@ -97,7 +97,7 @@ public class ExampleExtension extends GEarthExtension { } @Override - public void init() { + public void init(boolean isConnected) { System.out.println("Example extension is connected to G-Earth"); // the extension is now connected with G-Earth }