From 74b9f5dcb0a2f441d87212af9fe0ce6d282ba7cf Mon Sep 17 00:00:00 2001 From: Bluenaxela Date: Mon, 24 Aug 2020 23:55:24 -0700 Subject: [PATCH 01/11] Fix FileSystemWrapperMount.isDirectory() Pretty sure FileSystemWrapperMount.isDirectory() should call Filesystem.isDir(), not Filesystem.exists() --- .../computercraft/core/filesystem/FileSystemWrapperMount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java b/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java index 40e4634d8..f22e33654 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java +++ b/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java @@ -124,7 +124,7 @@ public class FileSystemWrapperMount implements IFileSystem { try { - return m_filesystem.exists( path ); + return m_filesystem.isDir( path ); } catch( FileSystemException e ) { From d5368d07194106ccad407f09e1838cf91faeffe3 Mon Sep 17 00:00:00 2001 From: JackMacWindows Date: Fri, 4 Sep 2020 12:35:46 -0400 Subject: [PATCH 02/11] Add date-specific MOTDs (like Minecraft) (#533) --- .../computercraft/lua/rom/programs/motd.lua | 29 ++++++++++++------- .../test-rom/spec/programs/motd_spec.lua | 28 ++++++++++++++++-- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/motd.lua b/src/main/resources/data/computercraft/lua/rom/programs/motd.lua index c8c75a40b..57ab7b916 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/motd.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/motd.lua @@ -1,15 +1,24 @@ -local tMotd = {} +local date = os.date("*t") +if date.month == 1 and date.day == 1 then + print("Happy new year!") +elseif date.month == 12 and date.day == 24 then + print("Merry X-mas!") +elseif date.month == 10 and date.day == 31 then + print("OOoooOOOoooo! Spooky!") +else + local tMotd = {} -for sPath in string.gmatch(settings.get("motd.path"), "[^:]+") do - if fs.exists(sPath) then - for sLine in io.lines(sPath) do - table.insert(tMotd, sLine) + for sPath in string.gmatch(settings.get("motd.path"), "[^:]+") do + if fs.exists(sPath) then + for sLine in io.lines(sPath) do + table.insert(tMotd, sLine) + end end end -end -if #tMotd == 0 then - print("missingno") -else - print(tMotd[math.random(1, #tMotd)]) + if #tMotd == 0 then + print("missingno") + else + print(tMotd[math.random(1, #tMotd)]) + end end diff --git a/src/test/resources/test-rom/spec/programs/motd_spec.lua b/src/test/resources/test-rom/spec/programs/motd_spec.lua index 72becbf30..d426fb6e7 100644 --- a/src/test/resources/test-rom/spec/programs/motd_spec.lua +++ b/src/test/resources/test-rom/spec/programs/motd_spec.lua @@ -1,14 +1,36 @@ local capture = require "test_helpers".capture_program describe("The motd program", function() + local function setup_date(month, day) + stub(os, "date", function() return { month = month, day = day } end) + end - it("displays MODT", function() - local file = fs.open("/modt_check.txt", "w") + it("displays MOTD", function() + setup_date(0, 0) + local file = fs.open("/motd_check.txt", "w") file.write("Hello World!") file.close() - settings.set("motd.path", "/modt_check.txt") + settings.set("motd.path", "/motd_check.txt") expect(capture(stub, "motd")) :matches { ok = true, output = "Hello World!\n", error = "" } end) + + it("displays date-specific MOTD (1/1)", function() + setup_date(1, 1) + expect(capture(stub, "motd")) + :matches { ok = true, output = "Happy new year!\n", error = "" } + end) + + it("displays date-specific MOTD (10/31)", function() + setup_date(10, 31) + expect(capture(stub, "motd")) + :matches { ok = true, output = "OOoooOOOoooo! Spooky!\n", error = "" } + end) + + it("displays date-specific MOTD (12/24)", function() + setup_date(12, 24) + expect(capture(stub, "motd")) + :matches { ok = true, output = "Merry X-mas!\n", error = "" } + end) end) From 73657410888ba9fadcbeae67c3180c99aee62f9a Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 5 Sep 2020 10:59:39 +0100 Subject: [PATCH 03/11] Don't use entity.captureDrops at all. This really should have been removed in 9e2232d24045af46b57162f3c3213e622e67bfe9. Otherwise we don't drop these items into the world at all. Fixes #537. --- .../java/dan200/computercraft/shared/util/DropConsumer.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/util/DropConsumer.java b/src/main/java/dan200/computercraft/shared/util/DropConsumer.java index 14200f0eb..477ad73de 100644 --- a/src/main/java/dan200/computercraft/shared/util/DropConsumer.java +++ b/src/main/java/dan200/computercraft/shared/util/DropConsumer.java @@ -42,8 +42,6 @@ public final class DropConsumer dropEntity = entity; dropWorld = entity.world; dropBounds = new AxisAlignedBB( entity.getPosition() ).grow( 2, 2, 2 ); - - entity.captureDrops( new ArrayList<>() ); } public static void set( World world, BlockPos pos, Function consumer ) @@ -86,7 +84,7 @@ public final class DropConsumer } } - @SubscribeEvent + @SubscribeEvent( priority = EventPriority.LOW ) public static void onLivingDrops( LivingDropsEvent drops ) { if( dropEntity == null || drops.getEntity() != dropEntity ) return; From 5155e18de279a193c558aa029963486fd1294769 Mon Sep 17 00:00:00 2001 From: Weblate Date: Mon, 7 Sep 2020 03:33:36 +0000 Subject: [PATCH 04/11] Added translation for Vietnamese Co-authored-by: Boom --- src/main/resources/assets/computercraft/lang/vi.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/main/resources/assets/computercraft/lang/vi.json diff --git a/src/main/resources/assets/computercraft/lang/vi.json b/src/main/resources/assets/computercraft/lang/vi.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/src/main/resources/assets/computercraft/lang/vi.json @@ -0,0 +1 @@ +{} From 7e121ff72f2b1504cd6af47b57500876682bac45 Mon Sep 17 00:00:00 2001 From: Weblate Date: Mon, 7 Sep 2020 06:37:58 +0000 Subject: [PATCH 05/11] Translations for Vietnamese Co-authored-by: Boom --- .../assets/computercraft/lang/vi.json | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/computercraft/lang/vi.json b/src/main/resources/assets/computercraft/lang/vi.json index 0967ef424..3983a91ae 100644 --- a/src/main/resources/assets/computercraft/lang/vi.json +++ b/src/main/resources/assets/computercraft/lang/vi.json @@ -1 +1,39 @@ -{} +{ + "gui.computercraft.tooltip.disk_id": "ID đĩa: %s", + "upgrade.computercraft.speaker.adjective": "Ồn ào", + "upgrade.computercraft.wireless_modem_advanced.adjective": "Ender", + "upgrade.computercraft.wireless_modem_normal.adjective": "Không dây", + "upgrade.minecraft.crafting_table.adjective": "Chế tạo", + "upgrade.minecraft.diamond_hoe.adjective": "Trồng trọt", + "upgrade.minecraft.diamond_axe.adjective": "Đốn", + "upgrade.minecraft.diamond_pickaxe.adjective": "Khai thác", + "upgrade.minecraft.diamond_shovel.adjective": "Đào", + "item.computercraft.pocket_computer_advanced.upgraded": "Máy tính bỏ túi tiên tiến %s", + "item.computercraft.pocket_computer_advanced": "Máy tính bỏ túi tiên tiến", + "item.computercraft.pocket_computer_normal.upgraded": "Máy tính bỏ túi %s", + "item.computercraft.pocket_computer_normal": "Máy tính bỏ túi", + "item.computercraft.printed_book": "Sách in", + "item.computercraft.printed_page": "Trang in", + "item.computercraft.treasure_disk": "Đĩa mềm", + "item.computercraft.disk": "Đĩa mềm", + "block.computercraft.turtle_advanced.upgraded_twice": "Rùa tiên tiến %s %s", + "block.computercraft.turtle_advanced.upgraded": "Rùa tiên tiến %s", + "block.computercraft.turtle_advanced": "Rùa tiên tiến", + "block.computercraft.turtle_normal.upgraded_twice": "Rùa %s %s", + "block.computercraft.turtle_normal.upgraded": "Rùa %s", + "block.computercraft.turtle_normal": "Rùa", + "block.computercraft.wired_modem_full": "Modem có dây", + "block.computercraft.cable": "Dây cáp mạng", + "block.computercraft.wired_modem": "Modem có dây", + "block.computercraft.wireless_modem_advanced": "Modem Ender", + "block.computercraft.wireless_modem_normal": "Modem không dây", + "block.computercraft.monitor_advanced": "Màn hình tiên tiếng", + "block.computercraft.monitor_normal": "Màn hình", + "block.computercraft.speaker": "Loa", + "block.computercraft.printer": "Máy in", + "block.computercraft.disk_drive": "Ỗ đĩa", + "block.computercraft.computer_command": "Máy tính điều khiển", + "block.computercraft.computer_normal": "Máy tính", + "itemGroup.computercraft": "ComputerCraft", + "block.computercraft.computer_advanced": "Máy tính tiên tiến" +} From ae6124d1f477487abab1858abde8c4ec49dfee3c Mon Sep 17 00:00:00 2001 From: Weblate Date: Tue, 8 Sep 2020 03:57:52 +0000 Subject: [PATCH 06/11] Translations for Vietnamese Co-authored-by: Boom --- .../resources/assets/computercraft/lang/vi.json | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/computercraft/lang/vi.json b/src/main/resources/assets/computercraft/lang/vi.json index 3983a91ae..b4261b8cb 100644 --- a/src/main/resources/assets/computercraft/lang/vi.json +++ b/src/main/resources/assets/computercraft/lang/vi.json @@ -1,5 +1,5 @@ { - "gui.computercraft.tooltip.disk_id": "ID đĩa: %s", + "gui.computercraft.tooltip.disk_id": "ID của đĩa: %s", "upgrade.computercraft.speaker.adjective": "Ồn ào", "upgrade.computercraft.wireless_modem_advanced.adjective": "Ender", "upgrade.computercraft.wireless_modem_normal.adjective": "Không dây", @@ -35,5 +35,14 @@ "block.computercraft.computer_command": "Máy tính điều khiển", "block.computercraft.computer_normal": "Máy tính", "itemGroup.computercraft": "ComputerCraft", - "block.computercraft.computer_advanced": "Máy tính tiên tiến" + "block.computercraft.computer_advanced": "Máy tính tiên tiến", + "tracking_field.computercraft.websocket_incoming.name": "Websocket đến", + "tracking_field.computercraft.websocket_outgoing.name": "Websocket đi", + "gui.computercraft.tooltip.computer_id": "ID của máy tính: %s", + "tracking_field.computercraft.coroutines_dead.name": "Coroutine bỏ đi", + "tracking_field.computercraft.coroutines_created.name": "Coroutine đã tạo", + "tracking_field.computercraft.http_download.name": "HTTP tải xuống", + "tracking_field.computercraft.http_upload.name": "HTTP tải lên", + "tracking_field.computercraft.http.name": "Yêu cầu HTTP", + "gui.computercraft.tooltip.copy": "Sao chép vào clipboard" } From cefde3f0037925ed59c531305986163f1cde8530 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 8 Sep 2020 18:11:20 +0100 Subject: [PATCH 07/11] Also block 0.0.0.0/8 See MightyPirates/OpenComputers#3356 --- src/main/java/dan200/computercraft/ComputerCraft.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 6a833d0fb..ab89ba49d 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -39,6 +39,7 @@ public final class ComputerCraft public static final String[] DEFAULT_HTTP_ALLOW = new String[] { "*" }; public static final String[] DEFAULT_HTTP_DENY = new String[] { "127.0.0.0/8", + "0.0.0.0/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", From 37f925de0a48478cc24d42f39bb9431d49e6dbee Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 8 Sep 2020 18:37:40 +0100 Subject: [PATCH 08/11] Remove references to cc.crzd.me's maven As CC only exists on 1.12.2, it's a bit meaningless to talk about it on 1.15+! --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bab8a02e7..71692f985 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,9 @@ I'd generally recommend you don't contact me directly (email, DM, etc...) unless report exploits). You'll get a far quicker response if you ask the whole community! ## Using -If you want to depend on CC: Tweaked, we have a maven repo. However, you should be wary that some functionality is only -exposed by CC:T's API and not vanilla ComputerCraft. If you wish to support all variations of ComputerCraft, I recommend -using [cc.crzd.me's maven](https://cc.crzd.me/maven/) instead. +CC: Tweaked is hosted on my maven repo, and so is relatively simple to depend on. You may wish to add a soft (or hard) +dependency in your `mods.toml` file, with the appropriate version bounds, to ensure that API functionality you depend +on is present. ```groovy dependencies { From 50473afea88421871ab0a7f8b08ecbe710fc1345 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Wed, 9 Sep 2020 08:39:28 +0100 Subject: [PATCH 09/11] Fix Gradle example for depending on CC:T See #405 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71692f985..d344fb157 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ dependency in your `mods.toml` file, with the appropriate version bounds, to ens on is present. ```groovy -dependencies { +repositories { maven { url 'https://squiddev.cc/maven/' } } From 59de21eae29849988e77fad6bc335f5ce78dfec7 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 11 Sep 2020 18:02:23 +0100 Subject: [PATCH 10/11] Handle tabs when parsing JSON Fixes #539 --- .../resources/data/computercraft/lua/rom/apis/textutils.lua | 4 ++-- .../test-rom/data/json-parsing/y_tab_whitespace.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json diff --git a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua index 40de6924b..576c6755e 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua @@ -432,7 +432,7 @@ do --- Skip any whitespace local function skip(str, pos) - local _, last = find(str, "^[ \n\r\v]+", pos) + local _, last = find(str, "^[ \n\r\t]+", pos) if last then return last + 1 else return pos end end @@ -472,7 +472,7 @@ do buf[n], n, pos = utf8.char(tonumber(num_str, 16)), n + 1, pos + 6 else local unesc = escapes[c] - if not unesc then error_at(pos + 1, "Unknown escape character %q.", unesc) end + if not unesc then error_at(pos + 1, "Unknown escape character %q.", c) end buf[n], n, pos = unesc, n + 1, pos + 2 end elseif c >= '\x20' then diff --git a/src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json b/src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json new file mode 100644 index 000000000..d9a9c8b4d --- /dev/null +++ b/src/test/resources/test-rom/data/json-parsing/y_tab_whitespace.json @@ -0,0 +1 @@ +[ ] From 748ebbe66bf0a4239bde34f557e4b4b75d61d990 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 12 Sep 2020 09:27:47 +0100 Subject: [PATCH 11/11] Bump to 1.92.0 A tiny release, but there's new features so it's technically a minor bump. --- gradle.properties | 2 +- .../data/computercraft/lua/rom/help/changelog.txt | 11 +++++++++++ .../data/computercraft/lua/rom/help/whatsnew.txt | 15 +++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6a2a622b9..2e9a93b9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.91.0 +mod_version=1.92.0 # Minecraft properties (update mods.toml when changing) mc_version=1.15.2 diff --git a/src/main/resources/data/computercraft/lua/rom/help/changelog.txt b/src/main/resources/data/computercraft/lua/rom/help/changelog.txt index fbb88d766..38cc9f6dd 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/changelog.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/changelog.txt @@ -1,3 +1,14 @@ +# New features in CC: Tweaked 1.92.0 + +* Bump Cobalt version: + * Add support for the __pairs metamethod. + * string.format now uses the __tostring metamethod. +* Add date-specific MOTDs (MCJack123). + +And several bug fixes: +* Correctly handle tabs within textutils.unserailizeJSON. +* Fix sheep not dropping items when sheered by turtles. + # New features in CC: Tweaked 1.91.0 * [Generic peripherals] Expose NBT hashes of items to inventory methods. diff --git a/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt b/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt index 1ad4527c2..9a79e5602 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt @@ -1,13 +1,12 @@ -New features in CC: Tweaked 1.91.0 +New features in CC: Tweaked 1.92.0 -* [Generic peripherals] Expose NBT hashes of items to inventory methods. -* Bump Cobalt version - * Optimise handling of string concatenation. - * Add string.{pack,unpack,packsize} (MCJack123) +* Bump Cobalt version: + * Add support for the __pairs metamethod. + * string.format now uses the __tostring metamethod. +* Add date-specific MOTDs (MCJack123). And several bug fixes: -* Escape non-ASCII characters in JSON strings (neumond) -* Make field names in fs.attributes more consistent (abby) -* Fix textutils.formatTime correctly handle 12 AM (R93950X) +* Correctly handle tabs within textutils.unserailizeJSON. +* Fix sheep not dropping items when sheered by turtles. Type "help changelog" to see the full version history.