mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 23:13:10 -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_CLI_OPTS: "--errors --fail-at-end --show-version"
|
||||
|
||||
image: maven:3-openjdk-16
|
||||
image: maven:3-openjdk-11
|
||||
|
||||
cache:
|
||||
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>
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>14</jvmTarget>
|
||||
<jvmTarget>${maven.compiler.target}</jvmTarget>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -73,8 +73,8 @@
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>14</source>
|
||||
<target>14</target>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -194,8 +194,8 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<exec.mainClass>de.bixilon.minosoft.Minosoft</exec.mainClass>
|
||||
<maven.compiler.source>14</maven.compiler.source>
|
||||
<maven.compiler.target>14</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
|
||||
<javafx.version>18-ea+4</javafx.version>
|
||||
<kotlin.version>1.5.21</kotlin.version>
|
||||
<lwjgl.version>3.2.3</lwjgl.version>
|
||||
|
@ -17,7 +17,10 @@ import org.lwjgl.glfw.GLFW.*
|
||||
import java.util.*
|
||||
|
||||
// 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_SPACE(GLFW_KEY_SPACE),
|
||||
KEY_APOSTROPHE(GLFW_KEY_APOSTROPHE),
|
||||
|
@ -45,14 +45,25 @@ public class CommandArgumentNode extends CommandLiteralNode {
|
||||
}
|
||||
if (BitByte.isBitMask(flags, 0x10)) {
|
||||
String resourceLocation = buffer.readResourceLocation().getFull();
|
||||
this.suggestionType = switch (resourceLocation) {
|
||||
case "minecraft:ask_server" -> CommandArgumentNode.SuggestionTypes.ASK_SERVER;
|
||||
case "minecraft:all_recipes" -> CommandArgumentNode.SuggestionTypes.ALL_RECIPES;
|
||||
case "minecraft:available_sounds" -> CommandArgumentNode.SuggestionTypes.AVAILABLE_SOUNDS;
|
||||
case "minecraft:summonable_entities" -> CommandArgumentNode.SuggestionTypes.SUMMONABLE_ENTITIES;
|
||||
case "minecraft:available_biomes" -> CommandArgumentNode.SuggestionTypes.AVAILABLE_BIOMES;
|
||||
default -> throw new IllegalArgumentException("Unexpected value: " + resourceLocation);
|
||||
};
|
||||
switch (resourceLocation) {
|
||||
case "minecraft:ask_server":
|
||||
this.suggestionType = CommandArgumentNode.SuggestionTypes.ASK_SERVER;
|
||||
break;
|
||||
case "minecraft:all_recipes":
|
||||
this.suggestionType = CommandArgumentNode.SuggestionTypes.ALL_RECIPES;
|
||||
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
|
||||
public Object parse(PlayConnection connection, ParserProperties properties, CommandStringReader stringReader) throws CommandParseException {
|
||||
StringParserProperties stringParserProperties = ((StringParserProperties) properties);
|
||||
String string = switch (stringParserProperties.getSetting()) {
|
||||
case SINGLE_WORD -> stringReader.readUnquotedString();
|
||||
case QUOTABLE_PHRASE -> stringReader.readString();
|
||||
case GREEDY_PHRASE -> stringReader.readRemaining();
|
||||
};
|
||||
String string;
|
||||
switch (stringParserProperties.getSetting()) {
|
||||
case SINGLE_WORD:
|
||||
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()) {
|
||||
throw new BlankStringCommandParseException(stringReader, string);
|
||||
|
@ -29,16 +29,22 @@ public class TimeParser extends CommandParser {
|
||||
|
||||
if (stringReader.canRead()) {
|
||||
char unit = stringReader.read();
|
||||
time *= switch (unit) {
|
||||
case 'd' -> 24000;
|
||||
case 's' -> 20;
|
||||
case 't' -> 1;
|
||||
case ' ' -> {
|
||||
switch (unit) {
|
||||
case 'd':
|
||||
time *= 24000;
|
||||
break;
|
||||
case 's':
|
||||
time *= 20;
|
||||
break;
|
||||
case 't':
|
||||
time *= 1;
|
||||
break;
|
||||
case ' ':
|
||||
stringReader.skip(-1);
|
||||
yield 1;
|
||||
}
|
||||
default -> throw new UnknownTimeUnitCommandParseException(stringReader, String.valueOf(unit));
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw new UnknownTimeUnitCommandParseException(stringReader, String.valueOf(unit));
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.bixilon.minosoft.Minosoft;
|
||||
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.Resources;
|
||||
import de.bixilon.minosoft.data.registries.versions.Version;
|
||||
@ -48,7 +49,7 @@ public class JarHashGenerator {
|
||||
|
||||
Resources.loadVersion(version, versionJson);
|
||||
|
||||
var resource = Resources.getAssetVersionByVersion(version);
|
||||
AssetVersion resource = Resources.getAssetVersionByVersion(version);
|
||||
MinecraftAssetsManager assetsManager = new MinecraftAssetsManager(resource, "dummy");
|
||||
String jarAssetsHash = assetsManager.generateJarAssets();
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.protocol.network;
|
||||
|
||||
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.PacketParseException;
|
||||
import de.bixilon.minosoft.protocol.exceptions.UnknownPacketException;
|
||||
@ -65,8 +66,8 @@ public abstract class Network {
|
||||
bytes = Util.decompress(bytes);
|
||||
}
|
||||
}
|
||||
var data = new InByteBuffer(bytes, this.connection);
|
||||
var packetId = data.readVarInt();
|
||||
InByteBuffer data = new InByteBuffer(bytes, this.connection);
|
||||
int packetId = data.readVarInt();
|
||||
|
||||
PacketTypes.S2C packetType = null;
|
||||
|
||||
@ -85,14 +86,14 @@ public abstract class Network {
|
||||
S2CPacket packet;
|
||||
try {
|
||||
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);
|
||||
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()));
|
||||
}
|
||||
((PlayS2CPacket) packet).check(((PlayConnection) this.connection));
|
||||
} else if (packetType.getStatusFactory() != null) {
|
||||
var statusData = new InByteBuffer(data);
|
||||
InByteBuffer statusData = new InByteBuffer(data);
|
||||
packet = packetType.getStatusFactory().invoke(statusData);
|
||||
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()));
|
||||
@ -104,7 +105,7 @@ public abstract class Network {
|
||||
|
||||
|
||||
} catch (Throwable exception) {
|
||||
var errorHandler = packetType.getErrorHandler();
|
||||
ErrorHandler errorHandler = packetType.getErrorHandler();
|
||||
if (errorHandler != null) {
|
||||
errorHandler.onError(this.connection);
|
||||
}
|
||||
@ -124,11 +125,11 @@ public abstract class Network {
|
||||
protected byte[] prepareC2SPacket(C2SPacket packet) {
|
||||
byte[] data;
|
||||
if (packet instanceof PlayC2SPacket) {
|
||||
var buffer = new PlayOutByteBuffer((PlayConnection) this.connection);
|
||||
PlayOutByteBuffer buffer = new PlayOutByteBuffer((PlayConnection) this.connection);
|
||||
((PlayC2SPacket) packet).write(buffer);
|
||||
data = buffer.toByteArray();
|
||||
} else if (packet instanceof AllC2SPacket) {
|
||||
var buffer = new OutByteBuffer(this.connection);
|
||||
OutByteBuffer buffer = new OutByteBuffer(this.connection);
|
||||
((AllC2SPacket) packet).write(buffer);
|
||||
data = buffer.toByteArray();
|
||||
} else {
|
||||
|
@ -111,7 +111,7 @@ public class BlockingSocketNetwork extends Network {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
var typeAndPacket = prepareS2CPacket(this.inputStream);
|
||||
Pair<PacketTypes.S2C, S2CPacket> typeAndPacket = prepareS2CPacket(this.inputStream);
|
||||
while (this.receivingPaused && this.connection.getProtocolState() != ProtocolStates.DISCONNECTED && !this.shouldDisconnect) {
|
||||
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.packets.c2s.C2SPacket;
|
||||
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.PacketTypes;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates;
|
||||
import de.bixilon.minosoft.util.Pair;
|
||||
import de.bixilon.minosoft.util.ServerAddress;
|
||||
import de.bixilon.minosoft.util.logging.Log;
|
||||
import de.bixilon.minosoft.util.logging.LogLevels;
|
||||
@ -138,7 +141,7 @@ public class NonBlockingSocketNetwork extends Network {
|
||||
if (!currentPacketBuffer.hasRemaining()) {
|
||||
currentPacketBuffer.flip();
|
||||
try {
|
||||
var typeAndPacket = receiveS2CPacket(decryptData(currentPacketBuffer.array()));
|
||||
Pair<PacketTypes.S2C, S2CPacket> typeAndPacket = receiveS2CPacket(decryptData(currentPacketBuffer.array()));
|
||||
handlePacket(typeAndPacket.getKey(), typeAndPacket.getValue());
|
||||
} catch (PacketParseException e) {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, e);
|
||||
|
@ -44,41 +44,51 @@ public class PacketDeclareRecipes extends PlayS2CPacket {
|
||||
}
|
||||
RecipeTypes type = RecipeTypes.byName(typeName);
|
||||
switch (type) {
|
||||
case SHAPELESS -> {
|
||||
case SHAPELESS: {
|
||||
String group = buffer.readString();
|
||||
Ingredient[] ingredients = buffer.readIngredientArray();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
recipe = new Recipe(type, group, ingredients, result);
|
||||
break;
|
||||
}
|
||||
case SHAPED -> {
|
||||
case SHAPED: {
|
||||
int width = buffer.readVarInt();
|
||||
int height = buffer.readVarInt();
|
||||
String group = buffer.readString();
|
||||
Ingredient[] ingredients = buffer.readIngredientArray(width * height);
|
||||
ItemStack result = buffer.readItemStack();
|
||||
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();
|
||||
Ingredient ingredient = buffer.readIngredient();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
float experience = buffer.readFloat();
|
||||
int cookingTime = buffer.readVarInt();
|
||||
recipe = new Recipe(type, group, ingredient, result, experience, cookingTime);
|
||||
break;
|
||||
}
|
||||
case STONE_CUTTING -> {
|
||||
case STONE_CUTTING: {
|
||||
String group = buffer.readString();
|
||||
Ingredient ingredient = buffer.readIngredient();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
recipe = new Recipe(type, group, ingredient, result);
|
||||
break;
|
||||
}
|
||||
case SMITHING -> {
|
||||
case SMITHING: {
|
||||
Ingredient base = buffer.readIngredient();
|
||||
Ingredient addition = buffer.readIngredient();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
recipe = new Recipe(type, base, addition, result);
|
||||
break;
|
||||
}
|
||||
default -> recipe = new Recipe(type);
|
||||
default:
|
||||
recipe = new Recipe(type);
|
||||
break;
|
||||
}
|
||||
this.recipes.put(resourceLocation, recipe);
|
||||
}
|
||||
|
@ -48,12 +48,13 @@ public class PacketMapData extends PlayS2CPacket {
|
||||
// read action
|
||||
this.dataData = PacketMapDataDataActions.byId(buffer.readUnsignedByte());
|
||||
switch (this.dataData) {
|
||||
case START -> {
|
||||
case START: {
|
||||
this.xStart = buffer.readByte();
|
||||
this.yStart = buffer.readByte();
|
||||
this.colors = buffer.readByteArray(length - 3); // 3: dataData(1) + xStart (1) + yStart (1)
|
||||
break;
|
||||
}
|
||||
case PLAYERS -> {
|
||||
case PLAYERS: {
|
||||
this.pins = new ArrayList<>();
|
||||
length--; // minus the dataData
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class PacketSelectAdvancementTab extends PlayS2CPacket {
|
||||
public static final HashMap<ResourceLocation, AdvancementTabs> VALUES = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (var tab : values()) {
|
||||
for (AdvancementTabs tab : values()) {
|
||||
VALUES.put(tab.resourceLocation, tab);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class PacketStatistics extends PlayS2CPacket {
|
||||
if (buffer.getVersionId() < V_17W47A) { // ToDo
|
||||
this.statistics.put(buffer.getConnection().getRegistries().getStatisticRegistry().get(buffer.readResourceLocation()), buffer.readVarInt());
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import de.bixilon.minosoft.data.commands.parser.properties.IntegerParserProperti
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandEntities extends Command {
|
||||
|
||||
@ -32,7 +33,7 @@ public class CommandEntities extends Command {
|
||||
new CommandLiteralNode("list", (connection, stack) -> {
|
||||
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()});
|
||||
}
|
||||
|
||||
@ -58,7 +59,7 @@ public class CommandEntities extends Command {
|
||||
tableData.add(new Object[]{"Effects", entity.getActiveStatusEffects()});
|
||||
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()});
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ import de.bixilon.minosoft.data.player.tab.TabListItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandTabList extends Command {
|
||||
@Override
|
||||
@ -67,7 +69,7 @@ public class CommandTabList extends Command {
|
||||
|
||||
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());
|
||||
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"});
|
||||
|
@ -319,7 +319,7 @@ public final class Util {
|
||||
|
||||
public static String[] headersMapToArray(Map<String, String> headers) {
|
||||
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.getValue());
|
||||
}
|
||||
@ -328,7 +328,7 @@ public final class Util {
|
||||
|
||||
public static String formatString(String string, Map<String, Object> format) {
|
||||
String output = string;
|
||||
for (var entry : format.entrySet()) {
|
||||
for (Map.Entry<String, Object> entry : format.entrySet()) {
|
||||
output = output.replace("${" + entry.getKey() + "}", entry.getValue().toString());
|
||||
}
|
||||
return output;
|
||||
|
Loading…
x
Reference in New Issue
Block a user