Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +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);
|
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");
|
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,9 @@ subprojects {
|
|||||||
else -> plugins.apply("via.standard-conventions")
|
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 {
|
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.netty)
|
||||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.guava)
|
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.guava)
|
||||||
TEST_IMPLEMENTATION_CONFIGURATION_NAME(rootProject.libs.bundles.junit)
|
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.
|
* Returns a meta filter builder.
|
||||||
* <p>
|
* <p>
|
||||||
* Calling {@link MetaFilter.Builder#register()} will automatically register the filter on this rewriter.
|
* 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
|
* @return meta filter builder
|
||||||
*/
|
*/
|
||||||
|
@ -84,11 +84,14 @@ public class MetaFilter {
|
|||||||
* @return whether the meta should be filtered
|
* @return whether the meta should be filtered
|
||||||
*/
|
*/
|
||||||
public boolean isFiltered(@Nullable EntityType type, Metadata metadata) {
|
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
|
// Check if no specific index is filtered or the indexes are equal
|
||||||
// Applicable 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.type == null
|
return (this.index == -1 || metadata.id() == this.index)
|
||||||
|| type != null && (this.filterFamily ? type.isOrHasParent(this.type) : this.type == type))
|
&& (this.type == null || matchesType(type));
|
||||||
&& (this.index == -1 || metadata.id() == this.index);
|
}
|
||||||
|
|
||||||
|
private boolean matchesType(@Nullable EntityType type) {
|
||||||
|
return type != null && (this.filterFamily ? type.isOrHasParent(this.type) : this.type == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -162,6 +165,7 @@ public class MetaFilter {
|
|||||||
* Should always be called last.
|
* Should always be called last.
|
||||||
*
|
*
|
||||||
* @param handler metadata handler
|
* @param handler metadata handler
|
||||||
|
* @throws IllegalArgumentException if a handler has already been set
|
||||||
*/
|
*/
|
||||||
public void handler(MetaHandler handler) {
|
public void handler(MetaHandler handler) {
|
||||||
Preconditions.checkArgument(this.handler == null);
|
Preconditions.checkArgument(this.handler == null);
|
||||||
|
@ -65,14 +65,6 @@ public interface MetaHandlerEvent {
|
|||||||
meta().setId(index);
|
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.
|
* Returns the metadata.
|
||||||
*
|
*
|
||||||
@ -92,10 +84,20 @@ public interface MetaHandlerEvent {
|
|||||||
*/
|
*/
|
||||||
boolean cancelled();
|
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.
|
* Returns an immutable metadata view.
|
||||||
|
* This list is not sorted or indexed by the actual metadata indexes.
|
||||||
*
|
*
|
||||||
* @return immutable metadata list
|
* @return immutable metadata list
|
||||||
|
* @see #metaAtIndex(int)
|
||||||
* @see #cancel()
|
* @see #cancel()
|
||||||
* @see #createExtraMeta(Metadata)
|
* @see #createExtraMeta(Metadata)
|
||||||
*/
|
*/
|
||||||
|
@ -44,16 +44,6 @@ public class MetaHandlerEventImpl implements MetaHandlerEvent {
|
|||||||
this.metadataList = metadataList;
|
this.metadataList = metadataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Metadata getMetaByIndex(int index) {
|
|
||||||
for (Metadata meta : metadataList) {
|
|
||||||
if (index == meta.id()) {
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserConnection user() {
|
public UserConnection user() {
|
||||||
return connection;
|
return connection;
|
||||||
@ -84,6 +74,16 @@ public class MetaHandlerEventImpl implements MetaHandlerEvent {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Metadata metaAtIndex(int index) {
|
||||||
|
for (Metadata meta : metadataList) {
|
||||||
|
if (index == meta.id()) {
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Metadata> metadataList() {
|
public List<Metadata> metadataList() {
|
||||||
return Collections.unmodifiableList(metadataList);
|
return Collections.unmodifiableList(metadataList);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren