reformatted event classes, added nullability annotations, made classes final.

This commit is contained in:
Sxtanna 2020-07-21 11:56:57 -04:00
parent ee78fc1775
commit bdf8a1bcc1
3 changed files with 120 additions and 62 deletions

View File

@ -24,38 +24,57 @@ import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class ExpansionRegisterEvent extends Event implements Cancellable { public final class ExpansionRegisterEvent extends Event implements Cancellable
{
@NotNull
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
private boolean cancelled;
@NotNull
private final PlaceholderExpansion expansion; private final PlaceholderExpansion expansion;
private boolean isCancelled;
public ExpansionRegisterEvent(@NotNull final PlaceholderExpansion expansion)
public ExpansionRegisterEvent(PlaceholderExpansion expansion) { {
this.expansion = expansion; this.expansion = expansion;
} }
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override @NotNull
public HandlerList getHandlers() { public PlaceholderExpansion getExpansion()
return HANDLERS; {
}
public PlaceholderExpansion getExpansion() {
return expansion; return expansion;
} }
@Override @Override
public boolean isCancelled() { public boolean isCancelled()
return isCancelled; {
return cancelled;
} }
@Override @Override
public void setCancelled(boolean b) { public void setCancelled(boolean cancelled)
this.isCancelled = b; {
this.cancelled = cancelled;
} }
@NotNull
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
@NotNull
public static HandlerList getHandlerList()
{
return HANDLERS;
}
} }

View File

@ -23,26 +23,43 @@ package me.clip.placeholderapi.events;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class ExpansionUnregisterEvent extends Event { public final class ExpansionUnregisterEvent extends Event
{
@NotNull
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
@NotNull
private final PlaceholderExpansion expansion; private final PlaceholderExpansion expansion;
public ExpansionUnregisterEvent(PlaceholderExpansion expansion) { public ExpansionUnregisterEvent(@NotNull final PlaceholderExpansion expansion)
{
this.expansion = expansion; this.expansion = expansion;
} }
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override @NotNull
public HandlerList getHandlers() { public PlaceholderExpansion getExpansion()
return HANDLERS; {
}
public PlaceholderExpansion getExpansion() {
return expansion; return expansion;
} }
@NotNull
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
@NotNull
public static HandlerList getHandlerList()
{
return HANDLERS;
}
} }

View File

@ -23,33 +23,55 @@ package me.clip.placeholderapi.events;
import me.clip.placeholderapi.PlaceholderHook; import me.clip.placeholderapi.PlaceholderHook;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* @deprecated This event is no longer used.
*/
@Deprecated @Deprecated
public class PlaceholderHookUnloadEvent extends Event { public final class PlaceholderHookUnloadEvent extends Event
{
@NotNull
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
@NotNull
private final String plugin; private final String plugin;
private final PlaceholderHook hook; @NotNull
private final PlaceholderHook placeholderHook;
public PlaceholderHookUnloadEvent(String plugin, PlaceholderHook placeholderHook) { public PlaceholderHookUnloadEvent(@NotNull final String plugin, @NotNull final PlaceholderHook placeholderHook)
{
this.plugin = plugin; this.plugin = plugin;
this.hook = placeholderHook; this.placeholderHook = placeholderHook;
} }
public static HandlerList getHandlerList() { @NotNull
return HANDLERS; public String getHookName()
} {
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public String getHookName() {
return plugin; return plugin;
} }
public PlaceholderHook getHook() { @NotNull
return hook; public PlaceholderHook getHook()
{
return placeholderHook;
} }
@NotNull
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
@NotNull
public static HandlerList getHandlerList()
{
return HANDLERS;
}
} }