Solved Config Error!

Discussion in 'Spigot Plugin Development' started by ShishKaBobz, Apr 18, 2017.

Thread Status:
Not open for further replies.
  1. Hey! So im making a plugin and this code does not seem to work for me (yes i have registered the Events)
    Thanks for help in advance! (Btw it does not output any error nor does it up anything in the config)

    Code:
    Code (Text):
    package com.ionmc.name;

    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;

    public class OnJoin implements Listener {
       
        private Main plugin;
        public OnJoin(Main pl){
            plugin = pl;
    }
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event){
            Player p;
            p = event.getPlayer();
            String Name;
            String NameA;
            String NameB;
            String NameC;
            Name = plugin.getConfig().getString("Admin");
            NameA = plugin.getConfig().getString("Mod");
            NameB = plugin.getConfig().getString("Helper");
            NameC = plugin.getConfig().getString("Reset");
            if(Name == p.getName()){
                p.setDisplayName("§e§lADMIN§4§l " + p.getName()+ "§c");
            }
            if(NameA == p.getName()){
                p.setDisplayName("§6§l[MOD]§8§l " + p.getName()+ "§2");
            }
            if(NameB == p.getName()){
                p.setDisplayName("§3§l[HELPER]§1§l " + p.getName()+ "§b");
            }
            if(NameC == p.getName()){
                p.setDisplayName(p.getName());
            }
        }

    }
     
    Event being registered:

    PluginManager pm = getServer().getPluginManager();

    pm.registerEvents(new Format(), this);
    pm.registerEvents(new OnJoin(this), this);
    }
     
  2. Use
    Name.equals(p.getName())
    Instead of
    Name == p.getName())

    Two different strings are not the "same".
     
  3. Thanks!
     
Thread Status:
Not open for further replies.