mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-28 15:30:08 -04:00
Merge branch 'master' of https://github.com/MightyPirates/OpenComputers into MC1.7
Conflicts: src/main/java/li/cil/oc/api/network/SidedEnvironment.java src/main/scala/li/cil/oc/OpenComputers.scala src/main/scala/li/cil/oc/common/ConnectionHandler.scala src/main/scala/li/cil/oc/common/SaveHandler.scala
This commit is contained in:
commit
e7f4a32d95
@ -36,4 +36,5 @@ version = "MC${config.minecraft.version}-${project.version}"
|
|||||||
|
|
||||||
apply from: 'gradle/forge.gradle'
|
apply from: 'gradle/forge.gradle'
|
||||||
apply from: 'gradle/artifact.gradle'
|
apply from: 'gradle/artifact.gradle'
|
||||||
|
apply from: 'gradle/sign.gradle'
|
||||||
apply from: 'gradle/release.gradle'
|
apply from: 'gradle/release.gradle'
|
||||||
|
@ -6,6 +6,10 @@ jar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
javadoc {
|
||||||
|
include 'li/cil/oc/api/**'
|
||||||
|
}
|
||||||
|
|
||||||
// because the normal default jar task has been modified to be obfuscated
|
// because the normal default jar task has been modified to be obfuscated
|
||||||
task deobfJar(type: Jar) {
|
task deobfJar(type: Jar) {
|
||||||
from sourceSets.main.output
|
from sourceSets.main.output
|
||||||
@ -22,7 +26,13 @@ task apiJar(type: Jar) {
|
|||||||
include 'li/cil/oc/api/**'
|
include 'li/cil/oc/api/**'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
from 'build/docs/javadoc'
|
||||||
|
classifier 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives deobfJar
|
archives deobfJar
|
||||||
archives apiJar
|
archives apiJar
|
||||||
|
archives javadocJar
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,10 @@ compileScala {
|
|||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "${config.minecraft.version}-${config.forge.version}"
|
version = "${config.minecraft.version}-${config.forge.version}"
|
||||||
|
|
||||||
|
replaceIn "li/cil/oc/OpenComputers.scala"
|
||||||
|
if (project.hasProperty("keystore_fingerprint"))
|
||||||
|
replace "@FINGERPRINT@", keystore_fingerprint
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
37
gradle/sign.gradle
Normal file
37
gradle/sign.gradle
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Based on the code from TinkersConstruct and Cazzar's repo.
|
||||||
|
// Thanks ProgWML6 and Cazzar!
|
||||||
|
|
||||||
|
// verify the properties exist... or initialize.
|
||||||
|
if (!project.hasProperty("keystore_location")) // keystore stuff
|
||||||
|
ext.keystore_location = ""
|
||||||
|
|
||||||
|
if (!project.hasProperty("keystore_alias")) // keystore stuff
|
||||||
|
ext.keystore_alias = ""
|
||||||
|
|
||||||
|
if (!project.hasProperty("keystore_password")) // keystore stuff
|
||||||
|
ext.keystore_password = ""
|
||||||
|
|
||||||
|
task("signJar", dependsOn: "reobf") {
|
||||||
|
inputs.file jar.getArchivePath()
|
||||||
|
inputs.file keystore_location
|
||||||
|
inputs.property "keystore_alias", keystore_alias
|
||||||
|
inputs.property "keystore_password", keystore_password
|
||||||
|
outputs.file jar.getArchivePath()
|
||||||
|
|
||||||
|
// only sign if the keystore exists
|
||||||
|
onlyIf {
|
||||||
|
return !keystore_location.empty
|
||||||
|
}
|
||||||
|
|
||||||
|
// the actual action - sign the jar.
|
||||||
|
doLast {
|
||||||
|
ant.signjar(
|
||||||
|
destDir: jar.destinationDir,
|
||||||
|
jar: jar.getArchivePath(),
|
||||||
|
keystore: keystore_location,
|
||||||
|
alias: keystore_alias,
|
||||||
|
storepass: keystore_password,
|
||||||
|
keypass: keystore_password
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package li.cil.oc.api.machine;
|
package li.cil.oc.api.machine;
|
||||||
|
|
||||||
import li.cil.oc.api.fs.FileSystem;
|
|
||||||
import li.cil.oc.api.network.Callback;
|
import li.cil.oc.api.network.Callback;
|
||||||
import li.cil.oc.api.network.Context;
|
import li.cil.oc.api.network.Context;
|
||||||
import li.cil.oc.api.network.ManagedEnvironment;
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
@ -79,7 +78,7 @@ public interface Machine extends ManagedEnvironment, Context {
|
|||||||
* The address of the file system that holds the machine's read only data
|
* The address of the file system that holds the machine's read only data
|
||||||
* (rom). This file system is populated based on the backing resource file
|
* (rom). This file system is populated based on the backing resource file
|
||||||
* systems specified for the machines architecture via
|
* systems specified for the machines architecture via
|
||||||
* {@link li.cil.oc.api.Machine#addRomResource(Class, FileSystem, String)}.
|
* {@link li.cil.oc.api.Machine#addRomResource(Class, java.util.concurrent.Callable, String)}.
|
||||||
* This may return <tt>null</tt> if the creation of the file system
|
* This may return <tt>null</tt> if the creation of the file system
|
||||||
* failed.
|
* failed.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -178,7 +178,7 @@ public interface Network {
|
|||||||
* @param name the name of the message.
|
* @param name the name of the message.
|
||||||
* @param data the message to send.
|
* @param data the message to send.
|
||||||
* @throws IllegalArgumentException if the source node is not in this network.
|
* @throws IllegalArgumentException if the source node is not in this network.
|
||||||
* @see `neighbors`
|
* @see #neighbors(Node)
|
||||||
*/
|
*/
|
||||||
void sendToNeighbors(Node source, String name, Object... data);
|
void sendToNeighbors(Node source, String name, Object... data);
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ public interface Network {
|
|||||||
* @param source the node that sends the message.
|
* @param source the node that sends the message.
|
||||||
* @param data the message to send.
|
* @param data the message to send.
|
||||||
* @throws IllegalArgumentException if the source node is not in this network.
|
* @throws IllegalArgumentException if the source node is not in this network.
|
||||||
* @see {@link #nodes(Node)}
|
* @see #nodes(Node)
|
||||||
*/
|
*/
|
||||||
void sendToReachable(Node source, String name, Object... data);
|
void sendToReachable(Node source, String name, Object... data);
|
||||||
|
|
||||||
@ -218,8 +218,8 @@ public interface Network {
|
|||||||
* @param source the node that sends the message.
|
* @param source the node that sends the message.
|
||||||
* @param data the message to send.
|
* @param data the message to send.
|
||||||
* @throws IllegalArgumentException if the source node is not in this network.
|
* @throws IllegalArgumentException if the source node is not in this network.
|
||||||
* @see {@link #nodes(Node)}
|
* @see #nodes(Node)
|
||||||
* @see {@link Component#canBeSeenFrom(Node)}
|
* @see Component#canBeSeenFrom(Node)
|
||||||
*/
|
*/
|
||||||
void sendToVisible(Node source, String name, Object... data);
|
void sendToVisible(Node source, String name, Object... data);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package li.cil.oc.api.network;
|
|||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,9 +12,9 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* This interface is intended to be used on tile entities that are environments.
|
* This interface is intended to be used on tile entities that are environments.
|
||||||
* It is used to determine which neighbors a tile entity can connect to when
|
* It is used to determine which neighbors a tile entity can connect to when
|
||||||
* calling {@link li.cil.oc.api.Network#joinOrCreateNetwork}. It is used by the
|
* calling {@link li.cil.oc.api.Network#joinOrCreateNetwork(TileEntity)}. It is
|
||||||
* keyboard to only interface with the side on which it is attached, as well as
|
* used by the keyboard to only interface with the side on which it is attached,
|
||||||
* the router to offer a different node for each side.
|
* as well as the router to offer a different node for each side.
|
||||||
*/
|
*/
|
||||||
public interface SidedEnvironment {
|
public interface SidedEnvironment {
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,7 @@ import org.luaj.vm3.lib.ResourceFinder;
|
|||||||
* <li>{@link STDIN} Current value for standard input in the laaded IoLib, if any.
|
* <li>{@link STDIN} Current value for standard input in the laaded IoLib, if any.
|
||||||
* <li>{@link STDOUT} Current value for standard output in the loaded IoLib, if any.
|
* <li>{@link STDOUT} Current value for standard output in the loaded IoLib, if any.
|
||||||
* <li>{@link STDERR} Current value for standard error in the loaded IoLib, if any.
|
* <li>{@link STDERR} Current value for standard error in the loaded IoLib, if any.
|
||||||
* <li>{@link FINDER} Current loaded {@link ResourceFinder}, if any.
|
* <li>{@link finder} Current loaded {@link ResourceFinder}, if any.
|
||||||
* <li>{@link compiler} Current loaded {@link Compiler}, if any.
|
* <li>{@link compiler} Current loaded {@link Compiler}, if any.
|
||||||
* <li>{@link undumper} Current loaded {@link Undumper}, if any.
|
* <li>{@link undumper} Current loaded {@link Undumper}, if any.
|
||||||
* <li>{@link loader} Current loaded {@link Loader}, if any.
|
* <li>{@link loader} Current loaded {@link Loader}, if any.
|
||||||
@ -122,7 +122,7 @@ public class Globals extends LuaTable {
|
|||||||
public PrintStream STDERR = System.err;
|
public PrintStream STDERR = System.err;
|
||||||
|
|
||||||
/** The installed ResourceFinder for looking files by name. */
|
/** The installed ResourceFinder for looking files by name. */
|
||||||
public ResourceFinder FINDER;
|
public ResourceFinder finder;
|
||||||
|
|
||||||
/** The currently running thread. Should not be changed by non-library code. */
|
/** The currently running thread. Should not be changed by non-library code. */
|
||||||
public LuaThread running = new LuaThread(this);
|
public LuaThread running = new LuaThread(this);
|
||||||
@ -178,7 +178,7 @@ public class Globals extends LuaTable {
|
|||||||
*/
|
*/
|
||||||
public LuaValue loadfile(String filename) {
|
public LuaValue loadfile(String filename) {
|
||||||
try {
|
try {
|
||||||
return load(FINDER.findResource(filename), "@"+filename, "bt", this);
|
return load(finder.findResource(filename), "@"+filename, "bt", this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return error("load "+filename+": "+e);
|
return error("load "+filename+": "+e);
|
||||||
}
|
}
|
||||||
|
@ -387,6 +387,12 @@ public class LuaString extends LuaValue {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Take a substring using Java zero-based indexes for begin and end or range.
|
||||||
|
* @param beginIndex The zero-based index of the first character to include.
|
||||||
|
* @param endIndex The zero-based index of position after the last character.
|
||||||
|
* @return LuaString which is a substring whose first character is at offset
|
||||||
|
* beginIndex and extending for (endIndex - beginIndex ) characters.
|
||||||
|
*/
|
||||||
public LuaString substring( int beginIndex, int endIndex ) {
|
public LuaString substring( int beginIndex, int endIndex ) {
|
||||||
return valueOf( m_bytes, m_offset + beginIndex, endIndex - beginIndex );
|
return valueOf( m_bytes, m_offset + beginIndex, endIndex - beginIndex );
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ import org.luaj.vm3.Varargs;
|
|||||||
* <p>
|
* <p>
|
||||||
* This contains all library functions listed as "basic functions" in the lua documentation for JME.
|
* This contains all library functions listed as "basic functions" in the lua documentation for JME.
|
||||||
* The functions dofile and loadfile use the
|
* The functions dofile and loadfile use the
|
||||||
* {@link #FINDER} instance to find resource files.
|
* {@link #finder} instance to find resource files.
|
||||||
* Since JME has no file system by default, {@link BaseLib} implements
|
* Since JME has no file system by default, {@link BaseLib} implements
|
||||||
* {@link ResourceFinder} using {@link Class#getResource(String)},
|
* {@link ResourceFinder} using {@link Class#getResource(String)},
|
||||||
* which is the closest equivalent on JME.
|
* which is the closest equivalent on JME.
|
||||||
@ -69,7 +69,7 @@ import org.luaj.vm3.Varargs;
|
|||||||
* This is a direct port of the corresponding library in C.
|
* This is a direct port of the corresponding library in C.
|
||||||
* @see JseBaseLib
|
* @see JseBaseLib
|
||||||
* @see ResourceFinder
|
* @see ResourceFinder
|
||||||
* @see #FINDER
|
* @see #finder
|
||||||
* @see LibFunction
|
* @see LibFunction
|
||||||
* @see JsePlatform
|
* @see JsePlatform
|
||||||
* @see JmePlatform
|
* @see JmePlatform
|
||||||
@ -81,7 +81,7 @@ public class BaseLib extends TwoArgFunction implements ResourceFinder {
|
|||||||
|
|
||||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||||
globals = env.checkglobals();
|
globals = env.checkglobals();
|
||||||
globals.FINDER = this;
|
globals.finder = this;
|
||||||
globals.baselib = this;
|
globals.baselib = this;
|
||||||
env.set( "_G", env );
|
env.set( "_G", env );
|
||||||
env.set( "_VERSION", Lua._VERSION );
|
env.set( "_VERSION", Lua._VERSION );
|
||||||
@ -424,7 +424,7 @@ public class BaseLib extends TwoArgFunction implements ResourceFinder {
|
|||||||
* @return Varargs containing chunk, or NIL,error-text on error
|
* @return Varargs containing chunk, or NIL,error-text on error
|
||||||
*/
|
*/
|
||||||
public Varargs loadFile(String filename, String mode, LuaValue env) {
|
public Varargs loadFile(String filename, String mode, LuaValue env) {
|
||||||
InputStream is = globals.FINDER.findResource(filename);
|
InputStream is = globals.finder.findResource(filename);
|
||||||
if ( is == null )
|
if ( is == null )
|
||||||
return varargsOf(NIL, valueOf("cannot open "+filename+": No such file or directory"));
|
return varargsOf(NIL, valueOf("cannot open "+filename+": No such file or directory"));
|
||||||
try {
|
try {
|
||||||
|
@ -72,8 +72,12 @@ import org.luaj.vm3.Varargs;
|
|||||||
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.10">Lua 5.2 Debug Lib Reference</a>
|
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.10">Lua 5.2 Debug Lib Reference</a>
|
||||||
*/
|
*/
|
||||||
public class DebugLib extends TwoArgFunction {
|
public class DebugLib extends TwoArgFunction {
|
||||||
public static final boolean CALLS = (null != System.getProperty("CALLS"));
|
public static boolean CALLS;
|
||||||
public static final boolean TRACE = (null != System.getProperty("TRACE"));
|
public static boolean TRACE;
|
||||||
|
static {
|
||||||
|
try { CALLS = (null != System.getProperty("CALLS")); } catch (Exception e) {}
|
||||||
|
try { TRACE = (null != System.getProperty("TRACE")); } catch (Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
private static final LuaString LUA = valueOf("Lua");
|
private static final LuaString LUA = valueOf("Lua");
|
||||||
private static final LuaString QMARK = valueOf("?");
|
private static final LuaString QMARK = valueOf("?");
|
||||||
|
@ -81,8 +81,13 @@ public class PackageLib extends TwoArgFunction {
|
|||||||
|
|
||||||
/** The default value to use for package.path. This can be set with the system property
|
/** The default value to use for package.path. This can be set with the system property
|
||||||
* <code>"luaj.package.path"</code>, and is <code>"?.lua"</code> by default. */
|
* <code>"luaj.package.path"</code>, and is <code>"?.lua"</code> by default. */
|
||||||
public static String DEFAULT_LUA_PATH = System.getProperty("luaj.package.path");
|
public static String DEFAULT_LUA_PATH;
|
||||||
static {
|
static {
|
||||||
|
try {
|
||||||
|
DEFAULT_LUA_PATH = System.getProperty("luaj.package.path");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.toString());
|
||||||
|
}
|
||||||
if (DEFAULT_LUA_PATH == null)
|
if (DEFAULT_LUA_PATH == null)
|
||||||
DEFAULT_LUA_PATH = "?.lua";
|
DEFAULT_LUA_PATH = "?.lua";
|
||||||
}
|
}
|
||||||
@ -294,7 +299,7 @@ public class PackageLib extends TwoArgFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try opening the file
|
// try opening the file
|
||||||
InputStream is = globals.FINDER.findResource(filename);
|
InputStream is = globals.finder.findResource(filename);
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
try { is.close(); } catch ( java.io.IOException ioe ) {}
|
try { is.close(); } catch ( java.io.IOException ioe ) {}
|
||||||
return valueOf(filename);
|
return valueOf(filename);
|
||||||
|
@ -31,13 +31,13 @@ import java.io.InputStream;
|
|||||||
* for both the Jme and Jse platforms.
|
* for both the Jme and Jse platforms.
|
||||||
* <p>
|
* <p>
|
||||||
* The Jme version of base lib {@link BaseLib}
|
* The Jme version of base lib {@link BaseLib}
|
||||||
* implements {@link BaseLib#FINDER} via {@link Class#getResourceAsStream(String)},
|
* implements {@link Globals#finder} via {@link Class#getResourceAsStream(String)},
|
||||||
* while the Jse version {@link JseBaseLib} implements it using {@link java.io.File#File(String)}.
|
* while the Jse version {@link JseBaseLib} implements it using {@link java.io.File#File(String)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The io library does not use this API for file manipulation.
|
* The io library does not use this API for file manipulation.
|
||||||
* <p>
|
* <p>
|
||||||
* @see BaseLib
|
* @see BaseLib
|
||||||
* @see BaseLib#FINDER
|
* @see Globals#finder
|
||||||
* @see JseBaseLib
|
* @see JseBaseLib
|
||||||
* @see JmePlatform
|
* @see JmePlatform
|
||||||
* @see JsePlatform
|
* @see JsePlatform
|
||||||
|
@ -1155,19 +1155,20 @@ public class StringLib extends TwoArgFunction {
|
|||||||
if ( poff == plen || poff + 1 == plen ) {
|
if ( poff == plen || poff + 1 == plen ) {
|
||||||
error( "unbalanced pattern" );
|
error( "unbalanced pattern" );
|
||||||
}
|
}
|
||||||
if ( soff >= s.length() || s.luaByte( soff ) != p.luaByte( poff ) )
|
final int slen = s.length();
|
||||||
|
if ( soff >= slen )
|
||||||
return -1;
|
return -1;
|
||||||
else {
|
final int b = p.luaByte( poff );
|
||||||
int b = p.luaByte( poff );
|
if ( s.luaByte( soff ) != b )
|
||||||
int e = p.luaByte( poff + 1 );
|
return -1;
|
||||||
|
final int e = p.luaByte( poff + 1 );
|
||||||
int cont = 1;
|
int cont = 1;
|
||||||
while ( ++soff < s.length() ) {
|
while ( ++soff < slen ) {
|
||||||
if ( s.luaByte( soff ) == e ) {
|
if ( s.luaByte( soff ) == e ) {
|
||||||
if ( --cont == 0 ) return soff + 1;
|
if ( --cont == 0 ) return soff + 1;
|
||||||
}
|
}
|
||||||
else if ( s.luaByte( soff ) == b ) cont++;
|
else if ( s.luaByte( soff ) == b ) cont++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,11 @@ import org.luaj.vm3.lib.ResourceFinder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of {@link BaseLib} and {@link LibFunction} which implements the lua basic library functions
|
* Subclass of {@link BaseLib} and {@link LibFunction} which implements the lua basic library functions
|
||||||
* and provides a directory based {@link ResourceFinder} as the {@link #FINDER}.
|
* and provides a directory based {@link ResourceFinder} as the {@link #finder}.
|
||||||
* <p>
|
* <p>
|
||||||
* Since JME has no file system by default, {@link BaseLib} implements
|
* Since JME has no file system by default, {@link BaseLib} implements
|
||||||
* {@link ResourceFinder} using {@link Class#getResource(String)}.
|
* {@link ResourceFinder} using {@link Class#getResource(String)}.
|
||||||
* The {@link JseBaseLib} implements {@link FINDER} by scanning the current directory
|
* The {@link JseBaseLib} implements {@link finder} by scanning the current directory
|
||||||
* first, then falling back to {@link Class#getResource(String)} if that fails.
|
* first, then falling back to {@link Class#getResource(String)} if that fails.
|
||||||
* Otherwise, the behavior is the same as that of {@link BaseLib}.
|
* Otherwise, the behavior is the same as that of {@link BaseLib}.
|
||||||
* <p>
|
* <p>
|
||||||
@ -62,7 +62,7 @@ import org.luaj.vm3.lib.ResourceFinder;
|
|||||||
* @see Globals
|
* @see Globals
|
||||||
* @see BaseLib
|
* @see BaseLib
|
||||||
* @see ResourceFinder
|
* @see ResourceFinder
|
||||||
* @see {@link Globals.FINDER}
|
* @see {@link Globals.finder}
|
||||||
* @see LibFunction
|
* @see LibFunction
|
||||||
* @see JsePlatform
|
* @see JsePlatform
|
||||||
* @see org.luaj.vm3.lib.jme.JmePlatform
|
* @see org.luaj.vm3.lib.jme.JmePlatform
|
||||||
|
@ -109,7 +109,7 @@ public class LuajavaLib extends VarArgFunction {
|
|||||||
// LuaValue modname = args.arg1();
|
// LuaValue modname = args.arg1();
|
||||||
LuaValue env = args.arg(2);
|
LuaValue env = args.arg(2);
|
||||||
LuaTable t = new LuaTable();
|
LuaTable t = new LuaTable();
|
||||||
bind( t, LuajavaLib.class, NAMES, BINDCLASS );
|
bind( t, this.getClass(), NAMES, BINDCLASS );
|
||||||
env.set("luajava", t);
|
env.set("luajava", t);
|
||||||
env.get("package").get("loaded").set("luajava", t);
|
env.get("package").get("loaded").set("luajava", t);
|
||||||
return t;
|
return t;
|
||||||
|
@ -95,6 +95,21 @@ public class LuaScriptEngine extends AbstractScriptEngine implements ScriptEngin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object eval(Reader reader, Bindings bindings) throws ScriptException {
|
||||||
|
return ((LuajCompiledScript) compile(reader)).eval(context.globals, bindings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object eval(String script, Bindings bindings) throws ScriptException {
|
||||||
|
return eval(new StringReader(script), bindings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ScriptContext getScriptContext(Bindings nn) {
|
||||||
|
throw new IllegalStateException("LuajScriptEngine should not be allocating contexts.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bindings createBindings() {
|
public Bindings createBindings() {
|
||||||
return new SimpleBindings();
|
return new SimpleBindings();
|
||||||
@ -109,7 +124,7 @@ public class LuaScriptEngine extends AbstractScriptEngine implements ScriptEngin
|
|||||||
@Override
|
@Override
|
||||||
public Object eval(Reader reader, ScriptContext context)
|
public Object eval(Reader reader, ScriptContext context)
|
||||||
throws ScriptException {
|
throws ScriptException {
|
||||||
return compile(reader).eval();
|
return compile(reader).eval(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,7 +157,7 @@ public class LuaScriptEngine extends AbstractScriptEngine implements ScriptEngin
|
|||||||
return eval(((LuajContext) context).globals, context.getBindings(ScriptContext.ENGINE_SCOPE));
|
return eval(((LuajContext) context).globals, context.getBindings(ScriptContext.ENGINE_SCOPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object eval(Globals g, Bindings b) throws ScriptException {
|
Object eval(Globals g, Bindings b) throws ScriptException {
|
||||||
g.setmetatable(new BindingsMetatable(b));
|
g.setmetatable(new BindingsMetatable(b));
|
||||||
LuaFunction f = function;
|
LuaFunction f = function;
|
||||||
if (f.isclosure())
|
if (f.isclosure())
|
||||||
|
@ -103,7 +103,7 @@ public class LuajContext extends SimpleScriptContext implements ScriptContext {
|
|||||||
@Override
|
@Override
|
||||||
public void setWriter(Writer writer) {
|
public void setWriter(Writer writer) {
|
||||||
globals.STDOUT = writer != null?
|
globals.STDOUT = writer != null?
|
||||||
new PrintStream(new WriterOutputStream(writer)):
|
new PrintStream(new WriterOutputStream(writer), true):
|
||||||
stdout;
|
stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,19 @@ public class LuajContext extends SimpleScriptContext implements ScriptContext {
|
|||||||
this.w = w;
|
this.w = w;
|
||||||
}
|
}
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
w.write(b);
|
w.write(new String(new byte[] {(byte)b}));
|
||||||
|
}
|
||||||
|
public void write(byte[] b, int o, int l) throws IOException {
|
||||||
|
w.write(new String(b, o, l));
|
||||||
|
}
|
||||||
|
public void write(byte[] b) throws IOException {
|
||||||
|
w.write(new String(b));
|
||||||
|
}
|
||||||
|
public void close() throws IOException {
|
||||||
|
w.close();
|
||||||
|
}
|
||||||
|
public void flush() throws IOException {
|
||||||
|
w.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ oc:gui.Analyzer.StoredEnergy=§6Gespeicherte Energie§f: %s
|
|||||||
oc:gui.Analyzer.TotalEnergy=§6Insgesamt gespeicherte Energie§f: %s
|
oc:gui.Analyzer.TotalEnergy=§6Insgesamt gespeicherte Energie§f: %s
|
||||||
oc:gui.Analyzer.Users=§6Benutzer§f: %s
|
oc:gui.Analyzer.Users=§6Benutzer§f: %s
|
||||||
oc:gui.Chat.NewVersion=Eine neue Version ist verfügbar: %s
|
oc:gui.Chat.NewVersion=Eine neue Version ist verfügbar: %s
|
||||||
|
oc:gui.Chat.WarningFingerprint=§cWARNUNG§f - ungültige Signatur! Sollte §a'%s'§f sein, aber war §e'%s'§f. Falls du kein Modder bist und die "deobfuscated"-Version des Mods benutzt, solltest du OpenComputers erneut herunterladen, da die JAR die du benutzt vermutlich modifiziert wurde.
|
||||||
oc:gui.Chat.WarningLuaFallback=Die native Lua-Implementierung ist nicht verfügbar. Computer können ihren Ausführungszustand nicht speichern. Sie werden automatisch neu starten, sobald ein Chunk neu geladen wird.
|
oc:gui.Chat.WarningLuaFallback=Die native Lua-Implementierung ist nicht verfügbar. Computer können ihren Ausführungszustand nicht speichern. Sie werden automatisch neu starten, sobald ein Chunk neu geladen wird.
|
||||||
oc:gui.Chat.WarningPower=Es ist kein unterstützter, Strom erzeugender Mod verfügbar. Computer, Bildschirme und alle anderen Komponenten werden §lkeine§f Energie benötigen. Installiere einen der folgenden Mods, um Stromnutzung zu ermöglichen: BuildCraft, IndustrialCraft2, Thermal Expansion oder Universal Electricity. Deaktiviere Stromverbrauch in der Konfiguration, um diese Warnung zu unterdrücken.
|
oc:gui.Chat.WarningPower=Es ist kein unterstützter, Strom erzeugender Mod verfügbar. Computer, Bildschirme und alle anderen Komponenten werden §lkeine§f Energie benötigen. Installiere einen der folgenden Mods, um Stromnutzung zu ermöglichen: BuildCraft, IndustrialCraft2, Thermal Expansion oder Universal Electricity. Deaktiviere Stromverbrauch in der Konfiguration, um diese Warnung zu unterdrücken.
|
||||||
oc:gui.Chat.WarningProjectRed=Die verwendete Version von Project: Red ist nicht mit OpenComputers kompatibel. Aktualisiere bitte deine Version von Project: Red.
|
oc:gui.Chat.WarningProjectRed=Die verwendete Version von Project: Red ist nicht mit OpenComputers kompatibel. Aktualisiere bitte deine Version von Project: Red.
|
||||||
|
@ -88,6 +88,7 @@ oc:gui.Analyzer.StoredEnergy=§6Stored energy§f: %s
|
|||||||
oc:gui.Analyzer.TotalEnergy=§6Total stored energy§f: %s
|
oc:gui.Analyzer.TotalEnergy=§6Total stored energy§f: %s
|
||||||
oc:gui.Analyzer.Users=§6Users§f: %s
|
oc:gui.Analyzer.Users=§6Users§f: %s
|
||||||
oc:gui.Chat.NewVersion=A new version is available: %s
|
oc:gui.Chat.NewVersion=A new version is available: %s
|
||||||
|
oc:gui.Chat.WarningFingerprint=§cWARNING§f - fingerprint mismatch! Expected §a'%s'§f but got §e'%s'§f. Unless you are a modder and are running the deobfuscated version of the mod, it is §lstrongly§f recommended to redownload OpenComputers, because the JAR you are using may have been tampered with.
|
||||||
oc:gui.Chat.WarningLuaFallback=Native Lua libraries are not available, computers will not be able to persist their state. They will reboot on chunk reloads.
|
oc:gui.Chat.WarningLuaFallback=Native Lua libraries are not available, computers will not be able to persist their state. They will reboot on chunk reloads.
|
||||||
oc:gui.Chat.WarningPower=No supported power providing mod available. Computers, screens and all other components will §lnot§f require energy. Install one of the following mods to enable power: BuildCraft, IndustrialCraft2, Thermal Expansion or Universal Electricity. Disable power in the config to suppress this warning.
|
oc:gui.Chat.WarningPower=No supported power providing mod available. Computers, screens and all other components will §lnot§f require energy. Install one of the following mods to enable power: BuildCraft, IndustrialCraft2, Thermal Expansion or Universal Electricity. Disable power in the config to suppress this warning.
|
||||||
oc:gui.Chat.WarningProjectRed=You are using a version of Project: Red that is incompatible with OpenComputers. Try updating your version of Project: Red.
|
oc:gui.Chat.WarningProjectRed=You are using a version of Project: Red that is incompatible with OpenComputers. Try updating your version of Project: Red.
|
||||||
|
@ -3,14 +3,13 @@ package li.cil.oc
|
|||||||
import cpw.mods.fml.common.Mod
|
import cpw.mods.fml.common.Mod
|
||||||
import cpw.mods.fml.common.Mod.EventHandler
|
import cpw.mods.fml.common.Mod.EventHandler
|
||||||
import cpw.mods.fml.common.SidedProxy
|
import cpw.mods.fml.common.SidedProxy
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent
|
import cpw.mods.fml.common.event.{FMLFingerprintViolationEvent, FMLInitializationEvent, FMLPostInitializationEvent, FMLPreInitializationEvent}
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent
|
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent
|
|
||||||
import cpw.mods.fml.common.network.FMLEventChannel
|
import cpw.mods.fml.common.network.FMLEventChannel
|
||||||
import java.util.logging.Logger
|
import java.util.logging.Logger
|
||||||
import li.cil.oc.common.Proxy
|
import li.cil.oc.common.Proxy
|
||||||
|
|
||||||
@Mod(modid = "OpenComputers", modLanguage = "scala", useMetadata = true)
|
@Mod(modid = "OpenComputers", modLanguage = "scala",
|
||||||
|
certificateFingerprint = "@FINGERPRINT@", useMetadata = true)
|
||||||
object OpenComputers {
|
object OpenComputers {
|
||||||
val log = Logger.getLogger("OpenComputers")
|
val log = Logger.getLogger("OpenComputers")
|
||||||
|
|
||||||
@ -19,6 +18,11 @@ object OpenComputers {
|
|||||||
|
|
||||||
var channel: FMLEventChannel = _
|
var channel: FMLEventChannel = _
|
||||||
|
|
||||||
|
var tampered: Option[FMLFingerprintViolationEvent] = None
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
def invalidFingerprint(e: FMLFingerprintViolationEvent) = tampered = Some(e)
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
def preInit(e: FMLPreInitializationEvent) = proxy.preInit(e)
|
def preInit(e: FMLPreInitializationEvent) = proxy.preInit(e)
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package li.cil.oc.common
|
package li.cil.oc.common
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler
|
||||||
import cpw.mods.fml.common.gameevent.PlayerEvent._
|
import cpw.mods.fml.common.gameevent.PlayerEvent._
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent
|
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent
|
||||||
import cpw.mods.fml.common.{Loader, FMLCommonHandler}
|
|
||||||
import li.cil.oc.api.Network
|
import li.cil.oc.api.Network
|
||||||
import li.cil.oc.server.driver.Registry
|
import li.cil.oc.server.driver.Registry
|
||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
import li.cil.oc.util.LuaStateFactory
|
import li.cil.oc.util.LuaStateFactory
|
||||||
import li.cil.oc.util.mods.ProjectRed
|
import li.cil.oc.util.mods.ProjectRed
|
||||||
import li.cil.oc.{UpdateCheck, Items, Settings}
|
import li.cil.oc.{OpenComputers, UpdateCheck, Items, Settings}
|
||||||
import net.minecraft.entity.player.EntityPlayerMP
|
import net.minecraft.entity.player.EntityPlayerMP
|
||||||
import net.minecraft.item.{ItemMap, ItemStack}
|
import net.minecraft.item.{ItemMap, ItemStack}
|
||||||
import net.minecraft.server.MinecraftServer
|
import net.minecraft.server.MinecraftServer
|
||||||
@ -57,6 +57,11 @@ object EventHandler {
|
|||||||
player.addChatMessage(new ChatComponentText("§aOpenComputers§f: ").appendSibling(
|
player.addChatMessage(new ChatComponentText("§aOpenComputers§f: ").appendSibling(
|
||||||
new ChatComponentTranslation(Settings.namespace + "gui.Chat.WarningPower")))
|
new ChatComponentTranslation(Settings.namespace + "gui.Chat.WarningPower")))
|
||||||
}
|
}
|
||||||
|
OpenComputers.tampered match {
|
||||||
|
case Some(event) => player.addChatMessage(new ChatComponentText("§aOpenComputers§f: ").appendSibling(
|
||||||
|
new ChatComponentTranslation(Settings.namespace + "gui.Chat.WarningFingerprint", event.expectedFingerprint, event.fingerprints.toArray.mkString(", "))))
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
// Do update check in local games and for OPs.
|
// Do update check in local games and for OPs.
|
||||||
if (!MinecraftServer.getServer.isDedicatedServer || MinecraftServer.getServer.getConfigurationManager.isPlayerOpped(player.getCommandSenderName)) {
|
if (!MinecraftServer.getServer.isDedicatedServer || MinecraftServer.getServer.getConfigurationManager.isPlayerOpped(player.getCommandSenderName)) {
|
||||||
UpdateCheck.checkForPlayer(player)
|
UpdateCheck.checkForPlayer(player)
|
||||||
|
@ -6,9 +6,12 @@ import java.util.logging.Level
|
|||||||
import li.cil.oc.{OpenComputers, Settings}
|
import li.cil.oc.{OpenComputers, Settings}
|
||||||
import net.minecraft.world.ChunkCoordIntPair
|
import net.minecraft.world.ChunkCoordIntPair
|
||||||
import net.minecraftforge.common.DimensionManager
|
import net.minecraftforge.common.DimensionManager
|
||||||
import net.minecraftforge.event.world.WorldEvent
|
import net.minecraftforge.event.world.{ChunkDataEvent, WorldEvent}
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
|
// Used by the native lua state to store kernel and stack data in auxiliary
|
||||||
|
// files instead of directly in the tile entity data, avoiding potential
|
||||||
|
// problems with the tile entity data becoming too large.
|
||||||
object SaveHandler {
|
object SaveHandler {
|
||||||
val saveData = mutable.Map.empty[ChunkCoordIntPair, mutable.Map[String, Array[Byte]]]
|
val saveData = mutable.Map.empty[ChunkCoordIntPair, mutable.Map[String, Array[Byte]]]
|
||||||
|
|
||||||
@ -46,19 +49,17 @@ object SaveHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by the native lua state to store kernel and stack data in auxiliary
|
|
||||||
// files instead of directly in the tile entity data, avoiding potential
|
|
||||||
// problems with the tile entity data becoming too large.
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onWorldSave(e: WorldEvent.Save) = saveData.synchronized {
|
def onChunkSave(e: ChunkDataEvent.Save) = saveData.synchronized {
|
||||||
val path = savePath
|
val path = savePath
|
||||||
path.mkdirs()
|
val chunk = e.getChunk.getChunkCoordIntPair
|
||||||
for ((chunk, entries) <- saveData) {
|
|
||||||
val chunkPath = new io.File(path, s"${chunk.chunkXPos}.${chunk.chunkZPos}")
|
val chunkPath = new io.File(path, s"${chunk.chunkXPos}.${chunk.chunkZPos}")
|
||||||
chunkPath.mkdirs()
|
|
||||||
if (chunkPath.exists && chunkPath.isDirectory) {
|
if (chunkPath.exists && chunkPath.isDirectory) {
|
||||||
for (file <- chunkPath.listFiles()) file.delete()
|
for (file <- chunkPath.listFiles()) file.delete()
|
||||||
}
|
}
|
||||||
|
saveData.get(chunk) match {
|
||||||
|
case Some(entries) =>
|
||||||
|
chunkPath.mkdirs()
|
||||||
for ((name, data) <- entries) {
|
for ((name, data) <- entries) {
|
||||||
val file = new io.File(chunkPath, name)
|
val file = new io.File(chunkPath, name)
|
||||||
try {
|
try {
|
||||||
@ -71,7 +72,12 @@ object SaveHandler {
|
|||||||
case e: io.IOException => OpenComputers.log.log(Level.WARNING, s"Error saving auxiliary tile entity data to '${file.getAbsolutePath}.", e)
|
case e: io.IOException => OpenComputers.log.log(Level.WARNING, s"Error saving auxiliary tile entity data to '${file.getAbsolutePath}.", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case _ => chunkPath.delete()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
def onWorldSave(e: WorldEvent.Save) = saveData.synchronized {
|
||||||
saveData.clear()
|
saveData.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -620,7 +620,7 @@ object Robot {
|
|||||||
catch {
|
catch {
|
||||||
case t: Throwable =>
|
case t: Throwable =>
|
||||||
OpenComputers.log.log(Level.WARNING, "Failed loading robot name list.", t)
|
OpenComputers.log.log(Level.WARNING, "Failed loading robot name list.", t)
|
||||||
Array.empty
|
Array.empty[String]
|
||||||
}
|
}
|
||||||
|
|
||||||
def randomName = names((math.random * names.length).toInt)
|
def randomName = names((math.random * names.length).toInt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user