mirror of
https://github.com/xoo0524tw/OpenMBedwars.git
synced 2026-12-05 22:06:02 +02:00
59 lines
1.6 KiB
Java
59 lines
1.6 KiB
Java
package de.marcely.bedwars.api;
|
|
|
|
import de.marcely.bedwars.api.command.CommandsCollection;
|
|
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
|
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
|
import de.marcely.bedwars.tools.Helper;
|
|
import java.io.File;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
public abstract class BedwarsAddon {
|
|
private final Plugin plugin;
|
|
private CommandsCollection commandsCollection;
|
|
|
|
public BedwarsAddon(Plugin var1) {
|
|
this.plugin = var1;
|
|
}
|
|
|
|
public final Plugin getPlugin() {
|
|
return this.plugin;
|
|
}
|
|
|
|
public String getName() {
|
|
return Helper.get().replaceFirst(this.plugin.getName(), "MBedwars_", "");
|
|
}
|
|
|
|
public String getVersion() {
|
|
return this.plugin.getDescription().getVersion();
|
|
}
|
|
|
|
public String[] getAuthors() {
|
|
return this.plugin.getDescription().getAuthors().stream().toArray(String[]::new);
|
|
}
|
|
|
|
@Nullable
|
|
public CommandsCollection getCommandsRoot() {
|
|
if (this.commandsCollection == null) {
|
|
return this.commandsCollection = BedwarsAPILayer.INSTANCE.getAddonCommandsCollection(this);
|
|
} else {
|
|
return this.isRegistered() ? this.commandsCollection : null;
|
|
}
|
|
}
|
|
|
|
public File getDataFolder() {
|
|
return BedwarsAPILayer.INSTANCE.getAddonDataFolder(this);
|
|
}
|
|
|
|
public final boolean register() {
|
|
return BedwarsAPILayer.INSTANCE.registerAddon(this);
|
|
}
|
|
|
|
public final boolean unregister() {
|
|
return BedwarsAPILayer.INSTANCE.unregisterAddon(this);
|
|
}
|
|
|
|
public final boolean isRegistered() {
|
|
return BedwarsAPILayer.INSTANCE.isRegisteredAddon(this);
|
|
}
|
|
}
|