Simple SignChangeEvent

Discussion in 'Resources' started by iPhysX, Jun 16, 2011.

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


    Ok so i was thinking, because i had a lot of trouble when i first started with bukkit.. with signs..
    maybe this would be able to help some people out, not necessarily people that are familiar with bukkit, but people who are just starting out :3
    This is just going to be simple placing and changing signs!


    A basic SignChangeEvent.
    The sign change event is fired after the 'Done' button is pressed.
    You will need to register the event SIGN_CHANGE.
    like this...
    2. PluginManager pm = this.getServer().getPluginManager();
    3. pm.registerEvent(Event.Type.SIGN_CHANGE, blocklistener,
    4. Event.Priority.Normal, this);

    2. public void onSignChange(SignChangeEvent event) {
    3. Player p = event.getPlayer();
    4. if(event.getLine(0).contains("[MySign]")){
    5. event.setLine(0, "§4[MySign]");
    6. event.setLine(1, "§2"+p.getName());
    7. p.sendMessage(ChatColor.BLUE + "MySign successfully created!");
    8. }
    9. }

    Ill split it up and comment it :p

    This is to check if the top line (line 0) contains '[MySign]'
    2. if(event.getLine(0).contains("[MySign]")){
    4. }

    inside this if statement you need to do any of the changing you need to do :p
    I change the top line to RED with the '§4'
    and i set the second line to the player who placed the sign!
    (in green) - '§2'
    with '"§2"+p.getName()'
    2. event.setLine(0, "§4[MySign]");
    3. event.setLine(1, "§2"+p.getName());

    and send the player a message so they can see everything has happened as it should!
    2. p.sendMessage(ChatColor.BLUE + "SpawnSign successfully created!");

    remember whenever i have typed 'p.'
    like in 'p.sendMessage("");'

    it is because
    2. Player p = event.getPlayer();

    I hope this was clear!
    waqlerg, edocsyl, Icelaunche and 4 others like this.
  2. Offline


    Im working on a plugin but know nothing about using signs, I'd like for players to be able to buy something by clicking on a sign and have it also update a string or integer on the sign as another string or integer updates. So like say a number changes every 5 minutes I'd like the sign to automatically update with that number every time it updates. Could you help me with that? I'm so lost
  3. Offline


    yeaah tank you
  4. Offline


    Anyone still watching this thread?

    I'm trying to make a sign that works as an item sensor: it detects a player within a certain range (range is configurable on sign) and checks their inventory for a specific item (item ID WITH DATA VALUE is configurable on the sign), then if they have that item and come in range, it emits a redstone current.

    The Data value is important, I want to use it alongside BookWorm. Can someone guide me along how I'd get the player to specify the range and ID/value?

    So far I have this:

        public void onSignChange(SignChangeEvent event) {
            Player p = event.getPlayer();
            if (event.getLine(1).equals("iSensor")){
                event.setLine(0,  "[&2Item Sensor]");
                event.setLine(1, "&4"+p.getName());
            p.sendMessage(ChatColor.DARK_GREEN + "iSensor created successfully!");
    (So they put iSensor on line 1, and it changes to Item Sensor on line 0 and their name on line 1. I want the Item ID on line 2, and range on line 3)
  5. @iPhysX how to I change the lines of a "Sign" object?
    When I set sign.update(true) and use sign.setLine(0, "bla");
    The sign itself wont update, it only works when I use the SignChangeEvent.
  6. Offline


    Cool thx
  7. Offline


    for the colors... does that require any other plugin?

    if you made it so it checks of you have a item and if they enter a radius and that have an item (Ex TNT) so if that walk into (Ex Spawn) spawn with TNT it kills them - that would be useful to know.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 16, 2016
  8. Offline


    aww, I was soo close to it.
    Thanks for this it really helped me:)

  9. Offline


    Very Nice!
  10. Offline


    Awesome tutorial. Definitely useful in the future :D
Thread Status:
Not open for further replies.

Share This Page