Skip to content

Commit 46d21c1

Browse files
committed
cleanup events
1 parent d8afce2 commit 46d21c1

File tree

290 files changed

+4823
-4172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+4823
-4172
lines changed

paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void setNotifyPlayer(final boolean notifyPlayer) {
109109

110110
/**
111111
* Gets the notification message that will be sent to the player
112-
* if {@link #willNotifyPlayer()} returns true.
112+
* if {@link #willNotifyPlayer()} returns {@code true}.
113113
*
114114
* @return {@code null} if no notification
115115
*/

paper-api/src/main/java/org/bukkit/World.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
6969
void setVoidDamageEnabled(boolean enabled);
7070

7171
/**
72-
* Gets the damage applied to the player when they are in the void in this world.
72+
* Gets the damage applied to the entities when they are in the void in this world.
7373
* Check {@link #isVoidDamageEnabled()} to see if void damage is enabled.
7474
*
7575
* @return amount of damage to apply
@@ -78,7 +78,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
7878
float getVoidDamageAmount();
7979

8080
/**
81-
* Sets the damage applied to the player when they are in the void in this world.
81+
* Sets the damage applied to the entities when they are in the void in this world.
8282
* Check {@link #isVoidDamageEnabled()} to see if void damage is enabled.
8383
*
8484
* @param voidDamageAmount amount of damage to apply

paper-api/src/main/java/org/bukkit/entity/Entity.java

+1
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ final class Holder {
529529
* @param event a {@link EntityDamageEvent}
530530
* @deprecated method is for internal use only and will be removed
531531
*/
532+
@ApiStatus.Internal
532533
@Deprecated(since = "1.20.4", forRemoval = true)
533534
public void setLastDamageCause(@Nullable EntityDamageEvent event);
534535

Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package org.bukkit.entity;
22

3+
import org.jetbrains.annotations.Contract;
4+
35
/**
4-
* Represents a Pig Zombie.
6+
* Represents a Zombified piglin.
57
*/
68
public interface PigZombie extends Zombie {
79

810
/**
9-
* Get the pig zombie's current anger level.
11+
* Get the zombified piglin's current anger level.
1012
*
1113
* @return The anger level.
1214
*/
1315
int getAnger();
1416

1517
/**
16-
* Set the pig zombie's current anger level.
18+
* Set the zombified piglin's current anger level.
1719
*
1820
* @param level The anger level. Higher levels of anger take longer to
1921
* wear off.
@@ -23,29 +25,31 @@ public interface PigZombie extends Zombie {
2325
/**
2426
* Shorthand; sets to either 0 or the default level.
2527
*
26-
* @param angry Whether the zombie should be angry.
28+
* @param angry Whether the piglin should be angry.
2729
*/
2830
void setAngry(boolean angry);
2931

3032
/**
31-
* Shorthand; gets whether the zombie is angry.
33+
* Shorthand; gets whether the piglin is angry.
3234
*
33-
* @return True if the zombie is angry, otherwise false.
35+
* @return True if the piglin is angry, otherwise false.
3436
*/
3537
boolean isAngry();
3638

3739
/**
3840
* <b>Not applicable to this entity</b>
3941
*
40-
* @return false
42+
* @return {@code false}
4143
*/
4244
@Override
45+
@Contract("-> false")
4346
public boolean isConverting();
4447

4548
/**
4649
* <b>Not applicable to this entity</b>
4750
*/
4851
@Override
52+
@Contract("-> fail")
4953
public int getConversionTime();
5054

5155
/**
@@ -54,5 +58,6 @@ public interface PigZombie extends Zombie {
5458
* @param time unused
5559
*/
5660
@Override
61+
@Contract("_ -> fail")
5762
public void setConversionTime(int time);
5863
}

paper-api/src/main/java/org/bukkit/event/Cancellable.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public interface Cancellable {
99
* Gets the cancellation state of this event. A cancelled event will not
1010
* be executed in the server, but will still pass to other plugins
1111
*
12-
* @return true if this event is cancelled
12+
* @return {@code true} if this event is cancelled
1313
*/
14-
public boolean isCancelled();
14+
boolean isCancelled();
1515

1616
/**
1717
* Sets the cancellation state of this event. A cancelled event will not
1818
* be executed in the server, but will still pass to other plugins.
1919
*
20-
* @param cancel true if you wish to cancel this event
20+
* @param cancel {@code true} if you wish to cancel this event
2121
*/
22-
public void setCancelled(boolean cancel);
22+
void setCancelled(boolean cancel);
2323
}

paper-api/src/main/java/org/bukkit/event/Event.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
package org.bukkit.event;
22

3+
import org.bukkit.Bukkit;
34
import org.bukkit.plugin.Plugin;
45
import org.bukkit.plugin.PluginManager;
56
import org.jetbrains.annotations.NotNull;
67

78
/**
89
* Represents an event.
9-
*
10+
* <br>
1011
* All events require a static method named getHandlerList() which returns the same {@link HandlerList} as {@link #getHandlers()}.
1112
*
1213
* @see PluginManager#callEvent(Event)
1314
* @see PluginManager#registerEvents(Listener,Plugin)
1415
*/
1516
public abstract class Event {
17+
1618
private String name;
17-
private final boolean async;
19+
private final boolean isAsync;
1820

1921
/**
2022
* The default constructor is defined for cleaner code. This constructor
@@ -28,28 +30,26 @@ public Event() {
2830
* This constructor is used to explicitly declare an event as synchronous
2931
* or asynchronous.
3032
*
31-
* @param isAsync true indicates the event will fire asynchronously, false
33+
* @param isAsync {@code true} indicates the event will fire asynchronously, {@code false}
3234
* by default from default constructor
3335
*/
3436
public Event(boolean isAsync) {
35-
this.async = isAsync;
37+
this.isAsync = isAsync;
3638
}
3739

38-
// Paper start
3940
/**
4041
* Calls the event and tests if cancelled.
4142
*
42-
* @return false if event was cancelled, if cancellable. otherwise true.
43+
* @return {@code false} if event was cancelled, if cancellable. otherwise {@code true}.
4344
*/
4445
public boolean callEvent() {
45-
org.bukkit.Bukkit.getPluginManager().callEvent(this);
46+
Bukkit.getPluginManager().callEvent(this);
4647
if (this instanceof Cancellable) {
4748
return !((Cancellable) this).isCancelled();
4849
} else {
4950
return true;
5051
}
5152
}
52-
// Paper end
5353

5454
/**
5555
* Convenience method for providing a user-friendly identifier. By
@@ -60,23 +60,23 @@ public boolean callEvent() {
6060
*/
6161
@NotNull
6262
public String getEventName() {
63-
if (name == null) {
64-
name = getClass().getSimpleName();
63+
if (this.name == null) {
64+
this.name = this.getClass().getSimpleName();
6565
}
66-
return name;
66+
return this.name;
6767
}
6868

6969
@NotNull
7070
public abstract HandlerList getHandlers();
7171

7272
/**
73-
* Any custom event that should not by synchronized with other events must
73+
* Any custom event that should not be synchronized with other events must
7474
* use the specific constructor. These are the caveats of using an
7575
* asynchronous event:
7676
* <ul>
7777
* <li>The event is never fired from inside code triggered by a
7878
* synchronous event. Attempting to do so results in an {@link
79-
* java.lang.IllegalStateException}.
79+
* IllegalStateException}.
8080
* <li>However, asynchronous event handlers may fire synchronous or
8181
* asynchronous events
8282
* <li>The event may be fired multiple times simultaneously and in any
@@ -89,10 +89,10 @@ public String getEventName() {
8989
* <li>Asynchronous calls are not calculated in the plugin timing system.
9090
* </ul>
9191
*
92-
* @return false by default, true if the event fires asynchronously
92+
* @return {@code false} by default, {@code true} if the event fires asynchronously
9393
*/
9494
public final boolean isAsynchronous() {
95-
return async;
95+
return this.isAsync;
9696
}
9797

9898
public enum Result {
@@ -113,6 +113,6 @@ public enum Result {
113113
* take place if possible, even if the server would not normally allow
114114
* the action. Some actions may not be allowed.
115115
*/
116-
ALLOW;
116+
ALLOW
117117
}
118118
}

paper-api/src/main/java/org/bukkit/event/EventException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public EventException(String message) {
4444
/**
4545
* If applicable, returns the Exception that triggered this Exception
4646
*
47-
* @return Inner exception, or null if one does not exist
47+
* @return Inner exception, or {@code null} if one does not exist
4848
*/
4949
@Override
5050
public Throwable getCause() {

paper-api/src/main/java/org/bukkit/event/EventHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/**
3333
* Define if the handler ignores a cancelled event.
3434
* <p>
35-
* If ignoreCancelled is true and the event is cancelled, the method is
35+
* If ignoreCancelled is {@code true} and the event is cancelled, the method is
3636
* not called. Otherwise, the method is always called.
3737
*
3838
* @return whether cancelled events should be ignored

paper-api/src/main/java/org/bukkit/event/EventPriority.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public enum EventPriority {
4343

4444
private final int slot;
4545

46-
private EventPriority(int slot) {
46+
EventPriority(int slot) {
4747
this.slot = slot;
4848
}
4949

paper-api/src/main/java/org/bukkit/event/HandlerList.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ public class HandlerList {
3131
/**
3232
* List of all HandlerLists which have been created, for use in bakeAll()
3333
*/
34-
private static ArrayList<HandlerList> allLists = new ArrayList<HandlerList>();
34+
private static final ArrayList<HandlerList> allLists = new ArrayList<>();
3535

36-
// Paper start
3736
/**
3837
* Event types which have instantiated a {@link HandlerList}.
3938
*/
4039
private static final java.util.Set<String> EVENT_TYPES = java.util.concurrent.ConcurrentHashMap.newKeySet();
41-
// Paper end
4240

4341
/**
4442
* Bake all handler lists. Best used just after all normal event
@@ -101,15 +99,14 @@ public static void unregisterAll(@NotNull Listener listener) {
10199
* The HandlerList is then added to meta-list for use in bakeAll()
102100
*/
103101
public HandlerList() {
104-
// Paper start
105102
java.lang.StackWalker.getInstance(java.util.EnumSet.of(java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE), 4)
106103
.walk(s -> s.filter(f -> Event.class.isAssignableFrom(f.getDeclaringClass())).findFirst())
107104
.map(f -> f.getDeclaringClass().getName())
108105
.ifPresent(EVENT_TYPES::add);
109-
// Paper end
110-
handlerslots = new EnumMap<EventPriority, ArrayList<RegisteredListener>>(EventPriority.class);
106+
107+
handlerslots = new EnumMap<>(EventPriority.class);
111108
for (EventPriority o : EventPriority.values()) {
112-
handlerslots.put(o, new ArrayList<RegisteredListener>());
109+
handlerslots.put(o, new ArrayList<>());
113110
}
114111
synchronized (allLists) {
115112
allLists.add(this);
@@ -191,7 +188,7 @@ public synchronized void unregister(@NotNull Listener listener) {
191188
*/
192189
public synchronized void bake() {
193190
if (handlers != null) return; // don't re-bake when still valid
194-
List<RegisteredListener> entries = new ArrayList<RegisteredListener>();
191+
List<RegisteredListener> entries = new ArrayList<>();
195192
for (Entry<EventPriority, ArrayList<RegisteredListener>> entry : handlerslots.entrySet()) {
196193
entries.addAll(entry.getValue());
197194
}

paper-api/src/main/java/org/bukkit/event/block/BellResonateEvent.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.bukkit.block.Block;
55
import org.bukkit.entity.LivingEntity;
66
import org.bukkit.event.HandlerList;
7+
import org.jetbrains.annotations.ApiStatus;
78
import org.jetbrains.annotations.NotNull;
89

910
/**
@@ -12,16 +13,18 @@
1213
*/
1314
public class BellResonateEvent extends BlockEvent {
1415

15-
private static final HandlerList handlers = new HandlerList();
16+
private static final HandlerList HANDLER_LIST = new HandlerList();
17+
1618
private final List<LivingEntity> resonatedEntities;
1719

20+
@ApiStatus.Internal
1821
public BellResonateEvent(@NotNull Block bell, @NotNull List<LivingEntity> resonatedEntities) {
1922
super(bell);
2023
this.resonatedEntities = resonatedEntities;
2124
}
2225

2326
/**
24-
* Get a mutable list of all {@link LivingEntity LivingEntities} to be
27+
* Get a mutable list of all {@link LivingEntity entities} to be
2528
* highlighted by the bell's resonating. This list can be added to or
2629
* removed from to change which entities are highlighted, and may be empty
2730
* if no entities were resonated as a result of this event.
@@ -34,17 +37,17 @@ public BellResonateEvent(@NotNull Block bell, @NotNull List<LivingEntity> resona
3437
*/
3538
@NotNull
3639
public List<LivingEntity> getResonatedEntities() {
37-
return resonatedEntities;
40+
return this.resonatedEntities;
3841
}
3942

4043
@NotNull
4144
@Override
4245
public HandlerList getHandlers() {
43-
return handlers;
46+
return HANDLER_LIST;
4447
}
4548

4649
@NotNull
4750
public static HandlerList getHandlerList() {
48-
return handlers;
51+
return HANDLER_LIST;
4952
}
5053
}

paper-api/src/main/java/org/bukkit/event/block/BellRingEvent.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.bukkit.entity.Entity;
66
import org.bukkit.event.Cancellable;
77
import org.bukkit.event.HandlerList;
8+
import org.jetbrains.annotations.ApiStatus;
89
import org.jetbrains.annotations.NotNull;
910
import org.jetbrains.annotations.Nullable;
1011

@@ -13,11 +14,14 @@
1314
*/
1415
public class BellRingEvent extends BlockEvent implements Cancellable {
1516

16-
private static final HandlerList handlers = new HandlerList();
17+
private static final HandlerList HANDLER_LIST = new HandlerList();
18+
1719
private final BlockFace direction;
1820
private final Entity entity;
21+
1922
private boolean cancelled;
2023

24+
@ApiStatus.Internal
2125
public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) {
2226
super(block);
2327
this.direction = direction;
@@ -57,11 +61,11 @@ public boolean isCancelled() {
5761
@NotNull
5862
@Override
5963
public HandlerList getHandlers() {
60-
return handlers;
64+
return HANDLER_LIST;
6165
}
6266

6367
@NotNull
6468
public static HandlerList getHandlerList() {
65-
return handlers;
69+
return HANDLER_LIST;
6670
}
6771
}

0 commit comments

Comments
 (0)