Skip to content

Commit

Permalink
Changes for 1.5.6-Alpha
Browse files Browse the repository at this point in the history
* rename to consistently SkyCofl
* send help command to server
* Break reconnect loop
* Keep online in prototype lobby
  • Loading branch information
Ekwav committed Jun 25, 2024
1 parent e0cb151 commit e9626ba
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/do-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: CoflSky-CI
path: build/libs/CoflMod-*-all.jar
path: build/libs/SkyCofl-*-all.jar
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "de.torui.coflmod"
version = "1.5.5-alpha"
version = "1.5.6-alpha"

// Toolchains:
java {
Expand Down Expand Up @@ -63,7 +63,7 @@ tasks.withType(JavaCompile::class) {
}

tasks.withType(Jar::class) {
archiveBaseName.set("CoflMod")
archiveBaseName.set("SkyCofl")
manifest.attributes.run {
this["FMLCorePluginContainsFMLMod"] = "true"
this["ForceLoadAsMod"] = "true"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ pluginManagement {
}
}

rootProject.name = "CoflMod"
rootProject.name = "SkyCofl"
2 changes: 1 addition & 1 deletion src/main/java/de/torui/coflsky/CoflSky.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Mod(modid = CoflSky.MODID, version = CoflSky.VERSION)
public class CoflSky {
public static final String MODID = "CoflSky";
public static final String VERSION = "1.5.5-Alpha";
public static final String VERSION = "1.5.6-Alpha";

public static WSClientWrapper Wrapper;
public static KeyBinding[] keyBindings;
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/de/torui/coflsky/CoflSkyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
CoflSky.Wrapper.stop();
sender.addChatMessage(new ChatComponentText("Opening connection to " + destination));
if (CoflSky.Wrapper.initializeNewSocket(destination)) {
sender.addChatMessage(new ChatComponentText("Success"));
sender.addChatMessage(new ChatComponentText("SkyCofl server is reachable, waiting for connection to be established"));
} else {
sender.addChatMessage(new ChatComponentText("Could not open connection, please check the logs"));
sender.addChatMessage(new ChatComponentText("Could not open connection, please check the logs and report them on your Discord!"));
}
} else {
sender.addChatMessage(new ChatComponentText("§cPleace specify a server to connect to"));
Expand Down Expand Up @@ -187,19 +187,19 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
SendCommandToServer(args, sender);
}
} else {
ListHelp(sender);
SendCommandToServer("help", "general");
}
}).start();
}

private void HandleReset() {
CoflSky.Wrapper.SendMessage(new Command<String>(CommandType.Reset, ""));
CoflSky.Wrapper.stop();
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Stopping Connection to CoflNet"));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Stopping Connection to SkyCofl"));
CoflSessionManager.DeleteAllCoflSessions();
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Deleting CoflNet sessions..."));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Deleting SkyCofl sessions..."));
if (CoflSky.Wrapper.startConnection())
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Started the Connection to CoflNet"));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Started the Connection to SkyCofl"));
}

public String StatusMessage() {
Expand Down Expand Up @@ -228,9 +228,11 @@ public String StatusMessage() {

public void SendCommandToServer(String[] args, ICommandSender sender) {
String command = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
SendCommandToServer(args[0], command);
}

//JsonStringCommand sc = new JsonStringCommand(args[0], WSClient.gson.toJson(command));
RawCommand rc = new RawCommand(args[0], WSClient.gson.toJson(command));
public void SendCommandToServer(string command, string arguments) {
RawCommand rc = new RawCommand(command, WSClient.gson.toJson(arguments));
if (CoflSky.Wrapper.isRunning) {
CoflSky.Wrapper.SendMessage(rc);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/torui/coflsky/handlers/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ private static void ProcessTabMenu(String line) {
}

private static void checkIfInSkyblock(String s) {
if (s.contains("SKYBLOCK") && !isInSkyblock) {
if ((s.contains("SKYBLOCK") || s.contains("E")) && !isInSkyblock) {
if (config.autoStart) {
CoflSky.Wrapper.stop();
CoflSky.Wrapper.startConnection();
}
isInSkyblock = true;
} else if (!s.contains("SKYBLOCK") && isInSkyblock) {
} else if (!s.contains("SKYBLOCK") && !s.contains("E") && isInSkyblock) {
if (config.autoStart) {
CoflSky.Wrapper.stop();
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("connection to ")
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/de/torui/coflsky/network/WSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public WSClient(URI uri) {

}

public void start() throws IOException, WebSocketException, NoSuchAlgorithmException {
public synchronized void start() throws IOException, WebSocketException, NoSuchAlgorithmException {
WebSocketFactory factory = new WebSocketFactory();

/*// Create a custom SSL context.
Expand All @@ -70,7 +70,7 @@ public void start() throws IOException, WebSocketException, NoSuchAlgorithmExcep
factory.*/
factory.setVerifyHostname(false);
factory.setSSLContext(NaiveSSLContext.getInstance("TLSv1.2"));
factory.setConnectionTimeout(10*1000);
factory.setConnectionTimeout(5*1000);
this.socket = factory.createSocket(uri);
this.socket.addListener(this);
this.socket.connect();
Expand All @@ -91,9 +91,13 @@ public void onStateChanged(WebSocket websocket, WebSocketState newState) throws
System.out.println("WebSocket Changed state to: " + newState);
currentState = newState;

if(newState == WebSocketState.CLOSED && shouldRun) {
boolean isActiveSocket = CoflSky.Wrapper.socket == this;
if(newState == WebSocketState.CLOSED && shouldRun && isActiveSocket) {
CoflSky.Wrapper.restartWebsocketConnection();
}
if(!isActiveSocket){
websocket.clearListeners();
}

super.onStateChanged(websocket, newState);
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/de/torui/coflsky/network/WSClientWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.UUID;

import com.neovisionaries.ws.client.WebSocketException;
import com.neovisionaries.ws.client.WebSocketState;

import de.torui.coflsky.CoflSky;
import de.torui.coflsky.commands.Command;
Expand Down Expand Up @@ -116,13 +117,11 @@ public boolean initializeNewSocket(String uriPrefix) {

}

private synchronized boolean start() {
if(!isRunning) {
private boolean start() {
if(socket.currentState == WebSocketState.CLOSED) {
try {

socket.start();
isRunning = true;

return true;
} catch (IOException e) {
// TODO Auto-generated catch block
Expand All @@ -133,9 +132,11 @@ private synchronized boolean start() {
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
}
} else {
System.out.println("Status is " + socket.currentState);
}
return false;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[
{
"modid": "CoflSky",
"name": "CoflSky",
"description": "Example placeholder mod.",
"version": "${version}",
"name": "SkyCofl",
"description": "Marketdata in item lore",
"version": "1.5.6-Alpha",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
"authorList": ["Torui"],
"url": "https://sky.coflnet.com/mod",
"updateUrl": "https://github.com/Coflnet/SkyblockMod/tags",
"authorList": ["Torui","Äkwav","Ragult","HackOS"],
"credits": "Coflnet for comissioning this mod.",
"logoFile": "",
"screenshots": [],
Expand Down

0 comments on commit e9626ba

Please sign in to comment.