Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public final class StaticSimpleEnvironment {
private StaticSimpleEnvironment() {}

private static final Map<Environment, Node> nodes = new HashMap<Environment, Node>();
private static final Map<Environment, Node> nodes = new HashMap<>();

public static Node node(final SimpleComponentImpl self) {
// Save ourselves the lookup time in the hash map and avoid mixing in
Expand Down Expand Up @@ -86,4 +86,8 @@ public static void writeToNBT(final SimpleComponentImpl self, NBTTagCompound nbt
nbt.setTag("oc:node", nodeNbt);
}
}

public static void onServerStopped() {
nodes.clear();
}
}
21 changes: 6 additions & 15 deletions src/main/java/li/cil/oc/util/SideTracker.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
package li.cil.oc.util;

import cpw.mods.fml.common.FMLCommonHandler;
import java.util.Collections;
import java.util.Set;

public final class SideTracker {
private static final Set<Thread> serverThreads =
Collections.newSetFromMap(new java.util.WeakHashMap<Thread, Boolean>());

public static void addServerThread() {
serverThreads.add(Thread.currentThread());
}
public static boolean isServer() {
return FMLCommonHandler.instance().getEffectiveSide().isServer();
}

public static boolean isServer() {
return FMLCommonHandler.instance().getEffectiveSide().isServer()
|| serverThreads.contains(Thread.currentThread());
}

public static boolean isClient() {
return !isServer();
}
public static boolean isClient() {
return !isServer();
}
}
2 changes: 2 additions & 0 deletions src/main/scala/li/cil/oc/OpenComputers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import cpw.mods.fml.common.event._
import cpw.mods.fml.common.network.FMLEventChannel
import li.cil.oc.common.IMC
import li.cil.oc.common.Proxy
import li.cil.oc.common.asm.template.StaticSimpleEnvironment
import li.cil.oc.server.command.CommandHandler
import li.cil.oc.util.ThreadPoolFactory
import org.apache.logging.log4j.LogManager
Expand Down Expand Up @@ -91,6 +92,7 @@ object OpenComputers {
@EventHandler
def serverStop(e: FMLServerStoppedEvent): Unit = {
ThreadPoolFactory.safePools.foreach(_.waitForCompletion())
StaticSimpleEnvironment.onServerStopped()
}

@EventHandler
Expand Down
Loading