Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] NoSuchFileException when a fresh server starts #38

Closed
4 tasks done
ToooAir opened this issue Jun 12, 2022 · 10 comments
Closed
4 tasks done

[Bug] NoSuchFileException when a fresh server starts #38

ToooAir opened this issue Jun 12, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@ToooAir
Copy link

ToooAir commented Jun 12, 2022

Checks

  • I confirm that I have searched for existing issues before reporting to avoid duplicate reporting.
  • I confirm that this problem still exists with the latest build version of MCDiscordChat.
  • I confirm that this problem still exists with only MCDiscordChat and Fabric API installed.
  • I confirm that I followed the MCDC Docs and read the Changelog, but this problem still exists.

Java Version

17.0.3

Minecraft Version

1.19

MCDiscordChat Version

Latest build

Description

https://github.com/Xujiayao/MCDiscordChat/blob/6f5ef9e9d48b2f4b5f3283388aa53d11703d612c/src/main/java/top/xujiayao/mcdiscordchat/utils/Utils.java#L245

If there is no "world/stats", It will crash.

To Reproduce

Make a new world, and run it with MCDiscordChat.
Keep updateChannelTopic on, and it will throw java.nio.file.NoSuchFileException: world/stats.

Log

Starting net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture
[18:35:12] [main/INFO]: Loading Minecraft 1.19 with Fabric Loader 0.14.7
[18:35:12] [main/INFO]: Loading 53 mods:
        - com_fasterxml_jackson_core_jackson-annotations 2.13.3 via mcdiscordchat
        - com_fasterxml_jackson_core_jackson-core 2.13.3 via mcdiscordchat
        - com_fasterxml_jackson_core_jackson-databind 2.13.3 via mcdiscordchat
        - com_google_code_gson_gson 2.9.0 via mcdiscordchat
        - com_neovisionaries_nv-websocket-client 2.14 via mcdiscordchat
        - com_squareup_okhttp3_okhttp 4.9.3 via mcdiscordchat
        - com_squareup_okio_okio 2.10.0 via mcdiscordchat
        - com_vdurmont_emoji-java 5.1.1 via mcdiscordchat
        - fabric 0.55.3+1.19
        - fabric-api-base 0.4.9+e62f51a3a9 via fabric
        - fabric-api-lookup-api-v1 1.6.6+9ff28f40a9 via fabric
        - fabric-biome-api-v1 9.0.12+e62f51a3a9 via fabric
        - fabric-command-api-v1 1.2.5+f71b366fa9 via fabric
        - fabric-command-api-v2 2.1.1+cda9839ba9 via fabric
        - fabric-commands-v0 0.2.22+df3654b3a9 via fabric
        - fabric-containers-v0 0.1.27+df3654b3a9 via fabric
        - fabric-content-registries-v0 3.0.16+9ff28f40a9 via fabric
        - fabric-convention-tags-v1 1.0.8+37622d24a9 via fabric
        - fabric-crash-report-info-v1 0.2.3+bd0a0d4aa9 via fabric
        - fabric-data-generation-api-v1 5.0.1+2a5b9210a9 via fabric
        - fabric-dimensions-v1 2.1.27+72da3b3da9 via fabric
        - fabric-entity-events-v1 1.4.16+9ff28f40a9 via fabric
        - fabric-events-interaction-v0 0.4.26+9ff28f40a9 via fabric
        - fabric-events-lifecycle-v0 0.2.24+df3654b3a9 via fabric
        - fabric-game-rule-api-v1 1.0.19+18990361a9 via fabric
        - fabric-item-api-v1 1.5.4+767db26ea9 via fabric
        - fabric-item-groups-v0 0.3.23+9ff28f40a9 via fabric
        - fabric-lifecycle-events-v1 2.0.9+21a5acaaa9 via fabric
        - fabric-loot-api-v2 1.0.1+9e7660c6a9 via fabric
        - fabric-loot-tables-v1 1.1.1+9e7660c6a9 via fabric
        - fabric-message-api-v1 1.0.1+513f4a59a9 via fabric
        - fabric-mining-level-api-v1 2.1.7+9ff28f40a9 via fabric
        - fabric-networking-api-v1 1.0.27+7fe97409a9 via fabric
        - fabric-networking-v0 0.3.14+df3654b3a9 via fabric
        - fabric-object-builder-api-v1 4.0.5+9ff28f40a9 via fabric
        - fabric-particles-v1 1.0.8+dc39553aa9 via fabric
        - fabric-registry-sync-v0 0.9.16+92cf9a3ea9 via fabric
        - fabric-rendering-data-attachment-v1 0.3.12+9ff28f40a9 via fabric
        - fabric-rendering-fluids-v1 3.0.5+9ff28f40a9 via fabric
        - fabric-resource-conditions-api-v1 2.0.9+e62f51a3a9 via fabric
        - fabric-resource-loader-v0 0.5.3+9e7660c6a9 via fabric
        - fabric-screen-handler-api-v1 1.2.6+9ff28f40a9 via fabric
        - fabric-transfer-api-v1 2.0.8+e62f51a3a9 via fabric
        - fabric-transitive-access-wideners-v1 1.1.1+9e7660c6a9 via fabric
        - fabricloader 0.14.7
        - java 17
        - mcdiscordchat 1.19-2.0.0-alpha.3
        - minecraft 1.19
        - net_dv8tion_jda 5.0.0-alpha.12 via mcdiscordchat
        - net_sf_trove4j_trove4j 3.0.3 via mcdiscordchat
        - org_apache_commons_commons-collections4 4.4 via mcdiscordchat
        - org_jetbrains_kotlin_kotlin-stdlib 1.7.0 via mcdiscordchat
        - org_json_json 20220320 via mcdiscordchat
[18:35:12] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/home/minecraft/server/libraries/net/fabricmc/sponge-mixin/0.11.4+mixin.0.8.5/sponge-mixin-0.11.4+mixin.0.8.5.jar Service=Knot/Fabric Env=SERVER
[18:35:12] [main/INFO]: Compatibility level set to JAVA_16
[18:35:12] [main/INFO]: Compatibility level set to JAVA_17
[18:35:16] [main/INFO]: Building unoptimized datafixer
[18:35:17] [main/INFO]: -----------------------------------------
[18:35:17] [main/INFO]: MCDiscordChat (MCDC) 2.0.0-alpha.3
[18:35:17] [main/INFO]: By Xujiayao
[18:35:17] [main/INFO]:
[18:35:17] [main/INFO]: More information + Docs:
[18:35:17] [main/INFO]: https://blog.xujiayao.top/posts/4ba0a17a/
[18:35:17] [main/INFO]: -----------------------------------------
[18:35:18] [main/INFO]: Login Successful!
[18:35:18] [JDA MainWS-WriteThread/INFO]: Connected to WebSocket
[18:35:20] [JDA MainWS-ReadThread/INFO]: Finished Loading!
[18:35:20] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[18:35:22] [main/INFO]: Loaded 7 recipes
[18:35:22] [main/INFO]: Loaded 1179 advancements
[18:35:23] [main/INFO]: Applied 0 biome modifications to 0 of 63 new biomes in 1.857 ms
[18:35:23] [Server thread/INFO]: Starting minecraft server version 1.19
[18:35:23] [Server thread/INFO]: Loading properties
[18:35:23] [Server thread/INFO]: Default game type: SURVIVAL
[18:35:23] [Server thread/INFO]: Generating keypair
[18:35:23] [Server thread/INFO]: Starting Minecraft server on *:25565
[18:35:23] [Server thread/INFO]: Using epoll channel type
[18:35:23] [Server thread/INFO]: Preparing level "world"
[18:35:25] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[18:35:25] [Server thread/INFO]: Preparing spawn area: 0%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-1/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-3/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-3/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:37] [Worker-Main-2/INFO]: Preparing spawn area: 1%
[18:35:38] [Worker-Main-3/INFO]: Preparing spawn area: 86%
[18:35:38] [Worker-Main-3/INFO]: Preparing spawn area: 86%
[18:35:39] [Worker-Main-1/INFO]: Preparing spawn area: 86%
[18:35:39] [Worker-Main-2/INFO]: Preparing spawn area: 86%
[18:35:40] [Worker-Main-3/INFO]: Preparing spawn area: 86%
[18:35:40] [Worker-Main-1/INFO]: Preparing spawn area: 86%
[18:35:41] [Worker-Main-2/INFO]: Preparing spawn area: 86%
[18:35:41] [Worker-Main-2/INFO]: Preparing spawn area: 86%
[18:35:42] [Worker-Main-2/INFO]: Preparing spawn area: 86%
[18:35:42] [Worker-Main-3/INFO]: Preparing spawn area: 86%
[18:35:43] [Worker-Main-2/INFO]: Preparing spawn area: 86%
[18:35:43] [Worker-Main-3/INFO]: Preparing spawn area: 86%
[18:35:44] [Worker-Main-2/INFO]: Preparing spawn area: 87%
[18:35:44] [Worker-Main-3/INFO]: Preparing spawn area: 89%
[18:35:45] [Worker-Main-2/INFO]: Preparing spawn area: 90%
[18:35:45] [Worker-Main-1/INFO]: Preparing spawn area: 93%
[18:35:46] [Worker-Main-2/INFO]: Preparing spawn area: 96%
[18:35:46] [Worker-Main-3/INFO]: Preparing spawn area: 98%
[18:35:46] [Server thread/INFO]: Time elapsed: 21829 ms
[18:35:46] [Server thread/INFO]: Done (23.308s)! For help, type "help"
[18:35:47] [Timer-2/ERROR]: Uncaught exception in thread "Timer-2"
java.io.UncheckedIOException: world/stats
        at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:2153) ~[commons-io-2.11.0.jar:?]
        at top.xujiayao.mcdiscordchat.utils.Utils$2.run(Utils.java:245) ~[MCDiscordChat-1.19-2.0.0-alpha.3.jar:?]
        at java.util.TimerThread.mainLoop(Timer.java:566) ~[?:?]
        at java.util.TimerThread.run(Timer.java:516) ~[?:?]
Caused by: java.nio.file.NoSuchFileException: world/stats
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
        at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55) ~[?:?]
        at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:148) ~[?:?]
        at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99) ~[?:?]
        at java.nio.file.Files.readAttributes(Files.java:1851) ~[?:?]
        at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:226) ~[?:?]
        at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:277) ~[?:?]
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:323) ~[?:?]
        at java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:71) ~[?:?]
        at java.nio.file.Files.walk(Files.java:3918) ~[?:?]
        at org.apache.commons.io.file.PathUtils.walk(PathUtils.java:1044) ~[commons-io-2.11.0.jar:?]
        at org.apache.commons.io.FileUtils.streamFiles(FileUtils.java:2971) ~[commons-io-2.11.0.jar:?]
        at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:2151) ~[commons-io-2.11.0.jar:?]
        ... 3 more

Config

{
  "generic": {
    "useEngInsteadOfChin": false,
    "botToken": "",
    "botPlayingStatus": "Minecraft",
    "botListeningStatus": "",
    "webhookUrl": "",
    "channelId": "",
    "consoleLogChannelId": "",
    "useUuidInsteadOfName": true,
    "avatarApi": "https://mc-heads.net/avatar/%player%.png",
    "broadcastCommandExecution": true,
    "allowMentions": true,
    "modifyChatMessages": true,
    "useServerNickname": true,
    "announceHighMspt": true,
    "msptCheckInterval": 5000,
    "msptLimit": 50,
    "mentionAdmins": true,
    "updateChannelTopic": true,
    "channelTopicUpdateInterval": 600000,
    "excludedCommands": [
      "/tell"
    ],
    "adminsIds": [""]
  },
  "multiServer": {
    "enable": false,
    "host": "127.0.0.1",
    "port": 5000,
    "name": "SMP",
    "botIds": []
  },
  "textsZH": {
    "unformattedResponseMessage": "    ┌──── <%name%> %message%",
    "unformattedChatMessage": "[%server%] <%name%> %message%",
    "unformattedOtherMessage": "[%server%] %message%",
    "formattedResponseMessage": [
      {
        "text": "    ┌──── ",
        "bold": true,
        "color": "dark_gray"
      },
      {
        "text": "<%name%> ",
        "bold": false,
        "color": "%roleColor%"
      },
      {
        "text": "%message%",
        "bold": false,
        "color": "dark_gray"
      }
    ],
    "formattedChatMessage": [
      {
        "text": "[%server%] ",
        "bold": true,
        "color": "blue"
      },
      {
        "text": "<%name%> ",
        "bold": false,
        "color": "%roleColor%"
      },
      {
        "text": "%message%",
        "bold": false,
        "color": "gray"
      }
    ],
    "formattedOtherMessage": [
      {
        "text": "[%server%] ",
        "bold": true,
        "color": "blue"
      },
      {
        "text": "%message%",
        "bold": false,
        "color": "gray"
      }
    ],
    "serverStarted": "**伺服器已啟動!**",
    "serverStopped": "**伺服器已關閉!**",
    "joinServer": "**%playerName% 加入了遊戲**",
    "leftServer": "**%playerName% 離開了遊戲**",
    "deathMessage": "**%deathMessage%**",
    "advancementTask": "**%playerName% 達成了進度 [%advancement%]**",
    "advancementChallenge": "**%playerName% 完成了挑戰 [%advancement%]**",
    "advancementGoal": "**%playerName% 達成了目標 [%advancement%]**",
    "highMspt": "**伺服器 MSPT (%mspt%) 高於 %msptLimit%!**",
    "consoleLogMessage": "[%time%] [INFO] %message%",
    "offlineChannelTopic": ":x: 伺服器關閉 | 最後更新於:<t:%lastUpdateTime%:f>",
    "onlineChannelTopic": ":white_check_mark: %onlinePlayerCount%/%maxPlayerCount% 位玩家遊玩中 | 伺服器玩家總數:%uniquePlayerCount% | 伺服器於 <t:%serverStartedTime%:R> 啟動 | 最後更新於:<t:%lastUpdateTime%:f>",
    "onlineChannelTopicForMultiServer": ":white_check_mark: %onlinePlayerCount%/%maxPlayerCount% 位玩家遊玩中 | 伺服器玩家總數:%uniquePlayerCount% | %onlineServerCount% 個伺服器啟動 [%onlineServerList%] | 伺服器於 <t:%serverStartedTime%:R> 啟動 | 最後更新於:<t:%lastUpdateTime%:f>"
  },
  "textsEN": {
    "unformattedResponseMessage": "    ┌──── <%name%> %message%",
    "unformattedChatMessage": "[%server%] <%name%> %message%",
    "unformattedOtherMessage": "[%server%] %message%",
    "formattedResponseMessage": [
      {
        "text": "    ┌──── ",
        "bold": true,
        "color": "dark_gray"
      },
      {
        "text": "<%name%> ",
        "bold": false,
        "color": "%roleColor%"
      },
      {
        "text": "%message%",
        "bold": false,
        "color": "dark_gray"
      }
    ],
    "formattedChatMessage": [
      {
        "text": "[%server%] ",
        "bold": true,
        "color": "blue"
      },
      {
        "text": "<%name%> ",
        "bold": false,
        "color": "%roleColor%"
      },
      {
        "text": "%message%",
        "bold": false,
        "color": "gray"
      }
    ],
    "formattedOtherMessage": [
      {
        "text": "[%server%] ",
        "bold": true,
        "color": "blue"
      },
      {
        "text": "%message%",
        "bold": false,
        "color": "gray"
      }
    ],
    "serverStarted": "**Server started!**",
    "serverStopped": "**Server stopped!**",
    "joinServer": "**%playerName% joined the game**",
    "leftServer": "**%playerName% left the game**",
    "deathMessage": "**%deathMessage%**",
    "advancementTask": "**%playerName% has made the advancement [%advancement%]**",
    "advancementChallenge": "**%playerName% has completed the challenge [%advancement%]**",
    "advancementGoal": "**%playerName% has reached the goal [%advancement%]**",
    "highMspt": "**Server MSPT (%mspt%) is above %msptLimit%!**",
    "consoleLogMessage": "[%time%] [INFO] %message%",
    "offlineChannelTopic": ":x: Server offline | Last updated: <t:%lastUpdateTime%:f>",
    "onlineChannelTopic": ":white_check_mark: %onlinePlayerCount%/%maxPlayerCount% player(s) online | %uniquePlayerCount% unique player(s) ever joined | Server started <t:%serverStartedTime%:R> | Last updated: <t:%lastUpdateTime%:f>",
    "onlineChannelTopicForMultiServer": ":white_check_mark: %onlinePlayerCount%/%maxPlayerCount% player(s) online | %uniquePlayerCount% unique player(s) ever joined | %onlineServerCount% server(s) online [%onlineServerList%] | Server started <t:%serverStartedTime%:R> | Last updated: <t:%lastUpdateTime%:f>"
  }
}
@ToooAir ToooAir added the bug Something isn't working label Jun 12, 2022
@Xujiayao
Copy link
Owner

Xujiayao commented Jun 12, 2022

Hi, thank you for the star!

This is a known issue. There is no need to do anything about this, as this only happens when a fresh server starts. Also, the server doesn't crash with this exception, it keeps running and disappears on the next start.

@ToooAir
Copy link
Author

ToooAir commented Jun 12, 2022

Sorry for wrong info. It's work perfectly next start🤣.

@ToooAir ToooAir closed this as completed Jun 12, 2022
@Xujiayao
Copy link
Owner

Xujiayao commented Jun 12, 2022

👍🤣

@ToooAir
Copy link
Author

ToooAir commented Jun 12, 2022

@Xujiayao
想一想我還是打中文就好了
我想問問
"updateChannelTopic": true的狀況下
Server 下達 Stop 指令後不會在儲存後 Shutdown
會送出 "serverStopped" 的訊息
但ChannelTopic也會卡在上線時的狀態不會修改成下線的
Bot也還在線上

https://github.com/Xujiayao/MCDiscordChat/blob/01a0be33daeaca7c1ad37f86c777b14a979b2b97/src/main/java/top/xujiayao/mcdiscordchat/Main.java#L137
不確定是不是這邊出問題

@Xujiayao
Copy link
Owner

Xujiayao commented Jun 12, 2022

这个问题 (#36 (comment)) 昨天才刚修复 6f5ef9e,我个人是开启MCDC multiServer功能所以一直没有发现这个问题。

现版本暂时把 multiServer.enable 调成 true 即可解决,后续 MCDC 更新 2.0.0-alpha.4 版本就可以调回 false 了。

(所以你引用的其实是修复后的代码)

@ToooAir
Copy link
Author

ToooAir commented Jun 12, 2022

了解! 不好意思造成您的困擾🥲

@Xujiayao
Copy link
Owner

没关系,很欢迎此类提问2333

@Xujiayao Xujiayao changed the title [Bug] NoSuchFileException if make a new world without no one connect first [Bug] NoSuchFileException when a fresh server starts Jun 13, 2022
@Xujiayao Xujiayao mentioned this issue Feb 8, 2023
3 tasks
@Xujiayao Xujiayao reopened this May 14, 2024
@ToooAir
Copy link
Author

ToooAir commented May 14, 2024

這個問題太多人反應了嗎🤣收到email發現又被打開了

@Xujiayao
Copy link
Owner

确实。最近在整理所有已有的issue,我感觉应该有办法可以避免这个问题,所以就重新打开了

(不好意思这个issue老是打扰到你)

@Xujiayao
Copy link
Owner

Now all functions related to world/stats will not report an exception when world/stats does not exist, so that the functions can be used normally.

  • Channel topic (single-server & multi-server)
  • /stats command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants