Archived
0

fix Vanilla commands

This commit is contained in:
2018-06-24 15:16:30 +03:00
parent d3efd95151
commit 222d14a24e
2 changed files with 25 additions and 15 deletions

View File

@@ -7,9 +7,11 @@ package mc.commands;
import lombok.extern.slf4j.Slf4j;
import mc.core.chat.CommandExecutor;
import mc.core.chat.CommanderChatProcessor;
import mc.core.chat.MessageType;
import mc.core.player.Player;
import mc.core.text.Text;
import mc.core.text.TextColor;
import mc.core.text.TextTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -17,6 +19,12 @@ import java.util.Optional;
@Slf4j
public class HelpCommand implements CommandExecutor {
private static final TextTemplate messageFormat = TextTemplate.builder()
.arg("command", TextColor.RED)
.append(Text.of(TextColor.GRAY, " - "))
.arg("description", TextColor.WHITE)
.build();
@Autowired
private ApplicationContext applicationContext;
private CommanderChatProcessor commanderChatProcessor;
@@ -52,18 +60,11 @@ public class HelpCommand implements CommandExecutor {
}
}
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 -> {
commandNameText.setString(commandExecutor.getUsage().orElse(commandExecutor.getName()));
descriptionText.setString(commandExecutor.getDescription());
sender.getChannel().sendChatMessage(messageText);
Text message = messageFormat.apply(
"command", commandExecutor.getUsage().orElse(commandExecutor.getName()),
"description", commandExecutor.getDescription());
sender.getChannel().sendChatMessage(message, MessageType.SYSTEM_MESSAGE);
});
}
}