Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Merge branch 'master' into dev
Dieser Commit ist enthalten in:
Commit
bcfc77aa7d
@ -22,6 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.platform;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface UnsupportedSoftware {
|
||||
|
||||
/**
|
||||
@ -38,10 +40,19 @@ public interface UnsupportedSoftware {
|
||||
*/
|
||||
String getReason();
|
||||
|
||||
/**
|
||||
* Returns the name of unsupported software if present.
|
||||
*
|
||||
* @return name of unsupported software if it is matched, else null
|
||||
*/
|
||||
@Nullable String match();
|
||||
|
||||
/**
|
||||
* Returns whether the unsupported software is present.
|
||||
*
|
||||
* @return true if the unsupported software is found
|
||||
*/
|
||||
boolean findMatch();
|
||||
default boolean findMatch() {
|
||||
return match() != null;
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,8 @@ public class ViaManagerImpl implements ViaManager {
|
||||
private void unsupportedSoftwareWarning() {
|
||||
boolean found = false;
|
||||
for (final UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) {
|
||||
if (!software.findMatch()) {
|
||||
final String match = software.match();
|
||||
if (match == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -249,7 +250,7 @@ public class ViaManagerImpl implements ViaManager {
|
||||
found = true;
|
||||
}
|
||||
|
||||
platform.getLogger().severe("We strongly advise against using " + software.getName() + ":");
|
||||
platform.getLogger().severe("We strongly advise against using " + match + ":");
|
||||
platform.getLogger().severe(software.getReason());
|
||||
platform.getLogger().severe("");
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
||||
}
|
||||
}
|
||||
});
|
||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, Types1_17.META_TYPES.particleType);
|
||||
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, null, Types1_17.META_TYPES.particleType);
|
||||
|
||||
// Ticks frozen added with id 7
|
||||
filter().filterFamily(Entity1_17Types.ENTITY).addIndex(7);
|
||||
|
@ -96,7 +96,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
||||
}
|
||||
});
|
||||
|
||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null);
|
||||
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,7 +155,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
||||
final int id = meta.metaType().typeId();
|
||||
meta.setMetaType(Types1_19_3.META_TYPES.byId(id >= 2 ? id + 1 : id)); // long added
|
||||
});
|
||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, Types1_19_3.META_TYPES.particleType);
|
||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType);
|
||||
|
||||
filter().index(6).handler((event, meta) -> {
|
||||
// Sitting pose added
|
||||
|
@ -233,7 +233,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
|
||||
}
|
||||
meta.setMetaType(Types1_19_4.META_TYPES.byId(id));
|
||||
});
|
||||
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.particleType);
|
||||
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.optionalBlockStateType, Types1_19_4.META_TYPES.particleType);
|
||||
|
||||
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
final int blockState = meta.value();
|
||||
|
@ -355,7 +355,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> meta.setMetaType(Types1_19.META_TYPES.byId(meta.metaType().typeId())));
|
||||
|
||||
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, Types1_19.META_TYPES.particleType);
|
||||
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null, Types1_19.META_TYPES.particleType);
|
||||
|
||||
filter().filterFamily(Entity1_19Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
// Convert to new block id
|
||||
|
@ -69,7 +69,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_4
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().handler((event, meta) -> meta.setMetaType(Types1_20.META_TYPES.byId(meta.metaType().typeId())));
|
||||
registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.particleType);
|
||||
registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.optionalBlockStateType, Types1_20.META_TYPES.particleType);
|
||||
|
||||
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
final int blockState = meta.value();
|
||||
|
@ -234,18 +234,25 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
/**
|
||||
* Registers a metadata handler to rewrite, item, block, and particle ids stored in metadata.
|
||||
*
|
||||
* @param itemType item meta type if needed
|
||||
* @param blockType block meta type if needed
|
||||
* @param particleType particle meta type if needed
|
||||
* @param itemType item meta type if needed
|
||||
* @param blockStateType block state meta type if needed
|
||||
* @param optionalBlockStateType optional block state meta type if needed
|
||||
* @param particleType particle meta type if needed
|
||||
*/
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockType, @Nullable MetaType particleType) {
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockStateType, @Nullable MetaType optionalBlockStateType, @Nullable MetaType particleType) {
|
||||
filter().handler((event, meta) -> {
|
||||
if (itemType != null && meta.metaType() == itemType) {
|
||||
final MetaType type = meta.metaType();
|
||||
if (type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(meta.value());
|
||||
} else if (blockType != null && meta.metaType() == blockType) {
|
||||
} else if (type == blockStateType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (particleType != null && meta.metaType() == particleType) {
|
||||
} else if (type == optionalBlockStateType) {
|
||||
int data = meta.value();
|
||||
if (data != 0) {
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
} else if (type == particleType) {
|
||||
rewriteParticle(meta.value());
|
||||
}
|
||||
});
|
||||
|
@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.platform.UnsupportedSoftware;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class UnsupportedPlugin implements UnsupportedSoftware {
|
||||
|
||||
@ -50,13 +51,13 @@ public final class UnsupportedPlugin implements UnsupportedSoftware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean findMatch() {
|
||||
public final @Nullable String match() {
|
||||
for (final String identifier : identifiers) {
|
||||
if (Via.getPlatform().hasPlugin(identifier)) {
|
||||
return true;
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
|
@ -24,6 +24,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class UnsupportedServerSoftware implements UnsupportedSoftware {
|
||||
|
||||
@ -53,20 +54,20 @@ public final class UnsupportedServerSoftware implements UnsupportedSoftware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean findMatch() {
|
||||
public final @Nullable String match() {
|
||||
for (String className : classNames) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
return name;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
for (UnsupportedMethods method : methods) {
|
||||
if (method.findMatch()) {
|
||||
return true;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
|
Binäre Datei nicht angezeigt.
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren