mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 10:44:45 +00:00
Cleaned and generalised item loading/searching
Reimplemented subsets Added regex searching Fixed format error on delete all Fixed GuiButton handling clicks before NEI widgets could override Re-Implemented banned blocks implementation Added brewing recipes again note test obf ASM beacons Fixed some calls being intercepted by item panel when mouse was over a gui element Fixed crash on closing potion window with escape Disabled fast transfer, scrolling, and drag 'n' drop in creative Added item panel sorting Removed TMI uninstaller Fixed /give command Updated to 1.7.10
This commit is contained in:
1 parent
3c9ebc6961
commit
3c84527806
67 files changed
+3251
-2319
No files matched your search
@@ -0,0 +1,72 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class ThreadOperationTimer extends Thread
|
||||
{
|
||||
@SuppressWarnings("serial")
|
||||
public static class TimeoutException extends RuntimeException
|
||||
{
|
||||
public final Object operation;
|
||||
|
||||
public TimeoutException(String msg, Object op) {
|
||||
super(msg);
|
||||
operation = op;
|
||||
}
|
||||
}
|
||||
|
||||
private Thread thread;
|
||||
private Object operation;
|
||||
private long opTime;
|
||||
private long limit;
|
||||
|
||||
private ThreadOperationTimer(Thread thread, int limit) {
|
||||
super(thread.getName()+" Operation Timer");
|
||||
this.thread = thread;
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public synchronized void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
reset(null);
|
||||
}
|
||||
|
||||
public synchronized void reset(Object op) {
|
||||
operation = op;
|
||||
opTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public synchronized void update(Object op) {
|
||||
if(!Objects.equal(operation, op)) {
|
||||
operation = op;
|
||||
opTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
if(FMLCommonHandler.instance().findContainerFor("NotEnoughItems").getVersion().contains("$"))
|
||||
return;//don't run this thread in a source environment
|
||||
|
||||
while (thread.isAlive()) {
|
||||
synchronized (this) {
|
||||
if (operation != null && System.currentTimeMillis() - opTime > limit)
|
||||
thread.stop(new TimeoutException("Operation took too long", operation));
|
||||
}
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException ie) {}
|
||||
}
|
||||
}
|
||||
|
||||
public static ThreadOperationTimer start(Thread thread, int limit) {
|
||||
ThreadOperationTimer t = new ThreadOperationTimer(thread, limit);
|
||||
t.start();
|
||||
return t;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user