Skip to content

Commit

Permalink
Merge branch 'gui'
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeBather committed Nov 30, 2024
2 parents 84c6e57 + 0bd0529 commit e687697
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
22 changes: 12 additions & 10 deletions src/main/java/kasuga/lib/core/addons/node/AssetReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ public String apply(String path, String resourceType){
)
);
}
path = PackageScanner.joinPath(
PackageScanner.resolve(
PackageScanner.splitPath(
assetRoot
),
PackageScanner.splitPath(
path
)
)
);
if(assetRoot != null && !assetRoot.equals("")){
path = PackageScanner.joinPath(
PackageScanner.resolve(
PackageScanner.splitPath(
assetRoot
),
PackageScanner.splitPath(
path
)
)
);
}
UUID uuid;
do{
uuid = UUID.randomUUID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ protected void createRuntime(NodePackage nodePackage){
case CLIENT:
createRuntimeForEntryType(nodePackage, nodePackage.minecraft.commonEntries());
createRuntimeForEntryType(nodePackage, nodePackage.minecraft.clientEntries());
case SERVER:
createRuntimeForEntryType(nodePackage, nodePackage.minecraft.commonEntries());
createRuntimeForEntryType(nodePackage, nodePackage.minecraft.serverEntries());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import kasuga.lib.core.channel.peer.ChannelStatus;
import net.minecraft.nbt.CompoundTag;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicLong;

Expand Down Expand Up @@ -65,7 +66,8 @@ public void onExistedConnectionEstablished(long networkId, NetworkChannelSocket
}

public void close(){
for(Channel channel : channels.values()){
ArrayList<Channel> currentChannels = new ArrayList<>(channels.values());
for(Channel channel : currentChannels){
channel.close();
}
channels.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected JavascriptEngineModule load(
javascriptContext,
moduleInfo.getProvider(),
KasugaLib.STACKS.JAVASCRIPT.ASSETS.get(),
"/"));
""));
return module;

}catch (IOException e){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package kasuga.lib.core.events.server;

import kasuga.lib.KasugaLib;
import kasuga.lib.core.addons.minecraft.ServerAddon;
import kasuga.lib.core.util.Start;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
Expand All @@ -17,6 +19,8 @@ public class ServerStartingEvents {
public static void serverStarting(ServerStartingEvent event) {
MinecraftServer server = event.getServer();
CloseableResourceManager manager = server.getServerResources().resourceManager();
KasugaLib.STACKS.JAVASCRIPT.setupServer();
ServerAddon.init(event.getServer());
}

@SubscribeEvent
Expand All @@ -26,4 +30,9 @@ public static void serverAboutToStart(ServerAboutToStartEvent event) {
Start.printLogo();
}
}

public static void serverStopping(ServerStoppingEvent event) {
ServerAddon.unload();
KasugaLib.STACKS.JAVASCRIPT.destoryServer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public JavetJavascriptModule(
context,
nodePackage.reader,
KasugaLib.STACKS.JAVASCRIPT.ASSETS.get(),
nodePackage.minecraft.assetsFolder()
nodePackage.minecraft != null ? nodePackage.minecraft.assetsFolder() : ""
): null, absolutePath, directoryName, context);
}
public JavetJavascriptModule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public void reload() {
openJavascriptServer();
});
} else {
for(ChannelHandle handle : handles.values()){
handle.close();
}
openJavascriptServer();
}
}
Expand Down

0 comments on commit e687697

Please sign in to comment.