mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-10-05 19:07:52 +02:00
Option to disable the section server sum up of players
This commit is contained in:
parent
3b3e76adeb
commit
4e34013dab
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.jaimemartz</groupId>
|
||||
<artifactId>playerbalancer</artifactId>
|
||||
<version>2.1.0.1</version>
|
||||
<version>2.1.0.2</version>
|
||||
<name>PlayerBalancer</name>
|
||||
|
||||
<properties>
|
||||
|
@ -27,6 +27,7 @@ public class ServerConnectListener implements Listener {
|
||||
ServerInfo target = event.getTarget();
|
||||
|
||||
ServerSection section = getSection(player, target);
|
||||
|
||||
if (section != null) {
|
||||
new ConnectionIntent(plugin, player, section) {
|
||||
@Override
|
||||
|
@ -202,7 +202,7 @@ public class SectionManager {
|
||||
@Override
|
||||
public void execute(String sectionName, SectionProps sectionProps, ServerSection section) throws RuntimeException {
|
||||
if (sectionProps.getServerName() != null) {
|
||||
SectionServer server = new SectionServer(section);
|
||||
SectionServer server = new SectionServer(props, section);
|
||||
section.setServer(server);
|
||||
plugin.getSectionManager().register(server, section);
|
||||
FixedAdapter.getFakeServers().put(server.getName(), server);
|
||||
|
@ -1,18 +1,20 @@
|
||||
package com.jaimemartz.playerbalancer.section;
|
||||
|
||||
import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SectionServer extends BungeeServerInfo {
|
||||
private final BalancerProps props;
|
||||
private final ServerSection section;
|
||||
|
||||
public SectionServer(ServerSection section) {
|
||||
|
||||
public SectionServer(BalancerProps props, ServerSection section) {
|
||||
super(
|
||||
"@" + section.getProps().getServerName(),
|
||||
new InetSocketAddress("0.0.0.0", (int) Math.floor(Math.random() * (0xFFFF + 1))),
|
||||
@ -20,15 +22,20 @@ public class SectionServer extends BungeeServerInfo {
|
||||
false
|
||||
);
|
||||
|
||||
this.props = props;
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ProxiedPlayer> getPlayers() {
|
||||
List<ProxiedPlayer> res = new ArrayList<>();
|
||||
section.getServers().forEach(server -> {
|
||||
res.addAll(server.getPlayers());
|
||||
});
|
||||
return res;
|
||||
if (props.isShowPlayers()) {
|
||||
List<ProxiedPlayer> res = new ArrayList<>();
|
||||
section.getServers().forEach(server -> {
|
||||
res.addAll(server.getPlayers());
|
||||
});
|
||||
return res;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ public class BalancerProps {
|
||||
@Setting(value = "sections")
|
||||
private Map<String, SectionProps> sectionProps;
|
||||
|
||||
@Setting(value = "show-players")
|
||||
private boolean showPlayers;
|
||||
|
||||
public String getPrincipalSectionName() {
|
||||
return principalSectionName;
|
||||
}
|
||||
@ -53,6 +56,14 @@ public class BalancerProps {
|
||||
this.sectionProps = sectionProps;
|
||||
}
|
||||
|
||||
public boolean isShowPlayers() {
|
||||
return showPlayers;
|
||||
}
|
||||
|
||||
public void setShowPlayers(boolean showPlayers) {
|
||||
this.showPlayers = showPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BalancerProps{" +
|
||||
@ -60,6 +71,7 @@ public class BalancerProps {
|
||||
", dummySectionNames=" + dummySectionNames +
|
||||
", reiterativeSectionNames=" + reiterativeSectionNames +
|
||||
", sectionProps=" + sectionProps +
|
||||
", showPlayers=" + showPlayers +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,12 @@ features {
|
||||
dummy-sections=[]
|
||||
|
||||
# Reiterative sections remember the server the player connected to previously
|
||||
# The plugin will keep connecting the player to that server until he changes
|
||||
# The plugin will keep connecting the player to that server until a change occurs
|
||||
reiterative-sections=[]
|
||||
|
||||
# When true, section servers will show the sum of the players on all servers on that section
|
||||
# Important: This will make bungeecord think that your bungeecord has more players than it really does
|
||||
show-players: true
|
||||
}
|
||||
|
||||
# Pings servers to see if they are online or not and if they are accessible
|
||||
|
Loading…
Reference in New Issue
Block a user