mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-09 04:20:32 +01:00
Added back the ability to get connected to the same section
This commit is contained in:
parent
8db9300820
commit
2c0b36c0cd
@ -11,7 +11,7 @@
|
||||
|
||||
<name>PlayerBalancer Plugin</name>
|
||||
<artifactId>playerbalancer-plugin</artifactId>
|
||||
<version>2.1.4</version>
|
||||
<version>2.1.4.1</version>
|
||||
|
||||
<build>
|
||||
<finalName>PlayerBalancer</finalName>
|
||||
|
@ -32,14 +32,6 @@ public abstract class ConnectionIntent {
|
||||
throw new IllegalStateException("The servers list parameter is the same reference, this cannot happen");
|
||||
}
|
||||
|
||||
Server current = player.getServer();
|
||||
if (current != null) {
|
||||
if (section.getServers().contains(current.getInfo())) {
|
||||
MessageUtils.send(player, plugin.getSettings().getMessagesProps().getSameSectionMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (section.getImplicitProvider() != ProviderType.NONE) {
|
||||
ServerInfo target = this.fetchServer(player, section, provider, servers);
|
||||
if (target != null) {
|
||||
@ -101,6 +93,16 @@ public abstract class ConnectionIntent {
|
||||
|
||||
//TODO Create this as a type
|
||||
public static void simple(PlayerBalancer plugin, ProxiedPlayer player, ServerSection section) {
|
||||
//TODO Make this apply to all situations except kicks
|
||||
//TODO (It already works like that, but I want a better way)
|
||||
Server current = player.getServer();
|
||||
if (current != null) {
|
||||
if (section.getServers().contains(current.getInfo())) {
|
||||
MessageUtils.send(player, plugin.getSettings().getMessagesProps().getSameSectionMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new ConnectionIntent(plugin, player, section) {
|
||||
@Override
|
||||
public void connect(ServerInfo server, Callback<Boolean> callback) {
|
||||
|
@ -51,10 +51,10 @@ public class ServerKickListener implements Listener {
|
||||
}
|
||||
|
||||
if (props.isDebug()) {
|
||||
plugin.getLogger().info(String.format("The player %s got kicked from %s, reason: %s. Matched reasons: %s",
|
||||
plugin.getLogger().info(String.format("The player %s got kicked from %s, reason: \"%s\". Matched reasons: %s",
|
||||
player.getName(),
|
||||
from.getName(),
|
||||
TextComponent.toPlainText(event.getKickReasonComponent()),
|
||||
reason,
|
||||
matches
|
||||
));
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class ServerKickListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
event.setCancelServer(server);
|
||||
MessageUtils.send(player, messages.getKickMessage(), (str) -> str
|
||||
.replace("{reason}", event.getKickReason())
|
||||
.replace("{reason}", reason)
|
||||
.replace("{from}", from.getName())
|
||||
.replace("{to}", server.getName()));
|
||||
plugin.getProxy().getScheduler().schedule(plugin, () -> {
|
||||
|
@ -26,5 +26,9 @@ public final class MessageUtils {
|
||||
return string.replace(ChatColor.COLOR_CHAR, '&');
|
||||
}
|
||||
|
||||
public static String safePrint(String string) {
|
||||
return string.replace(ChatColor.COLOR_CHAR, '\u00A7');
|
||||
}
|
||||
|
||||
private MessageUtils() {}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ messages {
|
||||
invalid-input="&cThis is an invalid input type for this command"
|
||||
misc-failure="&cCould not find a server to get connected to"
|
||||
player-bypass="&cYou have not been moved because you have the playerbalancer.bypass permission"
|
||||
player-kicked="&cYou have been kicked from &a{from} &cand you are being moved to &a{to}, reason: &a{reason}"
|
||||
player-kicked="&cYou have been kicked from &a{from} &cso you are being moved to &a{to}\n&cReason: &a{reason}"
|
||||
same-section="&cYou are already connected to a server on this section!"
|
||||
unavailable-server="&cThis command cannot be executed on this server"
|
||||
unknown-section="&aCould not find a section with that name"
|
||||
|
Loading…
Reference in New Issue
Block a user