[SPIGOT-7791] Skull BlockState causes NullPointerException Created: 22/Jun/24 Updated: 25/Dec/24 Resolved: 22/Jun/24 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Simon | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
java version "21.0.3" 2024-04-16 LTS Windows 10 Output of /pl: Plugins (1): TestPlugin |
||
| Attachments: |
|
| Version: | This server is running CraftBukkit version 4231-Spigot-1aabe50-5e46f1c (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT) |
| Plugin: | TestPlugin |
| Guidelines Read: | Yes |
| Description |
|
If you set the type of a block to Material.PLAYER_HEAD a Nullpointer will occour. How to reproduce: @EventHandler public void on(PlayerInteractEvent e) { if (e.getHand() != EquipmentSlot.HAND) return; Block block = e.getClickedBlock(); block.setType(Material.PLAYER_HEAD); block.getState().setType(Material.PLAYER_HEAD); //optional. The NPE can be forced this way //But it also shows without this line //((Skull) block.getState()).setOwnerProfile(null); block.getState().update(true); }
The topic came up after this thread: |
| Comments |
| Comment by Doc [ 21/Jul/24 ] |
|
Timelordm1 The issue you comment its not related to this issue, the class GameProfile from mojang require the UUID and the NAME you are passing a null causing the exception. |
| Comment by MjdTime [ 21/Jul/24 ] |
|
Hello, I have a similar problem in one of the plugins I use. sorry not sure if this is related or if this is the correct place. final ItemStack myHead = new ItemStack(Material.PLAYER_HEAD, headAmount); SkullMeta headMeta = (SkullMeta) myHead.getItemMeta(); assert headMeta != null; GameProfile profile = new GameProfile(UUID.randomUUID(), null); profile.getProperties().put("textures", new Property("textures", textureValue)); Caused by: java.lang.NullPointerException: Profile name must not be nullat java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?] at com mojang.authlib.GameProfile.<init>(GameProfile.java:31)
|