mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-10 16:01:50 -04:00
lower java requirement down to 11
This commit is contained in:
parent
614d12978a
commit
3f656f1ba2
@ -2,7 +2,7 @@ variables:
|
|||||||
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
|
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
|
||||||
MAVEN_CLI_OPTS: "--errors --fail-at-end --show-version"
|
MAVEN_CLI_OPTS: "--errors --fail-at-end --show-version"
|
||||||
|
|
||||||
image: maven:3-openjdk-16
|
image: maven:3-openjdk-11
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
before_install:
|
|
||||||
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
|
|
||||||
- source install-jdk.sh --feature 16
|
|
||||||
- jshell --version
|
|
10
pom.xml
10
pom.xml
@ -41,7 +41,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<jvmTarget>14</jvmTarget>
|
<jvmTarget>${maven.compiler.target}</jvmTarget>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -73,8 +73,8 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>14</source>
|
<source>${maven.compiler.source}</source>
|
||||||
<target>14</target>
|
<target>${maven.compiler.target}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -194,8 +194,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<exec.mainClass>de.bixilon.minosoft.Minosoft</exec.mainClass>
|
<exec.mainClass>de.bixilon.minosoft.Minosoft</exec.mainClass>
|
||||||
<maven.compiler.source>14</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
<maven.compiler.target>14</maven.compiler.target>
|
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
|
||||||
<javafx.version>18-ea+4</javafx.version>
|
<javafx.version>18-ea+4</javafx.version>
|
||||||
<kotlin.version>1.5.21</kotlin.version>
|
<kotlin.version>1.5.21</kotlin.version>
|
||||||
<lwjgl.version>3.2.3</lwjgl.version>
|
<lwjgl.version>3.2.3</lwjgl.version>
|
||||||
|
@ -17,7 +17,10 @@ import org.lwjgl.glfw.GLFW.*
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// ToDo: Replace glfwKeyIds
|
// ToDo: Replace glfwKeyIds
|
||||||
enum class KeyCodes(val glfwKeyId: Int) {
|
enum class KeyCodes(
|
||||||
|
@Deprecated("GLFW specific -> abstraction layer")
|
||||||
|
val glfwKeyId: Int,
|
||||||
|
) {
|
||||||
KEY_UNKNOWN(GLFW_KEY_UNKNOWN),
|
KEY_UNKNOWN(GLFW_KEY_UNKNOWN),
|
||||||
KEY_SPACE(GLFW_KEY_SPACE),
|
KEY_SPACE(GLFW_KEY_SPACE),
|
||||||
KEY_APOSTROPHE(GLFW_KEY_APOSTROPHE),
|
KEY_APOSTROPHE(GLFW_KEY_APOSTROPHE),
|
||||||
|
@ -45,14 +45,25 @@ public class CommandArgumentNode extends CommandLiteralNode {
|
|||||||
}
|
}
|
||||||
if (BitByte.isBitMask(flags, 0x10)) {
|
if (BitByte.isBitMask(flags, 0x10)) {
|
||||||
String resourceLocation = buffer.readResourceLocation().getFull();
|
String resourceLocation = buffer.readResourceLocation().getFull();
|
||||||
this.suggestionType = switch (resourceLocation) {
|
switch (resourceLocation) {
|
||||||
case "minecraft:ask_server" -> CommandArgumentNode.SuggestionTypes.ASK_SERVER;
|
case "minecraft:ask_server":
|
||||||
case "minecraft:all_recipes" -> CommandArgumentNode.SuggestionTypes.ALL_RECIPES;
|
this.suggestionType = CommandArgumentNode.SuggestionTypes.ASK_SERVER;
|
||||||
case "minecraft:available_sounds" -> CommandArgumentNode.SuggestionTypes.AVAILABLE_SOUNDS;
|
break;
|
||||||
case "minecraft:summonable_entities" -> CommandArgumentNode.SuggestionTypes.SUMMONABLE_ENTITIES;
|
case "minecraft:all_recipes":
|
||||||
case "minecraft:available_biomes" -> CommandArgumentNode.SuggestionTypes.AVAILABLE_BIOMES;
|
this.suggestionType = CommandArgumentNode.SuggestionTypes.ALL_RECIPES;
|
||||||
default -> throw new IllegalArgumentException("Unexpected value: " + resourceLocation);
|
break;
|
||||||
};
|
case "minecraft:available_sounds":
|
||||||
|
this.suggestionType = CommandArgumentNode.SuggestionTypes.AVAILABLE_SOUNDS;
|
||||||
|
break;
|
||||||
|
case "minecraft:summonable_entities":
|
||||||
|
this.suggestionType = CommandArgumentNode.SuggestionTypes.SUMMONABLE_ENTITIES;
|
||||||
|
break;
|
||||||
|
case "minecraft:available_biomes":
|
||||||
|
this.suggestionType = CommandArgumentNode.SuggestionTypes.AVAILABLE_BIOMES;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unexpected value: " + resourceLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,20 @@ public class StringParser extends CommandParser {
|
|||||||
@Override
|
@Override
|
||||||
public Object parse(PlayConnection connection, ParserProperties properties, CommandStringReader stringReader) throws CommandParseException {
|
public Object parse(PlayConnection connection, ParserProperties properties, CommandStringReader stringReader) throws CommandParseException {
|
||||||
StringParserProperties stringParserProperties = ((StringParserProperties) properties);
|
StringParserProperties stringParserProperties = ((StringParserProperties) properties);
|
||||||
String string = switch (stringParserProperties.getSetting()) {
|
String string;
|
||||||
case SINGLE_WORD -> stringReader.readUnquotedString();
|
switch (stringParserProperties.getSetting()) {
|
||||||
case QUOTABLE_PHRASE -> stringReader.readString();
|
case SINGLE_WORD:
|
||||||
case GREEDY_PHRASE -> stringReader.readRemaining();
|
string = stringReader.readUnquotedString();
|
||||||
};
|
break;
|
||||||
|
case QUOTABLE_PHRASE:
|
||||||
|
string = stringReader.readString();
|
||||||
|
break;
|
||||||
|
case GREEDY_PHRASE:
|
||||||
|
string = stringReader.readRemaining();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
if (!stringParserProperties.isAllowEmptyString() && string.isBlank()) {
|
if (!stringParserProperties.isAllowEmptyString() && string.isBlank()) {
|
||||||
throw new BlankStringCommandParseException(stringReader, string);
|
throw new BlankStringCommandParseException(stringReader, string);
|
||||||
|
@ -29,16 +29,22 @@ public class TimeParser extends CommandParser {
|
|||||||
|
|
||||||
if (stringReader.canRead()) {
|
if (stringReader.canRead()) {
|
||||||
char unit = stringReader.read();
|
char unit = stringReader.read();
|
||||||
time *= switch (unit) {
|
switch (unit) {
|
||||||
case 'd' -> 24000;
|
case 'd':
|
||||||
case 's' -> 20;
|
time *= 24000;
|
||||||
case 't' -> 1;
|
break;
|
||||||
case ' ' -> {
|
case 's':
|
||||||
|
time *= 20;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
time *= 1;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
stringReader.skip(-1);
|
stringReader.skip(-1);
|
||||||
yield 1;
|
break;
|
||||||
|
default:
|
||||||
|
throw new UnknownTimeUnitCommandParseException(stringReader, String.valueOf(unit));
|
||||||
}
|
}
|
||||||
default -> throw new UnknownTimeUnitCommandParseException(stringReader, String.valueOf(unit));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import de.bixilon.minosoft.Minosoft;
|
import de.bixilon.minosoft.Minosoft;
|
||||||
import de.bixilon.minosoft.config.Configuration;
|
import de.bixilon.minosoft.config.Configuration;
|
||||||
|
import de.bixilon.minosoft.data.assets.AssetVersion;
|
||||||
import de.bixilon.minosoft.data.assets.MinecraftAssetsManager;
|
import de.bixilon.minosoft.data.assets.MinecraftAssetsManager;
|
||||||
import de.bixilon.minosoft.data.assets.Resources;
|
import de.bixilon.minosoft.data.assets.Resources;
|
||||||
import de.bixilon.minosoft.data.registries.versions.Version;
|
import de.bixilon.minosoft.data.registries.versions.Version;
|
||||||
@ -48,7 +49,7 @@ public class JarHashGenerator {
|
|||||||
|
|
||||||
Resources.loadVersion(version, versionJson);
|
Resources.loadVersion(version, versionJson);
|
||||||
|
|
||||||
var resource = Resources.getAssetVersionByVersion(version);
|
AssetVersion resource = Resources.getAssetVersionByVersion(version);
|
||||||
MinecraftAssetsManager assetsManager = new MinecraftAssetsManager(resource, "dummy");
|
MinecraftAssetsManager assetsManager = new MinecraftAssetsManager(resource, "dummy");
|
||||||
String jarAssetsHash = assetsManager.generateJarAssets();
|
String jarAssetsHash = assetsManager.generateJarAssets();
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.protocol.network;
|
package de.bixilon.minosoft.protocol.network;
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.versions.Version;
|
import de.bixilon.minosoft.data.registries.versions.Version;
|
||||||
|
import de.bixilon.minosoft.protocol.ErrorHandler;
|
||||||
import de.bixilon.minosoft.protocol.exceptions.PacketNotImplementedException;
|
import de.bixilon.minosoft.protocol.exceptions.PacketNotImplementedException;
|
||||||
import de.bixilon.minosoft.protocol.exceptions.PacketParseException;
|
import de.bixilon.minosoft.protocol.exceptions.PacketParseException;
|
||||||
import de.bixilon.minosoft.protocol.exceptions.UnknownPacketException;
|
import de.bixilon.minosoft.protocol.exceptions.UnknownPacketException;
|
||||||
@ -65,8 +66,8 @@ public abstract class Network {
|
|||||||
bytes = Util.decompress(bytes);
|
bytes = Util.decompress(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var data = new InByteBuffer(bytes, this.connection);
|
InByteBuffer data = new InByteBuffer(bytes, this.connection);
|
||||||
var packetId = data.readVarInt();
|
int packetId = data.readVarInt();
|
||||||
|
|
||||||
PacketTypes.S2C packetType = null;
|
PacketTypes.S2C packetType = null;
|
||||||
|
|
||||||
@ -85,14 +86,14 @@ public abstract class Network {
|
|||||||
S2CPacket packet;
|
S2CPacket packet;
|
||||||
try {
|
try {
|
||||||
if (packetType.getPlayFactory() != null) {
|
if (packetType.getPlayFactory() != null) {
|
||||||
var playData = new PlayInByteBuffer(data.readRest(), ((PlayConnection) this.connection));
|
PlayInByteBuffer playData = new PlayInByteBuffer(data.readRest(), ((PlayConnection) this.connection));
|
||||||
packet = packetType.getPlayFactory().invoke(playData);
|
packet = packetType.getPlayFactory().invoke(playData);
|
||||||
if (playData.getBytesLeft() > 0) {
|
if (playData.getBytesLeft() > 0) {
|
||||||
throw new PacketParseException(String.format("Could not parse packet %s (used=%d, available=%d, total=%d)", packetType, playData.getPointer(), playData.getBytesLeft(), playData.getSize()));
|
throw new PacketParseException(String.format("Could not parse packet %s (used=%d, available=%d, total=%d)", packetType, playData.getPointer(), playData.getBytesLeft(), playData.getSize()));
|
||||||
}
|
}
|
||||||
((PlayS2CPacket) packet).check(((PlayConnection) this.connection));
|
((PlayS2CPacket) packet).check(((PlayConnection) this.connection));
|
||||||
} else if (packetType.getStatusFactory() != null) {
|
} else if (packetType.getStatusFactory() != null) {
|
||||||
var statusData = new InByteBuffer(data);
|
InByteBuffer statusData = new InByteBuffer(data);
|
||||||
packet = packetType.getStatusFactory().invoke(statusData);
|
packet = packetType.getStatusFactory().invoke(statusData);
|
||||||
if (statusData.getBytesLeft() > 0) {
|
if (statusData.getBytesLeft() > 0) {
|
||||||
throw new PacketParseException(String.format("Could not parse packet %s (used=%d, available=%d, total=%d)", packetType, statusData.getPointer(), statusData.getBytesLeft(), statusData.getSize()));
|
throw new PacketParseException(String.format("Could not parse packet %s (used=%d, available=%d, total=%d)", packetType, statusData.getPointer(), statusData.getBytesLeft(), statusData.getSize()));
|
||||||
@ -104,7 +105,7 @@ public abstract class Network {
|
|||||||
|
|
||||||
|
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
var errorHandler = packetType.getErrorHandler();
|
ErrorHandler errorHandler = packetType.getErrorHandler();
|
||||||
if (errorHandler != null) {
|
if (errorHandler != null) {
|
||||||
errorHandler.onError(this.connection);
|
errorHandler.onError(this.connection);
|
||||||
}
|
}
|
||||||
@ -124,11 +125,11 @@ public abstract class Network {
|
|||||||
protected byte[] prepareC2SPacket(C2SPacket packet) {
|
protected byte[] prepareC2SPacket(C2SPacket packet) {
|
||||||
byte[] data;
|
byte[] data;
|
||||||
if (packet instanceof PlayC2SPacket) {
|
if (packet instanceof PlayC2SPacket) {
|
||||||
var buffer = new PlayOutByteBuffer((PlayConnection) this.connection);
|
PlayOutByteBuffer buffer = new PlayOutByteBuffer((PlayConnection) this.connection);
|
||||||
((PlayC2SPacket) packet).write(buffer);
|
((PlayC2SPacket) packet).write(buffer);
|
||||||
data = buffer.toByteArray();
|
data = buffer.toByteArray();
|
||||||
} else if (packet instanceof AllC2SPacket) {
|
} else if (packet instanceof AllC2SPacket) {
|
||||||
var buffer = new OutByteBuffer(this.connection);
|
OutByteBuffer buffer = new OutByteBuffer(this.connection);
|
||||||
((AllC2SPacket) packet).write(buffer);
|
((AllC2SPacket) packet).write(buffer);
|
||||||
data = buffer.toByteArray();
|
data = buffer.toByteArray();
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,7 +111,7 @@ public class BlockingSocketNetwork extends Network {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var typeAndPacket = prepareS2CPacket(this.inputStream);
|
Pair<PacketTypes.S2C, S2CPacket> typeAndPacket = prepareS2CPacket(this.inputStream);
|
||||||
while (this.receivingPaused && this.connection.getProtocolState() != ProtocolStates.DISCONNECTED && !this.shouldDisconnect) {
|
while (this.receivingPaused && this.connection.getProtocolState() != ProtocolStates.DISCONNECTED && !this.shouldDisconnect) {
|
||||||
Util.sleep(1L);
|
Util.sleep(1L);
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,12 @@ import de.bixilon.minosoft.protocol.network.Network;
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection;
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection;
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.C2SPacket;
|
import de.bixilon.minosoft.protocol.packets.c2s.C2SPacket;
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionResponseC2SP;
|
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionResponseC2SP;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket;
|
||||||
import de.bixilon.minosoft.protocol.protocol.CryptManager;
|
import de.bixilon.minosoft.protocol.protocol.CryptManager;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes;
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates;
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates;
|
||||||
|
import de.bixilon.minosoft.util.Pair;
|
||||||
import de.bixilon.minosoft.util.ServerAddress;
|
import de.bixilon.minosoft.util.ServerAddress;
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
import de.bixilon.minosoft.util.logging.Log;
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels;
|
import de.bixilon.minosoft.util.logging.LogLevels;
|
||||||
@ -138,7 +141,7 @@ public class NonBlockingSocketNetwork extends Network {
|
|||||||
if (!currentPacketBuffer.hasRemaining()) {
|
if (!currentPacketBuffer.hasRemaining()) {
|
||||||
currentPacketBuffer.flip();
|
currentPacketBuffer.flip();
|
||||||
try {
|
try {
|
||||||
var typeAndPacket = receiveS2CPacket(decryptData(currentPacketBuffer.array()));
|
Pair<PacketTypes.S2C, S2CPacket> typeAndPacket = receiveS2CPacket(decryptData(currentPacketBuffer.array()));
|
||||||
handlePacket(typeAndPacket.getKey(), typeAndPacket.getValue());
|
handlePacket(typeAndPacket.getKey(), typeAndPacket.getValue());
|
||||||
} catch (PacketParseException e) {
|
} catch (PacketParseException e) {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, e);
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, e);
|
||||||
|
@ -44,41 +44,51 @@ public class PacketDeclareRecipes extends PlayS2CPacket {
|
|||||||
}
|
}
|
||||||
RecipeTypes type = RecipeTypes.byName(typeName);
|
RecipeTypes type = RecipeTypes.byName(typeName);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SHAPELESS -> {
|
case SHAPELESS: {
|
||||||
String group = buffer.readString();
|
String group = buffer.readString();
|
||||||
Ingredient[] ingredients = buffer.readIngredientArray();
|
Ingredient[] ingredients = buffer.readIngredientArray();
|
||||||
ItemStack result = buffer.readItemStack();
|
ItemStack result = buffer.readItemStack();
|
||||||
recipe = new Recipe(type, group, ingredients, result);
|
recipe = new Recipe(type, group, ingredients, result);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case SHAPED -> {
|
case SHAPED: {
|
||||||
int width = buffer.readVarInt();
|
int width = buffer.readVarInt();
|
||||||
int height = buffer.readVarInt();
|
int height = buffer.readVarInt();
|
||||||
String group = buffer.readString();
|
String group = buffer.readString();
|
||||||
Ingredient[] ingredients = buffer.readIngredientArray(width * height);
|
Ingredient[] ingredients = buffer.readIngredientArray(width * height);
|
||||||
ItemStack result = buffer.readItemStack();
|
ItemStack result = buffer.readItemStack();
|
||||||
recipe = new Recipe(width, height, type, group, ingredients, result);
|
recipe = new Recipe(width, height, type, group, ingredients, result);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case SMELTING, BLASTING, SMOKING, CAMPFIRE -> {
|
case SMELTING:
|
||||||
|
case BLASTING:
|
||||||
|
case SMOKING:
|
||||||
|
case CAMPFIRE: {
|
||||||
String group = buffer.readString();
|
String group = buffer.readString();
|
||||||
Ingredient ingredient = buffer.readIngredient();
|
Ingredient ingredient = buffer.readIngredient();
|
||||||
ItemStack result = buffer.readItemStack();
|
ItemStack result = buffer.readItemStack();
|
||||||
float experience = buffer.readFloat();
|
float experience = buffer.readFloat();
|
||||||
int cookingTime = buffer.readVarInt();
|
int cookingTime = buffer.readVarInt();
|
||||||
recipe = new Recipe(type, group, ingredient, result, experience, cookingTime);
|
recipe = new Recipe(type, group, ingredient, result, experience, cookingTime);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case STONE_CUTTING -> {
|
case STONE_CUTTING: {
|
||||||
String group = buffer.readString();
|
String group = buffer.readString();
|
||||||
Ingredient ingredient = buffer.readIngredient();
|
Ingredient ingredient = buffer.readIngredient();
|
||||||
ItemStack result = buffer.readItemStack();
|
ItemStack result = buffer.readItemStack();
|
||||||
recipe = new Recipe(type, group, ingredient, result);
|
recipe = new Recipe(type, group, ingredient, result);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case SMITHING -> {
|
case SMITHING: {
|
||||||
Ingredient base = buffer.readIngredient();
|
Ingredient base = buffer.readIngredient();
|
||||||
Ingredient addition = buffer.readIngredient();
|
Ingredient addition = buffer.readIngredient();
|
||||||
ItemStack result = buffer.readItemStack();
|
ItemStack result = buffer.readItemStack();
|
||||||
recipe = new Recipe(type, base, addition, result);
|
recipe = new Recipe(type, base, addition, result);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default -> recipe = new Recipe(type);
|
default:
|
||||||
|
recipe = new Recipe(type);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.recipes.put(resourceLocation, recipe);
|
this.recipes.put(resourceLocation, recipe);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,13 @@ public class PacketMapData extends PlayS2CPacket {
|
|||||||
// read action
|
// read action
|
||||||
this.dataData = PacketMapDataDataActions.byId(buffer.readUnsignedByte());
|
this.dataData = PacketMapDataDataActions.byId(buffer.readUnsignedByte());
|
||||||
switch (this.dataData) {
|
switch (this.dataData) {
|
||||||
case START -> {
|
case START: {
|
||||||
this.xStart = buffer.readByte();
|
this.xStart = buffer.readByte();
|
||||||
this.yStart = buffer.readByte();
|
this.yStart = buffer.readByte();
|
||||||
this.colors = buffer.readByteArray(length - 3); // 3: dataData(1) + xStart (1) + yStart (1)
|
this.colors = buffer.readByteArray(length - 3); // 3: dataData(1) + xStart (1) + yStart (1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case PLAYERS -> {
|
case PLAYERS: {
|
||||||
this.pins = new ArrayList<>();
|
this.pins = new ArrayList<>();
|
||||||
length--; // minus the dataData
|
length--; // minus the dataData
|
||||||
for (int i = 0; i < length / 3; i++) { // loop over all sets ( 1 set: 3 bytes)
|
for (int i = 0; i < length / 3; i++) { // loop over all sets ( 1 set: 3 bytes)
|
||||||
@ -62,8 +63,11 @@ public class PacketMapData extends PlayS2CPacket {
|
|||||||
byte z = buffer.readByte();
|
byte z = buffer.readByte();
|
||||||
this.pins.add(new MapPinSet(MapPinTypes.byId(directionAndType & 0xF), directionAndType >>> 4, x, z));
|
this.pins.add(new MapPinSet(MapPinTypes.byId(directionAndType & 0xF), directionAndType >>> 4, x, z));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case SCALE -> this.scale = buffer.readByte();
|
case SCALE:
|
||||||
|
this.scale = buffer.readByte();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class PacketSelectAdvancementTab extends PlayS2CPacket {
|
|||||||
public static final HashMap<ResourceLocation, AdvancementTabs> VALUES = new HashMap<>();
|
public static final HashMap<ResourceLocation, AdvancementTabs> VALUES = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (var tab : values()) {
|
for (AdvancementTabs tab : values()) {
|
||||||
VALUES.put(tab.resourceLocation, tab);
|
VALUES.put(tab.resourceLocation, tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class PacketStatistics extends PlayS2CPacket {
|
|||||||
if (buffer.getVersionId() < V_17W47A) { // ToDo
|
if (buffer.getVersionId() < V_17W47A) { // ToDo
|
||||||
this.statistics.put(buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readResourceLocation()), buffer.readVarInt());
|
this.statistics.put(buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readResourceLocation()), buffer.readVarInt());
|
||||||
} else {
|
} else {
|
||||||
var category = buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readVarInt()); // category before?
|
Statistic category = buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readVarInt()); // category before?
|
||||||
this.statistics.put(buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readVarInt()), buffer.readVarInt());
|
this.statistics.put(buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readVarInt()), buffer.readVarInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import de.bixilon.minosoft.data.commands.parser.properties.IntegerParserProperti
|
|||||||
import de.bixilon.minosoft.data.entities.entities.Entity;
|
import de.bixilon.minosoft.data.entities.entities.Entity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class CommandEntities extends Command {
|
public class CommandEntities extends Command {
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public class CommandEntities extends Command {
|
|||||||
new CommandLiteralNode("list", (connection, stack) -> {
|
new CommandLiteralNode("list", (connection, stack) -> {
|
||||||
ArrayList<Object[]> tableData = new ArrayList<>();
|
ArrayList<Object[]> tableData = new ArrayList<>();
|
||||||
|
|
||||||
for (var entry : connection.getWorld().getEntities()) {
|
for (Entity entry : connection.getWorld().getEntities()) {
|
||||||
tableData.add(new Object[]{connection.getWorld().getEntities().getId(entry), connection.getWorld().getEntities().getUUID(entry), entry.getEntityType().toString(), entry.getEquipment(), entry.getPosition(), entry.getRotation()});
|
tableData.add(new Object[]{connection.getWorld().getEntities().getId(entry), connection.getWorld().getEntities().getUUID(entry), entry.getEntityType().toString(), entry.getEquipment(), entry.getPosition(), entry.getRotation()});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class CommandEntities extends Command {
|
|||||||
tableData.add(new Object[]{"Effects", entity.getActiveStatusEffects()});
|
tableData.add(new Object[]{"Effects", entity.getActiveStatusEffects()});
|
||||||
tableData.add(new Object[]{"Attached to", entity.getAttachedEntity() == -1 ? "" : entity.getAttachedEntity()});
|
tableData.add(new Object[]{"Attached to", entity.getAttachedEntity() == -1 ? "" : entity.getAttachedEntity()});
|
||||||
|
|
||||||
for (var entry : entity.getEntityMetaDataFormatted().entrySet()) {
|
for (Map.Entry<String, Object> entry : entity.getEntityMetaDataFormatted().entrySet()) {
|
||||||
tableData.add(new Object[]{entry.getKey(), entry.getValue()});
|
tableData.add(new Object[]{entry.getKey(), entry.getValue()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ import de.bixilon.minosoft.data.player.tab.TabListItem;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class CommandTabList extends Command {
|
public class CommandTabList extends Command {
|
||||||
@Override
|
@Override
|
||||||
@ -67,7 +69,7 @@ public class CommandTabList extends Command {
|
|||||||
|
|
||||||
ArrayList<Object[]> tableData = new ArrayList<>();
|
ArrayList<Object[]> tableData = new ArrayList<>();
|
||||||
|
|
||||||
for (var entry : connection.getTabList().getTabListItemsByUUID().entrySet()) {
|
for (Map.Entry<UUID, TabListItem> entry : connection.getTabList().getTabListItemsByUUID().entrySet()) {
|
||||||
PlayerEntity playerEntity = (PlayerEntity) connection.getWorld().getEntities().get(entry.getKey());
|
PlayerEntity playerEntity = (PlayerEntity) connection.getWorld().getEntities().get(entry.getKey());
|
||||||
Integer entityId = playerEntity != null ? connection.getWorld().getEntities().getId(playerEntity) : null;
|
Integer entityId = playerEntity != null ? connection.getWorld().getEntities().getId(playerEntity) : null;
|
||||||
tableData.add(new Object[]{entry.getKey(), entityId, entry.getValue().getName(), entry.getValue().getDisplayName(), entry.getValue().getGamemode(), entry.getValue().getPing() + "ms"});
|
tableData.add(new Object[]{entry.getKey(), entityId, entry.getValue().getName(), entry.getValue().getDisplayName(), entry.getValue().getGamemode(), entry.getValue().getPing() + "ms"});
|
||||||
|
@ -319,7 +319,7 @@ public final class Util {
|
|||||||
|
|
||||||
public static String[] headersMapToArray(Map<String, String> headers) {
|
public static String[] headersMapToArray(Map<String, String> headers) {
|
||||||
List<String> headerList = new ArrayList<>();
|
List<String> headerList = new ArrayList<>();
|
||||||
for (var entry : headers.entrySet()) {
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||||
headerList.add(entry.getKey());
|
headerList.add(entry.getKey());
|
||||||
headerList.add(entry.getValue());
|
headerList.add(entry.getValue());
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ public final class Util {
|
|||||||
|
|
||||||
public static String formatString(String string, Map<String, Object> format) {
|
public static String formatString(String string, Map<String, Object> format) {
|
||||||
String output = string;
|
String output = string;
|
||||||
for (var entry : format.entrySet()) {
|
for (Map.Entry<String, Object> entry : format.entrySet()) {
|
||||||
output = output.replace("${" + entry.getKey() + "}", entry.getValue().toString());
|
output = output.replace("${" + entry.getKey() + "}", entry.getValue().toString());
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user