Merge branch 'OC1.3-MC1.6.4' of github.com:MightyPirates/OpenComputers into OC1.3-MC1.7.10

This commit is contained in:
Florian Nücke 2014-09-13 23:30:01 +02:00
commit b1f64a6615
3 changed files with 28 additions and 25 deletions

View File

@ -13,6 +13,7 @@ import net.minecraft.nbt.{CompressedStreamTools, NBTTagCompound}
import net.minecraft.world.{ChunkCoordIntPair, World}
import net.minecraftforge.common.DimensionManager
import net.minecraftforge.event.world.{ChunkDataEvent, WorldEvent}
import org.apache.commons.lang3.{JavaVersion, SystemUtils}
import scala.collection.mutable
@ -180,7 +181,21 @@ object SaveHandler {
// Touch all externally saved data when loading, to avoid it getting
// deleted in the next save (because the now - save time will usually
// be larger than the time out after loading a world again).
try {
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)) visitJava17()
else visitJava16()
}
private def visitJava16() {
// This may run into infinite loops if there are evil symlinks.
// But that's really not something I'm bothered by, it's a fallback.
def recurse(file: File) {
file.setLastModified(System.currentTimeMillis())
if (file.isDirectory) file.listFiles().foreach(recurse)
}
recurse(statePath)
}
private def visitJava17() {
Files.walkFileTree(statePath.toPath, new FileVisitor[Path] {
override def visitFile(file: Path, attrs: BasicFileAttributes) = {
file.toFile.setLastModified(System.currentTimeMillis())
@ -194,18 +209,6 @@ object SaveHandler {
override def postVisitDirectory(dir: Path, exc: IOException) = FileVisitResult.CONTINUE
})
}
catch {
case _: Throwable =>
// Most likely we're on Java 1.6, so we can't use the walker...
// Which means we may run into infinite loops if there are
// evil symlinks. But that's really not something I'm bothered by.
def recurse(file: File) {
file.setLastModified(System.currentTimeMillis())
if (file.isDirectory) file.listFiles().foreach(recurse)
}
recurse(statePath)
}
}
@SubscribeEvent
def onWorldSave(e: WorldEvent.Save) {

View File

@ -51,7 +51,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
lua.pushScalaFunction(lua => {
if (lua.isNoneOrNil(1)) owner.bootAddress = ""
else owner.bootAddress = lua.checkString(1)
else owner.bootAddress = lua.checkString(1).take(36)
0
})
lua.setField(-2, "setBootAddress")

View File

@ -35,7 +35,7 @@ class ComputerAPI(owner: LuaJLuaArchitecture) extends LuaJAPI(owner) {
computer.set("setBootAddress", (args: Varargs) => {
if (args.isnoneornil(1)) owner.bootAddress = ""
else owner.bootAddress = args.checkjstring(1)
else owner.bootAddress = args.checkjstring(1).take(36)
LuaValue.NIL
})