Adds comments to all custom events

Adds full comments to every class implementing StarGateEvent
Adds another abstract event StargatePlayerEvent which reduces code duplication
This commit is contained in:
2021-02-19 12:06:23 +01:00
parent 5b7f5649b1
commit c912624df1
10 changed files with 344 additions and 173 deletions

View File

@ -5,9 +5,12 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class StargateCreateEvent extends StargateEvent {
/**
* This event should be called whenever a stargate is created
*/
@SuppressWarnings("unused")
public class StargateCreateEvent extends StargatePlayerEvent {
private final Player player;
private boolean deny;
private String denyReason;
private final String[] lines;
@ -15,54 +18,102 @@ public class StargateCreateEvent extends StargateEvent {
private static final HandlerList handlers = new HandlerList();
@NotNull
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Instantiates a new stargate creation event
*
* @param player <p>Thg player creating the stargate</p>
* @param portal <p>The created portal</p>
* @param lines <p>The lines of the sign creating the star gate</p>
* @param deny <p>Whether to deny the creation of the new gate</p>
* @param denyReason <p>The reason stargate creation was denied</p>
* @param cost <p>The cost of creating the new star gate</p>
*/
public StargateCreateEvent(Player player, Portal portal, String[] lines, boolean deny, String denyReason, int cost) {
super("StargateCreateEvent", portal);
this.player = player;
super("StargateCreateEvent", portal, player);
this.lines = lines;
this.deny = deny;
this.denyReason = denyReason;
this.cost = cost;
}
public Player getPlayer() {
return player;
}
/**
* Gets a given line from the sign creating the star gate
*
* @param index <p>The line number to get</p>
* @return <p>The text on the given line</p>
* @throws IndexOutOfBoundsException <p>If given a line index less than zero or above three</p>
*/
public String getLine(int index) throws IndexOutOfBoundsException {
return lines[index];
}
/**
* Gets whether the stargate creation should be denied
*
* @return <p>Whether the stargate creation should be denied</p>
*/
public boolean getDeny() {
return deny;
}
/**
* Sets whether the stargate creation should be denied
*
* @param deny <p>Whether the stargate creation should be denied</p>
*/
public void setDeny(boolean deny) {
this.deny = deny;
}
/**
* Gets the reason the stargate creation was denied
*
* @return <p>The reason the stargate creation was denied</p>
*/
public String getDenyReason() {
return denyReason;
}
/**
* Sets the reason the stargate creation was denied
*
* @param denyReason <p>The new reason why the stargate creation was denied</p>
*/
public void setDenyReason(String denyReason) {
this.denyReason = denyReason;
}
/**
* Gets the cost of creating the stargate
*
* @return <p>The cost of creating the stargate</p>
*/
public int getCost() {
return cost;
}
/**
* Sets the cost of creating the stargate
*
* @param cost <p>The new cost of creating the stargate</p>
*/
public void setCost(int cost) {
this.cost = cost;
}
/**
* Gets a handler-list containing all event handlers
*
* @return <p>A handler-list with all event handlers</p>
*/
public static HandlerList getHandlerList() {
return handlers;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
}