Solved Playsounds

Discussion in 'Spigot Plugin Development' started by Nico12, Jan 25, 2020.

  1. Hi, I was trying to reproduce the sound BLOCK_ENDER_CHEST_CLOSE when a player joins the server but when he joins he throws me this error:
    Code (Text):

    org.bukkit.event.EventException: null
            at$1.execute( ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.RegisteredListener.callEvent( ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.fireEvent( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.callEvent( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.PlayerConnection.a( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.PacketPlayInBlockPlace.a( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.PacketPlayInBlockPlace.a( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$ [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at java.util.concurrent.Executors$ Source) [?:1.8.0_231]
            at Source) [?:1.8.0_231]
            at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.D( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.DedicatedServer.D( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.C( [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            at Source) [?:1.8.0_231]
    Caused by: java.lang.NoSuchFieldError: BLOCK_ENDER_CHEST_CLOSE
            at me.LobbyBrain.Events.PlayerJoinEvents.skere( ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_231]
            at$1.execute( ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
            ... 18 more
    My Code:
    Code (Text):

        public void skere(PlayerJoinEvent e) {
            Player p = e.getPlayer();
                    World world = p.getWorld();
                    Location loc = p.getLocation();
                    p.playSound(loc, Sound.BLOCK_ENDER_CHEST_CLOSE, 1, 1);
    But when trying other sounds like GHAST_SCREAM it works.
    Could you help me?
    Thanks in advance
  2. What is the API-version of your plugin
  3. It's likely the version of the server you're running on is a different version from what your plugin uses. Your server seems to be running on 1.12 - make sure that your plugin also depends on the 1.12 version of the API.
  4. But I need my complement to be compatible with multiple versions, if I do it with nms could it work?
  5. NMS isn't going to help you any; really, it'll make your life 10x tougher.
    Firstly though, are you trying to make your own server support multiple versions for players? Or do you want to make your plugin work with different server versions?
    If you want your server to be compatible with players on multiple versions, all you need is ViaVersion or some plugin of that nature.
    If you're making a plugin for other people and want it to work on multiple server versions, you have a couple of options.

    The simple way: Use Sound.valueOf, check the server version to know what sound name to use.
    The roundabout (maybe-even-slightly-overkill way): Abstraction with a multi-module project. If you're not familiar with the idea or at least multi-module projects though, I wouldn't suggest it.
    • Agree Agree x 1
  6. And solve it, I apologize for not having notified and resolved this, I'm sorry.