HydrateDisplayName class
Пакет: com.hypixel.hytale.server.core.modules.entity.system
Файл: com/hypixel/hytale/server/core/modules/entity/system/DisplayNameSystems.java
extends: HolderSystem<EntityStore>
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private static final Query<EntityStore> |
QUERY |
|
PersistentDisplayName |
var4 |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public Query<EntityStore> |
getQuerypublic Query<EntityStore> getQuery() |
|
public void |
onEntityAddpublic void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) |
|
public void |
onEntityRemovedpublic void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.entity.system;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.data.unknown.UnknownComponents;
class="kw">import com.hypixel.hytale.component.dependency.Dependency;
class="kw">import com.hypixel.hytale.component.dependency.Order;
class="kw">import com.hypixel.hytale.component.dependency.SystemDependency;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.HolderSystem;
class="kw">import com.hypixel.hytale.component.system.RefChangeSystem;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PersistentDisplayName;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.Set;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class DisplayNameSystems {
class="kw">public DisplayNameSystems() {
}
class="kw">public class="kw">static class HydrateDisplayName class="kw">extends HolderSystem<EntityStore> {
@Nonnull
class="kw">private class="kw">static class="kw">final Query<EntityStore> QUERY = Query.and(PersistentDisplayName.getComponentType(), Query.not(DisplayNameComponent.getComponentType()));
class="kw">public HydrateDisplayName() {
}
@Nonnull
@Override
class="kw">public Query<EntityStore> getQuery() {
class="kw">return QUERY;
}
@Override
class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
PersistentDisplayName var4 = var1.getComponent(PersistentDisplayName.getComponentType());
assert var4 != null;
var1.putComponent(DisplayNameComponent.getComponentType(), new DisplayNameComponent(var4.getDisplayName()));
}
@Override
class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
}
}
class="kw">public class="kw">static class MigratePlayerDisplayName class="kw">extends EntityModule.MigrationSystem {
@Nonnull
class="kw">private class="kw">static class="kw">final Set<Dependency<EntityStore>> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, DisplayNameSystems.HydrateDisplayName.class));
class="kw">public MigratePlayerDisplayName() {
}
@Nullable
@Override
class="kw">public Query<EntityStore> getQuery() {
class="kw">return EntityStore.REGISTRY.getUnknownComponentType();
}
@Nonnull
@Override
class="kw">public Set<Dependency<EntityStore>> getDependencies() {
class="kw">return DEPENDENCIES;
}
@Override
class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
UnknownComponents var4 = var1.getComponent(EntityStore.REGISTRY.getUnknownComponentType());
assert var4 != null;
if (var4.contains("DisplayName")) {
PersistentDisplayName var5 = var4.removeComponent("DisplayName", PersistentDisplayName.CODEC);
if (var1.getComponent(Player.getComponentType()) == null) {
if (var5 != null) {
var1.putComponent(PersistentDisplayName.getComponentType(), var5);
}
}
}
}
@Override
class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
}
}
class="kw">public class="kw">static class SyncDisplayName class="kw">extends RefChangeSystem<EntityStore, PersistentDisplayName> {
class="kw">public SyncDisplayName() {
}
@Nonnull
@Override
class="kw">public Query<EntityStore> getQuery() {
class="kw">return PersistentDisplayName.getComponentType();
}
@Nonnull
@Override
class="kw">public ComponentType<EntityStore, PersistentDisplayName> componentType() {
class="kw">return PersistentDisplayName.getComponentType();
}
class="kw">public void onComponentAdded(
@Nonnull Ref<EntityStore> var1, @Nonnull PersistentDisplayName var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
) {
var4.putComponent(var1, DisplayNameComponent.getComponentType(), new DisplayNameComponent(var2.getDisplayName()));
}
class="kw">public void onComponentSet(
@Nonnull Ref<EntityStore> var1,
@Nullable PersistentDisplayName var2,
@Nonnull PersistentDisplayName var3,
@Nonnull Store<EntityStore> var4,
@Nonnull CommandBuffer<EntityStore> var5
) {
var5.putComponent(var1, DisplayNameComponent.getComponentType(), new DisplayNameComponent(var3.getDisplayName()));
}
class="kw">public void onComponentRemoved(
@Nonnull Ref<EntityStore> var1, @Nonnull PersistentDisplayName var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
) {
PlayerRef var5 = var4.getComponent(var1, PlayerRef.getComponentType());
Message var6 = var5 != null ? Message.raw(var5.getUsername()) : null;
var4.putComponent(var1, DisplayNameComponent.getComponentType(), new DisplayNameComponent(var6));
}
}
}