mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2025-02-17 04:31:45 +01:00
Added option to force the principal when kicked
This commit is contained in:
parent
b7d4831a6c
commit
afe9e230f9
@ -15,20 +15,4 @@
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.jaimemartz</groupId>
|
||||
<artifactId>lobbybalancer</artifactId>
|
||||
<version>2.0.9.3</version>
|
||||
<version>2.0.9.4</version>
|
||||
<name>LobbyBalancer</name>
|
||||
|
||||
<properties>
|
||||
|
@ -30,6 +30,7 @@ public class ConfigEntries implements ConfigEntryHolder {
|
||||
public static final ConfigEntry<List<String>> RECONNECT_KICK_IGNORED_SECTIONS = new ConfigEntry<>(0, "settings.reconnect-kick.ignored", Collections.emptyList());
|
||||
public static final ConfigEntry<Boolean> RECONNECT_KICK_RESTRICTED = new ConfigEntry<>(0, "settings.reconnect-kick.restricted", true);
|
||||
public static final ConfigEntry<Boolean> RECONNECT_KICK_EXCLUDE_FROM = new ConfigEntry<>(0, "settings.reconnect-kick.exclude-from", true);
|
||||
public static final ConfigEntry<Boolean> RECONNECT_KICK_FORCE_PRINCIPAL = new ConfigEntry<>(0, "settings.reconnect-kick.force-principal", false);
|
||||
public static final ConfigEntry<String> RECONNECT_KICK_MESSAGE = new ConfigEntry<>(0, "settings.reconnect-kick.message", "&cYou have been kicked from &a{from} &cand you are being moved to &a{to}&c, reason: &a{reason}");
|
||||
|
||||
public static final ConfigEntry<Boolean> FALLBACK_COMMAND_ENABLED = new ConfigEntry<>(0, "settings.fallback-command.enabled", true);
|
||||
|
@ -15,6 +15,8 @@ import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class ServerConnectListener implements Listener {
|
||||
private final LobbyBalancer plugin;
|
||||
|
||||
@ -28,41 +30,52 @@ public class ServerConnectListener implements Listener {
|
||||
ServerInfo target = event.getTarget();
|
||||
Messager msgr = new Messager(player);
|
||||
|
||||
ServerSection section = plugin.getSectionManager().getByServer(target);
|
||||
Callable<ServerSection> callable = () -> {
|
||||
ServerSection section = plugin.getSectionManager().getByServer(target);
|
||||
|
||||
if (section != null) {
|
||||
if (PlayerLocker.isLocked(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (section.getServers().contains(target)) {
|
||||
if (section.isDummy()) {
|
||||
return;
|
||||
if (section != null) {
|
||||
if (PlayerLocker.isLocked(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (player.hasPermission("lobbybalancer.bypass")) {
|
||||
msgr.send(ChatColor.RED + "You have not been moved because you have the lobbybalancer.bypass permission");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getServer() != null && section.getServers().contains(player.getServer().getInfo())) {
|
||||
if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) {
|
||||
ServerAssignRegistry.assignTarget(player, section, target);
|
||||
if (section.getServers().contains(target)) {
|
||||
if (section.isDummy()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (player.hasPermission("lobbybalancer.bypass")) {
|
||||
msgr.send(ChatColor.RED + "You have not been moved because you have the lobbybalancer.bypass permission");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (player.getServer() != null && section.getServers().contains(player.getServer().getInfo())) {
|
||||
if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) {
|
||||
ServerAssignRegistry.assignTarget(player, section, target);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new ConnectionIntent(plugin, player, section) {
|
||||
@Override
|
||||
public void connect(ServerInfo server) {
|
||||
if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) {
|
||||
ServerAssignRegistry.assignTarget(player, section, server);
|
||||
}
|
||||
return section;
|
||||
};
|
||||
|
||||
event.setTarget(server);
|
||||
}
|
||||
};
|
||||
try {
|
||||
ServerSection section = callable.call();
|
||||
if (section != null) {
|
||||
new ConnectionIntent(plugin, player, section) {
|
||||
@Override
|
||||
public void connect(ServerInfo server) {
|
||||
if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) {
|
||||
ServerAssignRegistry.assignTarget(player, section, server);
|
||||
}
|
||||
|
||||
event.setTarget(server);
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//Nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,18 +35,20 @@ public class ServerKickListener implements Listener {
|
||||
ServerInfo from = event.getKickedFrom();
|
||||
Messager msgr = new Messager(player);
|
||||
|
||||
//Player is not connected to any server
|
||||
if (player.getServer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Player is not connected to the server he is kicked from
|
||||
if (!player.getServer().getInfo().equals(from)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Section the player is going to be reconnected
|
||||
Callable<ServerSection> callable = () -> {
|
||||
if (player.getServer() == null) {
|
||||
if (ConfigEntries.RECONNECT_KICK_FORCE_PRINCIPAL.get()) {
|
||||
return plugin.getSectionManager().getPrincipal();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.getServer().getInfo().equals(from)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ServerSection section = plugin.getSectionManager().getByServer(from);
|
||||
|
||||
if (section != null) {
|
||||
|
@ -57,6 +57,9 @@ settings:
|
||||
# This will make it so that the server the player is kicked from will be excluded
|
||||
exclude-from: true
|
||||
|
||||
# If enabled, players that are kicked while connecting to the proxy will be forced to reconnect to the principal section
|
||||
force-principal: false
|
||||
|
||||
# This prints info every time a player gets kicked telling you the reason and if it matches the reasons
|
||||
print-info: false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user