Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
Merge pull request #1734 from KennyTV/abstraction
Add safety checks to skullowner conversion
Dieser Commit ist enthalten in:
Commit
c7bc9aa43c
@ -14,6 +14,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.TabCompleteThread;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ViaIdleThread;
|
||||
import us.myles.ViaVersion.update.UpdateUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -25,6 +26,7 @@ public class ViaManager {
|
||||
private final ViaInjector injector;
|
||||
private final ViaCommandHandler commandHandler;
|
||||
private final ViaPlatformLoader loader;
|
||||
private final Set<String> subPlatforms = new HashSet<>();
|
||||
private boolean debug;
|
||||
|
||||
@Builder
|
||||
@ -170,6 +172,16 @@ public class ViaManager {
|
||||
return loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mutable set of self-added subplatform version strings.
|
||||
* This set is expanded by the subplatform itself (e.g. ViaBackwards), and may not contain all running ones.
|
||||
*
|
||||
* @return mutable set of subplatform versions
|
||||
*/
|
||||
public Set<String> getSubPlatforms() {
|
||||
return subPlatforms;
|
||||
}
|
||||
|
||||
public UserConnection getConnection(UUID playerUUID) {
|
||||
return platform.getConnectionManager().getConnectedClient(playerUUID);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.io.InvalidObjectException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -34,10 +34,9 @@ public class DumpSubCmd extends ViaSubCommand {
|
||||
return "Dump information about your server, this is helpful if you report bugs.";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(final ViaCommandSender sender, String[] args) {
|
||||
final VersionInfo version = new VersionInfo(
|
||||
public boolean execute(ViaCommandSender sender, String[] args) {
|
||||
VersionInfo version = new VersionInfo(
|
||||
System.getProperty("java.version"),
|
||||
System.getProperty("os.name"),
|
||||
ProtocolRegistry.SERVER_PROTOCOL,
|
||||
@ -45,12 +44,13 @@ public class DumpSubCmd extends ViaSubCommand {
|
||||
Via.getPlatform().getPlatformName(),
|
||||
Via.getPlatform().getPlatformVersion(),
|
||||
Via.getPlatform().getPluginVersion(),
|
||||
ViaManager.class.getPackage().getImplementationVersion()
|
||||
ViaManager.class.getPackage().getImplementationVersion(),
|
||||
Via.getManager().getSubPlatforms()
|
||||
);
|
||||
|
||||
Map<String, Object> configuration = Via.getPlatform().getConfigurationProvider().getValues();
|
||||
|
||||
final DumpTemplate template = new DumpTemplate(version, configuration, Via.getPlatform().getDump(), Via.getManager().getInjector().getDump());
|
||||
DumpTemplate template = new DumpTemplate(version, configuration, Via.getPlatform().getDump(), Via.getManager().getInjector().getDump());
|
||||
|
||||
Via.getPlatform().runAsync(new Runnable() {
|
||||
@Override
|
||||
@ -71,7 +71,7 @@ public class DumpSubCmd extends ViaSubCommand {
|
||||
con.setDoOutput(true);
|
||||
|
||||
OutputStream out = con.getOutputStream();
|
||||
out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(Charset.forName("UTF-8")));
|
||||
out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(StandardCharsets.UTF_8));
|
||||
out.close();
|
||||
|
||||
if (con.getResponseCode() == 429) {
|
||||
|
@ -11,9 +11,10 @@ public class VersionInfo {
|
||||
private final String platformVersion;
|
||||
private final String pluginVersion;
|
||||
private final String implementationVersion;
|
||||
private final Set<String> subPlatforms;
|
||||
|
||||
public VersionInfo(String javaVersion, String operatingSystem, int serverProtocol, Set<Integer> enabledProtocols,
|
||||
String platformName, String platformVersion, String pluginVersion, String implementationVersion) {
|
||||
String platformName, String platformVersion, String pluginVersion, String implementationVersion, Set<String> subPlatforms) {
|
||||
this.javaVersion = javaVersion;
|
||||
this.operatingSystem = operatingSystem;
|
||||
this.serverProtocol = serverProtocol;
|
||||
@ -22,6 +23,7 @@ public class VersionInfo {
|
||||
this.platformVersion = platformVersion;
|
||||
this.pluginVersion = pluginVersion;
|
||||
this.implementationVersion = implementationVersion;
|
||||
this.subPlatforms = subPlatforms;
|
||||
}
|
||||
|
||||
public String getJavaVersion() {
|
||||
@ -55,5 +57,9 @@ public class VersionInfo {
|
||||
public String getImplementationVersion() {
|
||||
return implementationVersion;
|
||||
}
|
||||
|
||||
public Set<String> getSubPlatforms() {
|
||||
return subPlatforms;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
@ -140,10 +141,14 @@ public class InventoryPackets {
|
||||
|
||||
if (item.getIdentifier() == 771 && item.getTag() != null) {
|
||||
CompoundTag tag = item.getTag();
|
||||
CompoundTag ownerTag = tag.get("SkullOwner");
|
||||
if (ownerTag != null) {
|
||||
UUID id = UUID.fromString(((StringTag) ownerTag.get("Id")).getValue());
|
||||
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(id)));
|
||||
Tag ownerTag = tag.get("SkullOwner");
|
||||
if (ownerTag instanceof CompoundTag) {
|
||||
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
||||
Tag idTag = ownerCompundTag.get("Id");
|
||||
if (idTag instanceof StringTag) {
|
||||
UUID id = UUID.fromString((String) idTag.getValue());
|
||||
ownerCompundTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,10 +162,14 @@ public class InventoryPackets {
|
||||
|
||||
if (item.getIdentifier() == 771 && item.getTag() != null) {
|
||||
CompoundTag tag = item.getTag();
|
||||
CompoundTag ownerTag = tag.get("SkullOwner");
|
||||
if (ownerTag != null && ownerTag.contains("Id")) {
|
||||
UUID id = UUIDIntArrayType.uuidFromIntArray(((IntArrayTag) ownerTag.get("Id")).getValue());
|
||||
ownerTag.put(new StringTag("Id", id.toString()));
|
||||
Tag ownerTag = tag.get("SkullOwner");
|
||||
if (ownerTag instanceof CompoundTag) {
|
||||
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
||||
Tag idTag = ownerCompundTag.get("Id");
|
||||
if (idTag instanceof IntArrayTag) {
|
||||
UUID id = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue());
|
||||
ownerCompundTag.put(new StringTag("Id", id.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,17 +61,16 @@ public class WorldPackets {
|
||||
StringTag targetUuidTag = blockEntity.remove("target_uuid");
|
||||
if (targetUuidTag == null) continue;
|
||||
|
||||
|
||||
// target_uuid -> Target
|
||||
UUID targetUuid = UUID.fromString(targetUuidTag.getValue());
|
||||
blockEntity.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid)));
|
||||
} else if (id.equals("minecraft:skull")) {
|
||||
} else if (id.equals("minecraft:skull") && blockEntity.get("Owner") instanceof CompoundTag) {
|
||||
CompoundTag ownerTag = blockEntity.remove("Owner");
|
||||
if (ownerTag == null) continue;
|
||||
|
||||
StringTag ownerUuidTag = ownerTag.remove("Id");
|
||||
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
|
||||
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
|
||||
if (ownerUuidTag != null) {
|
||||
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
|
||||
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
|
||||
}
|
||||
|
||||
// Owner -> SkullOwner
|
||||
CompoundTag skullOwnerTag = new CompoundTag("SkullOwner");
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren