Making config translate alternate color codes?

Discussion in 'Plugin Development' started by SuippoKala, Jul 11, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    SuippoKala

    Hello, i was making a simple plugin to override /plugins command but i am facing this problem.
    Since i want to make the plugin public so that everyone can change the "Plugins" on their liking with color codes the color codes won't work when i change them on config.

    Here is my code:
    Code:
    package me.Wife;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Pluginit extends JavaPlugin implements Listener{
       
       
        @Override
        public void onEnable() {
            getConfig().options().copyDefaults(true);
            saveConfig();
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
       
        System.out.print("Pluginit käynnistyy!");
       
        }
    
       
        @EventHandler(priority = EventPriority.LOWEST)
        public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
            if(event.getMessage().toLowerCase().equalsIgnoreCase("?")){
        }
            if(event.getMessage().toLowerCase().equalsIgnoreCase("pl")){
        }
            if(event.getMessage().toLowerCase().startsWith("/plugins")){
                }
                event.setCancelled(true);
               
                event.getPlayer().sendMessage("Plugins (1): " + getConfig().getString("pluginit"));
        }
    }
    And here is my config:
    Code:
    pluginit: &1Plugins
     
  2. Offline

    poepdrolify

    Code:
    ChatColor.translateAlternateColorCodes('&', getConfig().getString("pluginit"));
     
  3. Offline

    SuippoKala

  4. No, you put this where you send the message
     
  5. Offline

    SuippoKala

    d
     
    Last edited: Jul 11, 2015
  6. Offline

    mythbusterma


    *cries, just a little*
     
    teej107 likes this.
  7. Offline

    SuippoKala

    @SuippoKala
    well, this is akward.
     
  8. Offline

    poepdrolify

    event.getPlayer().sendMessage("Plugins (1): " + ChatColor.translateblablabla('&', getConfig().getString("blabla"); Something like this
     
Thread Status:
Not open for further replies.

Share This Page