Skip to content

Commit 2c0b36c

Browse files
committed
Added back the ability to get connected to the same section
1 parent 8db9300 commit 2c0b36c

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

Main Plugin/pom.xml

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

1212
<name>PlayerBalancer Plugin</name>
1313
<artifactId>playerbalancer-plugin</artifactId>
14-
<version>2.1.4</version>
14+
<version>2.1.4.1</version>
1515

1616
<build>
1717
<finalName>PlayerBalancer</finalName>

Main Plugin/src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ public ConnectionIntent(PlayerBalancer plugin, ProxiedPlayer player, ProviderTyp
3232
throw new IllegalStateException("The servers list parameter is the same reference, this cannot happen");
3333
}
3434

35-
Server current = player.getServer();
36-
if (current != null) {
37-
if (section.getServers().contains(current.getInfo())) {
38-
MessageUtils.send(player, plugin.getSettings().getMessagesProps().getSameSectionMessage());
39-
return;
40-
}
41-
}
42-
4335
if (section.getImplicitProvider() != ProviderType.NONE) {
4436
ServerInfo target = this.fetchServer(player, section, provider, servers);
4537
if (target != null) {
@@ -101,6 +93,16 @@ private ServerInfo fetchServer(ProxiedPlayer player, ServerSection section, Prov
10193

10294
//TODO Create this as a type
10395
public static void simple(PlayerBalancer plugin, ProxiedPlayer player, ServerSection section) {
96+
//TODO Make this apply to all situations except kicks
97+
//TODO (It already works like that, but I want a better way)
98+
Server current = player.getServer();
99+
if (current != null) {
100+
if (section.getServers().contains(current.getInfo())) {
101+
MessageUtils.send(player, plugin.getSettings().getMessagesProps().getSameSectionMessage());
102+
return;
103+
}
104+
}
105+
104106
new ConnectionIntent(plugin, player, section) {
105107
@Override
106108
public void connect(ServerInfo server, Callback<Boolean> callback) {

Main Plugin/src/main/java/com/jaimemartz/playerbalancer/listeners/ServerKickListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public void onKick(ServerKickEvent event) {
5151
}
5252

5353
if (props.isDebug()) {
54-
plugin.getLogger().info(String.format("The player %s got kicked from %s, reason: %s. Matched reasons: %s",
54+
plugin.getLogger().info(String.format("The player %s got kicked from %s, reason: \"%s\". Matched reasons: %s",
5555
player.getName(),
5656
from.getName(),
57-
TextComponent.toPlainText(event.getKickReasonComponent()),
57+
reason,
5858
matches
5959
));
6060
}
@@ -78,7 +78,7 @@ public void connect(ServerInfo server, Callback<Boolean> callback) {
7878
event.setCancelled(true);
7979
event.setCancelServer(server);
8080
MessageUtils.send(player, messages.getKickMessage(), (str) -> str
81-
.replace("{reason}", event.getKickReason())
81+
.replace("{reason}", reason)
8282
.replace("{from}", from.getName())
8383
.replace("{to}", server.getName()));
8484
plugin.getProxy().getScheduler().schedule(plugin, () -> {

Main Plugin/src/main/java/com/jaimemartz/playerbalancer/utils/MessageUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ public static String revertColor(String string) {
2626
return string.replace(ChatColor.COLOR_CHAR, '&');
2727
}
2828

29+
public static String safePrint(String string) {
30+
return string.replace(ChatColor.COLOR_CHAR, '\u00A7');
31+
}
32+
2933
private MessageUtils() {}
3034
}

Main Plugin/src/main/resources/default.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ messages {
3333
invalid-input="&cThis is an invalid input type for this command"
3434
misc-failure="&cCould not find a server to get connected to"
3535
player-bypass="&cYou have not been moved because you have the playerbalancer.bypass permission"
36-
player-kicked="&cYou have been kicked from &a{from} &cand you are being moved to &a{to}, reason: &a{reason}"
36+
player-kicked="&cYou have been kicked from &a{from} &cso you are being moved to &a{to}\n&cReason: &a{reason}"
3737
same-section="&cYou are already connected to a server on this section!"
3838
unavailable-server="&cThis command cannot be executed on this server"
3939
unknown-section="&aCould not find a section with that name"

0 commit comments

Comments
 (0)