Skip to content

Commit 576f21c

Browse files
committed
fix(nav): 🐛 Fix data handling for buildteams e.g. /bt
1 parent 48046cf commit 576f21c

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.buildtheearth.buildteamtools;
22

3+
import com.alpsbte.alpslib.utils.ChatHelper;
34
import lombok.Getter;
4-
import lombok.Setter;
55
import net.buildtheearth.buildteamtools.modules.ModuleHandler;
66
import net.buildtheearth.buildteamtools.modules.common.CommonModule;
77
import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
@@ -26,7 +26,7 @@ public class BuildTeamTools extends JavaPlugin {
2626
public static String PREFIX = "§9§lBTE §8> §7";
2727
public static String CONSOLE_PREFIX = "[BuildTeamTools] ";
2828

29-
@Getter @Setter
29+
@Getter
3030
private boolean debug;
3131

3232
@Getter
@@ -83,4 +83,9 @@ public void saveConfig() {
8383
public File getPluginFile() {
8484
return this.getFile();
8585
}
86+
87+
public void setDebug(boolean debug) {
88+
this.debug = debug;
89+
ChatHelper.DEBUG = debug;
90+
}
8691
}

src/main/java/net/buildtheearth/buildteamtools/modules/network/NetworkModule.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.bukkit.Bukkit;
2020
import org.bukkit.entity.Player;
2121
import org.jetbrains.annotations.NotNull;
22+
import org.jetbrains.annotations.Nullable;
2223

2324
import java.util.ArrayList;
2425
import java.util.List;
@@ -31,9 +32,13 @@ public class NetworkModule extends Module {
3132

3233
public static final int CACHE_UPLOAD_SPEED = 20 * 60 * 10 + 20;
3334

34-
/** Information about the build team of this server */
35-
@Getter @Setter
36-
private BuildTeam buildTeam;
35+
/**
36+
* Information about the build team of this server
37+
* Nullable if build team is not loaded yet
38+
*/
39+
@Getter
40+
@Setter
41+
private @Nullable BuildTeam buildTeam;
3742

3843
/** A list of players that are communicating with this server. */
3944
@Getter

src/main/java/net/buildtheearth/buildteamtools/modules/network/api/NetworkAPI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public void onResponse(String response) {
262262
NetworkModule networkModule = NetworkModule.getInstance();
263263
BuildTeam buildTeam = networkModule.getBuildTeamByID(teamID);
264264
networkModule.setBuildTeam(buildTeam);
265+
if (!buildTeam.isHasBTToolsInstalled()) setBuildTeamToolsInstalled(true);
265266
} catch (Exception e) {
266267
future.completeExceptionally(e);
267268
return;

src/main/java/net/buildtheearth/buildteamtools/modules/network/model/BuildTeam.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ public BuildTeam(String ID, String serverIP, String name, String blankName, Stri
4545
this.name = name;
4646
this.blankName = blankName;
4747
this.serverName = serverName;
48-
this.isConnected = isConnected;
48+
this.isConnected = isConnected && (serverName != null && !serverName.isEmpty()); // We need to verify the Data manually because NwApi i quite scuffed
4949
this.hasBTToolsInstalled = hasBTToolsInstalled;
5050

5151
this.regions = new ArrayList<>();
5252
this.warpGroups = new ArrayList<>();
5353
this.allowsTransfers = allowsTransfers;
5454
this.tag = tag;
5555

56-
if(!isConnected)
57-
this.IP = serverIP;
58-
else
56+
if (isConnected && NetworkModule.getInstance().getBuildTeam() != null && NetworkModule.getInstance().getBuildTeam().isConnected())
5957
this.IP = null;
58+
else
59+
this.IP = serverIP;
6060
}
6161

6262
public void createWarp(Player creator, Warp warp){

0 commit comments

Comments
 (0)