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

Empty custom entity names no really empty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-4520628-84676f3 (MC: 1.13-pre7) (Implementing API version 1.13-pre7-R0.1-SNAPSHOT)

      When clearing the custom name of an entity (by passing null or an empty string), on 1.13 it will result in an 'empty' ChatComponent being used (instead of null/none). Resulting in a small, empty name tag above entities (instead of no name tag at all).

      A fix might be to replace

      if (name == null) {
          name = "";
      }
      

      with

      if (name == "") {
          name = null;
      }
      

      inside CraftEntity#setCustomName. And the name length checking would have to check for null then.

      Reproduction plugin:

      package de.blablubbabc.test2;
      
      import org.bukkit.Bukkit;
      import org.bukkit.Location;
      import org.bukkit.entity.Entity;
      import org.bukkit.entity.EntityType;
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.player.PlayerJoinEvent;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public class Test extends JavaPlugin implements Listener {
      
      	public static Test INSTANCE = null;
      
      	@Override
      	public void onEnable() {
      		INSTANCE = this;
      		Bukkit.getPluginManager().registerEvents(this, this);
      	}
      
      	@Override
      	public void onDisable() {
      		INSTANCE = null;
      	}
      
      	@EventHandler
      	void onPlayerJoin(PlayerJoinEvent event) {
      		Bukkit.getScheduler().runTaskLater(this, () -> {
      			event.getPlayer().sendMessage("Spawning mob");
      			Location loc = event.getPlayer().getLocation();
      			Entity entity = loc.getWorld().spawnEntity(loc, EntityType.VILLAGER);
      			entity.setCustomName(null);
      		}, 1L);
      	}
      }
      
      

       

      name: Test
      version: '1.0'
      description: Testing some stuff
      main: de.blablubbabc.test2.Test
      
      Bug reports which do not 1) contain a declaration of testing in Vanilla and without plugins, or 2) in the case of plugin API bugs, contain a minimal reproduction case (source + jar please) will be closed. Bug reports must contain step by step instructions to reproduce the bug from a clean server install with no assumptions or prior knowledge. Also make sure you include the full output of /version in your report. Please copy and paste this statement to the bottom of your report to indicate that you have read and understood it. 
      

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: