Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
SignChangeEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.block.Block;
4 import org.bukkit.entity.Player;
7 
8 /**
9  * Called when a sign is changed by a player.
10  * <p>
11  * If a Sign Change event is cancelled, the sign will not be changed.
12  */
13 public class SignChangeEvent extends BlockEvent implements Cancellable {
14  private static final HandlerList handlers = new HandlerList();
15  private boolean cancel = false;
16  private final Player player;
17  private final String[] lines;
18 
19  public SignChangeEvent(final Block theBlock, final Player thePlayer, final String[] theLines) {
20  super(theBlock);
21  this.player = thePlayer;
22  this.lines = theLines;
23  }
24 
25  /**
26  * Gets the player changing the sign involved in this event.
27  *
28  * @return the Player involved in this event
29  */
30  public Player getPlayer() {
31  return player;
32  }
33 
34  /**
35  * Gets all of the lines of text from the sign involved in this event.
36  *
37  * @return the String array for the sign's lines new text
38  */
39  public String[] getLines() {
40  return lines;
41  }
42 
43  /**
44  * Gets a single line of text from the sign involved in this event.
45  *
46  * @param index index of the line to get
47  * @return the String containing the line of text associated with the
48  * provided index
49  * @throws IndexOutOfBoundsException thrown when the provided index is > 3
50  * or < 0
51  */
52  public String getLine(int index) throws IndexOutOfBoundsException {
53  return lines[index];
54  }
55 
56  /**
57  * Sets a single line for the sign involved in this event
58  *
59  * @param index index of the line to set
60  * @param line text to set
61  * @throws IndexOutOfBoundsException thrown when the provided index is > 3
62  * or < 0
63  */
64  public void setLine(int index, String line) throws IndexOutOfBoundsException {
65  lines[index] = line;
66  }
67 
68  public boolean isCancelled() {
69  return cancel;
70  }
71 
72  public void setCancelled(boolean cancel) {
73  this.cancel = cancel;
74  }
75 
76  @Override
77  public HandlerList getHandlers() {
78  return handlers;
79  }
80 
81  public static HandlerList getHandlerList() {
82  return handlers;
83  }
84 }
void setLine(int index, String line)