Plugin Help Changing a sign line with a command.

Discussion in 'Plugin Help/Development/Requests' started by HCMatt, Apr 6, 2015.

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

    HCMatt

    I need the sign that i'm looking at to change when i run a certain command. This is what I have so far...


    Code:
    if (cmd.getName().equalsIgnoreCase("ft")) {
                if (!(p.hasPermission("ft.use"))) {
                    p.sendMessage(ChatColor.RED + "You do not have permission.");
                    return true;
                } else {
                    if (args.length == 0) {
                        p.sendMessage(ChatColor.RED + "Usage: /ft <name> <1/2/3/4>");
                        return true;
                    } else if (args.length == 2) {
                        String name = args[0];
                        String id = args[1];
                        Sign sign = (Sign) p.getTargetBlock(null, 10).getState();
                        if (args[1].equalsIgnoreCase("1")) {
                            if (getConfig().get("FastTravel." + args[0] + "." + 1) != null) {
                                p.sendMessage(ChatColor.RED + args[0] + " 1 already exists please use another ID.");
                                return true;       
                            }else {
                                if(getConfig().get("FastTravel.Price") != null){
                                sign.setLine(0, "[FastTravel]");
                                sign.setLine(1, name + " 1");
                                sign.setLine(3, (String) getConfig().get("FastTravel.Price"));
                                p.sendMessage(ChatColor.GREEN + "You set the FastTravel sign '" + name + " 1'.");
                                return true;
                                }else {
                                    p.sendMessage(ChatColor.RED + "The price for FastTravel has not been set.");
                                    p.sendMessage(ChatColor.RED + "Please set the price by using /setprice <price>");
                                    return true;
                                }
                            }
                        }
                    }
                }
    The rest of it works apart from the sign changing... Is there something that i have done wrong?
    Please help.

    Thanks

    Matty.

    An example, if someone was to run the command '/ft Test 1', The sign that they were looking at would change to this
    Line 1 - [FastTravel]
    Line2 - Test 1

    Line 4 - Price

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  2. Offline

    cnc4

    @HCMatt
    Try adding sign.update(); after setting all the lines...
    EDIT: why did you use equalsIgnoreCase in line 13?
    no need for "else" when doing return;
     
    Last edited: Apr 7, 2015
Thread Status:
Not open for further replies.

Share This Page