Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ intuitive entry point for newcomers to the project.
## Features

🔨 **Easy-to-use** Tools
⏱ **Multi-Version** support from `1.18` - `26.x`
⏱ **Multi-Version** support from `1.20.6` - `26.x`<br/>
✔️ **User-friendly** GUIs and Commands
📆 **Automatic** Updates
🔌 **Easy setup** and configuration
Expand All @@ -82,7 +82,7 @@ outdated.*

💻 **Requirements:**

- A Server running Paper 1.18 - **26.x**.
- A Server running Paper 1.20.6 - **26.x**.

🚩 **How to install:**

Expand All @@ -102,6 +102,11 @@ outdated.*

**For more help, please see the [wiki](https://resources.buildtheearth.net/s/btt).**

Use `/btt help` for in-game command help. See the
[Commands & Permissions](https://resources.buildtheearth.net/s/btt/doc/commands-permissions-wbqTdIlhWx)
and [Configuration](https://resources.buildtheearth.net/s/btt/doc/configuration-tpEHSZ6Zt2)
pages for the maintained command and configuration documentation.

## Contributors

Thanks to all our contributors for contributing towards the plugin development and improvement!
Expand Down
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ dependencies {
implementation(libs.anvilgui)
implementation(libs.clipper2)
implementation(libs.dazzleconf)
implementation(libs.cloud.core)
implementation(libs.cloud.paper)
implementation(libs.cloud.minecraft.extras)
implementation(libs.json)
implementation(libs.googlecode.gson)
implementation(libs.okhttp.jvm)
Expand Down
7 changes: 7 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ bstats = "3.2.1"
buildtheearth-projection = "1.0.5"
# @pin Waiting for dependency update in alps - lib - Used in AlpsLib-Utils#GeneratorUtils https://github.com/micycle1/Clipper2-java/releases
clipper2 = "1.5.4"
# https://github.com/Incendo/cloud
cloud-core = "2.1.0"
# https://github.com/Incendo/cloud-minecraft
cloud-minecraft = "2.0.1"
# Ref https://github.com/A248/DazzleConf/releases
dazzleconf = "2.0.0-M3"
# Ref: https://github.com/IntellectualSites/bom
Expand Down Expand Up @@ -61,6 +65,9 @@ bluemap-api = { module = "de.bluecolored:bluemap-api", version.ref = "bluemap-ap
bstats-bukkit = { module = "org.bstats:bstats-bukkit", version.ref = "bstats" }
buildtheearth-projection = { module = "net.buildtheearth:projection", version.ref = "buildtheearth-projection" }
clipper2 = { module = "com.github.micycle1:Clipper2-java", version.ref = "clipper2" }
cloud-core = { module = "org.incendo:cloud-core", version.ref = "cloud-core" }
cloud-paper = { module = "org.incendo:cloud-paper", version.ref = "cloud-minecraft" }
cloud-minecraft-extras = { module = "org.incendo:cloud-minecraft-extras", version.ref = "cloud-minecraft" }
dazzleconf = { module = "space.arim.dazzleconf:dazzleconf-yaml", version.ref = "dazzleconf" }
com-alpsbte-alpslib-alpslib-libpsterra = { module = "com.alpsbte.alpslib:alpslib-libpsterra", version.ref = "alpslib-libpsterra" }
fawe-bom = { module = "com.intellectualsites.bom:bom-newest", version.ref = "fawe-bom" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Getter;
import net.buildtheearth.buildteamtools.modules.ModuleHandler;
import net.buildtheearth.buildteamtools.modules.common.CommonModule;
import net.buildtheearth.buildteamtools.modules.common.commands.BttCommandManager;
import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
import net.buildtheearth.buildteamtools.modules.miscellaneous.MiscModule;
import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
Expand Down Expand Up @@ -38,6 +39,8 @@ public class BuildTeamTools extends JavaPlugin {
private ConfigurationLoader<NavigationConfig> navigationConfigLoader;
private ConfigurationLoader<GeneratorConfig> generatorConfigLoader;
private ConfigurationLoader<PlotSystemConfig> plotSystemConfigLoader;
@Getter
private BttCommandManager commandManager;

@Override
public void onEnable() {
Expand All @@ -53,6 +56,7 @@ public void onEnable() {
NavigationConfig navigationConfig = navigationConfigLoader.load();
GeneratorConfig generatorConfig = generatorConfigLoader.load();
plotSystemConfigLoader.load();
commandManager = new BttCommandManager(this);

// Register Modules
ModuleHandler.getInstance().replaceModules(
Expand All @@ -65,6 +69,7 @@ public void onEnable() {
PlotSystemModule.getInstance()
);
ModuleHandler.getInstance().enableAll(null);
commandManager.registerEnabledCommands();
}

@Override
Expand Down
57 changes: 3 additions & 54 deletions src/main/java/net/buildtheearth/buildteamtools/modules/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
import com.alpsbte.alpslib.utils.ChatHelper;
import com.alpsbte.alpslib.utils.WikiDocumented;
import lombok.Getter;
import lombok.NonNull;
import net.buildtheearth.buildteamtools.BuildTeamTools;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
Expand All @@ -37,12 +32,6 @@ public abstract class Module implements WikiDocumented {
@Getter
private final List<Listener> listeners = new ArrayList<>();

@Getter
private final HashMap<PluginCommand, CommandExecutor> commands = new HashMap<>();

@Getter
private final HashMap<PluginCommand, TabCompleter> tabCompleter = new HashMap<>();

@Getter
private final List<Module> dependsOnModules = new ArrayList<>();

Expand Down Expand Up @@ -74,10 +63,12 @@ protected Module(String moduleName, String wikiPage, Module... dependsOnModules)
public void enable() {
checkForModuleDependencies();

loadCommands();
loadListeners();

enabled = true;
BuildTeamTools plugin = BuildTeamTools.getInstance();
if (plugin != null && plugin.getCommandManager() != null)
plugin.getCommandManager().registerEnabledCommands(this);
}

/**
Expand Down Expand Up @@ -113,48 +104,6 @@ public void shutdown(String reason) {
protected void registerCommands() {
}

/**
* Registers a command for the module.
* Note that this method will only register the command in the module, but it won't load it in Bukkit.
* To load the command, use the loadCommands() method.
*
* @param command The command to register
* @param executor The executor for the command. If the executor is also a TabCompleter, the TabCompleter will be
* registered as well.
*/
protected void registerCommand(@NonNull String command, @NonNull CommandExecutor executor) {
this.commands.put(BuildTeamTools.getInstance().getCommand(command), executor);

if (executor instanceof TabCompleter tc)
this.tabCompleter.put(BuildTeamTools.getInstance().getCommand(command), tc);
}

/**
* Registers a command for the module.
* Note that this method will only register the command in the module, but it won't load it in Bukkit.
* To load the command, use the loadCommands() method.
*
* @param command The command to register
* @param executor The executor for the command.
* @param tabCompleter The tab completer for the command. Only needed to specify if the TabCompleter is in a different
* class than the executor.
*/
protected void registerCommand(@NonNull String command, @NonNull CommandExecutor executor,
@NonNull TabCompleter tabCompleter) {
this.commands.put(BuildTeamTools.getInstance().getCommand(command), executor);
this.tabCompleter.put(BuildTeamTools.getInstance().getCommand(command), tabCompleter);
}

/**
* Loads the commands for the module into Bukkit
*/
private void loadCommands() {
for (var command : commands.entrySet())
command.getKey().setExecutor(command.getValue());

for (var command : tabCompleter.entrySet())
command.getKey().setTabCompleter(command.getValue());
}


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.buildtheearth.buildteamtools.modules.common.components.dependency.DependencyComponent;
import net.buildtheearth.buildteamtools.modules.common.components.pluginmessaging.PluginMessagingComponent;
import net.buildtheearth.buildteamtools.modules.common.components.updater.UpdaterComponent;
import net.buildtheearth.buildteamtools.modules.common.listeners.CommandListener;
import net.buildtheearth.buildteamtools.modules.common.listeners.ExceptionListener;
import net.buildtheearth.buildteamtools.modules.common.metrics.MetricsManager;
import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
Expand Down Expand Up @@ -72,12 +71,12 @@ public void enable() {

@Override
public void registerCommands() {
registerCommand("buildteamtools", new BuildTeamToolsCommand());
new BuildTeamToolsCommand().register(this);
}

@Override
public void registerListeners() {
super.registerListeners(new MenuFunctionListener(), new CommandListener(), new ExceptionListener());
super.registerListeners(new MenuFunctionListener(), new ExceptionListener());
}


Expand Down
Loading
Loading