Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7878

Server.getLootTable does not return null on invalid loot table

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Debian GNU/Linux 11 (bullseye) x86_64 5.10.0-23-amd64 

      Intel i5-6600K (4) @ 3.900GHz

    • This server is running CraftBukkit version 4295-Spigot-ca58122-7548afc (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      Server.getLootTable(NamespacedKey) should return null when given a key for a non-existent loot table, but returns a non-null object instead.

      This behavior contradicts documentation outlined here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Server.html#getLootTable(org.bukkit.NamespacedKey)

      import org.bukkit.NamespacedKey;
      import org.bukkit.loot.LootTable;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public final class SamplePlugin extends JavaPlugin {
          @Override
          public void onEnable() {
              final LootTable lt = getServer().getLootTable(NamespacedKey.fromString("asdf:hnu9awdfhaw9uh"));
              getLogger().info("" + lt); 
          }
      }

      Expected Output:

      [17:47:28] [Server thread/INFO]: [SamplePlugin] null

      Actual Output:

      [17:47:28] [Server thread/INFO]: [SamplePlugin] asdf:hnu9awdfhaw9uh

            md_5 md_5
            holographicftw@gmail.com FullPotato
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: