Add documentation to custom Plex events + config

This commit is contained in:
Taahh 2022-02-07 09:07:48 -08:00 committed by GitHub
parent 917775e7e7
commit bd8c772228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 100 additions and 4 deletions

View File

@ -4,12 +4,30 @@ import dev.plex.Plex;
import java.io.File;
import org.bukkit.configuration.file.YamlConfiguration;
/**
* Creates a custom Config object
*/
public class Config extends YamlConfiguration
{
/**
* The plugin instance
*/
private Plex plugin;
/**
* The File instance
*/
private File file;
/**
* The file name
*/
private String name;
/**
* Creates a config object
* @param plugin The plugin instance
* @param name The file name
*/
public Config(Plex plugin, String name)
{
this.plugin = plugin;
@ -22,6 +40,9 @@ public class Config extends YamlConfiguration
}
}
/**
* Loads the configuration file
*/
public void load()
{
try
@ -34,6 +55,9 @@ public class Config extends YamlConfiguration
}
}
/**
* Saves the configuration file
*/
public void save()
{
try
@ -46,6 +70,9 @@ public class Config extends YamlConfiguration
}
}
/**
* Moves the configuration file from the plugin's resources folder to the data folder (plugins/Plex/)
*/
private void saveDefault()
{
plugin.saveResource(name, false);

View File

@ -6,12 +6,22 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Event that is ran when a player is added to the admin list
*/
@Data
public class AdminAddEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
/**
* The sender who added the player
*/
private final CommandSender sender;
/**
* The PlexPlayer that was added
*/
private final PlexPlayer plexPlayer;
@Override

View File

@ -6,12 +6,22 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Event that is ran when a player is removed from the admin list
*/
@Data
public class AdminRemoveEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
/**
* The sender who added the player
*/
private final CommandSender sender;
/**
* The PlexPlayer that was removed
*/
private final PlexPlayer plexPlayer;
@Override

View File

@ -7,13 +7,27 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Event that is ran when an admin's rank is set
*/
@Data
public class AdminSetRankEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
/**
* The sender who added the player
*/
private final CommandSender sender;
/**
* The PlexPlayer that was removed
*/
private final PlexPlayer plexPlayer;
/**
* The rank the player was set to
*/
private final Rank rank;

View File

@ -8,13 +8,28 @@ import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
import org.bukkit.event.player.PlayerEvent;
/**
* Superclass for punishment events
*/
@Getter
public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancellable
{
/**
* The player who was punished
*/
protected PunishedPlayer punishedPlayer;
@Setter
protected boolean cancelled;
/**
* Whether the event was cancelled
*/
@Setter
protected boolean cancelled; //TODO: unsure if cancelling the event does anything
/**
* Creates an event object
* @param punishedPlayer The player who was punished
* @see PunishedPlayer
*/
protected PunishedPlayerEvent(PunishedPlayer punishedPlayer)
{
super(Bukkit.getPlayer(UUID.fromString(punishedPlayer.getUuid())));

View File

@ -5,16 +5,25 @@ import lombok.Getter;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
//TODO: Event doesn't look like it is called
/**
* Event that is called when a player is frozen or unfrozen
*/
@Getter
public class PunishedPlayerFreezeEvent extends PunishedPlayerEvent implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
/**
* Status of the Punished Player being frozen before the event's occurrence.
* New frozen state of the player
*/
private final boolean frozen;
/**
* Creates a new event instance
* @param punishedPlayer The player who was punished
* @param frozen The new frozen status
*/
public PunishedPlayerFreezeEvent(PunishedPlayer punishedPlayer, boolean frozen)
{
super(punishedPlayer);

View File

@ -5,16 +5,25 @@ import lombok.Getter;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
//TODO: Event doesn't look like it is called
/**
* Event that is called when a player is frozen or unfrozen
*/
@Getter
public class PunishedPlayerMuteEvent extends PunishedPlayerEvent implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
/**
* Status of the Punished Player being frozen before the event's occurrence.
* New muted state of the player
*/
private final boolean muted;
/**
* Creates a new event instance
* @param punishedPlayer The player who was punished
* @param muted The new muted status
*/
public PunishedPlayerMuteEvent(PunishedPlayer punishedPlayer, boolean muted)
{
super(punishedPlayer);

View File

@ -7,6 +7,7 @@ import dev.plex.command.impl.*;
import dev.plex.util.PlexLog;
import java.util.List;
//TODO: Switch to Reflections API
public class CommandHandler extends PlexBase
{
public CommandHandler()

View File

@ -13,6 +13,7 @@ import dev.plex.listener.impl.WorldListener;
import dev.plex.util.PlexLog;
import java.util.List;
//TODO: Switch to Reflections API
public class ListenerHandler
{
public ListenerHandler()