Skip to content

Instantly share code, notes, and snippets.

@RoboMWM
Created October 24, 2018 20:38
Show Gist options
  • Select an option

  • Save RoboMWM/8060e5e4fcd1504b3c46d25e6f0b70d2 to your computer and use it in GitHub Desktop.

Select an option

Save RoboMWM/8060e5e4fcd1504b3c46d25e6f0b70d2 to your computer and use it in GitHub Desktop.
spigot-4441

Where chest is a Chest blockstate:

 chest.setCustomName(ChatColor.translateAlternateColorCodes('&', "here is &rsomething"));
 chest.update();

For printing to file and broadcasting to chat:

@EventHandler
 private void chestName(PlayerInteractEvent event)
    
{
         if (event.getAction() != Action.LEFT_CLICK_BLOCK)
             return;
         Chest chest = (Chest)event.getClickedBlock().getState();
         String name = chest.getCustomName();
         getConfig().set("yolo", name);
         saveConfig();
         Bukkit.broadcastMessage(name);
} 

In the config, you'll see: here is §0something

In chat, something will appear in black.

What I expect to see in the config is: here is §rsomething

I don't mind if it shows up in chat as black, but I wish the original string kept the §r instead of converting when retrieving the custom name. It's obviously stored in the server since this changes depending on if it's an item or block, but if this is difficult to do (retrieving how it's stored vs. how it's displayed, since what I infer from your comment is that CB is reading and converting the displayed json representation; I'm not familiar with what the server does with this stuff), then probably not worth "fixing."

@RoboMWM
Copy link
Copy Markdown
Author

RoboMWM commented Oct 24, 2018

Also printing the item's custom name will print §f in config in place of the §0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment