Skip to content

Commit eea1bb4

Browse files
committed
Merge branch 'master' of github.com:jamezrin/PlayerBalancer
2 parents ed692bb + a4294a8 commit eea1bb4

27 files changed

+80
-126
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PlayerBalancer
2-
[Spigot Resource](https://www.spigotmc.org/resources/10788/)
2+
[Spigot Resource](https://www.spigotmc.org/resources/playerbalancer.55011/)
33

44
### Build
55
* Clone this repository

addon/pom.xml

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

77
<parent>
88
<groupId>com.jaimemartz</groupId>
9-
<version>2.1.6.2-SNAPSHOT</version>
9+
<version>2.2-SNAPSHOT</version>
1010
<artifactId>playerbalancer-parent</artifactId>
1111
</parent>
1212

addon/src/main/java/com/jaimemartz/playerbalanceraddon/PlayerBalancerAddon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void onEnable() {
1919

2020
@Override
2121
public void onDisable() {
22-
//Nothing to do...
22+
// Nothing to do...
2323
}
2424

2525
public PluginMessageManager getManager() {

addon/src/main/java/com/jaimemartz/playerbalanceraddon/PlayerBalancerPlaceholderExpansion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public String onRequest(OfflinePlayer player, String identifier) {
2222
if (section == null)
2323
return null;
2424

25-
//For the first call this placeholder will return 0
26-
//For the next one, the result of the previous one
25+
// For the first call this placeholder will return 0
26+
// For the next one, the result of the previous one
2727
plugin.getManager().getSectionPlayerCount(section, (count) -> {
2828
sectionPlayerCounts.put(section, count);
2929
});

addon/src/main/java/com/jaimemartz/playerbalanceraddon/PluginMessageManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public PluginMessageManager(PlayerBalancerAddon plugin) {
2727
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, PB_CHANNEL, this);
2828
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, PB_CHANNEL);
2929

30-
//In case we need to use BungeeCord channels
30+
// In case we need to use BungeeCord channels
3131
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, BC_CHANNEL, this);
3232
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, BC_CHANNEL);
3333
}

balancer/pom.xml

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

77
<parent>
88
<groupId>com.jaimemartz</groupId>
9-
<version>2.1.6.2-SNAPSHOT</version>
9+
<version>2.2-SNAPSHOT</version>
1010
<artifactId>playerbalancer-parent</artifactId>
1111
</parent>
1212

@@ -66,12 +66,6 @@
6666
<type>jar</type>
6767
<scope>provided</scope>
6868
</dependency>
69-
<dependency>
70-
<groupId>com.imaginarycode.minecraft</groupId>
71-
<artifactId>RedisBungee</artifactId>
72-
<version>0.3.8-SNAPSHOT</version>
73-
<scope>provided</scope>
74-
</dependency>
7569
<dependency>
7670
<groupId>ninja.leaping.configurate</groupId>
7771
<artifactId>configurate-hocon</artifactId>

balancer/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.jaimemartz.playerbalancer.commands.MainCommand;
66
import com.jaimemartz.playerbalancer.commands.ManageCommand;
77
import com.jaimemartz.playerbalancer.connection.ServerAssignRegistry;
8-
import com.jaimemartz.playerbalancer.helper.NetworkManager;
98
import com.jaimemartz.playerbalancer.helper.PasteHelper;
109
import com.jaimemartz.playerbalancer.helper.PlayerLocker;
1110
import com.jaimemartz.playerbalancer.listeners.*;
@@ -34,7 +33,6 @@ public class PlayerBalancer extends Plugin {
3433
private StatusManager statusManager;
3534
private SettingsHolder settings;
3635
private SectionManager sectionManager;
37-
private NetworkManager networkManager;
3836
private ConfigurationLoader<CommentedConfigurationNode> loader;
3937

4038
private FallbackCommand fallbackCommand;
@@ -78,7 +76,7 @@ public void onEnable() {
7876

7977
public boolean checkUpToDate() {
8078
try {
81-
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=10788").openConnection();
79+
URLConnection con = new URL("https:// api.spigotmc.org/legacy/update.php?resource=10788").openConnection();
8280
String reply = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
8381
return getDescription().getVersion().equals(reply);
8482
} catch (IOException e) {
@@ -89,7 +87,7 @@ public boolean checkUpToDate() {
8987

9088
@Override
9189
public void onDisable() {
92-
//Nothing else to do than normal stop
90+
// Nothing else to do than normal stop
9391
this.execStop();
9492
}
9593

@@ -128,8 +126,6 @@ private void execStart() {
128126
getProxy().getPluginManager().registerListener(this, reloadListener);
129127
}
130128

131-
networkManager = new NetworkManager(this);
132-
133129
sectionManager = new SectionManager(this);
134130
sectionManager.load();
135131

@@ -198,7 +194,7 @@ private void execStop() {
198194
}
199195

200196
if (settings.getGeneralProps().isEnabled()) {
201-
//Do not try to do anything if the plugin has not loaded correctly
197+
// Do not try to do anything if the plugin has not loaded correctly
202198
if (failed) return;
203199

204200
if (settings.getGeneralProps().isAutoReload()) {
@@ -284,10 +280,6 @@ public StatusManager getStatusManager() {
284280
return statusManager;
285281
}
286282

287-
public NetworkManager getNetworkManager() {
288-
return networkManager;
289-
}
290-
291283
public FallbackCommand getFallbackCommand() {
292284
return fallbackCommand;
293285
}

balancer/src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,10 @@ public void execute() {
3939
.replace("{alias}", safeNull(section.getProps().getAlias()))
4040
);
4141

42+
// Ensure a new copy of the section servers
4243
List<ServerInfo> servers = new ArrayList<>(section.getServers());
4344

44-
//Prevents removing servers from the section
45-
if (servers == section.getServers()) {
46-
throw new IllegalStateException("The servers list parameter is the same reference, this cannot happen");
47-
}
48-
49-
//Prevents connections to the same server
45+
// Prevents connections to the same server
5046
Server current = player.getServer();
5147
if (current != null) {
5248
servers.remove(current.getInfo());
@@ -56,7 +52,7 @@ public void execute() {
5652
ServerInfo target = this.fetchServer(player, section, section.getImplicitProvider(), servers);
5753
if (target != null) {
5854
this.connect(target, (response, throwable) -> {
59-
if (response) { //only if the connect has been executed correctly
55+
if (response) { // only if the connect has been executed correctly
6056
MessageUtils.send(player, plugin.getSettings().getMessagesProps().getConnectedMessage(),
6157
(str) -> str.replace("{server}", target.getName())
6258
.replace("{section}", section.getName())

balancer/src/main/java/com/jaimemartz/playerbalancer/connection/provider/types/progressive/ProgressiveFillerProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, Li
1717

1818
for (ServerInfo server : servers) {
1919
ServerStatus status = plugin.getStatusManager().getStatus(server);
20-
int count = plugin.getNetworkManager().getPlayers(server);
20+
int count = server.getPlayers().size();
2121

2222
if (count > max && count <= status.getMaximum()) {
2323
max = count;

balancer/src/main/java/com/jaimemartz/playerbalancer/connection/provider/types/progressive/ProgressiveLowestProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, Li
1515
ServerInfo target = null;
1616

1717
for (ServerInfo server : servers) {
18-
int count = plugin.getNetworkManager().getPlayers(server);
18+
int count = server.getPlayers().size();
1919

2020
if (count < min) {
2121
min = count;

0 commit comments

Comments
 (0)