RemoveOp class
Пакет: com.hypixel.hytale.builtin.worldgen.modifier.op
Файл: com/hypixel/hytale/builtin/worldgen/modifier/op/RemoveOp.java
implements: Op
Поля (10)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
String |
ID |
|
|
break |
|
|
break |
|
|
break |
|
String |
var12 |
|
int |
var2 |
|
Object |
var6 |
|
Object |
var6 |
|
IWeightedMap |
var7 |
|
String |
var7 |
Методы (12)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(String var16 : var1) |
|
|
for for(String var11 : var1) |
|
|
if if(this.rules.length != 0) |
|
|
if if(this.isClearAll) |
static |
<T> void |
modifyEventContent<T> void modifyEventContent(@Nonnull List<T> var0, @Nonnull ModifyEvent<T> var1) |
abstract |
|
modifyEventContent modifyEventContent(var4, var0) |
static |
<T> void |
removeContent<T> void removeContent(@Nonnull ModifyEvent<T> var0, @Nonnull String[] var1, @Nonnull ListPool<T> var2, @Nonnull Function<T, String> var3) |
abstract |
|
removeContent removeContent(var5, this.rules, CaveType.ENTRY_POOL, CaveType::getName) |
static |
<T> void |
removePrefabs<T> void removePrefabs(@Nonnull ModifyEvent<T> var0, @Nonnull String[] var1, @Nonnull ListPool<T> var2, @Nonnull Function<T, IWeightedMap<WorldGenPrefabSupplier>> var3) |
abstract |
|
removePrefabs removePrefabs(var4, this.rules, PrefabContainer.ENTRY_POOL, PrefabContainer.PrefabContainerEntry::getPrefabs) |
abstract |
|
removePrefabs removePrefabs(var6, this.rules, CavePrefabContainer.ENTRY_POOL, CavePrefabContainer.CavePrefabEntry::getPrefabs) |
|
|
switch switch(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.worldgen.modifier.op;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.content.Content;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.event.ModifyEvent;
class="kw">import com.hypixel.hytale.builtin.worldgen.modifier.event.ModifyEvents;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.common.map.IWeightedMap;
class="kw">import com.hypixel.hytale.common.util.ArrayUtil;
class="kw">import com.hypixel.hytale.common.util.StringUtil;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveType;
class="kw">import com.hypixel.hytale.server.worldgen.cave.prefab.CavePrefabContainer;
class="kw">import com.hypixel.hytale.server.worldgen.container.PrefabContainer;
class="kw">import com.hypixel.hytale.server.worldgen.loader.WorldGenPrefabSupplier;
class="kw">import com.hypixel.hytale.server.worldgen.util.ListPool;
class="kw">import com.hypixel.hytale.server.worldgen.util.LogUtil;
class="kw">import java.util.List;
class="kw">import java.util.function.Function;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">public class RemoveOp class="kw">implements Op {
class="kw">public class="kw">static class="kw">final String ID = "Remove";
class="kw">public class="kw">static class="kw">final BuilderCodec<RemoveOp> CODEC = BuilderCodec.builder(RemoveOp.class, RemoveOp::new)
.documentation("Removes matching content from the target content list")
.<Content.Type>append(new KeyedCodec<>("ContentType", Content.Type.CODEC), (var0, var1) -> var0.type = var1, var0 -> var0.type)
.documentation("The type of content to remove")
.add()
.<String[]>append(new KeyedCodec<>("Rules", BuilderCodec.STRING_ARRAY), (var0, var1) -> var0.rules = var1, var0 -> var0.rules)
.documentation(
"List of glob-matching rules to match entries. Rules are only implemented for Prefab paths and CaveType names, but can be set to '*' to remove all entries of any content type"
)
.add()
.afterDecode(var0 -> var0.isClearAll = ArrayUtil.contains(var0.rules, "*"))
.build();
class="kw">private Content.Type type = Content.Type.NONE;
class="kw">private String[] rules = ArrayUtil.EMPTY_STRING_ARRAY;
class="kw">private class="kw">transient boolean isClearAll = false;
class="kw">public RemoveOp() {
}
@Override
class="kw">public Content.Type type() {
class="kw">return this.type;
}
@Override
class="kw">public <T> void apply(@Nonnull ModifyEvent<T> var1) class="kw">throws Error {
if (this.rules.length != 0) {
if (this.isClearAll) {
var1.entries().clear();
} else {
class="kw">switch (var1) {
case ModifyEvents.BiomePrefabs var4:
removePrefabs(var4, this.rules, PrefabContainer.ENTRY_POOL, PrefabContainer.PrefabContainerEntry::getPrefabs);
break;
case ModifyEvents.CaveTypes var5:
removeContent(var5, this.rules, CaveType.ENTRY_POOL, CaveType::getName);
break;
case ModifyEvents.CavePrefabs var6:
removePrefabs(var6, this.rules, CavePrefabContainer.ENTRY_POOL, CavePrefabContainer.CavePrefabEntry::getPrefabs);
break;
class="kw">default:
}
}
}
}
class="kw">protected class="kw">static <T> void removePrefabs(
@Nonnull ModifyEvent<T> var0, @Nonnull String[] var1, @Nonnull ListPool<T> var2, @Nonnull Function<T, IWeightedMap<WorldGenPrefabSupplier>> var3
) {
try (ListPool.Resource var4 = var2.acquire(var0.entries().size())) {
label53:
for (int var5 = 0; var5 < var0.entries().size(); var5++) {
Object var6 = var0.entries().get(var5);
IWeightedMap var7 = var3.apply(var6);
for (WorldGenPrefabSupplier var11 : var7.internalKeys()) {
String var12 = var11.getPrefabKey();
for (String var16 : var1) {
if (StringUtil.isGlobMatching(var16, var12)) {
class="kw">continue label53;
}
}
}
var4.add(var6);
}
modifyEventContent(var4, var0);
}
}
class="kw">protected class="kw">static <T> void removeContent(@Nonnull ModifyEvent<T> var0, @Nonnull String[] var1, @Nonnull ListPool<T> var2, @Nonnull Function<T, String> var3) {
try (ListPool.Resource var4 = var2.acquire(var0.entries().size())) {
label44:
for (int var5 = 0; var5 < var0.entries().size(); var5++) {
Object var6 = var0.entries().get(var5);
String var7 = var3.apply(var6);
for (String var11 : var1) {
if (StringUtil.isGlobMatching(var11, var7)) {
class="kw">continue label44;
}
}
var4.add(var6);
}
modifyEventContent(var4, var0);
}
}
class="kw">protected class="kw">static <T> void modifyEventContent(@Nonnull List<T> var0, @Nonnull ModifyEvent<T> var1) {
if (var0.size() < var1.entries().size()) {
int var2 = var1.entries().size() - var0.size();
var1.entries().clear();
var1.entries().addAll(var0);
LogUtil.getLogger().at(Level.FINE).log("[%s] Removed %d entries from: %s", var1.type(), var2, var1.file().getContentPath());
}
}
}