Move item.json

This commit is contained in:
2026-06-12 14:21:45 +02:00
parent 914134600e
commit b88e592e79
3 changed files with 33 additions and 8 deletions
@@ -0,0 +1,31 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.velocitycore.advancements;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Items {
static final JsonObject values = new Gson().fromJson(new BufferedReader(new InputStreamReader(Items.class.getResourceAsStream("/de/steamwar/velocitycore/advancements/item.json"))), JsonObject.class);
}
@@ -19,8 +19,6 @@
package de.steamwar.velocitycore.advancements; package de.steamwar.velocitycore.advancements;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
@@ -29,7 +27,6 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder; import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import de.steamwar.messages.Chatter; import de.steamwar.messages.Chatter;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -38,8 +35,6 @@ import lombok.RequiredArgsConstructor;
import lombok.ToString; import lombok.ToString;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*; import java.util.*;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Function; import java.util.function.Function;
@@ -239,8 +234,6 @@ public class Advancement {
} }
} }
private static final JsonObject ITEMS = new Gson().fromJson(new BufferedReader(new InputStreamReader(Advancement.class.getResourceAsStream("/de/steamwar/velocitycore/advancements/item.json"))), JsonObject.class);
private void encodeAdvancement(ByteBuf byteBuf, ProtocolVersion protocolVersion, boolean showToast) { private void encodeAdvancement(ByteBuf byteBuf, ProtocolVersion protocolVersion, boolean showToast) {
ProtocolUtils.writeString(byteBuf, advancement.identifier); ProtocolUtils.writeString(byteBuf, advancement.identifier);
if (advancement.parent.isPresent()) { if (advancement.parent.isPresent()) {
@@ -256,7 +249,8 @@ public class Advancement {
new ComponentHolder(protocolVersion, advancement.display.description).write(byteBuf); new ComponentHolder(protocolVersion, advancement.display.description).write(byteBuf);
{ // Slot { // Slot
ProtocolUtils.writeVarInt(byteBuf, 1); ProtocolUtils.writeVarInt(byteBuf, 1);
int itemId = ITEMS.get(protocolVersion.name().replace("MINECRAFT_", "V_")) int itemId = Items.values
.get(protocolVersion.name().replace("MINECRAFT_", "V_"))
.getAsJsonObject() .getAsJsonObject()
.get(advancement.display.item) .get(advancement.display.item)
.getAsInt(); .getAsInt();