mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 00:38:16 +00:00
Added dock icon support for mac users (working for windows this time)
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package org.parabot.environment.scripts;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.parabot.environment.scripts.framework.AbstractFramework;
|
||||
import org.parabot.environment.scripts.framework.LoopTask;
|
||||
import org.parabot.environment.scripts.framework.Strategy;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds various script frameworks
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Frameworks {
|
||||
|
||||
public static Looper getLooper(LoopTask loopTask) {
|
||||
return new Looper(loopTask);
|
||||
}
|
||||
|
||||
public static StrategyWorker getStrategyWorker(Collection<Strategy> strategies) {
|
||||
return new StrategyWorker(strategies);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Looper extends AbstractFramework {
|
||||
private LoopTask loopTask = null;
|
||||
|
||||
public Looper(LoopTask loopTask) {
|
||||
this.loopTask = loopTask;
|
||||
}
|
||||
@Override
|
||||
public boolean execute() {
|
||||
int sleepTime = loopTask.loop();
|
||||
if(sleepTime < 0) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class StrategyWorker extends AbstractFramework {
|
||||
private Collection<Strategy> strategies;
|
||||
|
||||
public StrategyWorker(Collection<Strategy> strategies) {
|
||||
this.strategies = strategies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
for(Strategy s : strategies) {
|
||||
if(s.activate()) {
|
||||
s.execute();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.parabot.environment.servers;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.build.BuildPath;
|
||||
import org.parabot.core.classpath.ClassPath;
|
||||
import org.parabot.environment.servers.executers.ServerExecuter;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Loads locally stored server providers
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class LocalServerExecuter extends ServerExecuter {
|
||||
private final ServerProvider serverProvider;
|
||||
private ClassPath classPath;
|
||||
private String serverName;
|
||||
|
||||
public LocalServerExecuter(ServerProvider serverProvider,
|
||||
ClassPath classPath, final String serverName) {
|
||||
this.serverProvider = serverProvider;
|
||||
this.classPath = classPath;
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// add jar or directory to buildpath.
|
||||
if (this.classPath.isJar()) {
|
||||
Core.verbose("Adding server provider jar to buildpath: "
|
||||
+ this.classPath.lastParsed.toString());
|
||||
this.classPath.addToBuildPath();
|
||||
} else {
|
||||
Core.verbose("Adding server providers directory to buildpath: "
|
||||
+ Directories.getServerPath().getPath());
|
||||
try {
|
||||
BuildPath.add(Directories.getServerPath().toURI().toURL());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// finalize
|
||||
super.finalize(this.serverProvider, this.serverName);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user