Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 17:10: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.protocols.protocol1_9to1_8.ViaIdleThread;
|
||||||
import us.myles.ViaVersion.update.UpdateUtil;
|
import us.myles.ViaVersion.update.UpdateUtil;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -25,6 +26,7 @@ public class ViaManager {
|
|||||||
private final ViaInjector injector;
|
private final ViaInjector injector;
|
||||||
private final ViaCommandHandler commandHandler;
|
private final ViaCommandHandler commandHandler;
|
||||||
private final ViaPlatformLoader loader;
|
private final ViaPlatformLoader loader;
|
||||||
|
private final Set<String> subPlatforms = new HashSet<>();
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@ -170,6 +172,16 @@ public class ViaManager {
|
|||||||
return loader;
|
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) {
|
public UserConnection getConnection(UUID playerUUID) {
|
||||||
return platform.getConnectionManager().getConnectedClient(playerUUID);
|
return platform.getConnectionManager().getConnectedClient(playerUUID);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import java.io.InvalidObjectException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
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.";
|
return "Dump information about your server, this is helpful if you report bugs.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final ViaCommandSender sender, String[] args) {
|
public boolean execute(ViaCommandSender sender, String[] args) {
|
||||||
final VersionInfo version = new VersionInfo(
|
VersionInfo version = new VersionInfo(
|
||||||
System.getProperty("java.version"),
|
System.getProperty("java.version"),
|
||||||
System.getProperty("os.name"),
|
System.getProperty("os.name"),
|
||||||
ProtocolRegistry.SERVER_PROTOCOL,
|
ProtocolRegistry.SERVER_PROTOCOL,
|
||||||
@ -45,12 +44,13 @@ public class DumpSubCmd extends ViaSubCommand {
|
|||||||
Via.getPlatform().getPlatformName(),
|
Via.getPlatform().getPlatformName(),
|
||||||
Via.getPlatform().getPlatformVersion(),
|
Via.getPlatform().getPlatformVersion(),
|
||||||
Via.getPlatform().getPluginVersion(),
|
Via.getPlatform().getPluginVersion(),
|
||||||
ViaManager.class.getPackage().getImplementationVersion()
|
ViaManager.class.getPackage().getImplementationVersion(),
|
||||||
|
Via.getManager().getSubPlatforms()
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, Object> configuration = Via.getPlatform().getConfigurationProvider().getValues();
|
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() {
|
Via.getPlatform().runAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +71,7 @@ public class DumpSubCmd extends ViaSubCommand {
|
|||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
|
|
||||||
OutputStream out = con.getOutputStream();
|
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();
|
out.close();
|
||||||
|
|
||||||
if (con.getResponseCode() == 429) {
|
if (con.getResponseCode() == 429) {
|
||||||
|
@ -11,9 +11,10 @@ public class VersionInfo {
|
|||||||
private final String platformVersion;
|
private final String platformVersion;
|
||||||
private final String pluginVersion;
|
private final String pluginVersion;
|
||||||
private final String implementationVersion;
|
private final String implementationVersion;
|
||||||
|
private final Set<String> subPlatforms;
|
||||||
|
|
||||||
public VersionInfo(String javaVersion, String operatingSystem, int serverProtocol, Set<Integer> enabledProtocols,
|
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.javaVersion = javaVersion;
|
||||||
this.operatingSystem = operatingSystem;
|
this.operatingSystem = operatingSystem;
|
||||||
this.serverProtocol = serverProtocol;
|
this.serverProtocol = serverProtocol;
|
||||||
@ -22,6 +23,7 @@ public class VersionInfo {
|
|||||||
this.platformVersion = platformVersion;
|
this.platformVersion = platformVersion;
|
||||||
this.pluginVersion = pluginVersion;
|
this.pluginVersion = pluginVersion;
|
||||||
this.implementationVersion = implementationVersion;
|
this.implementationVersion = implementationVersion;
|
||||||
|
this.subPlatforms = subPlatforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJavaVersion() {
|
public String getJavaVersion() {
|
||||||
@ -55,5 +57,9 @@ public class VersionInfo {
|
|||||||
public String getImplementationVersion() {
|
public String getImplementationVersion() {
|
||||||
return implementationVersion;
|
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.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
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.Via;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
@ -140,10 +141,14 @@ public class InventoryPackets {
|
|||||||
|
|
||||||
if (item.getIdentifier() == 771 && item.getTag() != null) {
|
if (item.getIdentifier() == 771 && item.getTag() != null) {
|
||||||
CompoundTag tag = item.getTag();
|
CompoundTag tag = item.getTag();
|
||||||
CompoundTag ownerTag = tag.get("SkullOwner");
|
Tag ownerTag = tag.get("SkullOwner");
|
||||||
if (ownerTag != null) {
|
if (ownerTag instanceof CompoundTag) {
|
||||||
UUID id = UUID.fromString(((StringTag) ownerTag.get("Id")).getValue());
|
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
||||||
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(id)));
|
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) {
|
if (item.getIdentifier() == 771 && item.getTag() != null) {
|
||||||
CompoundTag tag = item.getTag();
|
CompoundTag tag = item.getTag();
|
||||||
CompoundTag ownerTag = tag.get("SkullOwner");
|
Tag ownerTag = tag.get("SkullOwner");
|
||||||
if (ownerTag != null && ownerTag.contains("Id")) {
|
if (ownerTag instanceof CompoundTag) {
|
||||||
UUID id = UUIDIntArrayType.uuidFromIntArray(((IntArrayTag) ownerTag.get("Id")).getValue());
|
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
||||||
ownerTag.put(new StringTag("Id", id.toString()));
|
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");
|
StringTag targetUuidTag = blockEntity.remove("target_uuid");
|
||||||
if (targetUuidTag == null) continue;
|
if (targetUuidTag == null) continue;
|
||||||
|
|
||||||
|
|
||||||
// target_uuid -> Target
|
// target_uuid -> Target
|
||||||
UUID targetUuid = UUID.fromString(targetUuidTag.getValue());
|
UUID targetUuid = UUID.fromString(targetUuidTag.getValue());
|
||||||
blockEntity.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid)));
|
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");
|
CompoundTag ownerTag = blockEntity.remove("Owner");
|
||||||
if (ownerTag == null) continue;
|
|
||||||
|
|
||||||
StringTag ownerUuidTag = ownerTag.remove("Id");
|
StringTag ownerUuidTag = ownerTag.remove("Id");
|
||||||
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
|
if (ownerUuidTag != null) {
|
||||||
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
|
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
|
||||||
|
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
|
||||||
|
}
|
||||||
|
|
||||||
// Owner -> SkullOwner
|
// Owner -> SkullOwner
|
||||||
CompoundTag skullOwnerTag = new CompoundTag("SkullOwner");
|
CompoundTag skullOwnerTag = new CompoundTag("SkullOwner");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren