Syrent / SayanVanish

A modular vanish system for Minecraft servers
https://docs.sayandev.org/sayanvanish
67 stars 15 forks source link

Vanish task fails on adding potion effect on folia #304

Closed YouHaveTrouble closed 5 months ago

YouHaveTrouble commented 7 months ago

Server backend version

git-Folia-"3a91a4a" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 3a91a4a)

Server backend Java version

Temurin 17

Server Velocity version

Velocity 3.3.0-SNAPSHOT (git-8891faa5-b370)

Server Velocity Java version

Temurin 17

VelocityVanish version

VelocityVanish v3.27.3-build.60-901daad

Describe the bug

Plugin uses wrong scheduler. It should use region scheduler for the region player is in afaik.

[14:02:13 ERROR]: Thread Region Scheduler Thread #0 failed main thread check: Cannot add effects to entities asynchronously
java.lang.Throwable: null
        at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:78) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at net.minecraft.world.entity.LivingEntity.addEffect(LivingEntity.java:1154) ~[?:?]
        at net.minecraft.world.entity.LivingEntity.addEffect(LivingEntity.java:1149) ~[?:?]
        at net.minecraft.world.entity.LivingEntity.addEffect(LivingEntity.java:1140) ~[?:?]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity.addPotionEffect(CraftLivingEntity.java:513) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity.addPotionEffect(CraftLivingEntity.java:507) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at ir.syrent.velocityvanish.spigot.core.VanishManager.addPotionEffects$lambda$6(VanishManager.kt:124) ~[VelocityVanish_3.27.3-build.60-901daad.jar:?]
        at ir.syrent.velocityvanish.spigot.ruom.Ruom.runSync$lambda$1(Ruom.kt:112) ~[VelocityVanish_3.27.3-build.60-901daad.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]
[14:02:13 WARN]: [VelocityVanish] Global task for VelocityVanish v3.27.3-build.60-901daad generated an exception
java.lang.IllegalStateException: Cannot add effects to entities asynchronously
        at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at net.minecraft.world.entity.LivingEntity.addEffect(LivingEntity.java:1154) ~[?:?]
        at net.minecraft.world.entity.LivingEntity.addEffect(LivingEntity.java:1149) ~[?:?]
        at net.minecraft.world.entity.LivingEntity.addEffect(LivingEntity.java:1140) ~[?:?]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity.addPotionEffect(CraftLivingEntity.java:513) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity.addPotionEffect(CraftLivingEntity.java:507) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at ir.syrent.velocityvanish.spigot.core.VanishManager.addPotionEffects$lambda$6(VanishManager.kt:124) ~[VelocityVanish_3.27.3-build.60-901daad.jar:?]
        at ir.syrent.velocityvanish.spigot.ruom.Ruom.runSync$lambda$1(Ruom.kt:112) ~[VelocityVanish_3.27.3-build.60-901daad.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"3a91a4a"]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]

Expected behavior

Plugin not throwing an exception due to usage of wrong scheduler

Steps to reproduce

Step 1: Setup folia server under velocity Step 2: Install plugin on both backend and proxy Step 3: Execute /v to vanish

LuckPerms webview link

No response

VelocityVanish's configuration file

# Full wiki is available at https://github.com/Syrent/VelocityVanish/wiki
config_version: 9
default_language: en_US
show_dependency_suggestions: true

# IMPORTANT: Legacy code support is strongly discouraged. It adversely affects performance and lacks new Minecraft chat features.
support_legacy_color_codes: false

# If you're the first player to join the server, Vanish data may not synchronize correctly,
# and you may not enter vanish mode. With this option enabled, you can still enter vanish mode
# if you have operator privileges or the "velocityvanish.action.vanish.force" permission.
# If you weren't previously in vanish mode, you'll be unvanished after a few seconds.
force_vanish_if_first: true

bstats: true
# Leave sounds blank to disable them
# Example: command: ""
sounds:
  command: ENTITY_EXPERIENCE_ORB_PICKUP
  vanish: ENTITY_EXPERIENCE_ORB_PICKUP
  unvanish: ENTITY_EXPERIENCE_ORB_PICKUP
vanish:
  # Show players an actionbar when they are vanished
  actionbar: true
  # Remember vanish data after switching servers?
  # Note: Requires Velocity as a proxy server
  remember: true
  # Should we change player type to spectator in tablist for players who have permission to see vanished players?
  # Note: Requires ProtocolLib in versions lower than 1.19
  see_as_spectator: true
  # Should vanished players be protected from all damage sources?
  invincible: true
  # You can also achieve this by setting the fake join/leave message to blank in the language file
  fake_join_leave_message: true
  silent_open_container: true
  # Might cause incompatibility with some plugins like TAB and eGlow
  disable_collision: false
  prevent:
    pickup: true
    block_break: false
    block_place: false
    interact: false
    # Only works on PaperMC servers (Paper, Purpur, Pufferfish, etc...)
    advancement: true
hooks:
  essentials:
    enabled: false
    force_prevent_private_messages: false
  sunlight:
    enabled: false
  placeholderapi:
    enabled: true
  protocollib:
    enabled: true
  squaremap:
    enabled: true
  discordsrv:
    enabled: true
  cmi:
    enabled: false

Plugins

VelocityVanish

Additional info

No response

Checklist

YouHaveTrouble commented 5 months ago

I fixed this and a few other folia-related issues here along with updating the plugin to 1.20.6

Feel free to grab the changes if you want to

Syrent commented 5 months ago

Hey, The project is recoded and rebranded to SayanVanish. I'll re-add the Folia support as soon as I can.