Strip Color

Discussion in 'Plugin Development' started by KoolzSkillz, Dec 5, 2014.

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

    KoolzSkillz

    that doesn't strip the color off the sign, so the SignClickEvent doesn't actavate

    if (sign.getLine(0).equalsIgnoreCase(ChatColor.stripColor("[Rank]"))) {

    thats the line that doesnt work but i posted full coding of the events below


    Code:
          }
         
            @EventHandler
            public void block(SignChangeEvent e) {
                    Player player = e.getPlayer();
                if (player.hasPermission("Ranks.Sign")
                        && e.getLine(0).equalsIgnoreCase("Test")) {
                    e.setLine(0, "§1[Rank]");
                    e.setLine(1, "Test");
                } else {
                   
                }
            }
                @EventHandler
                public void interactSign(PlayerInteractEvent e) {
                    Player p = e.getPlayer();
                    PlayerInventory pi= p.getInventory();
                    ItemStack iih = p.getInventory().getItemInHand();
     
                    if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
                        return;
                    }
                    if (!(e.getClickedBlock().getState() instanceof Sign)) {
                        return;
                    }
                    Sign sign = (Sign) e.getClickedBlock().getState();
                    if (sign.getLine(0).equalsIgnoreCase(ChatColor.stripColor("[Rank]"))) {
                        p.sendMessage("§cTest");
                                       
                                    }
                                   
                }
     
                    
     
  2. Offline

    Skionz

    KoolzSkillz Your stripping the color from the String "[Rank]" which has no color. Try using it on the signs first line instead.
     
    teej107 likes this.
  3. Offline

    KoolzSkillz

    Skionz
    Example please, i dont understand where to put the strip color
     
    Wingzzz likes this.
  4. Offline

    Skionz

    KoolzSkillz I explained it clearly. What don't you understand :eek:
     
  5. Offline

    KoolzSkillz

    Skionz i dont understand where to put the strip color, it doesnt work like that
    Code:
                    if (ChatColor.stripColor(sign.getLine(0).equalsIgnoreCase("[Rank]") && sign.getLine(1).equalsIgnoreCase("VIP"))) {
     
  6. Offline

    mythbusterma

    KoolzSkillz

    ChatColor.stripColor(...) returns a String, that String should be what you're invoking equalsIgnoreCase(...) on.
     
  7. You misplaced brackets:
    Code:java
    1. if (ChatColor.stripColor(sign.getLine(0).equalsIgnoreCase("[Rank]") && sign.getLine(1).equalsIgnoreCase("VIP"))) {

    Has to be
    Code:java
    1. if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase("[Rank]") && sign.getLine(1).equalsIgnoreCase("VIP")) {
     
Thread Status:
Not open for further replies.

Share This Page