Skip to content

Commit

Permalink
Add %player_name% placeholder into 'player-offline' message
Browse files Browse the repository at this point in the history
  • Loading branch information
bivashy committed Oct 10, 2023
1 parent 67b9337 commit e1f306a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.bivashy.auth.api.AuthPlugin;
import com.bivashy.auth.api.account.Account;
import com.bivashy.auth.api.config.PluginConfig;
import com.bivashy.auth.api.config.message.MessageContext;
import com.bivashy.auth.api.model.PlayerIdSupplier;
import com.bivashy.auth.api.server.command.ServerCommandActor;
import com.bivashy.auth.api.server.player.ServerPlayer;
Expand Down Expand Up @@ -42,7 +43,7 @@ public BungeeCommandsRegistry(BungeeAuthPluginBootstrap pluginBootstrap, AuthPlu
String value = context.pop();
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(value);
if (player == null) {
throw new SendComponentException(config.getServerMessages().getMessage("player-offline"));
throw new SendComponentException(config.getServerMessages().getMessage("player-offline", MessageContext.of("%player_name%", value)));
}
return new ArgumentServerPlayer(new BungeeServerPlayer(player));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void senderNotConsole(CommandActor actor, SenderNotConsoleException excep

@Override
public void invalidPlayer(CommandActor actor, InvalidPlayerException exception) {
sendComponent(actor, messages.getMessage("player-offline", MessageContext.of("%player%", exception.getInput())));
sendComponent(actor, messages.getMessage("player-offline", MessageContext.of("%player_name%", exception.getInput())));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/configurations/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ messages:
auth-reloaded: '&aПлагин успешно перезагрузил конфигурацию'
config-migrated: '&aКонфигурация успешно мигрирована'
# Ошибки в командах
player-offline: '&cИгрок с ником %account_name% оффлайн!'
player-offline: '&cИгрок с ником %player_name% оффлайн!'
command-cooldown: '&cВы слишком часто используете данную команду! Попробуйте позже.'
# Название аргумента указывается в виде arg1, arg2, arg3...
unresolved-argument: '&cВы не указали аргумент: %argument_name%'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.bivashy.auth.api.AuthPlugin;
import com.bivashy.auth.api.account.Account;
import com.bivashy.auth.api.config.PluginConfig;
import com.bivashy.auth.api.config.message.MessageContext;
import com.bivashy.auth.api.model.PlayerIdSupplier;
import com.bivashy.auth.api.server.command.ServerCommandActor;
import com.bivashy.auth.api.server.player.ServerPlayer;
Expand Down Expand Up @@ -42,7 +43,7 @@ public VelocityCommandRegistry(VelocityAuthPluginBootstrap pluginBootstrap, Auth
String value = context.pop();
Optional<ServerPlayer> player = authPlugin.getCore().getPlayer(value);
if (!player.isPresent())
throw new SendComponentException(config.getServerMessages().getMessage("player-offline"));
throw new SendComponentException(config.getServerMessages().getMessage("player-offline", MessageContext.of("%player_name%")));
return new ArgumentServerPlayer(player.get());
});
commandHandler.registerCondition((actor, command, arguments) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void senderNotConsole(@NotNull CommandActor actor, revxrsal.commands.velo

@Override
public void invalidPlayer(@NotNull CommandActor actor, revxrsal.commands.velocity.exception.@NotNull InvalidPlayerException exception) {
sendComponent(actor, messages.getMessage("player-offline", MessageContext.of("%player%", exception.getInput())));
sendComponent(actor, messages.getMessage("player-offline", MessageContext.of("%player_name%", exception.getInput())));
}

@Override
Expand Down

0 comments on commit e1f306a

Please sign in to comment.