Archived
0

отказ от старого ChatStyle

This commit is contained in:
2018-06-12 19:50:29 +03:00
parent 5cc4a8d1a4
commit a83e8e7230
8 changed files with 106 additions and 100 deletions

View File

@@ -5,10 +5,11 @@
package mc.commands;
import lombok.extern.slf4j.Slf4j;
import mc.core.chat.ChatStyle;
import mc.core.chat.CommandExecutor;
import mc.core.chat.CommanderChatProcessor;
import mc.core.player.Player;
import mc.core.text.Text;
import mc.core.text.TextColor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -46,17 +47,23 @@ public class HelpCommand implements CommandExecutor {
commanderChatProcessor = applicationContext.getBean(CommanderChatProcessor.class);
if (commanderChatProcessor == null) {
log.error("Error get bean of type \"CommanderChatProcessor\". WTF?!");
sender.getChannel().sendChatMessage(ChatStyle.RED + "!!-Server error-!!");
sender.getChannel().sendChatMessage(Text.of(TextColor.RED, "!!-Server error-!!"));
return;
}
}
final String messageFormat = ChatStyle.RED + "%s " + ChatStyle.GRAY + "- " + ChatStyle.WHITE + "%s";
Text commandNameText = Text.of(TextColor.RED);
Text descriptionText = Text.of(TextColor.WHITE);
Text messageText = Text.builder()
.append(commandNameText)
.append(Text.of(TextColor.GRAY, " - "))
.append(descriptionText)
.build();
commanderChatProcessor.getAllCommands().forEach(commandExecutor -> {
sender.getChannel().sendChatMessage(String.format(messageFormat,
commandExecutor.getUsage().orElse(commandExecutor.getName()),
commandExecutor.getDescription()
));
commandNameText.setString(commandExecutor.getUsage().orElse(commandExecutor.getName()));
descriptionText.setString(commandExecutor.getDescription());
sender.getChannel().sendChatMessage(messageText);
});
}
}