mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'OC1.3-MC1.6.4' of github.com:MightyPirates/OpenComputers into OC1.3-MC1.7.10
This commit is contained in:
commit
b1f64a6615
@ -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,31 +181,33 @@ 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 {
|
||||
Files.walkFileTree(statePath.toPath, new FileVisitor[Path] {
|
||||
override def visitFile(file: Path, attrs: BasicFileAttributes) = {
|
||||
file.toFile.setLastModified(System.currentTimeMillis())
|
||||
FileVisitResult.CONTINUE
|
||||
}
|
||||
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)) visitJava17()
|
||||
else visitJava16()
|
||||
}
|
||||
|
||||
override def visitFileFailed(file: Path, exc: IOException) = FileVisitResult.CONTINUE
|
||||
|
||||
override def preVisitDirectory(dir: Path, attrs: BasicFileAttributes) = FileVisitResult.CONTINUE
|
||||
|
||||
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)
|
||||
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())
|
||||
FileVisitResult.CONTINUE
|
||||
}
|
||||
|
||||
override def visitFileFailed(file: Path, exc: IOException) = FileVisitResult.CONTINUE
|
||||
|
||||
override def preVisitDirectory(dir: Path, attrs: BasicFileAttributes) = FileVisitResult.CONTINUE
|
||||
|
||||
override def postVisitDirectory(dir: Path, exc: IOException) = FileVisitResult.CONTINUE
|
||||
})
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user