mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
let extensions use passed path in CONNECTIONSTART for harble messages
This commit is contained in:
parent
0a7da856c2
commit
84f40ba982
@ -138,7 +138,8 @@ public abstract class Extension implements IExtension{
|
||||
String host = packet.readString();
|
||||
int connectionPort = packet.readInteger();
|
||||
String hotelVersion = packet.readString();
|
||||
notifyConnectionListeners(host, connectionPort, hotelVersion);
|
||||
String harbleMessagesPath = packet.readString();
|
||||
notifyConnectionListeners(host, connectionPort, hotelVersion, harbleMessagesPath);
|
||||
onStartConnection();
|
||||
}
|
||||
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONEND) {
|
||||
@ -370,15 +371,15 @@ public abstract class Extension implements IExtension{
|
||||
|
||||
|
||||
public interface OnConnectionListener {
|
||||
void act(String host, int port, String hotelversion);
|
||||
void act(String host, int port, String hotelversion, String harbleMessagesPath);
|
||||
}
|
||||
private List<OnConnectionListener> onConnectionListeners = new ArrayList<>();
|
||||
public void onConnect(OnConnectionListener listener){
|
||||
onConnectionListeners.add(listener);
|
||||
}
|
||||
private void notifyConnectionListeners(String host, int port, String hotelversion) {
|
||||
private void notifyConnectionListeners(String host, int port, String hotelversion, String harbleMessagesPath) {
|
||||
for (OnConnectionListener listener : onConnectionListeners) {
|
||||
listener.act(host, port, hotelversion);
|
||||
listener.act(host, port, hotelversion, harbleMessagesPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class ChatConsole {
|
||||
|
||||
final boolean[] doOncePerConnection = {false};
|
||||
|
||||
extension.onConnect((s, i, s1) -> doOncePerConnection[0] = true);
|
||||
extension.onConnect((s, i, s1, h1) -> doOncePerConnection[0] = true);
|
||||
|
||||
extension.intercept(HMessage.Side.TOSERVER, hMessage -> {
|
||||
// if the first packet on init is not 4000, the extension was already running, so we open the chat instantly
|
||||
|
@ -32,24 +32,9 @@ public class HashSupport {
|
||||
public HashSupport(IExtension extension) {
|
||||
this.extension = extension;
|
||||
|
||||
boolean[] isDebug = {false};
|
||||
File GEarthDir = null;
|
||||
try {
|
||||
GEarthDir = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile();
|
||||
if (!GEarthDir.getName().equals("Extensions")) { //we're probably in debugging mode / not an installed extension
|
||||
//this means; no harble api is provided in our Cache
|
||||
isDebug[0] = true;
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
extension.onConnect((host, port, hotelversion) -> {
|
||||
extension.onConnect((host, port, hotelversion, cachePath) -> {
|
||||
// synchronized (lock) {
|
||||
if (isDebug[0]) {
|
||||
HarbleAPIFetcher.fetch(hotelversion);
|
||||
}
|
||||
harbleAPI = new HarbleAPI(hotelversion);
|
||||
harbleAPI = new HarbleAPI(hotelversion, cachePath);
|
||||
// }
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user