mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +00:00
JavaDocs!
Simple Docs
This commit is contained in:
parent
29cd81edbc
commit
2b1e9b7362
@ -5,18 +5,41 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation must be used to annotate every command class.
|
||||||
|
* Please also ensure that your commands are in their own package (ie .commands)
|
||||||
|
* This helps the {@link io.github.simplexdev.simplexcore.command.CommandLoader} to correctly load your commands.
|
||||||
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface CommandInfo {
|
public @interface CommandInfo {
|
||||||
|
/**
|
||||||
|
* @return The name of the command.
|
||||||
|
*/
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The description of the command.
|
||||||
|
*/
|
||||||
String description();
|
String description();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return How the command should be used.
|
||||||
|
*/
|
||||||
String usage();
|
String usage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A list of aliases of the command separated by commas in a single String.
|
||||||
|
*/
|
||||||
String aliases() default "";
|
String aliases() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The permission for the command
|
||||||
|
*/
|
||||||
String permission() default "simplex.core";
|
String permission() default "simplex.core";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The message to send if someone does not have permission to use the command.
|
||||||
|
*/
|
||||||
String permissionMessage() default "You do not have permission to use this command.";
|
String permissionMessage() default "You do not have permission to use this command.";
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,10 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
|||||||
private TimeValues time;
|
private TimeValues time;
|
||||||
private Yaml internals;
|
private Yaml internals;
|
||||||
|
|
||||||
// should this just be 'new SimplexCorePlugin()' ?
|
protected static SimplexCorePlugin instance; // = getPlugin(SimplexCorePlugin.class);
|
||||||
protected static final SimplexCorePlugin instance = getPlugin(SimplexCorePlugin.class);
|
public static SimplexCorePlugin getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SimplexCorePlugin getPlugin() {
|
public SimplexCorePlugin getPlugin() {
|
||||||
@ -35,6 +37,7 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
|
instance = this;
|
||||||
this.dpm = new DependencyManagement();
|
this.dpm = new DependencyManagement();
|
||||||
this.config = new YamlFactory(this).setDefaultPathways();
|
this.config = new YamlFactory(this).setDefaultPathways();
|
||||||
this.time = new TimeValues();
|
this.time = new TimeValues();
|
||||||
@ -77,10 +80,6 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
|||||||
return suspended;
|
return suspended;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimplexCorePlugin getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return this.getServer().getLogger();
|
return this.getServer().getLogger();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,10 @@ public final class CommandLoader {
|
|||||||
private Reflections reflections;
|
private Reflections reflections;
|
||||||
private static final CommandLoader instance = new CommandLoader();
|
private static final CommandLoader instance = new CommandLoader();
|
||||||
|
|
||||||
public static CommandLoader getInstance() {
|
/**
|
||||||
|
* @return A Singleton Pattern instance of this class.
|
||||||
|
*/
|
||||||
|
public static synchronized CommandLoader getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +83,13 @@ public final class CommandLoader {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the command class as a child of {@link CommandExecutor} from the {@link CommandInfo#name()} annotation.
|
||||||
|
* This is for registering the CommandExecutor of the provided command with Bukkit.
|
||||||
|
* This should only be used by the CommandLoader.
|
||||||
|
* @param name The name of the command.
|
||||||
|
* @return An instance of the command class as a CommandExecutor.
|
||||||
|
*/
|
||||||
public synchronized CommandExecutor getExecutorFromName(String name) {
|
public synchronized CommandExecutor getExecutorFromName(String name) {
|
||||||
for (Class<? extends CommandExecutor> obj : reflections.getSubTypesOf(CommandExecutor.class)) {
|
for (Class<? extends CommandExecutor> obj : reflections.getSubTypesOf(CommandExecutor.class)) {
|
||||||
if (!obj.isAnnotationPresent(CommandInfo.class)) {
|
if (!obj.isAnnotationPresent(CommandInfo.class)) {
|
||||||
@ -101,6 +111,13 @@ public final class CommandLoader {
|
|||||||
throw new RuntimeException("Unable to get a command executor! Terminating!");
|
throw new RuntimeException("Unable to get a command executor! Terminating!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the command class as a child of {@link TabCompleter} from the {@link CommandInfo#name()} annotation.
|
||||||
|
* This is for registering the TabCompleter of the provided command with Bukkit.
|
||||||
|
* This should only be used by the CommandLoader.
|
||||||
|
* @param name The name of the command
|
||||||
|
* @return The command as an instance of TabCompleter
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public synchronized TabCompleter getTabFromName(String name) {
|
public synchronized TabCompleter getTabFromName(String name) {
|
||||||
for (Class<? extends TabCompleter> obj : reflections.getSubTypesOf(TabCompleter.class)) {
|
for (Class<? extends TabCompleter> obj : reflections.getSubTypesOf(TabCompleter.class)) {
|
||||||
|
@ -20,27 +20,55 @@ public abstract class SimplexCommand implements CommandExecutor, TabCompleter {
|
|||||||
return sender instanceof Player;
|
return sender instanceof Player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an online player from their username
|
||||||
|
* @param name The player's username
|
||||||
|
* @return An instance of {@link Player} which represents the online player in question.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Player getPlayer(String name) {
|
public Player getPlayer(String name) {
|
||||||
return SimplexCorePlugin.getInstance().getServer().getPlayer(name);
|
return SimplexCorePlugin.getInstance().getServer().getPlayer(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an online player from their {@link UUID}.
|
||||||
|
* @param uuid The player's UUID
|
||||||
|
* @return An instance of {@link Player} which represents the online player in question.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Player getPlayer(UUID uuid) {
|
public Player getPlayer(UUID uuid) {
|
||||||
return SimplexCorePlugin.getInstance().getServer().getPlayer(uuid);
|
return SimplexCorePlugin.getInstance().getServer().getPlayer(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an instance of {@link Player} based off an instance of {@link CommandSender}.
|
||||||
|
* This will be null if the condition {CommandSender instanceof Player} is false.
|
||||||
|
* @param sender The CommandSender to cast
|
||||||
|
* @return An instance of Player relating to CommandSender.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Player getPlayer(CommandSender sender) {
|
public Player getPlayer(CommandSender sender) {
|
||||||
return isPlayer(sender) ? (Player) sender : null;
|
return isPlayer(sender) ? (Player) sender : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message or a group of messages to a {@link Player}.
|
||||||
|
* If you want the messages to send on new lines, put \n at the end of each message to send.
|
||||||
|
* @param player The Player to send a message to
|
||||||
|
* @param messages The messages to send.
|
||||||
|
*/
|
||||||
public void playerMsg(Player player, String... messages) {
|
public void playerMsg(Player player, String... messages) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
Utilities.forEach(messages, builder::append);
|
Utilities.forEach(messages, builder::append);
|
||||||
player.sendMessage(builder.toString());
|
player.sendMessage(builder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message or a group of messages to a {@link CommandSender}
|
||||||
|
* If you want the messages to send on new lines, put \n at the end of each message to send.
|
||||||
|
* @param sender The CommandSender to send a message to.
|
||||||
|
* @param messages The messages to send.
|
||||||
|
*/
|
||||||
public void msg(CommandSender sender, String... messages) {
|
public void msg(CommandSender sender, String... messages) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
Utilities.forEach(messages, builder::append);
|
Utilities.forEach(messages, builder::append);
|
||||||
|
@ -14,7 +14,7 @@ public final class AddonRegistry {
|
|||||||
protected AddonRegistry() {
|
protected AddonRegistry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AddonRegistry getInstance() {
|
public static synchronized AddonRegistry getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user