Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}
}
}

/**
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 <filter1> <filter2> …");
return true;
Expand Down
22 changes: 16 additions & 6 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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]

Expand All @@ -22,15 +21,26 @@ commands:
warp:
description: Command for managing warps.
usage: /warp <subcommand>
aliases: [ warps, wp ]
warpbt:
aliases: [warps]
warpsbt:
description: Opens the warp menu for the specified BuildTeam
usage: /warpsbt <team>
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 <ID>
permission: plotsystem.pasteplot
plotsystemterra:
description: Sends info about the plugin
usage: /plotsystemterra
blockpalette:
description: Opens the block palette menu.
usage: /blockpalette [filter|menu|filter <filter1> <filter2> ...]
Expand Down
Loading