fix Vanilla commands
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,25 @@
|
||||
package mc.commands;
|
||||
|
||||
import mc.core.chat.CommandExecutor;
|
||||
import mc.core.chat.MessageType;
|
||||
import mc.core.player.Player;
|
||||
import mc.core.player.PlayerManager;
|
||||
import mc.core.text.Text;
|
||||
import mc.core.text.TextColor;
|
||||
import mc.core.text.TextTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class ListCommand implements CommandExecutor {
|
||||
private static final TextTemplate messageFormat = TextTemplate.builder()
|
||||
.append(Text.of(TextColor.GREEN, "Online("))
|
||||
.arg("count")
|
||||
.append(Text.of(TextColor.GREEN, "): "))
|
||||
.arg("players", TextColor.DARK_GREEN)
|
||||
.build();
|
||||
|
||||
@Autowired
|
||||
private PlayerManager playerManager;
|
||||
|
||||
@@ -43,9 +52,9 @@ public class ListCommand implements CommandExecutor {
|
||||
StringJoiner sj = new StringJoiner(", ");
|
||||
playerManager.getPlayers().forEach(pl -> sj.add(pl.getName()));
|
||||
|
||||
Text message = Text.builder(TextColor.GREEN, "Online(" + playerManager.getCountOnlinePlayers() + "): ")
|
||||
.append(Text.of(TextColor.DARK_GREEN, sj.toString()))
|
||||
.build();
|
||||
sender.getChannel().sendChatMessage(message);
|
||||
Text message = messageFormat.apply(
|
||||
"count", playerManager.getCountOnlinePlayers(),
|
||||
"players", sj.toString());
|
||||
sender.getChannel().sendChatMessage(message, MessageType.SYSTEM_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user