отказ от старого ChatStyle
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
*/
|
||||
package mc.commands;
|
||||
|
||||
import mc.core.chat.ChatStyle;
|
||||
import mc.core.chat.CommandExecutor;
|
||||
import mc.core.player.Player;
|
||||
import mc.core.player.PlayerManager;
|
||||
import mc.core.text.Text;
|
||||
import mc.core.text.TextColor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -42,8 +43,9 @@ public class ListCommand implements CommandExecutor {
|
||||
StringJoiner sj = new StringJoiner(", ");
|
||||
playerManager.getPlayers().forEach(pl -> sj.add(pl.getName()));
|
||||
|
||||
sender.getChannel().sendChatMessage(
|
||||
ChatStyle.GREEN + "Online(" + playerManager.getCountOnlinePlayers() + "): "
|
||||
+ ChatStyle.DARK_GREEN + sj.toString());
|
||||
Text message = Text.builder(TextColor.GREEN, "Online(" + playerManager.getCountOnlinePlayers() + "): ")
|
||||
.append(Text.of(TextColor.DARK_GREEN, sj.toString()))
|
||||
.build();
|
||||
sender.getChannel().sendChatMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user