Commits
md_5 authored a8e278f03b6
8 8 | |
9 9 | /** |
10 10 | * Called when a non-player entity is about to teleport because it is in |
11 11 | * contact with a portal. |
12 12 | * <p> |
13 13 | * For players see {@link org.bukkit.event.player.PlayerPortalEvent} |
14 14 | */ |
15 15 | public class EntityPortalEvent extends EntityTeleportEvent { |
16 16 | private static final HandlerList handlers = new HandlerList(); |
17 17 | private int searchRadius = 128; |
18 + | private boolean canCreatePortal = true; |
19 + | private int creationRadius = 16; |
18 20 | |
19 21 | public EntityPortalEvent( final Entity entity, final Location from, final Location to) { |
20 22 | super(entity, from, to); |
21 23 | } |
22 24 | |
23 25 | public EntityPortalEvent( Entity entity, Location from, Location to, int searchRadius) { |
24 26 | super(entity, from, to); |
25 27 | this.searchRadius = searchRadius; |
26 28 | } |
27 29 | |
30 + | public EntityPortalEvent( Entity entity, Location from, Location to, int searchRadius, boolean canCreatePortal, int creationRadius) { |
31 + | super(entity, from, to); |
32 + | this.searchRadius = searchRadius; |
33 + | this.canCreatePortal = canCreatePortal; |
34 + | this.creationRadius = creationRadius; |
35 + | } |
36 + | |
28 37 | /** |
29 38 | * Set the Block radius to search in for available portals. |
30 39 | * |
31 40 | * @param searchRadius the radius in which to search for a portal from the |
32 41 | * location |
33 42 | */ |
34 43 | public void setSearchRadius(int searchRadius) { |
35 44 | this.searchRadius = searchRadius; |
36 45 | } |
37 46 | |
38 47 | /** |
39 48 | * Gets the search radius value for finding an available portal. |
40 49 | * |
41 50 | * @return the currently set search radius |
42 51 | */ |
43 52 | public int getSearchRadius() { |
44 53 | return searchRadius; |
45 54 | } |
46 55 | |
56 + | /** |
57 + | * Returns whether the server will attempt to create a destination portal or |
58 + | * not. |
59 + | * |
60 + | * @return whether there should create be a destination portal created |
61 + | */ |
62 + | public boolean getCanCreatePortal() { |
63 + | return canCreatePortal; |
64 + | } |
65 + | |
66 + | /** |
67 + | * Sets whether the server should attempt to create a destination portal or |
68 + | * not. |
69 + | * |
70 + | * @param canCreatePortal Sets whether there should be a destination portal |
71 + | * created |
72 + | */ |
73 + | public void setCanCreatePortal(boolean canCreatePortal) { |
74 + | this.canCreatePortal = canCreatePortal; |
75 + | } |
76 + | |
77 + | /** |
78 + | * Sets the maximum radius the world is searched for a free space from the |
79 + | * given location. |
80 + | * |
81 + | * If enough free space is found then the portal will be created there, if |
82 + | * not it will force create with air-space at the target location. |
83 + | * |
84 + | * Does not apply to end portal target platforms which will always appear at |
85 + | * the target location. |
86 + | * |
87 + | * @param creationRadius the radius in which to create a portal from the |
88 + | * location |
89 + | */ |
90 + | public void setCreationRadius(int creationRadius) { |
91 + | this.creationRadius = creationRadius; |
92 + | } |
93 + | |
94 + | /** |
95 + | * Gets the maximum radius the world is searched for a free space from the |
96 + | * given location. |
97 + | * |
98 + | * If enough free space is found then the portal will be created there, if |
99 + | * not it will force create with air-space at the target location. |
100 + | * |
101 + | * Does not apply to end portal target platforms which will always appear at |
102 + | * the target location. |
103 + | * |
104 + | * @return the currently set creation radius |
105 + | */ |
106 + | public int getCreationRadius() { |
107 + | return creationRadius; |
108 + | } |
109 + | |
47 110 | |
48 111 | |
49 112 | public HandlerList getHandlers() { |
50 113 | return handlers; |
51 114 | } |
52 115 | |
53 116 | |
54 117 | public static HandlerList getHandlerList() { |
55 118 | return handlers; |
56 119 | } |
57 120 | } |