Skip to content

Commit 2218af8

Browse files
committed
Feedback when executing the command and not having a parent to connect to
1 parent a1d7aef commit 2218af8

File tree

7 files changed

+22
-20
lines changed

7 files changed

+22
-20
lines changed

lobbybalancer.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.2" level="project" />
117117
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
118118
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.2" level="project" />
119-
<orderEntry type="library" name="Maven: org.bstats:bstats-bungeecord:1.1-SNAPSHOT" level="project" />
119+
<orderEntry type="library" name="Maven: org.bstats:bstats-bungeecord:1.1" level="project" />
120120
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
121121
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
122122
</component>

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
<artifactId>maven-shade-plugin</artifactId>
5353
<version>2.4.3</version>
5454
<configuration>
55-
<minimizeJar>true</minimizeJar>
5655
<relocations>
5756
<relocation>
5857
<pattern>org.bstats</pattern>

src/main/java/me/jaimemartz/lobbybalancer/commands/FallbackCommand.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,29 @@ public void execute(CommandSender sender, String[] args) {
4444
}
4545

4646
return target;
47-
} else {
48-
Configuration rules = plugin.getConfig().getSection("settings.fallback-command.rules");
49-
String bind = rules.getString(section.getName());
50-
ServerSection target = plugin.getSectionManager().getByName(bind);
47+
}
5148

52-
if (target == null) {
49+
Configuration rules = plugin.getConfig().getSection("settings.fallback-command.rules");
50+
String bind = rules.getString(section.getName());
51+
ServerSection target = plugin.getSectionManager().getByName(bind);
52+
53+
if (target == null) {
54+
if (section.hasParent()) {
5355
target = section.getParent();
56+
} else {
57+
msgr.send(ConfigEntries.UNAVAILABLE_MESSAGE.get());
58+
return null;
5459
}
60+
}
5561

56-
if (ConfigEntries.FALLBACK_COMMAND_RESTRICTED.get()) {
57-
if (section.getPosition() >= 0 && target.getPosition() < 0) {
58-
msgr.send(ConfigEntries.UNAVAILABLE_MESSAGE.get());
59-
return null;
60-
}
62+
if (ConfigEntries.FALLBACK_COMMAND_RESTRICTED.get()) {
63+
if (section.getPosition() >= 0 && target.getPosition() < 0) {
64+
msgr.send(ConfigEntries.UNAVAILABLE_MESSAGE.get());
65+
return null;
6166
}
62-
63-
return target;
6467
}
68+
69+
return target;
6570
} else {
6671
if (ConfigEntries.FALLBACK_PRINCIPAL_ENABLED.get()) {
6772
return plugin.getSectionManager().getPrincipal();

src/main/java/me/jaimemartz/lobbybalancer/configuration/ConfigEntries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class ConfigEntries implements ConfigEntryHolder {
3030
public static final ConfigEntry<Boolean> RECONNECT_KICK_RESTRICTED = new ConfigEntry<>(0, "settings.reconnect-kick.restricted", true);
3131
public static final ConfigEntry<Boolean> RECONNECT_KICK_EXCLUDE_FROM = new ConfigEntry<>(0, "settings.reconnect-kick.exclude-from", true);
3232
public static final ConfigEntry<Boolean> RECONNECT_KICK_FORCE_PRINCIPAL = new ConfigEntry<>(0, "settings.reconnect-kick.force-principal", false);
33-
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}");
3433

3534
public static final ConfigEntry<Boolean> FALLBACK_COMMAND_ENABLED = new ConfigEntry<>(0, "settings.fallback-command.enabled", true);
3635
public static final ConfigEntry<String> FALLBACK_COMMAND_NAME = new ConfigEntry<>(0, "settings.fallback-command.name", "fallback");
@@ -50,6 +49,7 @@ public class ConfigEntries implements ConfigEntryHolder {
5049
public static final ConfigEntry<String> FAILURE_MESSAGE = new ConfigEntry<>(0, "settings.messages.failure", null);
5150
public static final ConfigEntry<String> UNAVAILABLE_MESSAGE = new ConfigEntry<>(0, "settings.messages.unavailable", null);
5251
public static final ConfigEntry<String> UNKNOWN_SECTION_MESSAGE = new ConfigEntry<>(0, "settings.messages.unknown", null);
52+
public static final ConfigEntry<String> KICK_MESSAGE = new ConfigEntry<>(0, "settings.messages.kick", null);
5353

5454
public static final ConfigEntry<String> CONFIG_VERSION = new ConfigEntry<>(0, "version", null);
5555
}

src/main/java/me/jaimemartz/lobbybalancer/listener/ServerKickListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void onKick(ServerKickEvent event) {
117117
@Override
118118
public void connect(ServerInfo server) {
119119
PlayerLocker.lock(player);
120-
msgr.send(ConfigEntries.RECONNECT_KICK_MESSAGE.get(),
120+
msgr.send(ConfigEntries.KICK_MESSAGE.get(),
121121
new Replacement("{from}", from.getName()),
122122
new Replacement("{to}", server.getName()),
123123
new Replacement("{reason}", TextComponent.toPlainText(event.getKickReasonComponent())));

src/main/resources/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ settings:
6060
# This prints info every time a player gets kicked telling you the reason and if it matches the reasons
6161
print-info: false
6262

63-
# The message the player is sent when kicked, comment it out to remove the message
64-
message: '&cYou have been kicked from &a{from} &cand you are being moved to &a{to}&c, reason: &a{reason}'
65-
6663
# You can override the behavior with rules, overriding the parent section
6764
# This will set the section to go when you come from the section specified
6865
# This will still require the kick reasons to match
@@ -137,6 +134,7 @@ settings:
137134
failure: '&cCould not find a server to get connected'
138135
unavailable: '&cThis command cannot be executed on this server'
139136
unknown: '&cCould not find a section with that name'
137+
kick: '&cYou have been kicked from &a{from} &cand you are being moved to &a{to}&c, reason: &a{reason}'
140138

141139
# Here you have an example of what you can do with the sections
142140
# The plugin will print out info telling you if your config is right or not

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name: LobbyBalancer
22
main: me.jaimemartz.lobbybalancer.LobbyBalancer
33
version: ${project.version}
44
author: jaime29010
5-
softdepend: [RedisBungee]
5+
softdepend: [RedisBungee, LibraryLoader]

0 commit comments

Comments
 (0)