Skip to content

Commit 8fae925

Browse files
authored
Merge pull request #49 from BuildTheEarth/improveNavigator
Improve Navigator (Feature Complete for First Release)
2 parents d2601ae + 31f31b5 commit 8fae925

39 files changed

+1126
-675
lines changed

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<p align="center">
1515
<b>An easy to use toolset for Build Teams in the BuildTheEarth project.</b>
1616
<br/>
17-
<a href="https://github.com/BuildTheEarth/BuildTeamTools/wiki/"><strong>WIKI »</strong></a>
17+
<a href="https://resources.buildtheearth.net/s/btt"><strong>WIKI »</strong></a>
1818
<br/><br/>
1919
</p>
2020

@@ -69,15 +69,15 @@ The **\*** symbol shows that this feature is still being developed or under main
6969
🚩 **How to install:**
7070
1. Download BuildTeamTools [here](https://www.spigotmc.org/resources/buildteamtools.101854/).
7171
2. Place the downloaded plugin in your server's **../plugins** folder.
72-
3. *(Optional)* Some of the modules require intial configuration or dependencies to run:
72+
3. *(Optional)* Some of the modules require initial configuration or dependencies to run:
7373
> - To activate the **Navigation Module**, please configure an **API Key** in the config.yml file.
7474
> - To activate the **Network Module**, please configure an **API Key** in the config.yml file.
75-
> - To activate the **Generator Module**, please install the [WorldEdit](https://dev.bukkit.org/projects/worldedit) or [AsyncWorldEdit](https://www.spigotmc.org/resources/asyncworldedit.327/) plugin.
75+
> - To activate the **Generator Module**, please install the [FastAsyncWorldEdit](https://modrinth.com/plugin/fastasyncworldedit/versions/) plugin.
7676
> - To activate the **Tree Generator Component**, install the [SchematicBrush 0.5.2](https://dev.bukkit.org/projects/schematicbrush) plugin.
7777
4. Restart your server.
7878
5. Done!
7979

80-
**For more help, please see the [wiki](https://github.com/BuildTheEarth/BuildTeamTools/wiki/Installation).**
80+
**For more help, please see the [wiki](https://resources.buildtheearth.net/s/btt).**
8181

8282
## Contributors
8383
Thank you to the following developers for contributing towards the plugin:
@@ -88,20 +88,21 @@ Thank you to the following developers for contributing towards the plugin:
8888
- **v4siv**
8989
- **Adam**
9090
- **Noah Husby**
91+
- **Zoriot**
9192

9293

9394
## Index
94-
Click the links below for more information, or see the [wiki](https://github.com/BuildTheEarth/BuildTeamTools/wiki).
95-
96-
- [Generators](https://github.com/BuildTheEarth/BuildTeamTools/wiki/Generators)
97-
- [Houses](https://github.com/BuildTheEarth/BuildTeamTools/wiki/House-Command)
98-
- [Roads](https://github.com/BuildTheEarth/BuildTeamTools/wiki/Road-Command)
99-
- [Railways](https://github.com/BuildTheEarth/BuildTeamTools/wiki/Rail-Command)
100-
- [Trees](https://github.com/BuildTheEarth/BuildTeamTools/wiki/Tree-Command)
101-
- [Fields](https://github.com/BuildTheEarth/BuildTeamTools/wiki/Field-Command)
102-
- [Sledgehammer](https://github.com/noahhusby/Sledgehammer) (PLANNED)
103-
- Statistics (PLANNED)
104-
- Plot System (PLANNED)
105-
- Tutorials (PLANNED)
95+
Click the links below for more information, or see the [wiki](https://resources.buildtheearth.net/s/btt).
96+
97+
- [Generators](https://resources.buildtheearth.net/s/btt/doc/generator-module-13zqgI4yFA)
98+
- [Houses](https://resources.buildtheearth.net/s/btt/doc/house-generator-YKQunon6Bp)
99+
- [Roads](https://resources.buildtheearth.net/s/btt/doc/road-generator-QqKBBP0nqO)
100+
- [Railways](https://resources.buildtheearth.net/s/btt/doc/rail-generator-EfgKXdBvk1)
101+
- [Trees](https://resources.buildtheearth.net/s/btt/doc/tree-generator-pnDmYC9hzW)
102+
- [Fields](https://resources.buildtheearth.net/s/btt/doc/field-generator-OqIN2BrZT7)
103+
- [Sledgehammer](https://resources.buildtheearth.net/s/btt/doc/sledgehammer-module-T7I0PWPsTD)
104+
- [Statistics](https://resources.buildtheearth.net/s/btt/doc/statistics-module-iM7IfoKroF) (PLANNED)
105+
- [Plot System](https://resources.buildtheearth.net/s/btt/doc/plot-system-module-kkcH00jpcQ) (PLANNED)
106+
- [Tutorials](https://resources.buildtheearth.net/s/btt/doc/tutorials-module-lkc3LaOrql) (PLANNED)
106107
- Miscellaneous (PLANNED)
107-
- Security (PLANNED)
108+
- [Security](https://resources.buildtheearth.net/s/btt/doc/security-module-iOmxV0djrW) (PLANNED)

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
<dependency>
281281
<groupId>com.github.cryptomorin</groupId>
282282
<artifactId>XSeries</artifactId>
283-
<version>13.3.3</version>
283+
<version>13.4.0</version>
284284
<scope>compile</scope>
285285
</dependency>
286286

@@ -289,7 +289,7 @@
289289
<dependency>
290290
<groupId>net.wesjd</groupId>
291291
<artifactId>anvilgui</artifactId>
292-
<version>1.10.7-SNAPSHOT</version>
292+
<version>1.10.8-SNAPSHOT</version>
293293
<scope>compile</scope>
294294
</dependency>
295295

src/main/java/net/buildtheearth/BuildTeamTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void onEnable() {
5252
StatsModule.getInstance(),
5353
MiscModule.getInstance()
5454
);
55-
ModuleHandler.getInstance().enableAll(null, true);
55+
ModuleHandler.getInstance().enableAll(null);
5656
}
5757

5858
@Override

src/main/java/net/buildtheearth/modules/ModuleHandler.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import net.buildtheearth.utils.ChatHelper;
66
import org.bukkit.Bukkit;
77
import org.bukkit.ChatColor;
8-
import org.bukkit.entity.Player;
8+
import org.bukkit.command.CommandSender;
9+
import org.jetbrains.annotations.NotNull;
910

1011
import javax.annotation.Nullable;
1112
import java.util.ArrayList;
@@ -50,11 +51,10 @@ public void registerModules(Module... modules) {
5051
* Enables a specific module
5152
*
5253
* @param module {@link Module}
53-
* @param executor the player that executed the command. If null, the command was executed by the system.
54-
* @param isStarting if the server is starting
54+
* @param executor the sender, if it's triggered via command, else null, when it's called by btt on plugin start.
5555
* @return True if successfully enabled, false if not
5656
*/
57-
public boolean enable(Module module, Player executor, boolean isStarting) {
57+
public boolean enable(@NotNull Module module, @Nullable CommandSender executor) {
5858
for (Module m : modules)
5959
if (m.getModuleName().equals(module.getModuleName()) && m.isEnabled())
6060
return false;
@@ -71,14 +71,14 @@ public boolean enable(Module module, Player executor, boolean isStarting) {
7171
module.enable();
7272
} catch (Exception ex) {
7373
if (BuildTeamTools.getInstance().isDebug()) {
74-
ChatHelper.logError("An error occurred while enabling the %s Module: %s", module.getModuleName(), ex.getMessage());
75-
ex.printStackTrace();
74+
ChatHelper.logError("An error occurred while enabling the %s Module: %s", ex, module.getModuleName(),
75+
ex.getMessage());
7676
}
7777

7878
module.shutdown(ex.getMessage());
7979
}
8080

81-
if (!isStarting) {
81+
if (executor != null) {
8282
if (module.isEnabled() && BuildTeamTools.getInstance().isDebug())
8383
ChatHelper.log("Successfully enabled %s Module", module.getModuleName());
8484
else {
@@ -112,10 +112,10 @@ public boolean enable(Module module, Player executor, boolean isStarting) {
112112
* Disables a specific module
113113
*
114114
* @param module {@link Module}
115-
* @param executor the player that executed the command. If null, the command was executed by the system.
115+
* @param executor the sender, if it's triggered via command, else null - when it's called by btt on plugin stop).
116116
* @return True if successfully disabled, false if not
117117
*/
118-
public boolean disable(Module module, Player executor) {
118+
public boolean disable(@NotNull Module module, @Nullable CommandSender executor) {
119119
boolean contains = false;
120120
for(Module m : modules)
121121
if (m.getModuleName().equals(module.getModuleName())) {
@@ -131,7 +131,7 @@ public boolean disable(Module module, Player executor) {
131131
if (!module.isEnabled()) {
132132
if(BuildTeamTools.getInstance().isDebug())
133133
ChatHelper.log("Successfully disabled %s Module", module.getModuleName());
134-
}else {
134+
} else {
135135
String reason = "";
136136

137137
if(module.getError() != null && !module.getError().isEmpty())
@@ -158,23 +158,22 @@ public boolean disable(Module module, Player executor) {
158158

159159
/** Enables all modules
160160
*
161-
* @param executor the player that executed the command. If null, the command was executed by the system.
162-
* @param isStarting if the server is starting
161+
* @param executor the player, if it's triggered via command, else null (when it's called by btt on plugin start).
163162
*/
164-
public void enableAll(@Nullable Player executor, boolean isStarting) {
163+
public void enableAll(@Nullable CommandSender executor) {
165164
for (Module module : new ArrayList<>(modules))
166165
if (!module.isEnabled())
167-
enable(module, executor, isStarting);
166+
enable(module, executor);
168167

169-
if(isStarting)
168+
if (executor == null)
170169
sendBuildTeamToolsConsoleStartupMessage();
171170
}
172171

173172
/** Disables all modules
174173
*
175-
* @param executor the player that executed the command. If null, the command was executed by the system.
174+
* @param executor the player, if it's triggered via command, else null (when it's called by btt on plugin stop).
176175
*/
177-
public void disableAll(@Nullable Player executor) {
176+
public void disableAll(@Nullable CommandSender executor) {
178177
for (Module module : new ArrayList<>(modules))
179178
if (module.isEnabled())
180179
disable(module, executor);
@@ -183,9 +182,9 @@ public void disableAll(@Nullable Player executor) {
183182
/**
184183
* Reloads all modules
185184
*/
186-
public void reloadAll(Player executor) {
185+
public void reloadAll(@Nullable CommandSender executor) {
187186
disableAll(executor);
188-
enableAll(executor, false);
187+
enableAll(executor);
189188
}
190189

191190
private void sendBuildTeamToolsConsoleStartupMessage(){

src/main/java/net/buildtheearth/modules/common/CommonModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void enable() {
8181

8282
@Override
8383
public void registerCommands() {
84-
registerCommand("buildteam", new BuildTeamToolsCommand());
84+
registerCommand("buildteamtools", new BuildTeamToolsCommand());
8585
}
8686

8787
@Override

src/main/java/net/buildtheearth/modules/common/commands/BuildTeamToolsCommand.java

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.buildtheearth.modules.common.commands;
22

3+
import com.google.gson.Gson;
34
import net.buildtheearth.BuildTeamTools;
45
import net.buildtheearth.modules.Module;
56
import net.buildtheearth.modules.ModuleHandler;
@@ -17,30 +18,23 @@
1718
import org.bukkit.command.CommandExecutor;
1819
import org.bukkit.command.CommandSender;
1920
import org.bukkit.command.TabCompleter;
20-
import org.bukkit.entity.Player;
2121
import org.jetbrains.annotations.NotNull;
2222

23+
import java.util.ArrayList;
2324
import java.util.Arrays;
2425
import java.util.Collections;
2526
import java.util.List;
2627
import java.util.UUID;
2728

2829
public class BuildTeamToolsCommand implements CommandExecutor, TabCompleter {
2930

30-
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
31+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String @NotNull [] args) {
3132

32-
if(!(sender instanceof Player)){
33-
sender.sendMessage("§cYou need to be a player to execute this command.");
34-
return true;
35-
}
36-
Player player = (Player) sender;
37-
38-
if(!player.hasPermission(Permissions.BUILD_TEAM_TOOLS)){
33+
if(!sender.hasPermission(Permissions.BUILD_TEAM_TOOLS)){
3934
sender.sendMessage("§cYou don't have permission to execute this command.");
4035
return true;
4136
}
4237

43-
4438
if(args.length == 0){
4539
sendBuildTeamToolsInfo(sender);
4640
return true;
@@ -58,9 +52,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
5852
return true;
5953
}
6054

61-
6255
if(args[0].equalsIgnoreCase("communicators")) {
63-
if(!player.hasPermission(Permissions.BUILD_TEAM_TOOLS_COMMUNICATORS)){
56+
if(!sender.hasPermission(Permissions.BUILD_TEAM_TOOLS_COMMUNICATORS)){
6457
sender.sendMessage("§cYou don't have permission to execute this command.");
6558
return true;
6659
}
@@ -73,7 +66,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
7366
}
7467

7568
if (args[0].equalsIgnoreCase("cache")) {
76-
if(!player.hasPermission(Permissions.BUILD_TEAM_TOOLS_CACHE)){
69+
if(!sender.hasPermission(Permissions.BUILD_TEAM_TOOLS_CACHE)){
7770
sender.sendMessage("§cYou don't have permission to execute this command.");
7871
return true;
7972
}
@@ -90,15 +83,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
9083
return true;
9184
}
9285

93-
94-
9586
if (args[0].equalsIgnoreCase("debug")) {
96-
if(!player.hasPermission(Permissions.BUILD_TEAM_TOOLS_DEBUG)){
87+
if(!sender.hasPermission(Permissions.BUILD_TEAM_TOOLS_DEBUG)){
9788
sender.sendMessage("§cYou don't have permission to execute this command.");
9889
return true;
9990
}
10091

101-
if(!(args.length > 1)) {
92+
if(args.length <= 1) {
10293
sender.sendMessage("§cYou need to add a value: true/false");
10394
return true;
10495
}
@@ -111,12 +102,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
111102
boolean debug = Boolean.parseBoolean(args[1]);
112103

113104
BuildTeamTools.getInstance().setDebug(debug);
114-
player.sendMessage(ChatHelper.getStandardString("§7Debug Mode was set to: %s", debug));
105+
sender.sendMessage(ChatHelper.getStandardString("§7Debug Mode was set to: %s", debug));
115106
return true;
116107
}
117108

118109
if (args[0].equalsIgnoreCase("checkForUpdates")) {
119-
if(!player.hasPermission(Permissions.BUILD_TEAM_TOOLS_CHECK_FOR_UPDATES)){
110+
if(!sender.hasPermission(Permissions.BUILD_TEAM_TOOLS_CHECK_FOR_UPDATES)){
120111
sender.sendMessage("§cYou don't have permission to execute this command.");
121112
return true;
122113
}
@@ -131,23 +122,21 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
131122
}
132123

133124
if(args[0].equalsIgnoreCase("reload")) {
134-
if(!player.hasPermission(Permissions.BUILD_TEAM_TOOLS_RELOAD)){
125+
if(!sender.hasPermission(Permissions.BUILD_TEAM_TOOLS_RELOAD)){
135126
sender.sendMessage("§cYou don't have permission to execute this command.");
136127
return true;
137128
}
138129

139130
sender.sendMessage(ChatHelper.getStandardString("§7Reloading all modules..."));
140-
ModuleHandler.getInstance().reloadAll(player);
131+
ModuleHandler.getInstance().reloadAll(sender);
141132
sender.sendMessage(ChatHelper.getStandardString("§7All modules have been reloaded."));
142133
}
143134

144-
145-
146135
return true;
147136
}
148137

149138
@Override
150-
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
139+
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
151140
if(args.length == 1)
152141
return Arrays.asList("help", "communicators", "checkForUpdates", "cache", "debug", "reload");
153142

@@ -175,11 +164,6 @@ public static void sendBuildTeamToolsInfo(CommandSender sender){
175164
&& NetworkModule.getInstance().getBuildTeam().getServerName() != null)
176165
serverName = NetworkModule.getInstance().getBuildTeam().getServerName();
177166

178-
String continent = "-";
179-
if (NetworkModule.getInstance().getBuildTeam() != null
180-
&& NetworkModule.getInstance().getBuildTeam().getContinent() != null)
181-
continent = NetworkModule.getInstance().getBuildTeam().getContinent().getLabel();
182-
183167
String status = "§c§lDISCONNECTED";
184168
if (NetworkModule.getInstance().getBuildTeam() != null
185169
&& NetworkModule.getInstance().getBuildTeam().isConnected() && !buildTeamID.equals("-") && !serverName.equals("-"))
@@ -189,9 +173,6 @@ else if (!buildTeamID.equals("-") && !serverName.equals("-"))
189173

190174
boolean debug = BuildTeamTools.getInstance().isDebug();
191175

192-
193-
194-
195176
sender.sendMessage("§eStatus: " + status);
196177
sender.sendMessage("§eVersion: §7" + BuildTeamTools.getInstance().getDescription().getVersion());
197178

@@ -213,14 +194,24 @@ else if(!module.isEnabled())
213194
}
214195

215196
if(NetworkModule.getInstance().getBuildTeam() != null){
197+
198+
List<String> regions = new ArrayList<>();
199+
List<String> continents = new ArrayList<>();
200+
for (Region region : NetworkModule.getInstance().getBuildTeam().getRegions()) {
201+
if (region.getContinent() != null && !continents.contains(region.getContinent().getLabel()))
202+
continents.add(region.getContinent().getLabel());
203+
204+
if (!regions.contains(region.getName()))
205+
regions.add(region.getName());
206+
}
207+
208+
Gson gson = new Gson();
209+
216210
sender.sendMessage("");
217211
sender.sendMessage("§eBuildTeam ID: §7" + buildTeamID);
218212
sender.sendMessage("§eServer Name: §7" + serverName);
219-
sender.sendMessage("§eContinent: §7" + continent);
220-
sender.sendMessage("§eRegions: §7");
221-
222-
for(Region region : NetworkModule.getInstance().getBuildTeam().getRegions())
223-
sender.sendMessage("- §7" + region.getName());
213+
sender.sendMessage("§eContinents: §7" + gson.toJson(continents));
214+
sender.sendMessage("§eRegions: §7" + gson.toJson(regions));
224215
}
225216

226217
sender.sendMessage("");

0 commit comments

Comments
 (0)