diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/ModuleHandler.java b/src/main/java/net/buildtheearth/buildteamtools/modules/ModuleHandler.java index 2bb8e756..d2ad004f 100644 --- a/src/main/java/net/buildtheearth/buildteamtools/modules/ModuleHandler.java +++ b/src/main/java/net/buildtheearth/buildteamtools/modules/ModuleHandler.java @@ -1,17 +1,18 @@ -package net.buildtheearth.buildteamtools.modules; +package net.buildtheearth.modules; -import com.alpsbte.alpslib.utils.ChatHelper; import lombok.Getter; -import net.buildtheearth.buildteamtools.BuildTeamTools; -import net.buildtheearth.buildteamtools.utils.io.ConfigPaths; +import net.buildtheearth.BuildTeamTools; +import net.buildtheearth.utils.ChatHelper; +import net.buildtheearth.utils.io.ConfigPaths; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Noah Husby @@ -44,8 +45,11 @@ public void registerModule(Module module) { * @param modules {@link Module} */ public void registerModules(Module @NotNull ... modules) { - for (Module m : modules) - registerModule(m); + for (Module m : modules) { + if (!Objects.requireNonNull(BuildTeamTools.getInstance().getConfig().getList(ConfigPaths.DISABLED_MODULES)).contains(m.getModuleName())) { + registerModule(m); + } + } } /** @@ -60,31 +64,24 @@ public boolean enable(@NotNull Module module, @Nullable CommandSender executor) if (m.getModuleName().equals(module.getModuleName()) && m.isEnabled()) return false; - if (!module.getModuleName().equals("Common") && BuildTeamTools.getInstance().getConfig() - .getStringList(ConfigPaths.DISABLED_MODULES).stream().anyMatch(module.getModuleName()::equalsIgnoreCase)) { - module.shutdown("This module is disabled in the config."); - } else { - boolean containsDisabledDependencyModule = false; - for (Module m : module.getDependsOnModules()) - if (!m.isEnabled()) { - module.checkForModuleDependencies(); - containsDisabledDependencyModule = true; - } - - try { - if (!containsDisabledDependencyModule) - module.enable(); - } catch (Exception ex) { - if (BuildTeamTools.getInstance().isDebug()) { - ChatHelper.logError("An error occurred while enabling the %s Module: %s", ex, module.getModuleName(), - ex.getMessage()); - } - - module.shutdown(ex.getMessage()); + boolean containsDisabledDependencyModule = false; + for (Module m : module.getDependsOnModules()) + if (!m.isEnabled()) { + module.checkForModuleDependencies(); + containsDisabledDependencyModule = true; } - } + try { + if (!containsDisabledDependencyModule) + module.enable(); + } catch (Exception ex) { + if (BuildTeamTools.getInstance().isDebug()) { + ChatHelper.logError("An error occurred while enabling the %s Module: %s", ex, module.getModuleName(), + ex.getMessage()); + } + module.shutdown(ex.getMessage()); + } if (executor != null) { if (module.isEnabled() && BuildTeamTools.getInstance().isDebug()) diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java index b94edbc6..824e9353 100644 --- a/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java +++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java @@ -35,11 +35,17 @@ public boolean onCommand(CommandSender sender, sender.sendMessage("This command can only be used by players."); return true; } + Player player = (Player) sender; - // /bp or /bp menu ⇒ default filters + open block menu - if (args.length == 0 - || (args.length == 1 && args[0].equalsIgnoreCase("menu"))) { + // /bp ⇒ open block menu with remembered filters (do NOT reset to "color") + if (args.length == 0) { + blockPalletManager.openBlockMenu(player); + return true; + } + + // /bp menu ⇒ reset to default filters + open block menu + if (args.length == 1 && args[0].equalsIgnoreCase("menu")) { blockPalletManager.setPlayerFiltersAndOpen(player); return true; } @@ -61,7 +67,8 @@ public boolean onCommand(CommandSender sender, } // invalid usage ⇒ show help - sender.sendMessage("§cUsage: §7/bp menu\n" + sender.sendMessage("§cUsage: §7/bp\n" + + "§c or §7/bp menu\n" + "§c or §7/bp filter\n" + "§c or §7/bp filter …"); return true; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b7984b01..dece42e8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,8 +1,7 @@ name: BuildTeamTools -main: net.buildtheearth.buildteamtools.BuildTeamTools +main: net.buildtheearth.BuildTeamTools api-version: 1.13 -version: ${version} -description: ${description} +version: 0.1.3-alpha author: MineFact, frikandelworst, George112n, ELgamer, SirJodelstein, Zoriot softdepend: [WorldEdit, HeadDatabase, PlotSystem-Terra] @@ -22,15 +21,26 @@ commands: warp: description: Command for managing warps. usage: /warp - aliases: [ warps, wp ] - warpbt: + aliases: [warps] + warpsbt: description: Opens the warp menu for the specified BuildTeam usage: /warpsbt - aliases: [ wbt, wpt, warpsbuildteam, warpsbt ] + aliases: [ wbt ] kml: description: kml pasting and parsing usage: /kml aliases: [geopoints, geopath, georing, geosurface] + createplot: + description: Creates a new plot for the PlotSystem. + usage: /createplot + permission: plotsystem.createplot + pasteplot: + description: Pastes a plot manually with specific ID + usage: /pasteplot + permission: plotsystem.pasteplot + plotsystemterra: + description: Sends info about the plugin + usage: /plotsystemterra blockpalette: description: Opens the block palette menu. usage: /blockpalette [filter|menu|filter ...]