Solved Split string in sign ?

Discussion in 'Plugin Development' started by StellarFX, Apr 27, 2019.

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

    StellarFX

    Hello,

    I'm trying to make a sign shop plugin (yes it already exists) but I'm blocking on this :
    My string won't split or something but it doesn't work
    Code:
            if (b.getType() == Material.SIGN || b.getType() == Material.WALL_SIGN) {
                Sign sign = (Sign) b.getState();
                if (sign.getLine(0).equalsIgnoreCase("[Shop]")) {
                    sign.setLine(0, "§2[§aShop§2]");
                    sign.update();
                }
                if (sign.getLine(0).equals("§2[§aShop§2]")) {
                    String bloc = sign.getLine(2).toString().toUpperCase();
                    String[] Splitted = sign.getLine(1).split("\\:");
                   
                   
                    player.sendMessage("Oui");
                    if (Splitted[0] == "B") {
                        player.sendMessage("t");
                        if (isInt(Splitted[1])) {
                            player.sendMessage("tt");
                            if (!sign.getLine(2).isEmpty()) {
                                player.sendMessage("ttt");
                                if (!isInt(bloc)) {
                                    player.sendMessage("tttt");
                                    if(economy.getBalance(player.getName()) >= Integer.parseInt(Splitted[1]) ) {
                                        player.sendMessage("ttttt");
                                        economy.withdrawPlayer(player.getName(), Integer.parseInt(Splitted[1]));
                                        player.getInventory().addItem(new ItemStack(Material.matchMaterial(bloc)));
                                        player.sendMessage(prefix + "You bought a §6" + sign.getLine(2).toString() + " §7!");
                                    } else {
                                        player.sendMessage(prefix + "You don't have enough money !");
                                    }
                                }
                            } else {
                                player.sendMessage("té");
                                player.sendMessage(prefix + "This shop sells nothing !");;
    So it only says "Oui" as I wrote here. My code doesn't find "B". I tried to make it in a command and it works perfectly.

    Please help!

    StellarFX
     
  2. Offline

    timtower Administrator Administrator Moderator

    @StellarFX String comparing needs to hapoen with equals or equalsIgnoreCase, not with==
     
  3. Offline

    StellarFX

    @timtower Thank you! I was blocking on this all day.
     
Thread Status:
Not open for further replies.

Share This Page