Commits

Miles Holder authored and md_5 committed 82af5dc60ea
SPIGOT-7396: Add PlayerSignOpenEvent
No tags

src/main/java/org/bukkit/event/player/PlayerSignOpenEvent.java

Added
1 +package org.bukkit.event.player;
2 +
3 +import org.bukkit.block.Sign;
4 +import org.bukkit.block.sign.Side;
5 +import org.bukkit.entity.Player;
6 +import org.bukkit.event.Cancellable;
7 +import org.bukkit.event.HandlerList;
8 +import org.jetbrains.annotations.ApiStatus;
9 +import org.jetbrains.annotations.NotNull;
10 +
11 +/**
12 + * This event is fired when a sign is opened by the player.
13 + */
14 +@ApiStatus.Experimental
15 +public class PlayerSignOpenEvent extends PlayerEvent implements Cancellable {
16 +
17 + private static final HandlerList handlers = new HandlerList();
18 + private final Sign sign;
19 + private final Side side;
20 + private final Cause cause;
21 + private boolean cancelled;
22 +
23 + public PlayerSignOpenEvent(@NotNull final Player player, @NotNull final Sign sign, @NotNull final Side side, @NotNull final Cause cause) {
24 + super(player);
25 + this.sign = sign;
26 + this.side = side;
27 + this.cause = cause;
28 + }
29 +
30 + /**
31 + * Gets the sign that was opened.
32 + *
33 + * @return opened sign
34 + */
35 + @NotNull
36 + public Sign getSign() {
37 + return this.sign;
38 + }
39 +
40 + /**
41 + * Gets side of the sign opened.
42 + *
43 + * @return side of sign opened
44 + */
45 + @NotNull
46 + public Side getSide() {
47 + return this.side;
48 + }
49 +
50 + /**
51 + * Gets the cause of the sign open.
52 + *
53 + * @return sign open cause
54 + */
55 + @NotNull
56 + public Cause getCause() {
57 + return this.cause;
58 + }
59 +
60 + @Override
61 + public boolean isCancelled() {
62 + return this.cancelled;
63 + }
64 +
65 + @Override
66 + public void setCancelled(boolean cancel) {
67 + this.cancelled = cancel;
68 + }
69 +
70 + @NotNull
71 + @Override
72 + public HandlerList getHandlers() {
73 + return handlers;
74 + }
75 +
76 + @NotNull
77 + public static HandlerList getHandlerList() {
78 + return handlers;
79 + }
80 +
81 + @ApiStatus.Experimental
82 + public enum Cause {
83 +
84 + /**
85 + * Indicate the sign was opened because of an interaction.
86 + */
87 + INTERACT,
88 + /**
89 + * Indicate the sign was opened because the sign was placed.
90 + */
91 + PLACE,
92 + /**
93 + * Indicate the sign was opened because of a plugin.
94 + */
95 + PLUGIN,
96 + /**
97 + * Indicate the sign was opened for an unknown reason.
98 + */
99 + UNKNOWN;
100 + }
101 +}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut