mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-19 08:36:27 +01:00
might break
This commit is contained in:
parent
85c933cf7c
commit
3735799629
@ -19,12 +19,12 @@ public abstract class Extension extends ExtensionBase {
|
|||||||
protected FlagsCheckListener flagRequestCallback = null;
|
protected FlagsCheckListener flagRequestCallback = null;
|
||||||
|
|
||||||
private String[] args;
|
private String[] args;
|
||||||
private boolean isCorrupted = false;
|
private volatile boolean isCorrupted = false;
|
||||||
private static final String[] PORT_FLAG = {"--port", "-p"};
|
private static final String[] PORT_FLAG = {"--port", "-p"};
|
||||||
private static final String[] FILE_FLAG = {"--filename", "-f"};
|
private static final String[] FILE_FLAG = {"--filename", "-f"};
|
||||||
private static final String[] COOKIE_FLAG = {"--auth-token", "-c"}; // don't add a cookie or filename when debugging
|
private static final String[] COOKIE_FLAG = {"--auth-token", "-c"}; // don't add a cookie or filename when debugging
|
||||||
|
|
||||||
protected PacketInfoManager packetInfoManager = new PacketInfoManager(new ArrayList<>()); // empty
|
private volatile boolean delayed_init = false;
|
||||||
|
|
||||||
private OutputStream out = null;
|
private OutputStream out = null;
|
||||||
|
|
||||||
@ -130,13 +130,17 @@ public abstract class Extension extends ExtensionBase {
|
|||||||
String hotelVersion = packet.readString();
|
String hotelVersion = packet.readString();
|
||||||
String clientIdentifier = packet.readString();
|
String clientIdentifier = packet.readString();
|
||||||
HClient clientType = HClient.valueOf(packet.readString());
|
HClient clientType = HClient.valueOf(packet.readString());
|
||||||
packetInfoManager = PacketInfoManager.readFromPacket(packet);
|
setPacketInfoManager(PacketInfoManager.readFromPacket(packet));
|
||||||
|
|
||||||
Constants.UNITY_PACKETS = clientType == HClient.UNITY;
|
Constants.UNITY_PACKETS = clientType == HClient.UNITY;
|
||||||
getOnConnectionObservable().fireEvent(l -> l.onConnection(
|
getOnConnectionObservable().fireEvent(l -> l.onConnection(
|
||||||
host, connectionPort, hotelVersion,
|
host, connectionPort, hotelVersion,
|
||||||
clientIdentifier, clientType, packetInfoManager)
|
clientIdentifier, clientType)
|
||||||
);
|
);
|
||||||
|
if (delayed_init) {
|
||||||
|
initExtension();
|
||||||
|
delayed_init = false;
|
||||||
|
}
|
||||||
onStartConnection();
|
onStartConnection();
|
||||||
}
|
}
|
||||||
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONEND) {
|
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONEND) {
|
||||||
@ -155,8 +159,10 @@ public abstract class Extension extends ExtensionBase {
|
|||||||
flagRequestCallback = null;
|
flagRequestCallback = null;
|
||||||
}
|
}
|
||||||
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT) {
|
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT) {
|
||||||
// boolean isConnected = packet.readBoolean(); - don't read since not relevant here
|
delayed_init = packet.readBoolean();
|
||||||
|
if (!delayed_init) {
|
||||||
initExtension();
|
initExtension();
|
||||||
|
}
|
||||||
writeToConsole("green","Extension \"" + getInfoAnnotations().Title() + "\" successfully initialized", false);
|
writeToConsole("green","Extension \"" + getInfoAnnotations().Title() + "\" successfully initialized", false);
|
||||||
}
|
}
|
||||||
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.ONDOUBLECLICK) {
|
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.ONDOUBLECLICK) {
|
||||||
@ -300,5 +306,4 @@ public abstract class Extension extends ExtensionBase {
|
|||||||
protected boolean canDelete() {
|
protected boolean canDelete() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package gearth.extensions;
|
|||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
import gearth.services.packet_info.PacketInfoManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -21,6 +22,8 @@ public abstract class ExtensionBase extends IExtension {
|
|||||||
protected final Map<Integer, List<MessageListener>> incomingMessageListeners = new HashMap<>();
|
protected final Map<Integer, List<MessageListener>> incomingMessageListeners = new HashMap<>();
|
||||||
protected final Map<Integer, List<MessageListener>> outgoingMessageListeners = new HashMap<>();
|
protected final Map<Integer, List<MessageListener>> outgoingMessageListeners = new HashMap<>();
|
||||||
|
|
||||||
|
protected PacketInfoManager packetInfoManager = new PacketInfoManager(new ArrayList<>()); // empty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a listener on a specific packet Type
|
* Register a listener on a specific packet Type
|
||||||
* @param direction ToClient or ToServer
|
* @param direction ToClient or ToServer
|
||||||
@ -127,4 +130,13 @@ public abstract class ExtensionBase extends IExtension {
|
|||||||
Observable<OnConnectionListener> getOnConnectionObservable() {
|
Observable<OnConnectionListener> getOnConnectionObservable() {
|
||||||
return onConnectionObservable;
|
return onConnectionObservable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setPacketInfoManager(PacketInfoManager packetInfoManager) {
|
||||||
|
this.packetInfoManager = packetInfoManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketInfoManager getPacketInfoManager() {
|
||||||
|
return packetInfoManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package gearth.extensions;
|
|||||||
|
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
import gearth.services.packet_info.PacketInfoManager;
|
||||||
|
|
||||||
public abstract class IExtension {
|
public abstract class IExtension {
|
||||||
|
|
||||||
@ -21,4 +22,6 @@ public abstract class IExtension {
|
|||||||
abstract ExtensionInfo getInfoAnnotations();
|
abstract ExtensionInfo getInfoAnnotations();
|
||||||
abstract boolean canLeave();
|
abstract boolean canLeave();
|
||||||
abstract boolean canDelete();
|
abstract boolean canDelete();
|
||||||
|
|
||||||
|
public abstract PacketInfoManager getPacketInfoManager();
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,10 @@ public class InternalExtensionBuilder extends GEarthExtension {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager) {
|
public void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager) {
|
||||||
|
extension.setPacketInfoManager(packetInfoManager);
|
||||||
extension.getOnConnectionObservable().fireEvent(l -> l.onConnection(
|
extension.getOnConnectionObservable().fireEvent(l -> l.onConnection(
|
||||||
host, port, hotelVersion,
|
host, port, hotelVersion,
|
||||||
clientIdentifier, clientType, packetInfoManager)
|
clientIdentifier, clientType)
|
||||||
);
|
);
|
||||||
extension.onStartConnection();
|
extension.onStartConnection();
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ import gearth.services.packet_info.PacketInfoManager;
|
|||||||
import gearth.protocol.connection.HClient;
|
import gearth.protocol.connection.HClient;
|
||||||
|
|
||||||
public interface OnConnectionListener {
|
public interface OnConnectionListener {
|
||||||
void onConnection(String host, int port, String hotelversion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager);
|
void onConnection(String host, int port, String hotelversion, String clientIdentifier, HClient clientType);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class ChatConsole {
|
|||||||
this.infoMessage = infoMessage;
|
this.infoMessage = infoMessage;
|
||||||
|
|
||||||
final boolean[] doOncePerConnection = {false};
|
final boolean[] doOncePerConnection = {false};
|
||||||
extension.onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) ->
|
extension.onConnect((host, port, hotelversion, clientIdentifier, clientType) ->
|
||||||
doOncePerConnection[0] = true
|
doOncePerConnection[0] = true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ public class PacketInfoSupport {
|
|||||||
|
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
private PacketInfoManager packetInfoManager = new PacketInfoManager(new ArrayList<>()); //empty
|
|
||||||
private Map<String, List<Extension.MessageListener>> incomingMessageListeners = new HashMap<>();
|
private Map<String, List<Extension.MessageListener>> incomingMessageListeners = new HashMap<>();
|
||||||
private Map<String, List<Extension.MessageListener>> outgoingMessageListeners = new HashMap<>();
|
private Map<String, List<Extension.MessageListener>> outgoingMessageListeners = new HashMap<>();
|
||||||
|
|
||||||
@ -26,10 +25,6 @@ public class PacketInfoSupport {
|
|||||||
public PacketInfoSupport(IExtension extension) {
|
public PacketInfoSupport(IExtension extension) {
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
|
|
||||||
extension.onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) ->
|
|
||||||
this.packetInfoManager = packetInfoManager
|
|
||||||
);
|
|
||||||
|
|
||||||
extension.intercept(HMessage.Direction.TOSERVER, message -> onReceivePacket(HMessage.Direction.TOSERVER, message));
|
extension.intercept(HMessage.Direction.TOSERVER, message -> onReceivePacket(HMessage.Direction.TOSERVER, message));
|
||||||
extension.intercept(HMessage.Direction.TOCLIENT, message -> onReceivePacket(HMessage.Direction.TOCLIENT, message));
|
extension.intercept(HMessage.Direction.TOCLIENT, message -> onReceivePacket(HMessage.Direction.TOCLIENT, message));
|
||||||
}
|
}
|
||||||
@ -41,7 +36,7 @@ public class PacketInfoSupport {
|
|||||||
? outgoingMessageListeners
|
? outgoingMessageListeners
|
||||||
: incomingMessageListeners);
|
: incomingMessageListeners);
|
||||||
|
|
||||||
List<PacketInfo> packetInfos = packetInfoManager.getAllPacketInfoFromHeaderId(direction, message.getPacket().headerId());
|
List<PacketInfo> packetInfos = extension.getPacketInfoManager().getAllPacketInfoFromHeaderId(direction, message.getPacket().headerId());
|
||||||
|
|
||||||
for (PacketInfo packetInfo : packetInfos) {
|
for (PacketInfo packetInfo : packetInfos) {
|
||||||
List<Extension.MessageListener> listeners_hash = messageListeners.get(packetInfo.getHash());
|
List<Extension.MessageListener> listeners_hash = messageListeners.get(packetInfo.getHash());
|
||||||
@ -72,12 +67,12 @@ public class PacketInfoSupport {
|
|||||||
|
|
||||||
private boolean send(HMessage.Direction direction, String hashOrName, Object... objects) {
|
private boolean send(HMessage.Direction direction, String hashOrName, Object... objects) {
|
||||||
int headerId;
|
int headerId;
|
||||||
PacketInfo fromname = packetInfoManager.getPacketInfoFromName(direction, hashOrName);
|
PacketInfo fromname = extension.getPacketInfoManager().getPacketInfoFromName(direction, hashOrName);
|
||||||
if (fromname != null) {
|
if (fromname != null) {
|
||||||
headerId = fromname.getHeaderId();
|
headerId = fromname.getHeaderId();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PacketInfo fromHash = packetInfoManager.getPacketInfoFromHash(direction, hashOrName);
|
PacketInfo fromHash = extension.getPacketInfoManager().getPacketInfoFromHash(direction, hashOrName);
|
||||||
if (fromHash == null) return false;
|
if (fromHash == null) return false;
|
||||||
headerId = fromHash.getHeaderId();
|
headerId = fromHash.getHeaderId();
|
||||||
}
|
}
|
||||||
@ -109,8 +104,4 @@ public class PacketInfoSupport {
|
|||||||
public boolean sendToServer(String hashOrName, Object... objects) {
|
public boolean sendToServer(String hashOrName, Object... objects) {
|
||||||
return send(HMessage.Direction.TOSERVER, hashOrName, objects);
|
return send(HMessage.Direction.TOSERVER, hashOrName, objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketInfoManager getPacketInfoManager() {
|
|
||||||
return packetInfoManager;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,6 @@ public class BlockAndReplacePackets extends ExtensionForm {
|
|||||||
|
|
||||||
List<BlockReplaceRule> rules = new ArrayList<>();
|
List<BlockReplaceRule> rules = new ArrayList<>();
|
||||||
|
|
||||||
private PacketInfoManager packetInfoManager = PacketInfoManager.EMPTY;
|
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
// runExtensionForm(args, BlockAndReplacePackets.class);
|
// runExtensionForm(args, BlockAndReplacePackets.class);
|
||||||
// }
|
// }
|
||||||
@ -210,10 +208,6 @@ public class BlockAndReplacePackets extends ExtensionForm {
|
|||||||
|
|
||||||
intercept(HMessage.Direction.TOSERVER, messageListener);
|
intercept(HMessage.Direction.TOSERVER, messageListener);
|
||||||
intercept(HMessage.Direction.TOCLIENT, messageListener);
|
intercept(HMessage.Direction.TOCLIENT, messageListener);
|
||||||
|
|
||||||
onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) -> {
|
|
||||||
this.packetInfoManager = packetInfoManager;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,17 +110,17 @@ public class PacketInfoExplorer extends ExtensionForm {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initExtension() {
|
protected void initExtension() {
|
||||||
onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) -> {
|
onConnect((host, port, hotelversion, clientIdentifier, clientType) -> {
|
||||||
setPacketInfoManager(packetInfoManager);
|
init(packetInfoManager);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEndConnection() {
|
protected void onEndConnection() {
|
||||||
setPacketInfoManager(PacketInfoManager.EMPTY);
|
init(PacketInfoManager.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPacketInfoManager(PacketInfoManager packetInfoManager) {
|
private void init(PacketInfoManager packetInfoManager) {
|
||||||
packetInfoList = packetInfoManager.getPacketInfoList();
|
packetInfoList = packetInfoManager.getPacketInfoList();
|
||||||
packetInfoList.sort(Comparator.comparingInt(PacketInfo::getHeaderId));
|
packetInfoList.sort(Comparator.comparingInt(PacketInfo::getHeaderId));
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ public class UiLogger extends ExtensionForm implements PacketLogger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initExtension() {
|
protected void initExtension() {
|
||||||
onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) -> {
|
controller.init(this);
|
||||||
controller.setPacketInfoManager(packetInfoManager);
|
onConnect((host, port, hotelversion, clientIdentifier, clientType) -> {
|
||||||
controller.onConnect();
|
controller.onConnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -55,7 +55,6 @@ public class UiLogger extends ExtensionForm implements PacketLogger {
|
|||||||
@Override
|
@Override
|
||||||
protected void onEndConnection() {
|
protected void onEndConnection() {
|
||||||
controller.onDisconnect();
|
controller.onDisconnect();
|
||||||
controller.setPacketInfoManager(PacketInfoManager.EMPTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,7 +71,6 @@ public class UiLoggerController implements Initializable {
|
|||||||
private StyleClassedTextArea area;
|
private StyleClassedTextArea area;
|
||||||
|
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private PacketInfoManager packetInfoManager = null;
|
|
||||||
|
|
||||||
private int filteredAmount = 0;
|
private int filteredAmount = 0;
|
||||||
|
|
||||||
@ -79,6 +78,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
private final List<Element> appendLater = new ArrayList<>();
|
private final List<Element> appendLater = new ArrayList<>();
|
||||||
|
|
||||||
private List<MenuItem> allMenuItems = new ArrayList<>();
|
private List<MenuItem> allMenuItems = new ArrayList<>();
|
||||||
|
private UiLogger uiLogger;
|
||||||
|
|
||||||
private boolean isSelected(MenuItem item) {
|
private boolean isSelected(MenuItem item) {
|
||||||
if (item instanceof CheckMenuItem) {
|
if (item instanceof CheckMenuItem) {
|
||||||
@ -216,10 +216,10 @@ public class UiLoggerController implements Initializable {
|
|||||||
elements.add(new Element(String.format("(timestamp: %d)\n", System.currentTimeMillis()), "timestamp"));
|
elements.add(new Element(String.format("(timestamp: %d)\n", System.currentTimeMillis()), "timestamp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
boolean packetInfoAvailable = uiLogger.getPacketInfoManager().getPacketInfoList().size() > 0;
|
||||||
|
|
||||||
if ((chkMessageName.isSelected() || chkMessageHash.isSelected()) && packetInfoAvailable) {
|
if ((chkMessageName.isSelected() || chkMessageHash.isSelected()) && packetInfoAvailable) {
|
||||||
List<PacketInfo> messages = packetInfoManager.getAllPacketInfoFromHeaderId(
|
List<PacketInfo> messages = uiLogger.getPacketInfoManager().getAllPacketInfoFromHeaderId(
|
||||||
(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
|
(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
|
||||||
packet.headerId()
|
packet.headerId()
|
||||||
);
|
);
|
||||||
@ -277,7 +277,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
|
|
||||||
if (packet.length() <= 2000) {
|
if (packet.length() <= 2000) {
|
||||||
try {
|
try {
|
||||||
String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER, packetInfoManager, chkUseNewStructures.isSelected());
|
String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER, uiLogger.getPacketInfoManager(), chkUseNewStructures.isSelected());
|
||||||
String cleaned = cleanTextContent(expr);
|
String cleaned = cleanTextContent(expr);
|
||||||
if (cleaned.equals(expr)) {
|
if (cleaned.equals(expr)) {
|
||||||
if (!expr.equals("") && chkDisplayStructure.isSelected())
|
if (!expr.equals("") && chkDisplayStructure.isSelected())
|
||||||
@ -338,16 +338,11 @@ public class UiLoggerController implements Initializable {
|
|||||||
lblAutoScrolll.setText("Autoscroll: " + (chkAutoscroll.isSelected() ? "True" : "False"));
|
lblAutoScrolll.setText("Autoscroll: " + (chkAutoscroll.isSelected() ? "True" : "False"));
|
||||||
lblFiltered.setText("Filtered: " + filteredAmount);
|
lblFiltered.setText("Filtered: " + filteredAmount);
|
||||||
|
|
||||||
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
boolean packetInfoAvailable = uiLogger.getPacketInfoManager().getPacketInfoList().size() > 0;
|
||||||
lblPacketInfo.setText("Packet info: " + (packetInfoAvailable ? "True" : "False"));
|
lblPacketInfo.setText("Packet info: " + (packetInfoAvailable ? "True" : "False"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPacketInfoManager(PacketInfoManager packetInfoManager) {
|
|
||||||
this.packetInfoManager = packetInfoManager;
|
|
||||||
Platform.runLater(this::updateLoggerInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleAlwaysOnTop(ActionEvent actionEvent) {
|
public void toggleAlwaysOnTop(ActionEvent actionEvent) {
|
||||||
stage.setAlwaysOnTop(chkAlwaysOnTop.isSelected());
|
stage.setAlwaysOnTop(chkAlwaysOnTop.isSelected());
|
||||||
}
|
}
|
||||||
@ -376,6 +371,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Platform.runLater(this::updateLoggerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportAll(ActionEvent actionEvent) {
|
public void exportAll(ActionEvent actionEvent) {
|
||||||
@ -406,4 +402,8 @@ public class UiLoggerController implements Initializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void init(UiLogger uiLogger) {
|
||||||
|
this.uiLogger = uiLogger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user