убираем лишнее
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
package mc.world.anvil;
|
|
||||||
|
|
||||||
import com.flowpowered.nbt.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import mc.core.world.block.BlockLocation;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
class LevelInfo {
|
|
||||||
private long seed;
|
|
||||||
private BlockLocation spawn;
|
|
||||||
private int version;
|
|
||||||
|
|
||||||
LevelInfo(CompoundTag levelDatTag) {
|
|
||||||
CompoundMap dataMapTag = ((CompoundTag) levelDatTag.getValue().get("Data")).getValue();
|
|
||||||
|
|
||||||
seed = ((LongTag) dataMapTag.get("RandomSeed")).getValue();
|
|
||||||
spawn = new BlockLocation(
|
|
||||||
((IntTag) dataMapTag.get("SpawnX")).getValue(),
|
|
||||||
((IntTag) dataMapTag.get("SpawnY")).getValue(),
|
|
||||||
((IntTag) dataMapTag.get("SpawnZ")).getValue()
|
|
||||||
);
|
|
||||||
version = ((IntTag) dataMapTag.get("version")).getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* DmitriyMX <dimon550@gmail.com>
|
|
||||||
* 2018-05-22
|
|
||||||
*/
|
|
||||||
package mc.core.chat;
|
|
||||||
|
|
||||||
import mc.core.player.Player;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface CommandExecutor {
|
|
||||||
String getName();
|
|
||||||
Optional<String[]> getAliases();
|
|
||||||
Optional<String> getUsage();
|
|
||||||
String getDescription();
|
|
||||||
void execute(Player sender, String... args);
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* DmitriyMX <dimon550@gmail.com>
|
|
||||||
* 2018-05-23
|
|
||||||
*/
|
|
||||||
package mc.core.chat;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import mc.core.player.Player;
|
|
||||||
import mc.core.text.Text;
|
|
||||||
import mc.core.text.TextColor;
|
|
||||||
import mc.core.text.TextTemplate;
|
|
||||||
import org.slf4j.Marker;
|
|
||||||
import org.slf4j.helpers.BasicMarkerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class CommanderChatProcessor extends SimpleChatProcessor {
|
|
||||||
private static final Marker COMMAND_MARKER = new BasicMarkerFactory().getMarker("Command");
|
|
||||||
private static final TextTemplate UNKNOW_COMMAND_MSG = TextTemplate.builder()
|
|
||||||
.append(Text.of("Unknown command \"", TextColor.RED))
|
|
||||||
.arg("command", TextColor.WHITE)
|
|
||||||
.append(Text.of("\"", TextColor.RED))
|
|
||||||
.build();
|
|
||||||
@Autowired
|
|
||||||
private ApplicationContext applicationContext;
|
|
||||||
private Map<String, CommandExecutor> commands = new HashMap<>();
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
Map<String, CommandExecutor> beans = applicationContext.getBeansOfType(CommandExecutor.class);
|
|
||||||
beans.values().forEach(commandExecutor -> {
|
|
||||||
log.trace("Add command \"{}\" ({})", commandExecutor.getName(), commandExecutor.getClass().getName());
|
|
||||||
if (commands.containsKey(commandExecutor.getName())) {
|
|
||||||
log.warn("Override command \"{}\"", commandExecutor.getName());
|
|
||||||
log.debug("{} -> {}",
|
|
||||||
commands.get(commandExecutor.getName()).getClass().getName(),
|
|
||||||
commandExecutor.getClass().getName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
commands.put(commandExecutor.getName(), commandExecutor);
|
|
||||||
|
|
||||||
if (commandExecutor.getAliases().isPresent()) {
|
|
||||||
Arrays.stream(commandExecutor.getAliases().get()).forEach(aliase -> {
|
|
||||||
log.trace("Add aliase \"{}\" ({})", aliase, commandExecutor.getClass().getName());
|
|
||||||
if (commands.containsKey(aliase)) {
|
|
||||||
log.warn("Override aliase \"{}\"", aliase);
|
|
||||||
log.debug("{} -> {}",
|
|
||||||
commands.get(aliase).getClass().getName(),
|
|
||||||
commandExecutor.getClass().getName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
commands.put(aliase, commandExecutor);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
log.debug("Load {} commands", commands.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(Player player, String message) {
|
|
||||||
if (message.startsWith("/")) {
|
|
||||||
log.info(COMMAND_MARKER, "<{}> {}", player.getName(), message);
|
|
||||||
|
|
||||||
int idx = message.indexOf(' ');
|
|
||||||
if (idx == -1) {
|
|
||||||
idx = message.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
String command = message.substring(1, idx).toLowerCase();
|
|
||||||
if (commands.containsKey(command)) {
|
|
||||||
String[] args = message.substring(idx).split(" ");
|
|
||||||
commands.get(command).execute(player, args);
|
|
||||||
} else {
|
|
||||||
player.getChannel().sendChatMessage(
|
|
||||||
UNKNOW_COMMAND_MSG.apply("command", command),
|
|
||||||
MessageType.SYSTEM_MESSAGE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
super.process(player, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<CommandExecutor> getAllCommands() {
|
|
||||||
return commands.values();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* Протокол Minecraft версии 1.12.2 (номер версии протокола - 340)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Типы данных.
|
|
||||||
*
|
|
||||||
* (см. http://wiki.vg/Protocol#Data_types)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Формат пакетов.
|
|
||||||
*
|
|
||||||
* Есть два варианта: без использования сжатия и с использованием.
|
|
||||||
* Регулируется это пакетом {@link mc.core.network.proto_1_12_2.packets.SetCompressionPacket}
|
|
||||||
*
|
|
||||||
* Формат без использования сжатия:
|
|
||||||
*
|
|
||||||
* +---------------+------------+--------------------+
|
|
||||||
* | Название | Тип | Комментарий |
|
|
||||||
* +---------------+------------+--------------------+
|
|
||||||
* | Размер пакета | VarInt | ID пакета + данные |
|
|
||||||
* +---------------+------------+--------------------+
|
|
||||||
* | ID пакета | VarInt | |
|
|
||||||
* +---------------+------------+--------------------+
|
|
||||||
* | Данные | Byte Array | |
|
|
||||||
* +---------------+------------+--------------------+
|
|
||||||
*
|
|
||||||
* Формат с использованием сжатия:
|
|
||||||
*
|
|
||||||
* (см. http://wiki.vg/Protocol#With_compression)
|
|
||||||
*/
|
|
||||||
|
|
||||||
package mc.core.network.proto_1_12_2;
|
|
||||||
Reference in New Issue
Block a user