diff --git a/build.gradle b/build.gradle index 3e548226a..ec41249e9 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ minecraft { } server { - workingDirectory project.file("run/server-${mc_version}") + workingDirectory project.file("run/server") property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' @@ -388,14 +388,14 @@ license { it.configure { include("**/*.java") exclude("dan200/computercraft/api/**") - header rootProject.file('config/license/main.txt') + header file('config/license/main.txt') } } [licenseTest, licenseFormatTest].forEach { it.configure { include("**/*.java") - header rootProject.file('config/license/main.txt') + header file('config/license/main.txt') } } @@ -412,7 +412,7 @@ task licenseFormatAPI(type: LicenseFormat); it.configure { source = sourceSets.main.java include("dan200/computercraft/api/**") - header rootProject.file('config/license/api.txt') + header file('config/license/api.txt') } } @@ -430,7 +430,7 @@ task checkRelease { def ok = true // Check we're targetting the current version - def whatsnew = new File("src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt").readLines() + def whatsnew = new File(projectDir, "src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt").readLines() if (whatsnew[0] != "New features in CC: Tweaked $mod_version") { ok = false project.logger.error("Expected `whatsnew.txt' to target $mod_version.") @@ -447,7 +447,7 @@ task checkRelease { // Check whatsnew and changelog match. def versionChangelog = "# " + whatsnew.join("\n") - def changelog = new File("src/main/resources/data/computercraft/lua/rom/help/changelog.txt").getText() + def changelog = new File(projectDir, "src/main/resources/data/computercraft/lua/rom/help/changelog.txt").getText() if (!changelog.startsWith(versionChangelog)) { ok = false project.logger.error("whatsnew and changelog are not in sync") @@ -535,7 +535,7 @@ githubRelease { tagName "v${mc_version}-${mod_version}" releaseName "[${mc_version}] ${mod_version}" body { - "## " + new File("src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt") + "## " + new File(projectDir, "src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt") .readLines() .takeWhile { it != 'Type "help changelog" to see the full version history.' } .join("\n").trim() diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 03959f78e..89de6f153 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -7,7 +7,7 @@ - + diff --git a/src/generated/resources/data/computercraft/recipes/disk_1.json b/src/generated/resources/data/computercraft/recipes/disk_1.json index 66ce73a90..f062cd66f 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_1.json +++ b/src/generated/resources/data/computercraft/recipes/disk_1.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:1118481}" + "nbt": "{Color:1118481}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_10.json b/src/generated/resources/data/computercraft/recipes/disk_10.json index 9c064f0fb..45771c169 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_10.json +++ b/src/generated/resources/data/computercraft/recipes/disk_10.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:15905484}" + "nbt": "{Color:15905484}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_11.json b/src/generated/resources/data/computercraft/recipes/disk_11.json index bfd6b21dc..d86dbf599 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_11.json +++ b/src/generated/resources/data/computercraft/recipes/disk_11.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:8375321}" + "nbt": "{Color:8375321}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_12.json b/src/generated/resources/data/computercraft/recipes/disk_12.json index 7fa0ff4be..b1306ad27 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_12.json +++ b/src/generated/resources/data/computercraft/recipes/disk_12.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:14605932}" + "nbt": "{Color:14605932}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_13.json b/src/generated/resources/data/computercraft/recipes/disk_13.json index ab237e75c..3305efea1 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_13.json +++ b/src/generated/resources/data/computercraft/recipes/disk_13.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:10072818}" + "nbt": "{Color:10072818}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_14.json b/src/generated/resources/data/computercraft/recipes/disk_14.json index 458ad2a71..d5ed6873b 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_14.json +++ b/src/generated/resources/data/computercraft/recipes/disk_14.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:15040472}" + "nbt": "{Color:15040472}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_15.json b/src/generated/resources/data/computercraft/recipes/disk_15.json index 35147838e..e296c592a 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_15.json +++ b/src/generated/resources/data/computercraft/recipes/disk_15.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:15905331}" + "nbt": "{Color:15905331}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_16.json b/src/generated/resources/data/computercraft/recipes/disk_16.json index 1f86b573a..e62f6c34f 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_16.json +++ b/src/generated/resources/data/computercraft/recipes/disk_16.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:15790320}" + "nbt": "{Color:15790320}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_2.json b/src/generated/resources/data/computercraft/recipes/disk_2.json index 40f55f5a4..ee4f4ba1d 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_2.json +++ b/src/generated/resources/data/computercraft/recipes/disk_2.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:13388876}" + "nbt": "{Color:13388876}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_3.json b/src/generated/resources/data/computercraft/recipes/disk_3.json index 5ed4b4d72..c8a8fae24 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_3.json +++ b/src/generated/resources/data/computercraft/recipes/disk_3.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:5744206}" + "nbt": "{Color:5744206}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_4.json b/src/generated/resources/data/computercraft/recipes/disk_4.json index ecc80c9e2..109934949 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_4.json +++ b/src/generated/resources/data/computercraft/recipes/disk_4.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:8349260}" + "nbt": "{Color:8349260}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_5.json b/src/generated/resources/data/computercraft/recipes/disk_5.json index 94beac68a..53b5186b4 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_5.json +++ b/src/generated/resources/data/computercraft/recipes/disk_5.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:3368652}" + "nbt": "{Color:3368652}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_6.json b/src/generated/resources/data/computercraft/recipes/disk_6.json index 0416fba6e..b45ca974c 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_6.json +++ b/src/generated/resources/data/computercraft/recipes/disk_6.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:11691749}" + "nbt": "{Color:11691749}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_7.json b/src/generated/resources/data/computercraft/recipes/disk_7.json index 99f64b544..1fb41dea8 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_7.json +++ b/src/generated/resources/data/computercraft/recipes/disk_7.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:5020082}" + "nbt": "{Color:5020082}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_8.json b/src/generated/resources/data/computercraft/recipes/disk_8.json index be1b7fea9..8043bf87f 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_8.json +++ b/src/generated/resources/data/computercraft/recipes/disk_8.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:10066329}" + "nbt": "{Color:10066329}" } } \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/disk_9.json b/src/generated/resources/data/computercraft/recipes/disk_9.json index 48620dbdd..c9593d5f2 100644 --- a/src/generated/resources/data/computercraft/recipes/disk_9.json +++ b/src/generated/resources/data/computercraft/recipes/disk_9.json @@ -14,6 +14,6 @@ ], "result": { "item": "computercraft:disk", - "nbt": "{color:5000268}" + "nbt": "{Color:5000268}" } } \ No newline at end of file diff --git a/src/main/java/dan200/computercraft/core/apis/FSAPI.java b/src/main/java/dan200/computercraft/core/apis/FSAPI.java index 6ae65f62a..fada96ecd 100644 --- a/src/main/java/dan200/computercraft/core/apis/FSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/FSAPI.java @@ -471,8 +471,8 @@ public class FSAPI implements ILuaAPI /** * Get attributes about a specific file or folder. * - * The returned attributes table contains information about the size of the file, whether it is a directory, and - * when it was created and last modified. + * The returned attributes table contains information about the size of the file, whether it is a directory, + * when it was created and last modified, and whether it is read only. * * The creation and modification times are given as the number of milliseconds since the UNIX epoch. This may be * given to {@link OSAPI#date} in order to convert it to more usable form. @@ -480,7 +480,7 @@ public class FSAPI implements ILuaAPI * @param path The path to get attributes for. * @return The resulting attributes. * @throws LuaException If the path does not exist. - * @cc.treturn { size = number, isDir = boolean, created = number, modified = number } The resulting attributes. + * @cc.treturn { size = number, isDir = boolean, isReadOnly = boolean, created = number, modified = number } The resulting attributes. * @see #getSize If you only care about the file's size. * @see #isDir If you only care whether a path is a directory or not. */ @@ -496,6 +496,7 @@ public class FSAPI implements ILuaAPI result.put( "created", getFileTime( attributes.creationTime() ) ); result.put( "size", attributes.isDirectory() ? 0 : attributes.size() ); result.put( "isDir", attributes.isDirectory() ); + result.put( "isReadOnly", fileSystem.isReadOnly( path ) ); return result; } catch( FileSystemException e ) diff --git a/src/main/java/dan200/computercraft/data/Recipes.java b/src/main/java/dan200/computercraft/data/Recipes.java index 8e67ab1e6..c99b3940f 100644 --- a/src/main/java/dan200/computercraft/data/Recipes.java +++ b/src/main/java/dan200/computercraft/data/Recipes.java @@ -10,6 +10,7 @@ import dan200.computercraft.data.Tags.CCTags; import dan200.computercraft.shared.PocketUpgrades; import dan200.computercraft.shared.Registry; import dan200.computercraft.shared.TurtleUpgrades; +import dan200.computercraft.shared.common.IColouredItem; import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory; import dan200.computercraft.shared.turtle.items.TurtleItemFactory; @@ -64,7 +65,7 @@ public class Recipes extends RecipeProvider .addCriterion( "has_drive", inventoryChange( Registry.ModBlocks.DISK_DRIVE.get() ) ) .build( RecipeWrapper.wrap( ImpostorShapelessRecipe.SERIALIZER, add, - x -> x.putInt( "color", colour.getHex() ) + x -> x.putInt( IColouredItem.NBT_COLOUR, colour.getHex() ) ), new ResourceLocation( ComputerCraft.MOD_ID, "disk_" + (colour.ordinal() + 1) ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java b/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java index d3057a21b..f3b016d61 100644 --- a/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java +++ b/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java @@ -56,7 +56,7 @@ public final class RepeatArgumentType implements ArgumentType> public static RepeatArgumentType some( ArgumentType appender, SimpleCommandExceptionType missing ) { - return new RepeatArgumentType<>( appender, List::add, true, missing ); + return new RepeatArgumentType<>( appender, List::add, false, missing ); } public static RepeatArgumentType> someFlat( ArgumentType> appender, SimpleCommandExceptionType missing ) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/edit.lua b/src/main/resources/data/computercraft/lua/rom/programs/edit.lua index 8f0af9356..8656798df 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/edit.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/edit.lua @@ -667,8 +667,8 @@ while bRunning do end end - elseif param == keys.enter then - -- Enter + elseif param == keys.enter or param == keys.numPadEnter then + -- Enter/Numpad Enter if not bMenu and not bReadOnly then -- Newline local sLine = tLines[y] diff --git a/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua b/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua index 862bc2afe..ad1f96b34 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua @@ -350,7 +350,7 @@ local function accessMenu() selection = #mChoices end - elseif key == keys.enter then + elseif key == keys.enter or key == keys.numPadEnter then -- Select an option return menu_choices[mChoices[selection]]() elseif key == keys.leftCtrl or keys == keys.rightCtrl then diff --git a/src/main/resources/data/computercraft/lua/rom/programs/fun/worm.lua b/src/main/resources/data/computercraft/lua/rom/programs/fun/worm.lua index eaaa54869..9d98ac2fd 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/fun/worm.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/fun/worm.lua @@ -199,8 +199,8 @@ while true do drawMenu() drawFrontend() end - elseif key == keys.enter then - -- Enter + elseif key == keys.enter or key == keys.numPadEnter then + -- Enter/Numpad Enter break end end diff --git a/src/main/resources/data/computercraft/lua/rom/programs/pocket/falling.lua b/src/main/resources/data/computercraft/lua/rom/programs/pocket/falling.lua index deb01c380..62e8e7eae 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/pocket/falling.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/pocket/falling.lua @@ -546,7 +546,7 @@ local function playGame() msgBox("Game Over!") while true do local _, k = os.pullEvent("key") - if k == keys.space or k == keys.enter then + if k == keys.space or k == keys.enter or k == keys.numPadEnter then break end end @@ -627,7 +627,7 @@ local function runMenu() elseif key == keys.down or key == keys.s then selected = selected % 2 + 1 drawMenu() - elseif key == keys.enter or key == keys.space then + elseif key == keys.enter or key == keys.numPadEnter or key == keys.space then break --begin play! end end diff --git a/src/test/resources/test-rom/spec/apis/fs_spec.lua b/src/test/resources/test-rom/spec/apis/fs_spec.lua index 9a861af34..32503598e 100644 --- a/src/test/resources/test-rom/spec/apis/fs_spec.lua +++ b/src/test/resources/test-rom/spec/apis/fs_spec.lua @@ -194,7 +194,7 @@ describe("The fs library", function() end) it("returns information about read-only mounts", function() - expect(fs.attributes("rom")):matches { isDir = true, size = 0 } + expect(fs.attributes("rom")):matches { isDir = true, size = 0, isReadOnly = true } end) it("returns information about files", function() @@ -206,7 +206,7 @@ describe("The fs library", function() h.close() local attributes = fs.attributes("tmp/basic-file") - expect(attributes):matches { isDir = false, size = 25 } + expect(attributes):matches { isDir = false, size = 25, isReadOnly = false } if attributes.created - now >= 1000 then fail(("Expected created time (%d) to be within 1000ms of now (%d"):format(attributes.created, now))