Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Add/change comments
Dieser Commit ist enthalten in:
Ursprung
016b8f1dbc
Commit
ff140c421a
@ -150,7 +150,7 @@ public class MappingDataBase implements MappingData {
|
||||
return new IntArrayMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff);
|
||||
}
|
||||
|
||||
protected JsonObject loadDiffFile() {
|
||||
protected @Nullable JsonObject loadDiffFile() {
|
||||
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,9 @@ subprojects {
|
||||
else -> plugins.apply("via.standard-conventions")
|
||||
}
|
||||
|
||||
// Note: If manually starting tests doesn't work for you in IJ, change 'Gradle -> Run Tests Using' to 'IntelliJ IDEA'
|
||||
dependencies {
|
||||
// Note: If manually starting tests doesn't work for you in IJ, change 'Gradle -> Run Tests Using' to 'IntelliJ IDEA'
|
||||
// The alternative to this long boi is writing "testImplementation", including the quotes
|
||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.netty)
|
||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.guava)
|
||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.bundles.junit)
|
||||
|
@ -73,7 +73,6 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
* Returns a meta filter builder.
|
||||
* <p>
|
||||
* Calling {@link MetaFilter.Builder#register()} will automatically register the filter on this rewriter.
|
||||
* Don't forget to call {@link MetaFilter.Builder#register()}.
|
||||
*
|
||||
* @return meta filter builder
|
||||
*/
|
||||
|
@ -84,11 +84,14 @@ public class MetaFilter {
|
||||
* @return whether the meta should be filtered
|
||||
*/
|
||||
public boolean isFiltered(@Nullable EntityType type, Metadata metadata) {
|
||||
// First check if the filter has no type or the type is equal or part of the filtered parent types
|
||||
// Applicable if no specific index is filtered or the indexes are equal
|
||||
return (this.type == null
|
||||
|| type != null && (this.filterFamily ? type.isOrHasParent(this.type) : this.type == type))
|
||||
&& (this.index == -1 || metadata.id() == this.index);
|
||||
// Check if no specific index is filtered or the indexes are equal
|
||||
// Then check if the filter has no entity type or the type is equal to or part of the filtered parent type
|
||||
return (this.index == -1 || metadata.id() == this.index)
|
||||
&& (this.type == null || matchesType(type));
|
||||
}
|
||||
|
||||
private boolean matchesType(@Nullable EntityType type) {
|
||||
return type != null && (this.filterFamily ? type.isOrHasParent(this.type) : this.type == type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,6 +165,7 @@ public class MetaFilter {
|
||||
* Should always be called last.
|
||||
*
|
||||
* @param handler metadata handler
|
||||
* @throws IllegalArgumentException if a handler has already been set
|
||||
*/
|
||||
public void handler(MetaHandler handler) {
|
||||
Preconditions.checkArgument(this.handler == null);
|
||||
|
@ -65,14 +65,6 @@ public interface MetaHandlerEvent {
|
||||
meta().setId(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the metadata by the given index if present.
|
||||
*
|
||||
* @param index metadata index
|
||||
* @return metadata by index if present
|
||||
*/
|
||||
@Nullable Metadata getMetaByIndex(int index);
|
||||
|
||||
/**
|
||||
* Returns the metadata.
|
||||
*
|
||||
@ -92,10 +84,20 @@ public interface MetaHandlerEvent {
|
||||
*/
|
||||
boolean cancelled();
|
||||
|
||||
/**
|
||||
* Returns metadata by the given index if present.
|
||||
*
|
||||
* @param index metadata index
|
||||
* @return metadata if present, else null
|
||||
*/
|
||||
@Nullable Metadata metaAtIndex(int index);
|
||||
|
||||
/**
|
||||
* Returns an immutable metadata view.
|
||||
* This list is not sorted or indexed by the actual metadata indexes.
|
||||
*
|
||||
* @return immutable metadata list
|
||||
* @see #metaAtIndex(int)
|
||||
* @see #cancel()
|
||||
* @see #createExtraMeta(Metadata)
|
||||
*/
|
||||
|
@ -44,16 +44,6 @@ public class MetaHandlerEventImpl implements MetaHandlerEvent {
|
||||
this.metadataList = metadataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Metadata getMetaByIndex(int index) {
|
||||
for (Metadata meta : metadataList) {
|
||||
if (index == meta.id()) {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserConnection user() {
|
||||
return connection;
|
||||
@ -84,6 +74,16 @@ public class MetaHandlerEventImpl implements MetaHandlerEvent {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Metadata metaAtIndex(int index) {
|
||||
for (Metadata meta : metadataList) {
|
||||
if (index == meta.id()) {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Metadata> metadataList() {
|
||||
return Collections.unmodifiableList(metadataList);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren