убираем модуль Vanilla commands
This commit is contained in:
@@ -3,7 +3,6 @@ rootProject.name = 'mc-server'
|
||||
include('core') // Core
|
||||
include('simple_world')
|
||||
include('h2_playermanager')
|
||||
include('vanilla_commands')
|
||||
include('proto_1.12.2') // Protocol 1.12.2
|
||||
include('proto_1.12.2_netty') // Protocol 1.12.2 (Netty impl.)
|
||||
include('anvil-loader') // Vanilla world loader (aka Anvil)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
dependencies {
|
||||
/* Core */
|
||||
compile_excludeCopy project(':core')
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-23
|
||||
*/
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "help";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String[]> getAliases() {
|
||||
return Optional.of(new String[]{"?"});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getUsage() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "shows this message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, String... args) {
|
||||
if (commanderChatProcessor == null) {
|
||||
commanderChatProcessor = applicationContext.getBean(CommanderChatProcessor.class);
|
||||
if (commanderChatProcessor == null) {
|
||||
log.error("Error get bean of type \"CommanderChatProcessor\". WTF?!");
|
||||
sender.getChannel().sendChatMessage(Text.of(TextColor.RED, "!!-Server error-!!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
commanderChatProcessor.getAllCommands().forEach(commandExecutor -> {
|
||||
Text message = messageFormat.apply(
|
||||
"command", commandExecutor.getUsage().orElse(commandExecutor.getName()),
|
||||
"description", commandExecutor.getDescription());
|
||||
sender.getChannel().sendChatMessage(message, MessageType.SYSTEM_MESSAGE);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-23
|
||||
*/
|
||||
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;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String[]> getAliases() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getUsage() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "lists all currently connected players";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, String... args) {
|
||||
StringJoiner sj = new StringJoiner(", ");
|
||||
playerManager.getPlayers().forEach(pl -> sj.add(pl.getName()));
|
||||
|
||||
Text message = messageFormat.apply(
|
||||
"count", playerManager.getCountPlayers(),
|
||||
"players", sj.toString());
|
||||
sender.getChannel().sendChatMessage(message, MessageType.SYSTEM_MESSAGE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user