Skip to content

Commit 4e34013

Browse files
committed
Option to disable the section server sum up of players
1 parent 3b3e76a commit 4e34013

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.jaimemartz</groupId>
88
<artifactId>playerbalancer</artifactId>
9-
<version>2.1.0.1</version>
9+
<version>2.1.0.2</version>
1010
<name>PlayerBalancer</name>
1111

1212
<properties>

src/main/java/com/jaimemartz/playerbalancer/listener/ServerConnectListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void onConnect(ServerConnectEvent event) {
2727
ServerInfo target = event.getTarget();
2828

2929
ServerSection section = getSection(player, target);
30+
3031
if (section != null) {
3132
new ConnectionIntent(plugin, player, section) {
3233
@Override

src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void execute(String sectionName, SectionProps sectionProps, ServerSection
202202
@Override
203203
public void execute(String sectionName, SectionProps sectionProps, ServerSection section) throws RuntimeException {
204204
if (sectionProps.getServerName() != null) {
205-
SectionServer server = new SectionServer(section);
205+
SectionServer server = new SectionServer(props, section);
206206
section.setServer(server);
207207
plugin.getSectionManager().register(server, section);
208208
FixedAdapter.getFakeServers().put(server.getName(), server);
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
package com.jaimemartz.playerbalancer.section;
22

3+
import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps;
34
import net.md_5.bungee.BungeeServerInfo;
45
import net.md_5.bungee.api.connection.ProxiedPlayer;
56

67
import java.net.InetSocketAddress;
78
import java.util.ArrayList;
89
import java.util.Collection;
10+
import java.util.Collections;
911
import java.util.List;
1012

1113
public class SectionServer extends BungeeServerInfo {
14+
private final BalancerProps props;
1215
private final ServerSection section;
1316

14-
public SectionServer(ServerSection section) {
15-
17+
public SectionServer(BalancerProps props, ServerSection section) {
1618
super(
1719
"@" + section.getProps().getServerName(),
1820
new InetSocketAddress("0.0.0.0", (int) Math.floor(Math.random() * (0xFFFF + 1))),
1921
"Section server of " + section.getName(),
2022
false
2123
);
2224

25+
this.props = props;
2326
this.section = section;
2427
}
2528

2629
@Override
2730
public Collection<ProxiedPlayer> getPlayers() {
28-
List<ProxiedPlayer> res = new ArrayList<>();
29-
section.getServers().forEach(server -> {
30-
res.addAll(server.getPlayers());
31-
});
32-
return res;
31+
if (props.isShowPlayers()) {
32+
List<ProxiedPlayer> res = new ArrayList<>();
33+
section.getServers().forEach(server -> {
34+
res.addAll(server.getPlayers());
35+
});
36+
return res;
37+
} else {
38+
return Collections.emptyList();
39+
}
3340
}
3441
}

src/main/java/com/jaimemartz/playerbalancer/settings/props/features/BalancerProps.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class BalancerProps {
2121
@Setting(value = "sections")
2222
private Map<String, SectionProps> sectionProps;
2323

24+
@Setting(value = "show-players")
25+
private boolean showPlayers;
26+
2427
public String getPrincipalSectionName() {
2528
return principalSectionName;
2629
}
@@ -53,13 +56,22 @@ public void setSectionProps(Map<String, SectionProps> sectionProps) {
5356
this.sectionProps = sectionProps;
5457
}
5558

59+
public boolean isShowPlayers() {
60+
return showPlayers;
61+
}
62+
63+
public void setShowPlayers(boolean showPlayers) {
64+
this.showPlayers = showPlayers;
65+
}
66+
5667
@Override
5768
public String toString() {
5869
return "BalancerProps{" +
5970
"principalSectionName='" + principalSectionName + '\'' +
6071
", dummySectionNames=" + dummySectionNames +
6172
", reiterativeSectionNames=" + reiterativeSectionNames +
6273
", sectionProps=" + sectionProps +
74+
", showPlayers=" + showPlayers +
6375
'}';
6476
}
6577
}

src/main/resources/default.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ features {
110110
dummy-sections=[]
111111

112112
# Reiterative sections remember the server the player connected to previously
113-
# The plugin will keep connecting the player to that server until he changes
113+
# The plugin will keep connecting the player to that server until a change occurs
114114
reiterative-sections=[]
115+
116+
# When true, section servers will show the sum of the players on all servers on that section
117+
# Important: This will make bungeecord think that your bungeecord has more players than it really does
118+
show-players: true
115119
}
116120

117121
# Pings servers to see if they are online or not and if they are accessible

0 commit comments

Comments
 (0)