fancynpcs, fancyholograms: Drop support for 1.19.4

This commit is contained in:
Oliver
2025-11-21 14:02:01 +01:00
parent a35c2ac786
commit d7c6f1bc81
60 changed files with 15 additions and 2706 deletions

View File

@@ -14,7 +14,7 @@ repositories {
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT")
compileOnly("de.oliver.FancyAnalytics:logger:0.0.8")
compileOnly("org.jetbrains:annotations:26.0.2")

View File

@@ -36,7 +36,7 @@ With this plugin you can create holograms with customizable properties like:
## Installation
Paper **1.19.4** - **1.21.8** with **Java 21** (or higher) is required. Plugin should also work on **Paper** forks.
Paper **1.20** - **1.21.8** with **Java 21** (or higher) is required. Plugin should also work on **Paper** forks.
**Spigot** is **not** supported.

View File

@@ -1 +1 @@
2.8.0.158
2.8.0.159

View File

@@ -4,7 +4,7 @@ plugins {
id("com.gradleup.shadow")
}
val minecraftVersion = "1.19.4"
val minecraftVersion = "1.20"
dependencies {
compileOnly("io.papermc.paper:paper-api:$minecraftVersion-R0.1-SNAPSHOT")

View File

@@ -39,7 +39,6 @@ dependencies {
implementation(project(":plugins:fancyholograms-v2:implementation_1_20_4", configuration = "reobf"))
implementation(project(":plugins:fancyholograms-v2:implementation_1_20_2", configuration = "reobf"))
implementation(project(":plugins:fancyholograms-v2:implementation_1_20_1", configuration = "reobf"))
implementation(project(":plugins:fancyholograms-v2:implementation_1_19_4", configuration = "reobf"))
rootProject.subprojects
.filter { it.path.startsWith(":libraries:packets:implementations") }

View File

@@ -1,33 +0,0 @@
plugins {
id("java-library")
id("io.papermc.paperweight.userdev")
}
val minecraftVersion = "1.19.4"
dependencies {
paperweight.paperDevBundle("$minecraftVersion-R0.1-SNAPSHOT")
implementation(project(":plugins:fancyholograms-v2:api"))
implementation(project(":libraries:common"))
compileOnly("com.viaversion:viaversion-api:5.2.1")
}
tasks {
named("assemble") {
dependsOn(named("reobfJar"))
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
}

View File

@@ -1,271 +0,0 @@
package de.oliver.fancyholograms.hologram.version;
import com.mojang.math.Transformation;
import de.oliver.fancyholograms.api.data.*;
import de.oliver.fancyholograms.api.events.HologramHideEvent;
import de.oliver.fancyholograms.api.events.HologramShowEvent;
import de.oliver.fancyholograms.api.hologram.Hologram;
import de.oliver.fancylib.ReflectionUtils;
import io.papermc.paper.adventure.PaperAdventure;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.SynchedEntityData.DataItem;
import net.minecraft.network.syncher.SynchedEntityData.DataValue;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Brightness;
import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Display.TextDisplay;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Quaternionf;
import java.util.ArrayList;
import static de.oliver.fancylib.ReflectionUtils.getValue;
public final class Hologram1_19_4 extends Hologram {
@Nullable
private Display display;
public Hologram1_19_4(@NotNull final HologramData data) {
super(data);
}
@Override
public int getEntityId() {
return display.getId();
}
@Override
public @Nullable org.bukkit.entity.Display getDisplayEntity() {
return display != null ? (org.bukkit.entity.Display) display.getBukkitEntity() : null;
}
@Override
public void create() {
final var location = data.getLocation();
if (location.getWorld() == null) {
return; // no location data, cannot be created
}
ServerLevel world = ((CraftWorld) location.getWorld()).getHandle();
switch (data.getType()) {
case TEXT -> this.display = new Display.TextDisplay(EntityType.TEXT_DISPLAY, world);
case BLOCK -> this.display = new Display.BlockDisplay(EntityType.BLOCK_DISPLAY, world);
case ITEM -> this.display = new Display.ItemDisplay(EntityType.ITEM_DISPLAY, world);
}
if (data instanceof DisplayHologramData dd) {
final var DATA_INTERPOLATION_DURATION_ID = ReflectionUtils.getStaticValue(Display.class, MappingKeys1_19_4.DATA_INTERPOLATION_DURATION_ID.getMapping());
display.getEntityData().set((EntityDataAccessor<Integer>) DATA_INTERPOLATION_DURATION_ID, dd.getInterpolationDuration());
final var DATA_INTERPOLATION_START_DELTA_TICKS_ID = ReflectionUtils.getStaticValue(Display.class, MappingKeys1_19_4.DATA_INTERPOLATION_START_DELTA_TICKS_ID.getMapping());
display.getEntityData().set((EntityDataAccessor<Integer>) DATA_INTERPOLATION_START_DELTA_TICKS_ID, 0);
}
update();
}
@Override
public void delete() {
this.display = null;
}
@Override
public void update() {
final var display = this.display;
if (display == null) {
return; // doesn't exist, nothing to update
}
// location data
final var location = data.getLocation();
if (!location.isWorldLoaded()) {
return;
} else {
display.setPosRaw(location.x(), location.y(), location.z());
display.setYRot(location.getYaw());
display.setXRot(location.getPitch());
}
if (display instanceof TextDisplay textDisplay && data instanceof TextHologramData textData) {
// line width
final var DATA_LINE_WIDTH_ID = ReflectionUtils.getStaticValue(TextDisplay.class, MappingKeys1_19_4.DATA_LINE_WIDTH_ID.getMapping());
display.getEntityData().set((EntityDataAccessor<Integer>) DATA_LINE_WIDTH_ID, Hologram.LINE_WIDTH);
// background
final var DATA_BACKGROUND_COLOR_ID = ReflectionUtils.getStaticValue(TextDisplay.class, MappingKeys1_19_4.DATA_BACKGROUND_COLOR_ID.getMapping());
final var background = textData.getBackground();
if (background == null) {
display.getEntityData().set((EntityDataAccessor<Integer>) DATA_BACKGROUND_COLOR_ID, TextDisplay.INITIAL_BACKGROUND);
} else if (background == Hologram.TRANSPARENT) {
display.getEntityData().set((EntityDataAccessor<Integer>) DATA_BACKGROUND_COLOR_ID, 0);
} else {
display.getEntityData().set((EntityDataAccessor<Integer>) DATA_BACKGROUND_COLOR_ID, background.asARGB());
}
// text shadow
if (textData.hasTextShadow()) {
textDisplay.setFlags((byte) (textDisplay.getFlags() | TextDisplay.FLAG_SHADOW));
} else {
textDisplay.setFlags((byte) (textDisplay.getFlags() & ~TextDisplay.FLAG_SHADOW));
}
// text alignment
if (textData.getTextAlignment() == org.bukkit.entity.TextDisplay.TextAlignment.LEFT) {
textDisplay.setFlags((byte) (textDisplay.getFlags() | TextDisplay.FLAG_ALIGN_LEFT));
} else {
textDisplay.setFlags((byte) (textDisplay.getFlags() & ~TextDisplay.FLAG_ALIGN_LEFT));
}
// see through
if (textData.isSeeThrough()) {
textDisplay.setFlags((byte) (textDisplay.getFlags() | TextDisplay.FLAG_SEE_THROUGH));
} else {
textDisplay.setFlags((byte) (textDisplay.getFlags() & ~TextDisplay.FLAG_SEE_THROUGH));
}
if (textData.getTextAlignment() == org.bukkit.entity.TextDisplay.TextAlignment.RIGHT) {
textDisplay.setFlags((byte) (textDisplay.getFlags() | TextDisplay.FLAG_ALIGN_RIGHT));
} else {
textDisplay.setFlags((byte) (textDisplay.getFlags() & ~TextDisplay.FLAG_ALIGN_RIGHT));
}
} else if (display instanceof Display.ItemDisplay itemDisplay && data instanceof ItemHologramData itemData) {
// item
itemDisplay.setItemStack(ItemStack.fromBukkitCopy(itemData.getItemStack()));
} else if (display instanceof Display.BlockDisplay blockDisplay && data instanceof BlockHologramData blockData) {
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.of("minecraft:" + blockData.getBlock().name().toLowerCase(), ':'));
blockDisplay.setBlockState(block.defaultBlockState());
}
if (data instanceof DisplayHologramData displayData) {
// billboard data
display.setBillboardConstraints(switch (displayData.getBillboard()) {
case FIXED -> Display.BillboardConstraints.FIXED;
case VERTICAL -> Display.BillboardConstraints.VERTICAL;
case HORIZONTAL -> Display.BillboardConstraints.HORIZONTAL;
case CENTER -> Display.BillboardConstraints.CENTER;
});
// brightness
if (displayData.getBrightness() != null) {
display.setBrightnessOverride(new Brightness(displayData.getBrightness().getBlockLight(), displayData.getBrightness().getSkyLight()));
}
// entity scale AND MORE!
display.setTransformation(new Transformation(
displayData.getTranslation(),
new Quaternionf(),
displayData.getScale(),
new Quaternionf())
);
// entity shadow
display.setShadowRadius(displayData.getShadowRadius());
display.setShadowStrength(displayData.getShadowStrength());
// view range
display.setViewRange(displayData.getVisibilityDistance());
}
}
@Override
public boolean show(@NotNull final Player player) {
if (!new HologramShowEvent(this, player).callEvent()) {
return false;
}
if (this.display == null) {
create(); // try to create it if it doesn't exist every time
}
final var display = this.display;
if (display == null) {
return false; // could not be created, nothing to show
}
if (!data.getLocation().getWorld().getName().equals(player.getLocation().getWorld().getName())) {
return false;
}
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
// TODO: cache player protocol version
// TODO: fix this
// final var protocolVersion = FancyHologramsPlugin.get().isUsingViaVersion() ? Via.getAPI().getPlayerVersion(player) : MINIMUM_PROTOCOL_VERSION;
// if (protocolVersion < MINIMUM_PROTOCOL_VERSION) {
// return false;
// }
serverPlayer.connection.send(new ClientboundAddEntityPacket(display));
this.viewers.add(player.getUniqueId());
refreshHologram(player);
return true;
}
@Override
public boolean hide(@NotNull final Player player) {
if (!new HologramHideEvent(this, player).callEvent()) {
return false;
}
final var display = this.display;
if (display == null) {
return false; // doesn't exist, nothing to hide
}
((CraftPlayer) player).getHandle().connection.send(new ClientboundRemoveEntitiesPacket(display.getId()));
this.viewers.remove(player.getUniqueId());
return true;
}
@Override
public void refresh(@NotNull final Player player) {
final var display = this.display;
if (display == null) {
return; // doesn't exist, nothing to refresh
}
if (!isViewer(player)) {
return;
}
((CraftPlayer) player).getHandle().connection.send(new ClientboundTeleportEntityPacket(display));
if (display instanceof TextDisplay textDisplay) {
textDisplay.setText(PaperAdventure.asVanilla(getShownText(player)));
}
final var values = new ArrayList<DataValue<?>>();
//noinspection unchecked
for (final var item : ((Int2ObjectMap<DataItem<?>>) getValue(display.getEntityData(), "e")).values()) {
values.add(item.value());
}
((CraftPlayer) player).getHandle().connection.send(new ClientboundSetEntityDataPacket(display.getId(), values));
}
}

View File

@@ -1,20 +0,0 @@
package de.oliver.fancyholograms.hologram.version;
public enum MappingKeys1_19_4 {
DATA_INTERPOLATION_DURATION_ID("r"),
DATA_INTERPOLATION_START_DELTA_TICKS_ID("q"),
DATA_LINE_WIDTH_ID("aL"),
DATA_BACKGROUND_COLOR_ID("aM"),
;
private final String mapping;
MappingKeys1_19_4(String mapping) {
this.mapping = mapping;
}
public String getMapping() {
return mapping;
}
}

View File

@@ -5,7 +5,6 @@
"changelog_path": "../../../../plugins/fancyholograms-v2/CHANGELOG.md",
"version_path": "../../../../plugins/fancyholograms-v2/VERSION",
"supported_versions": [
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",

View File

@@ -5,7 +5,6 @@
"changelog_path": "../../../../plugins/fancyholograms-v2/CHANGELOG-SNAPSHOT.md",
"version_path": "../../../../plugins/fancyholograms-v2/VERSION",
"supported_versions": [
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",

View File

@@ -17,7 +17,10 @@ import de.oliver.fancyholograms.api.hologram.Hologram;
import de.oliver.fancyholograms.commands.FancyHologramsCMD;
import de.oliver.fancyholograms.commands.FancyHologramsTestCMD;
import de.oliver.fancyholograms.commands.HologramCMD;
import de.oliver.fancyholograms.hologram.version.*;
import de.oliver.fancyholograms.hologram.version.Hologram1_20_1;
import de.oliver.fancyholograms.hologram.version.Hologram1_20_2;
import de.oliver.fancyholograms.hologram.version.Hologram1_20_4;
import de.oliver.fancyholograms.hologram.version.HologramImpl;
import de.oliver.fancyholograms.listeners.*;
import de.oliver.fancyholograms.storage.FlatFileHologramStorage;
import de.oliver.fancyholograms.storage.converter.FHConversionRegistry;
@@ -109,7 +112,7 @@ public final class FancyHolograms extends JavaPlugin implements FancyHologramsPl
final var adapter = resolveHologramAdapter();
if (adapter == null) {
List<String> supportedVersions = new ArrayList<>(List.of("1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4"));
List<String> supportedVersions = new ArrayList<>(List.of("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4"));
supportedVersions.addAll(ServerVersion.getSupportedVersions());
fancyLogger.warn("""
@@ -268,7 +271,6 @@ public final class FancyHolograms extends JavaPlugin implements FancyHologramsPl
case "1.20.3", "1.20.4" -> Hologram1_20_4::new;
case "1.20.2" -> Hologram1_20_2::new;
case "1.20", "1.20.1" -> Hologram1_20_1::new;
case "1.19.4" -> Hologram1_19_4::new;
default -> null;
};
}

View File

@@ -4,7 +4,7 @@ plugins {
id("com.gradleup.shadow")
}
val minecraftVersion = "1.19.4"
val minecraftVersion = "1.20"
dependencies {
compileOnly("io.papermc.paper:paper-api:$minecraftVersion-R0.1-SNAPSHOT")

View File

@@ -35,7 +35,7 @@ Check out **[images section](#images)** down below.
## Installation
Paper **1.19.4** - **1.21.11** with **Java 21** (or higher) is required. Plugin should also work on **Paper** forks.
Paper **1.20** - **1.21.11** with **Java 21** (or higher) is required. Plugin should also work on **Paper** forks.
**Spigot** is **not** supported.

View File

@@ -1 +1 @@
2.8.0.309
2.8.0.310

View File

@@ -43,7 +43,6 @@ dependencies {
implementation(project(":plugins:fancynpcs:implementation_1_20_2", configuration = "reobf"))
implementation(project(":plugins:fancynpcs:implementation_1_20_1", configuration = "reobf"))
implementation(project(":plugins:fancynpcs:implementation_1_20", configuration = "reobf"))
implementation(project(":plugins:fancynpcs:implementation_1_19_4", configuration = "reobf"))
rootProject.subprojects
.filter { it.path.startsWith(":libraries:packets:implementations") }

View File

@@ -4,7 +4,7 @@ plugins {
id("com.gradleup.shadow")
}
val minecraftVersion = "1.19.4"
val minecraftVersion = "1.20"
dependencies {
compileOnly("io.papermc.paper:paper-api:$minecraftVersion-R0.1-SNAPSHOT")

View File

@@ -1,34 +0,0 @@
plugins {
id("java-library")
id("io.papermc.paperweight.userdev")
}
val minecraftVersion = "1.19.4"
dependencies {
paperweight.paperDevBundle("$minecraftVersion-R0.1-SNAPSHOT")
compileOnly(project(":plugins:fancynpcs:fn-api"))
compileOnly(project(":libraries:common"))
compileOnly("org.lushplugins:ChatColorHandler:5.1.6") // KEEP, newer versions require Java 21
}
tasks {
named("assemble") {
dependsOn(named("reobfJar"))
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release = 17
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

View File

@@ -1,23 +0,0 @@
package de.oliver.fancynpcs.v1_19_4;
public enum MappingKeys1_19_4 {
ENTITY_TYPE__FACTORY("bA"),
SYNCHED_ENTITY_DATA__ITEMS_BY_ID("e"),
CLIENTBOUND_TELEPORT_ENTITY_PACKET__X("b"),
CLIENTBOUND_TELEPORT_ENTITY_PACKET__Y("c"),
CLIENTBOUND_TELEPORT_ENTITY_PACKET__Z("d"),
CLIENTBOUND_PLAYER_INFO_UPDATE_PACKET__ENTRIES("b"),
PANDA__DATA_ID_FLAGS("ca"),
;
private final String mapping;
MappingKeys1_19_4(String mapping) {
this.mapping = mapping;
}
public String getMapping() {
return mapping;
}
}

View File

@@ -1,391 +0,0 @@
package de.oliver.fancynpcs.v1_19_4;
import com.google.common.collect.ImmutableList;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.datafixers.util.Pair;
import de.oliver.fancylib.ReflectionUtils;
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.api.NpcData;
import de.oliver.fancynpcs.api.events.NpcSpawnEvent;
import de.oliver.fancynpcs.api.utils.NpcEquipmentSlot;
import io.papermc.paper.adventure.PaperAdventure;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.world.scores.Team;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R3.util.CraftNamespacedKey;
import org.bukkit.entity.Player;
import org.lushplugins.chatcolorhandler.ModernChatColorHandler;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
public class Npc_1_19_4 extends Npc {
private final String localName;
private final UUID uuid;
private Entity npc;
private Display.TextDisplay sittingVehicle;
public Npc_1_19_4(NpcData data) {
super(data);
this.localName = generateLocalName();
this.uuid = UUID.randomUUID();
}
@Override
public void create() {
MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();
ServerLevel serverLevel = ((CraftWorld) data.getLocation().getWorld()).getHandle();
GameProfile gameProfile = new GameProfile(uuid, localName);
if (data.getType() == org.bukkit.entity.EntityType.PLAYER) {
npc = new ServerPlayer(minecraftServer, serverLevel, new GameProfile(uuid, ""));
((ServerPlayer) npc).gameProfile = gameProfile;
} else {
EntityType<?> nmsType = BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(data.getType().getKey()));
EntityType.EntityFactory factory = (EntityType.EntityFactory) ReflectionUtils.getValue(nmsType, MappingKeys1_19_4.ENTITY_TYPE__FACTORY.getMapping()); // EntityType.factory
npc = factory.create(nmsType, serverLevel);
isTeamCreated.clear();
}
}
@Override
public void spawn(Player player) {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
if (npc == null) {
return;
}
if (!data.getLocation().getWorld().getName().equalsIgnoreCase(serverPlayer.getLevel().getWorld().getName())) {
return;
}
if (data.getSkinData() != null && data.getSkinData().hasTexture()) {
String value = data.getSkinData().getTextureValue();
String signature = data.getSkinData().getTextureSignature();
((ServerPlayer) npc).getGameProfile().getProperties().replaceValues(
"textures",
ImmutableList.of(new Property("textures", value, signature))
);
}
NpcSpawnEvent spawnEvent = new NpcSpawnEvent(this, player);
spawnEvent.callEvent();
if (spawnEvent.isCancelled()) {
return;
}
if (npc instanceof ServerPlayer npcPlayer) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.noneOf(ClientboundPlayerInfoUpdatePacket.Action.class);
actions.add(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
actions.add(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME);
if (data.isShowInTab()) {
actions.add(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED);
}
ClientboundPlayerInfoUpdatePacket playerInfoPacket = new ClientboundPlayerInfoUpdatePacket(actions, List.of(npcPlayer));
if (data.isMirrorSkin()) {
handleMirroredSkin(playerInfoPacket, serverPlayer);
}
serverPlayer.connection.send(playerInfoPacket);
if (data.isSpawnEntity()) {
npc.setPos(data.getLocation().x(), data.getLocation().y(), data.getLocation().z());
ClientboundAddPlayerPacket spawnPlayerPacket = new ClientboundAddPlayerPacket(npcPlayer);
serverPlayer.connection.send(spawnPlayerPacket);
}
}
ClientboundAddEntityPacket addEntityPacket = new ClientboundAddEntityPacket(npc);
serverPlayer.connection.send(addEntityPacket);
isVisibleForPlayer.put(player.getUniqueId(), true);
int removeNpcsFromPlayerlistDelay = FancyNpcsPlugin.get().getFancyNpcConfig().getRemoveNpcsFromPlayerlistDelay();
if (!data.isShowInTab() && removeNpcsFromPlayerlistDelay > 0) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.getUUID()));
serverPlayer.connection.send(playerInfoRemovePacket);
}, removeNpcsFromPlayerlistDelay, TimeUnit.MILLISECONDS);
}
update(player);
}
@Override
public void remove(Player player) {
if (npc == null) {
return;
}
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
if (npc instanceof ServerPlayer npcPlayer) {
ClientboundPlayerInfoRemovePacket playerInfoRemovePacket = new ClientboundPlayerInfoRemovePacket(List.of((npcPlayer.getUUID())));
serverPlayer.connection.send(playerInfoRemovePacket);
}
// remove entity
ClientboundRemoveEntitiesPacket removeEntitiesPacket = new ClientboundRemoveEntitiesPacket(npc.getId());
serverPlayer.connection.send(removeEntitiesPacket);
// remove sitting vehicle
if (sittingVehicle != null) {
ClientboundRemoveEntitiesPacket removeSittingVehiclePacket = new ClientboundRemoveEntitiesPacket(sittingVehicle.getId());
serverPlayer.connection.send(removeSittingVehiclePacket);
}
isVisibleForPlayer.put(serverPlayer.getUUID(), false);
}
@Override
public void lookAt(Player player, Location location) {
if (npc == null) {
return;
}
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
npc.setRot(location.getYaw(), location.getPitch());
npc.setYHeadRot(location.getYaw());
npc.setXRot(location.getPitch());
npc.setYRot(location.getYaw());
ClientboundTeleportEntityPacket teleportEntityPacket = new ClientboundTeleportEntityPacket(npc);
serverPlayer.connection.send(teleportEntityPacket);
float angelMultiplier = 256f / 360f;
ClientboundRotateHeadPacket rotateHeadPacket = new ClientboundRotateHeadPacket(npc, (byte) (location.getYaw() * angelMultiplier));
serverPlayer.connection.send(rotateHeadPacket);
}
@Override
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
if (!isVisibleForPlayer.getOrDefault(player.getUniqueId(), false)) {
return;
}
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
PlayerTeam team = new PlayerTeam(new Scoreboard(), "npc-" + localName);
team.getPlayers().clear();
team.getPlayers().add(npc instanceof ServerPlayer npcPlayer ? npcPlayer.getGameProfile().getName() : npc.getStringUUID());
team.setColor(PaperAdventure.asVanilla(data.getGlowingColor()));
if (!data.isCollidable()) {
team.setCollisionRule(Team.CollisionRule.NEVER);
}
net.kyori.adventure.text.Component displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
Component vanillaComponent = PaperAdventure.asVanilla(displayName);
if (!(npc instanceof ServerPlayer)) {
npc.setCustomName(vanillaComponent);
npc.setCustomNameVisible(true);
} else {
npc.setCustomName(null);
npc.setCustomNameVisible(false);
}
if (data.getDisplayName().equalsIgnoreCase("<empty>")) {
team.setNameTagVisibility(Team.Visibility.NEVER);
npc.setCustomName(null);
npc.setCustomNameVisible(false);
} else {
team.setNameTagVisibility(Team.Visibility.ALWAYS);
}
if (npc instanceof ServerPlayer npcPlayer) {
team.setPlayerPrefix(vanillaComponent);
npcPlayer.listName = vanillaComponent;
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.noneOf(ClientboundPlayerInfoUpdatePacket.Action.class);
actions.add(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME);
if (data.isShowInTab()) {
actions.add(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED);
}
ClientboundPlayerInfoUpdatePacket playerInfoPacket = new ClientboundPlayerInfoUpdatePacket(actions, List.of(npcPlayer));
if (data.isMirrorSkin()) {
handleMirroredSkin(playerInfoPacket, serverPlayer);
}
serverPlayer.connection.send(playerInfoPacket);
}
boolean isTeamCreatedForPlayer = this.isTeamCreated.getOrDefault(player.getUniqueId(), false);
serverPlayer.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, !isTeamCreatedForPlayer));
isTeamCreated.put(player.getUniqueId(), true);
npc.setGlowingTag(data.isGlowing());
if (data.getEquipment() != null && data.getEquipment().size() > 0) {
List<Pair<EquipmentSlot, ItemStack>> equipmentList = new ArrayList<>();
for (NpcEquipmentSlot slot : data.getEquipment().keySet()) {
equipmentList.add(new Pair<>(EquipmentSlot.byName(slot.toNmsName()), CraftItemStack.asNMSCopy(data.getEquipment().get(slot))));
}
ClientboundSetEquipmentPacket setEquipmentPacket = new ClientboundSetEquipmentPacket(npc.getId(), equipmentList);
serverPlayer.connection.send(setEquipmentPacket);
}
if (npc instanceof ServerPlayer) {
// Enable second layer of skin (https://wiki.vg/Entity_metadata#Player)
npc.getEntityData().set(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40));
}
data.applyAllAttributes(this);
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
if (data.getAttributes().containsKey(playerPoseAttr)) {
String pose = data.getAttributes().get(playerPoseAttr);
if (pose.equals("sitting")) {
setSitting(serverPlayer);
} else {
if (sittingVehicle != null) {
ClientboundRemoveEntitiesPacket removeSittingVehiclePacket = new ClientboundRemoveEntitiesPacket(sittingVehicle.getId());
serverPlayer.connection.send(removeSittingVehiclePacket);
}
}
}
}
@Override
protected void refreshEntityData(Player player) {
if (!isVisibleForPlayer.getOrDefault(player.getUniqueId(), false)) {
return;
}
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
Int2ObjectMap<SynchedEntityData.DataItem<?>> itemsById = (Int2ObjectMap<SynchedEntityData.DataItem<?>>) ReflectionUtils.getValue(npc.getEntityData(), MappingKeys1_19_4.SYNCHED_ENTITY_DATA__ITEMS_BY_ID.getMapping()); // itemsById
List<SynchedEntityData.DataValue<?>> entityData = new ArrayList<>();
for (SynchedEntityData.DataItem<?> dataItem : itemsById.values()) {
entityData.add(dataItem.value());
}
ClientboundSetEntityDataPacket setEntityDataPacket = new ClientboundSetEntityDataPacket(npc.getId(), entityData);
serverPlayer.connection.send(setEntityDataPacket);
}
public void move(Player player, boolean swingArm) {
if (npc == null) {
return;
}
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
npc.setPosRaw(data.getLocation().x(), data.getLocation().y(), data.getLocation().z());
npc.setRot(data.getLocation().getYaw(), data.getLocation().getPitch());
npc.setYHeadRot(data.getLocation().getYaw());
npc.setXRot(data.getLocation().getPitch());
npc.setYRot(data.getLocation().getYaw());
ClientboundTeleportEntityPacket teleportEntityPacket = new ClientboundTeleportEntityPacket(npc);
ReflectionUtils.setValue(teleportEntityPacket, MappingKeys1_19_4.CLIENTBOUND_TELEPORT_ENTITY_PACKET__X.getMapping(), data.getLocation().x()); // 'x'
ReflectionUtils.setValue(teleportEntityPacket, MappingKeys1_19_4.CLIENTBOUND_TELEPORT_ENTITY_PACKET__Y.getMapping(), data.getLocation().y()); // 'y'
ReflectionUtils.setValue(teleportEntityPacket, MappingKeys1_19_4.CLIENTBOUND_TELEPORT_ENTITY_PACKET__Z.getMapping(), data.getLocation().z()); // 'z'
serverPlayer.connection.send(teleportEntityPacket);
float angelMultiplier = 256f / 360f;
ClientboundRotateHeadPacket rotateHeadPacket = new ClientboundRotateHeadPacket(npc, (byte) (data.getLocation().getYaw() * angelMultiplier));
serverPlayer.connection.send(rotateHeadPacket);
if (swingArm && npc instanceof ServerPlayer) {
ClientboundAnimatePacket animatePacket = new ClientboundAnimatePacket(npc, 0);
serverPlayer.connection.send(animatePacket);
}
}
public void setSitting(ServerPlayer serverPlayer) {
if (npc == null) {
return;
}
if (sittingVehicle == null) {
sittingVehicle = new Display.TextDisplay(EntityType.TEXT_DISPLAY, ((CraftWorld) data.getLocation().getWorld()).getHandle());
}
sittingVehicle.setPos(data.getLocation().x(), data.getLocation().y(), data.getLocation().z());
ClientboundAddEntityPacket addEntityPacket = new ClientboundAddEntityPacket(sittingVehicle);
serverPlayer.connection.send(addEntityPacket);
sittingVehicle.passengers = ImmutableList.of(npc);
ClientboundSetPassengersPacket packet = new ClientboundSetPassengersPacket(sittingVehicle);
serverPlayer.connection.send(packet);
}
private void handleMirroredSkin(ClientboundPlayerInfoUpdatePacket playerInfoUpdatePacket, ServerPlayer viewer) {
if (!ServerLoginPacketListenerImpl.isValidUsername(viewer.getGameProfile().getName())) return;
ClientboundPlayerInfoUpdatePacket.Entry entry = playerInfoUpdatePacket.entries().get(0);
GameProfile profile = entry.profile();
GameProfile newProfile = new GameProfile(profile.getId(), profile.getName());
newProfile.getProperties().putAll(viewer.getGameProfile().getProperties());
ClientboundPlayerInfoUpdatePacket.Entry newEntry = new ClientboundPlayerInfoUpdatePacket.Entry(
entry.profileId(),
newProfile,
entry.listed(),
entry.latency(),
entry.gameMode(),
entry.displayName(),
entry.chatSession()
);
ReflectionUtils.setValue(playerInfoUpdatePacket, "b", List.of(newEntry)); // 'entries'
}
@Override
public float getEyeHeight() {
return npc.getEyeHeight();
}
@Override
public int getEntityId() {
return npc.getId();
}
public Entity getNpc() {
return npc;
}
}

View File

@@ -1,74 +0,0 @@
package de.oliver.fancynpcs.v1_19_4;
import de.oliver.fancylib.FancyLib;
import de.oliver.fancylib.ReflectionUtils;
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.actions.ActionTrigger;
import de.oliver.fancynpcs.api.events.PacketReceivedEvent;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
import net.minecraft.server.level.ServerPlayer;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.EquipmentSlot;
import java.util.List;
public class PacketReader_1_19_4 implements Listener {
public static boolean inject(Player player) {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
Channel channel = serverPlayer.connection.connection.channel;
if (channel.pipeline().get("PacketInjector") != null) {
return false;
}
channel.pipeline().addAfter("decoder", "PacketInjector", new MessageToMessageDecoder<ServerboundInteractPacket>() {
@Override
protected void decode(ChannelHandlerContext ctx, ServerboundInteractPacket msg, List<Object> out) {
out.add(msg);
PacketReceivedEvent packetReceivedEvent = new PacketReceivedEvent(msg, player);
FancyLib.getInstance().getScheduler().runTaskLater(null, 1L, packetReceivedEvent::callEvent);
}
});
return true;
}
@EventHandler
public void onPacketReceived(final PacketReceivedEvent event) {
// Skipping packets other than ServerboundInteractPacket...
if (!(event.getPacket() instanceof ServerboundInteractPacket interactPacket))
return;
// Getting NPC from entity identifier.
final Npc npc = FancyNpcsPlugin.get().getNpcManager().getNpc(interactPacket.getEntityId());
// Skipping entities that are not FancyNpcs' NPCs...
if (npc == null)
return;
// Getting interaction information.
final boolean isAttack = (interactPacket.getActionType() == ServerboundInteractPacket.ActionType.ATTACK);
final boolean isInteract = (interactPacket.getActionType() == ServerboundInteractPacket.ActionType.INTERACT_AT);
final EquipmentSlot hand = (interactPacket.getActionType() == ServerboundInteractPacket.ActionType.ATTACK)
? EquipmentSlot.HAND
: ReflectionUtils.getValue(ReflectionUtils.getValue(interactPacket, "b"), "a").toString().equals("MAIN_HAND") // ServerboundInteractPacket.InteractionAction.hand
? EquipmentSlot.HAND
: EquipmentSlot.OFF_HAND;
// This can optionally be ALSO called for OFF-HAND slot. Making sure to run logic only ONCE.
if (hand == EquipmentSlot.HAND) {
// This packet can be sent multiple times for interactions that are NOT attacks, making sure to run logic only ONCE.
if (isAttack || !isInteract || npc.getData().getType() == EntityType.ARMOR_STAND) {
npc.interact(event.getPlayer(), isAttack ? ActionTrigger.LEFT_CLICK : ActionTrigger.RIGHT_CLICK);
}
}
}
}

View File

@@ -1,13 +0,0 @@
package de.oliver.fancynpcs.v1_19_4;
import de.oliver.fancylib.ReflectionUtils;
import de.oliver.fancynpcs.api.Npc;
import net.minecraft.world.entity.Entity;
public class ReflectionHelper {
public static <T extends Entity> T getEntity(Npc npc) {
return (T) ReflectionUtils.getValue(npc, "npc");
}
}

View File

@@ -1,38 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.AgeableMob;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AgeableMobAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"baby",
List.of("true", "false"),
Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && Ageable.class.isAssignableFrom(type.getEntityClass()))
.toList(),
AgeableMobAttributes::setBaby
));
return attributes;
}
private static void setBaby(Npc npc, String value) {
AgeableMob mob = ReflectionHelper.getEntity(npc);
boolean isBaby = Boolean.parseBoolean(value);
mob.setBaby(isBaby);
}
}

View File

@@ -1,34 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.allay.Allay;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class AllayAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"dancing",
List.of("true", "false"),
List.of(EntityType.ALLAY),
AllayAttributes::setDancing
));
return attributes;
}
private static void setDancing(Npc npc, String value) {
Allay allay = ReflectionHelper.getEntity(npc);
boolean dancing = Boolean.parseBoolean(value);
allay.setDancing(dancing);
}
}

View File

@@ -1,35 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.decoration.ArmorStand;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class ArmorStandAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"show_arms",
List.of("true", "false"),
List.of(EntityType.ARMOR_STAND),
ArmorStandAttributes::setShowArms
));
return attributes;
}
private static void setShowArms(Npc npc, String value) {
ArmorStand armorStand = ReflectionHelper.getEntity(npc);
boolean showArms = Boolean.parseBoolean(value.toLowerCase());
armorStand.setShowArms(showArms);
}
}

View File

@@ -1,51 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.NpcAttribute;
import java.util.ArrayList;
import java.util.List;
public class Attributes_1_19_4 {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.addAll(EntityAttributes.getAllAttributes());
attributes.addAll(LivingEntityAttributes.getAllAttributes());
attributes.addAll(AgeableMobAttributes.getAllAttributes());
attributes.addAll(IllagerAttributes.getAllAttributes());
attributes.addAll(SpellCasterAttributes.getAllAttributes());
attributes.addAll(PlayerAttributes.getAllAttributes());
attributes.addAll(SheepAttributes.getAllAttributes());
attributes.addAll(VillagerAttributes.getAllAttributes());
attributes.addAll(FrogAttributes.getAllAttributes());
attributes.addAll(HorseAttributes.getAllAttributes());
attributes.addAll(ParrotAttributes.getAllAttributes());
attributes.addAll(AxolotlAttributes.getAllAttributes());
attributes.addAll(TropicalFishAttributes.getAllAttributes());
attributes.addAll(FoxAttributes.getAllAttributes());
attributes.addAll(PandaAttributes.getAllAttributes());
attributes.addAll(GoatAttributes.getAllAttributes());
attributes.addAll(AllayAttributes.getAllAttributes());
attributes.addAll(CamelAttributes.getAllAttributes());
attributes.addAll(RabbitAttributes.getAllAttributes());
attributes.addAll(PiglinAttributes.getAllAttributes());
attributes.addAll(CatAttributes.getAllAttributes());
attributes.addAll(ShulkerAttributes.getAllAttributes());
attributes.addAll(WolfAttributes.getAllAttributes());
attributes.addAll(SlimeAttributes.getAllAttributes());
attributes.addAll(PigAttributes.getAllAttributes());
attributes.addAll(ArmorStandAttributes.getAllAttributes());
attributes.addAll(BeeAttributes.getAllAttributes());
attributes.addAll(VexAttributes.getAllAttributes());
attributes.addAll(DisplayAttributes.getAllAttributes());
attributes.addAll(TextDisplayAttributes.getAllAttributes());
attributes.addAll(BlockDisplayAttributes.getAllAttributes());
attributes.addAll(InteractionAttributes.getAllAttributes());
return attributes;
}
}

View File

@@ -1,51 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AxolotlAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"variant",
Arrays.stream(Axolotl.Variant.values())
.map(Enum::name)
.toList(),
List.of(EntityType.AXOLOTL),
AxolotlAttributes::setVariant
));
attributes.add(new NpcAttribute(
"playing_dead",
List.of("true", "false"),
List.of(EntityType.AXOLOTL),
AxolotlAttributes::setPlayingDead
));
return attributes;
}
private static void setVariant(Npc npc, String value) {
Axolotl axolotl = ReflectionHelper.getEntity(npc);
Axolotl.Variant variant = Axolotl.Variant.valueOf(value.toUpperCase());
axolotl.setVariant(variant);
}
private static void setPlayingDead(Npc npc, String value) {
Axolotl axolotl = ReflectionHelper.getEntity(npc);
boolean playingDead = Boolean.parseBoolean(value);
axolotl.setPlayingDead(playingDead);
}
}

View File

@@ -1,84 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Bee;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class BeeAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"angry",
List.of("true", "false"),
List.of(EntityType.BEE),
BeeAttributes::setAngry
));
attributes.add(new NpcAttribute(
"sting",
List.of("true", "false"),
List.of(EntityType.BEE),
BeeAttributes::setSting
));
attributes.add(new NpcAttribute(
"nectar",
List.of("true", "false"),
List.of(EntityType.BEE),
BeeAttributes::setNectar
));
attributes.add(new NpcAttribute(
"rolling",
List.of("true", "false"),
List.of(EntityType.BEE),
BeeAttributes::setRolling
));
return attributes;
}
private static void setAngry(Npc npc, String value) {
Bee bee = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "true" -> bee.setRemainingPersistentAngerTime(1);
case "false" -> bee.setRemainingPersistentAngerTime(0);
}
}
private static void setSting(Npc npc, String value) {
Bee bee = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "true" -> bee.setHasStung(false);
case "false" -> bee.setHasStung(true);
}
}
private static void setNectar(Npc npc, String value) {
Bee bee = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "true" -> bee.setHasNectar(true);
case "false" -> bee.setHasNectar(false);
}
}
private static void setRolling(Npc npc, String value) {
Bee bee = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "true" -> bee.setRolling(true);
case "false" -> bee.setRolling(false);
}
}
}

View File

@@ -1,42 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Display;
import net.minecraft.world.level.block.Block;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.StreamSupport;
public class BlockDisplayAttributes {
private static final List<String> BLOCKS = StreamSupport.stream(Registry.MATERIAL.spliterator(), false).filter(Material::isBlock).map(it -> it.key().value()).toList();
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"block",
BLOCKS,
List.of(EntityType.BLOCK_DISPLAY),
BlockDisplayAttributes::setBlock
));
return attributes;
}
private static void setBlock(Npc npc, String value) {
Display.BlockDisplay display = ReflectionHelper.getEntity(npc);
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.of("minecraft:" + value.toLowerCase(), ':'));
display.setBlockState(block.defaultBlockState());
}
}

View File

@@ -1,46 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.camel.Camel;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class CamelAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "sitting", "dashing"),
List.of(EntityType.CAMEL),
CamelAttributes::setPose
));
return attributes;
}
private static void setPose(Npc npc, String value) {
Camel camel = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> {
camel.setDashing(false);
camel.standUp();
}
case "sitting" -> {
camel.setDashing(false);
camel.sitDown();
}
case "dashing" -> {
camel.standUp();
camel.setDashing(true);
}
}
}
}

View File

@@ -1,92 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.animal.Cat;
import net.minecraft.world.item.DyeColor;
import org.bukkit.entity.EntityType;
import org.checkerframework.checker.units.qual.N;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CatAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"variant",
Arrays.stream(org.bukkit.entity.Cat.Type.values())
.map(Enum::name)
.toList(),
List.of(EntityType.CAT),
CatAttributes::setVariant
));
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "sleeping", "sitting"),
List.of(EntityType.CAT),
CatAttributes::setPose
));
attributes.add(new NpcAttribute(
"collar_color",
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
List.of(EntityType.CAT),
CatAttributes::setCollarColor
));
return attributes;
}
private static void setVariant(Npc npc, String value) {
final Cat cat = ReflectionHelper.getEntity(npc);
BuiltInRegistries.CAT_VARIANT.getOptional(ResourceLocation.of(value.toLowerCase(), ':'))
.ifPresent(cat::setVariant);
}
private static void setPose(Npc npc, String value) {
final Cat cat = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> {
cat.setInSittingPose(false, false);
cat.setLying(false);
}
case "sleeping" -> {
cat.setInSittingPose(false, false);
cat.setLying(true);
}
case "sitting" -> {
cat.setLying(false);
cat.setOrderedToSit(true);
cat.setInSittingPose(true, false);
}
}
}
private static void setCollarColor(Npc npc, String value){
final Cat cat = ReflectionHelper.getEntity(npc);
if (value.equalsIgnoreCase("none") || value.isEmpty()){
cat.setTame(false);
return;
}
try {
DyeColor color = DyeColor.valueOf(value.toUpperCase());
if (!cat.isTame()){
cat.setTame(true);
}
cat.setCollarColor(color);
} catch (IllegalArgumentException e){
System.out.print("Invalid Color: " + value);
}
}
}

View File

@@ -1,37 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.Display;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class DisplayAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"billboard",
Arrays.stream(org.bukkit.entity.Display.Billboard.values())
.map(Enum::name)
.toList(),
List.of(EntityType.TEXT_DISPLAY, EntityType.BLOCK_DISPLAY, EntityType.ITEM_DISPLAY),
DisplayAttributes::setBillboard
));
return attributes;
}
private static void setBillboard(Npc npc, String value) {
Display display = ReflectionHelper.getEntity(npc);
Display.BillboardConstraints billboard = Display.BillboardConstraints.valueOf(value.toUpperCase());
display.setBillboardConstraints(billboard);
}
}

View File

@@ -1,103 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.Entity;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class EntityAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"on_fire",
List.of("true", "false"),
Arrays.stream(EntityType.values()).toList(),
EntityAttributes::setOnFire
));
attributes.add(new NpcAttribute(
"invisible",
List.of("true", "false"),
Arrays.stream(EntityType.values()).toList(),
EntityAttributes::setInvisible
));
attributes.add(new NpcAttribute(
"silent",
List.of("true", "false"),
Arrays.stream(EntityType.values()).toList(),
EntityAttributes::setSilent
));
attributes.add(new NpcAttribute(
"shaking",
List.of("true", "false"),
Arrays.stream(EntityType.values()).toList(),
EntityAttributes::setShaking
));
attributes.add(new NpcAttribute(
"on_ground",
List.of("true", "false"),
Arrays.stream(EntityType.values()).toList(),
EntityAttributes::setOnGround
));
/*attributes.add(new NpcAttribute(
"entity_pose",
Arrays.stream(Pose.values()).map(Enum::toString).toList(),
Arrays.stream(EntityType.values()).toList(),
EntityAttributes::setEntityPose
));*/
return attributes;
}
private static void setOnFire(Npc npc, String value) {
Entity entity = ReflectionHelper.getEntity(npc);
boolean onFire = Boolean.parseBoolean(value);
entity.setSharedFlagOnFire(onFire);
}
private static void setInvisible(Npc npc, String value) {
Entity entity = ReflectionHelper.getEntity(npc);
boolean invisible = Boolean.parseBoolean(value);
entity.setInvisible(invisible);
}
private static void setSilent(Npc npc, String value) {
Entity entity = ReflectionHelper.getEntity(npc);
boolean silent = Boolean.parseBoolean(value);
entity.setSilent(silent);
}
private static void setShaking(Npc npc, String value) {
Entity entity = ReflectionHelper.getEntity(npc);
boolean shaking = Boolean.parseBoolean(value);
entity.setTicksFrozen(shaking ? entity.getTicksRequiredToFreeze() : 0);
}
private static void setOnGround(Npc npc, String value) {
Entity entity = ReflectionHelper.getEntity(npc);
boolean onGround = Boolean.parseBoolean(value);
entity.setOnGround(onGround);
}
}

View File

@@ -1,66 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Fox;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FoxAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"type",
Arrays.stream(Fox.Type.values())
.map(Enum::name)
.toList(),
List.of(EntityType.FOX),
FoxAttributes::setType
));
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "sleeping", "sitting"),
List.of(EntityType.FOX),
FoxAttributes::setPose
));
return attributes;
}
private static void setType(Npc npc, String value) {
Fox fox = ReflectionHelper.getEntity(npc);
Fox.Type type = Fox.Type.valueOf(value.toUpperCase());
fox.setVariant(type);
}
private static void setPose(Npc npc, String value) {
Fox fox = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> {
fox.setIsCrouching(false);
fox.setSleeping(false);
fox.setSitting(false, false);
}
case "sleeping" -> {
fox.setSleeping(true);
fox.setSitting(false, false);
fox.setIsCrouching(false);
}
case "sitting" -> {
fox.setSitting(true, false);
fox.setSleeping(false);
fox.setIsCrouching(false);
}
}
}
}

View File

@@ -1,44 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.FrogVariant;
import net.minecraft.world.entity.animal.frog.Frog;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FrogAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"variant",
Arrays.stream(org.bukkit.entity.Frog.Variant.values())
.map(Enum::name)
.toList(),
List.of(EntityType.FROG),
FrogAttributes::setVariant
));
return attributes;
}
private static void setVariant(Npc npc, String value) {
Frog frog = ReflectionHelper.getEntity(npc);
FrogVariant variant;
switch (value.toUpperCase()) {
case "COLD" -> variant = FrogVariant.COLD;
case "WARM" -> variant = FrogVariant.WARM;
default -> variant = FrogVariant.TEMPERATE;
}
frog.setVariant(variant);
}
}

View File

@@ -1,44 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.goat.Goat;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class GoatAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"horns",
List.of("none", "left", "right", "both"),
List.of(EntityType.GOAT),
GoatAttributes::setHorns
));
return attributes;
}
private static void setHorns(Npc npc, String value) {
Goat goat = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "none" -> goat.removeHorns();
case "both" -> goat.addHorns();
case "left" -> {
goat.getEntityData().set(Goat.DATA_HAS_LEFT_HORN, true);
goat.getEntityData().set(Goat.DATA_HAS_RIGHT_HORN, false);
}
case "right" -> {
goat.getEntityData().set(Goat.DATA_HAS_RIGHT_HORN, true);
goat.getEntityData().set(Goat.DATA_HAS_LEFT_HORN, false);
}
}
}
}

View File

@@ -1,84 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.horse.Horse;
import net.minecraft.world.entity.animal.horse.Markings;
import net.minecraft.world.entity.animal.horse.Variant;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class HorseAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"variant",
Arrays.stream(Variant.values())
.map(Enum::name)
.toList(),
List.of(EntityType.HORSE),
HorseAttributes::setVariant
));
attributes.add(new NpcAttribute(
"markings",
Arrays.stream(Markings.values())
.map(Enum::name)
.toList(),
List.of(EntityType.HORSE),
HorseAttributes::setMarkings
));
attributes.add(new NpcAttribute(
"pose",
List.of("eating", "rearing", "standing"),
Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && (type == EntityType.HORSE || type == EntityType.DONKEY ||
type == EntityType.MULE || type == EntityType.SKELETON_HORSE ||type == EntityType.ZOMBIE_HORSE))
.toList(),
HorseAttributes::setPose
));
return attributes;
}
private static void setVariant(Npc npc, String value) {
Horse horse = ReflectionHelper.getEntity(npc);
Variant variant = Variant.valueOf(value.toUpperCase());
horse.setVariant(variant);
}
private static void setMarkings(Npc npc, String value) {
Horse horse = ReflectionHelper.getEntity(npc);
Markings markings = Markings.valueOf(value.toUpperCase());
horse.setVariantAndMarkings(horse.getVariant(), markings);
}
private static void setPose(Npc npc, String value) {
net.minecraft.world.entity.animal.horse.AbstractHorse horse = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> {
horse.setEating(false);
horse.setForceStanding(false);
}
case "rearing" -> {
horse.setForceStanding(true);
horse.setEating(false);
}
case "eating" -> {
horse.setForceStanding(false);
horse.setEating(true);
}
}
}
}

View File

@@ -1,39 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.raid.Raider;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Illager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class IllagerAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"celebrating",
List.of("true", "false"),
Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && Illager.class.isAssignableFrom(type.getEntityClass()))
.toList(),
IllagerAttributes::setCelebrating
));
return attributes;
}
private static void setCelebrating(Npc npc, String value) {
Raider raider = ReflectionHelper.getEntity(npc);
boolean isCelebrating = Boolean.parseBoolean(value);
raider.setCelebrating(isCelebrating);
}
}

View File

@@ -1,60 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.Interaction;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class InteractionAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"height",
new ArrayList<>(),
List.of(EntityType.INTERACTION),
InteractionAttributes::setHeight
));
attributes.add(new NpcAttribute(
"width",
new ArrayList<>(),
List.of(EntityType.INTERACTION),
InteractionAttributes::setWidth
));
return attributes;
}
private static void setHeight(Npc npc, String value) {
Interaction interaction = ReflectionHelper.getEntity(npc);
float height;
try {
height = Float.parseFloat(value);
} catch (NumberFormatException e) {
return;
}
interaction.setHeight(height);
}
private static void setWidth(Npc npc, String value) {
Interaction interaction = ReflectionHelper.getEntity(npc);
float width;
try {
width = Float.parseFloat(value);
} catch (NumberFormatException e) {
return;
}
interaction.setWidth(width);
}
}

View File

@@ -1,67 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.InteractionHand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class LivingEntityAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
/*attributes.add(new NpcAttribute(
"hurt",
List.of("true", "false"),
Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && LivingEntity.class.isAssignableFrom(type.getEntityClass()))
.toList(),
LivingEntityAttributes::setHurt
));*/
attributes.add(new NpcAttribute(
"use_item",
List.of("main_hand", "off_hand", "none"),
Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && LivingEntity.class.isAssignableFrom(type.getEntityClass()))
.toList(),
LivingEntityAttributes::setUseItem
));
return attributes;
}
private static void setHurt(Npc npc, String value) {
net.minecraft.world.entity.LivingEntity livingEntity = ReflectionHelper.getEntity(npc);
boolean isHurt = Boolean.parseBoolean(value);
if (isHurt) {
livingEntity.hurtDuration = 1;
livingEntity.hurtTime = 1;
livingEntity.hurtMarked = true;
livingEntity.animateHurt(0);
} else {
livingEntity.hurtDuration = 0;
livingEntity.hurtTime = 0;
livingEntity.hurtMarked = false;
}
}
private static void setUseItem(Npc npc, String value) {
net.minecraft.world.entity.LivingEntity livingEntity = ReflectionHelper.getEntity(npc);
switch (value.toUpperCase()) {
case "NONE" -> livingEntity.stopUsingItem();
case "MAIN_HAND" -> livingEntity.startUsingItem(InteractionHand.MAIN_HAND, true);
case "OFF_HAND" -> livingEntity.startUsingItem(InteractionHand.OFF_HAND, true);
}
}
}

View File

@@ -1,102 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancylib.ReflectionUtils;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.MappingKeys1_19_4;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.entity.animal.Panda;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class PandaAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"gene",
Arrays.stream(Panda.Gene.values())
.map(Enum::name)
.toList(),
List.of(EntityType.PANDA),
PandaAttributes::setGene
));
attributes.add(new NpcAttribute(
"eating",
List.of("true", "false"),
List.of(EntityType.PANDA),
PandaAttributes::setEating
));
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "sitting", "onBack", "rolling"),
List.of(EntityType.PANDA),
PandaAttributes::setPose
));
return attributes;
}
private static void setGene(Npc npc, String value) {
Panda panda = ReflectionHelper.getEntity(npc);
Panda.Gene gene = Panda.Gene.valueOf(value.toUpperCase());
panda.setMainGene(gene);
}
private static void setPose(Npc npc, String value) {
Panda panda = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> {
setFlag(panda, 8, false); //sitting
panda.roll(false);
panda.setOnBack(false);
}
case "sitting" -> {
panda.roll(false);
panda.setOnBack(false);
setFlag(panda, 8, true); //sitting
}
case "onback" -> {
setFlag(panda, 8, false); //sitting
panda.roll(false);
panda.setOnBack(true);
}
case "rolling" -> {
setFlag(panda, 8, false); //sitting
panda.setOnBack(false);
panda.roll(true);
}
}
}
private static void setEating(Npc npc, String value) {
Panda panda = ReflectionHelper.getEntity(npc);
boolean eating = Boolean.parseBoolean(value);
panda.eat(eating);
}
private static void setFlag(Panda panda, int mask, boolean value) {
EntityDataAccessor<Byte> DATA_ID_FLAGS = (EntityDataAccessor<Byte>) ReflectionUtils.getValue(panda, MappingKeys1_19_4.PANDA__DATA_ID_FLAGS.getMapping());
byte b0 = panda.getEntityData().get(DATA_ID_FLAGS);
if (value) {
panda.getEntityData().set(DATA_ID_FLAGS, (byte) (b0 | mask));
} else {
panda.getEntityData().set(DATA_ID_FLAGS, (byte) (b0 & ~mask));
}
}
}

View File

@@ -1,59 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Parrot;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ParrotAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"variant",
Arrays.stream(Parrot.Variant.values())
.map(Enum::name)
.toList(),
List.of(EntityType.PARROT),
ParrotAttributes::setVariant
));
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "sitting"),
List.of(EntityType.PARROT),
ParrotAttributes::setPose
));
return attributes;
}
private static void setVariant(Npc npc, String value) {
Parrot parrot = ReflectionHelper.getEntity(npc);
Parrot.Variant variant = Parrot.Variant.valueOf(value.toUpperCase());
parrot.setVariant(variant);
}
private static void setPose(Npc npc, String value) {
Parrot parrot = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> {
parrot.setOrderedToSit(false);
parrot.setInSittingPose(false, false);
}
case "sitting" -> {
parrot.setOrderedToSit(true);
parrot.setInSittingPose(true, false);
}
}
}
}

View File

@@ -1,35 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Pig;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class PigAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"has_saddle",
List.of("true", "false"),
List.of(EntityType.PIG),
PigAttributes::setHasSaddle
));
return attributes;
}
private static void setHasSaddle(Npc npc, String value) {
Pig pig = ReflectionHelper.getEntity(npc);
boolean hasSaddle = Boolean.parseBoolean(value.toLowerCase());
pig.steering.setSaddle(hasSaddle);
}
}

View File

@@ -1,34 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.monster.piglin.Piglin;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class PiglinAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"dancing",
List.of("true", "false"),
List.of(EntityType.PIGLIN),
PiglinAttributes::setDancing
));
return attributes;
}
private static void setDancing(Npc npc, String value) {
Piglin piglin = ReflectionHelper.getEntity(npc);
boolean dancing = Boolean.parseBoolean(value);
piglin.setDancing(dancing);
}
}

View File

@@ -1,40 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancylib.ReflectionUtils;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class PlayerAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "crouching", "sleeping", "swimming", "sitting"),
List.of(EntityType.PLAYER),
PlayerAttributes::setPose
));
return attributes;
}
private static void setPose(Npc npc, String value) {
Player player = ReflectionHelper.getEntity(npc);
Pose pose = Pose.valueOf(value.toUpperCase());
EntityDataAccessor<Pose> DATA_POSE = (EntityDataAccessor<Pose>) ReflectionUtils.getStaticValue(Entity.class, "ar"); // DATA_POSE
player.getEntityData().set(DATA_POSE, pose);
}
}

View File

@@ -1,37 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Rabbit;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class RabbitAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"variant",
Arrays.stream(Rabbit.Variant.values())
.map(Enum::name)
.toList(),
List.of(EntityType.RABBIT),
RabbitAttributes::setVariant
));
return attributes;
}
private static void setVariant(Npc npc, String value) {
Rabbit rabbit = ReflectionHelper.getEntity(npc);
Rabbit.Variant variant = Rabbit.Variant.valueOf(value.toUpperCase());
rabbit.setVariant(variant);
}
}

View File

@@ -1,50 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Sheep;
import net.minecraft.world.item.DyeColor;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SheepAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"wool_color",
Arrays.stream(DyeColor.values()).map(dyeColor -> dyeColor.name().toLowerCase()).toList(),
List.of(EntityType.SHEEP),
SheepAttributes::setColor
));
attributes.add(new NpcAttribute(
"sheared",
Arrays.asList("true", "false"),
List.of(EntityType.SHEEP),
SheepAttributes::setSheared
));
return attributes;
}
private static void setColor(Npc npc, String value) {
Sheep sheep = ReflectionHelper.getEntity(npc);
sheep.setColor(DyeColor.byName(value.toLowerCase(), DyeColor.WHITE));
}
private static void setSheared(Npc npc, String value) {
Sheep sheep = ReflectionHelper.getEntity(npc);
boolean sheared = Boolean.parseBoolean(value);
sheep.setSheared(sheared);
}
}

View File

@@ -1,55 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.monster.Shulker;
import net.minecraft.world.item.DyeColor;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
public class ShulkerAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"color",
Arrays.stream(DyeColor.values())
.map(Enum::name)
.toList(),
List.of(EntityType.SHULKER),
ShulkerAttributes::setColor
));
attributes.add(new NpcAttribute(
"shield",
List.of("open", "closed"),
List.of(EntityType.SHULKER),
ShulkerAttributes::setShield
));
return attributes;
}
private static void setColor(Npc npc, String value) {
Shulker shulker = ReflectionHelper.getEntity(npc);
DyeColor color = DyeColor.byName(value.toLowerCase(), DyeColor.PURPLE);
shulker.setVariant(Optional.of(color));
}
private static void setShield(Npc npc, String value) {
Shulker shulker = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "closed" -> shulker.setRawPeekAmount(0);
case "open" -> shulker.setRawPeekAmount(Byte.MAX_VALUE);
}
}
}

View File

@@ -1,40 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.monster.Slime;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class SlimeAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"size",
new ArrayList<>(),
List.of(EntityType.SLIME),
SlimeAttributes::setSize
));
return attributes;
}
private static void setSize(Npc npc, String value) {
Slime slime = ReflectionHelper.getEntity(npc);
int size;
try {
size = Integer.parseInt(value);
} catch (NumberFormatException e) {
return;
}
slime.setSize(size, false);
}
}

View File

@@ -1,39 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.monster.SpellcasterIllager;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Spellcaster;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SpellCasterAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"casting",
Arrays.stream(SpellcasterIllager.IllagerSpell.values()).map(Enum::toString).toList(),
Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && Spellcaster.class.isAssignableFrom(type.getEntityClass()))
.toList(),
SpellCasterAttributes::setPose
));
return attributes;
}
private static void setPose(Npc npc, String value) {
SpellcasterIllager spellcasterIllager = ReflectionHelper.getEntity(npc);
SpellcasterIllager.IllagerSpell spell = SpellcasterIllager.IllagerSpell.valueOf(value);
spellcasterIllager.setIsCastingSpell(spell);
}
}

View File

@@ -1,36 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import io.papermc.paper.adventure.PaperAdventure;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.world.entity.Display;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class TextDisplayAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"text",
new ArrayList<>(),
List.of(EntityType.TEXT_DISPLAY),
TextDisplayAttributes::setText
));
return attributes;
}
private static void setText(Npc npc, String value) {
Display.TextDisplay display = ReflectionHelper.getEntity(npc);
Component text = MiniMessage.miniMessage().deserialize(value);
display.setText(PaperAdventure.asVanilla(text));
}
}

View File

@@ -1,72 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.TropicalFish;
import net.minecraft.world.item.DyeColor;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TropicalFishAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"pattern",
Arrays.stream(TropicalFish.Pattern.values())
.map(Enum::name)
.toList(),
List.of(EntityType.TROPICAL_FISH),
TropicalFishAttributes::setPattern
));
attributes.add(new NpcAttribute(
"base_color",
Arrays.stream(DyeColor.values())
.map(Enum::name)
.toList(),
List.of(EntityType.TROPICAL_FISH),
TropicalFishAttributes::setBaseColor
));
attributes.add(new NpcAttribute(
"pattern_color",
Arrays.stream(DyeColor.values())
.map(Enum::name)
.toList(),
List.of(EntityType.TROPICAL_FISH),
TropicalFishAttributes::setPatternColor
));
return attributes;
}
private static void setPattern(Npc npc, String value) {
TropicalFish tropicalFish = ReflectionHelper.getEntity(npc);
TropicalFish.Pattern pattern = TropicalFish.Pattern.valueOf(value.toUpperCase());
tropicalFish.setVariant(pattern);
}
private static void setBaseColor(Npc npc, String value) {
TropicalFish tropicalFish = ReflectionHelper.getEntity(npc);
DyeColor color = DyeColor.byName(value.toLowerCase(), DyeColor.WHITE);
TropicalFish.Variant variant = new TropicalFish.Variant(tropicalFish.getVariant(), color, tropicalFish.getPatternColor());
tropicalFish.setPackedVariant(variant.getPackedId());
}
private static void setPatternColor(Npc npc, String value) {
TropicalFish tropicalFish = ReflectionHelper.getEntity(npc);
DyeColor color = DyeColor.byName(value.toLowerCase(), DyeColor.WHITE);
TropicalFish.Variant variant = new TropicalFish.Variant(tropicalFish.getVariant(), tropicalFish.getBaseColor(), color);
tropicalFish.setPackedVariant(variant.getPackedId());
}
}

View File

@@ -1,36 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.monster.Vex;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class VexAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"charging",
List.of("true", "false"),
List.of(EntityType.VEX),
VexAttributes::setCharging
));
return attributes;
}
private static void setCharging(Npc npc, String value) {
Vex vex = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "true" -> vex.setIsCharging(true);
case "false" -> vex.setIsCharging(false);
}
}
}

View File

@@ -1,86 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerType;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class VillagerAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"profession",
Arrays.stream(org.bukkit.entity.Villager.Profession.values())
.map(Enum::name)
.toList(),
List.of(EntityType.VILLAGER),
VillagerAttributes::setProfession
));
attributes.add(new NpcAttribute(
"type",
Arrays.stream(org.bukkit.entity.Villager.Type.values())
.map(Enum::name)
.toList(),
List.of(EntityType.VILLAGER),
VillagerAttributes::setType
));
return attributes;
}
private static void setProfession(Npc npc, String value) {
Villager villager = ReflectionHelper.getEntity(npc);
VillagerProfession profession;
switch (value.toUpperCase()) {
case "ARMORER" -> profession = VillagerProfession.ARMORER;
case "BUTCHER" -> profession = VillagerProfession.BUTCHER;
case "CARTOGRAPHER" -> profession = VillagerProfession.CARTOGRAPHER;
case "CLERIC" -> profession = VillagerProfession.CLERIC;
case "FARMER" -> profession = VillagerProfession.FARMER;
case "FISHERMAN" -> profession = VillagerProfession.FISHERMAN;
case "FLETCHER" -> profession = VillagerProfession.FLETCHER;
case "LEATHERWORKER" -> profession = VillagerProfession.LEATHERWORKER;
case "LIBRARIAN" -> profession = VillagerProfession.LIBRARIAN;
case "MASON" -> profession = VillagerProfession.MASON;
case "NITWIT" -> profession = VillagerProfession.NITWIT;
case "SHEPHERD" -> profession = VillagerProfession.SHEPHERD;
case "TOOLSMITH" -> profession = VillagerProfession.TOOLSMITH;
case "WEAPONSMITH" -> profession = VillagerProfession.WEAPONSMITH;
default -> profession = VillagerProfession.NONE;
}
villager.setVillagerData(villager.getVillagerData().setProfession(profession));
}
private static void setType(Npc npc, String value) {
Villager villager = ReflectionHelper.getEntity(npc);
VillagerType type;
switch (value.toUpperCase()) {
case "DESERT" -> type = VillagerType.DESERT;
case "JUNGLE" -> type = VillagerType.JUNGLE;
case "SAVANNA" -> type = VillagerType.SAVANNA;
case "SNOW" -> type = VillagerType.SNOW;
case "SWAMP" -> type = VillagerType.SWAMP;
case "TAIGA" -> type = VillagerType.TAIGA;
default -> type = VillagerType.PLAINS;
}
villager.setVillagerData(villager.getVillagerData().setType(type));
}
}

View File

@@ -1,79 +0,0 @@
package de.oliver.fancynpcs.v1_19_4.attributes;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
import net.minecraft.world.entity.animal.Wolf;
import org.apache.commons.io.IOExceptionList;
import net.minecraft.world.item.DyeColor;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class WolfAttributes {
public static List<NpcAttribute> getAllAttributes() {
List<NpcAttribute> attributes = new ArrayList<>();
attributes.add(new NpcAttribute(
"pose",
List.of("standing", "sitting"),
List.of(EntityType.WOLF),
WolfAttributes::setPose
));
attributes.add(new NpcAttribute(
"angry",
List.of("true", "false"),
List.of(EntityType.WOLF),
WolfAttributes::setAngry
));
attributes.add(new NpcAttribute(
"collar_color",
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
List.of(EntityType.WOLF),
WolfAttributes::setCollarColor
));
return attributes;
}
private static void setPose(Npc npc, String value) {
Wolf wolf = ReflectionHelper.getEntity(npc);
switch (value.toLowerCase()) {
case "standing" -> wolf.setInSittingPose(false, false);
case "sitting" -> wolf.setInSittingPose(true, false);
}
}
private static void setAngry(Npc npc, String value) {
Wolf wolf = ReflectionHelper.getEntity(npc);
boolean angry = Boolean.parseBoolean(value.toLowerCase());
wolf.setRemainingPersistentAngerTime(angry ? 100 : 0);
}
private static void setCollarColor(Npc npc, String value) {
Wolf wolf = ReflectionHelper.getEntity(npc);
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
// Reset to no collar
wolf.setTame(false);
return;
}
try {
DyeColor color = DyeColor.valueOf(value.toUpperCase());
if (!wolf.isTame()){
wolf.setTame(true);
}
wolf.setCollarColor(color);
} catch (IllegalArgumentException e) {
System.out.println("Invalid wolf collar color: " + value);
}
}
}

View File

@@ -5,7 +5,6 @@
"changelog_path": "../../../../plugins/fancynpcs/CHANGELOG.md",
"version_path": "../../../../plugins/fancynpcs/VERSION",
"supported_versions": [
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",

View File

@@ -5,7 +5,6 @@
"changelog_path": "../../../../plugins/fancynpcs/CHANGELOG-SNAPSHOT.md",
"version_path": "../../../../plugins/fancynpcs/VERSION",
"supported_versions": [
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",

View File

@@ -2,7 +2,6 @@ package de.oliver.fancynpcs;
import de.oliver.fancynpcs.api.AttributeManager;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.v1_19_4.attributes.Attributes_1_19_4;
import de.oliver.fancynpcs.v1_20_1.attributes.Attributes_1_20_1;
import de.oliver.fancynpcs.v1_20_2.attributes.Attributes_1_20_2;
import de.oliver.fancynpcs.v1_20_4.attributes.Attributes_1_20_4;
@@ -43,7 +42,6 @@ public class AttributeManagerImpl implements AttributeManager {
case "1.20.3", "1.20.4" -> attributes = Attributes_1_20_4.getAllAttributes();
case "1.20.2" -> attributes = Attributes_1_20_2.getAllAttributes();
case "1.20.1", "1.20" -> attributes = Attributes_1_20_1.getAllAttributes();
case "1.19.4" -> attributes = Attributes_1_19_4.getAllAttributes();
}
}

View File

@@ -45,8 +45,6 @@ import de.oliver.fancynpcs.tests.PlaceholderApiEnv;
import de.oliver.fancynpcs.tracker.TurnToPlayerTracker;
import de.oliver.fancynpcs.tracker.VisibilityTracker;
import de.oliver.fancynpcs.utils.OldSkinCacheMigrator;
import de.oliver.fancynpcs.v1_19_4.Npc_1_19_4;
import de.oliver.fancynpcs.v1_19_4.PacketReader_1_19_4;
import de.oliver.fancynpcs.v1_20.PacketReader_1_20;
import de.oliver.fancynpcs.v1_20_1.Npc_1_20_1;
import de.oliver.fancynpcs.v1_20_2.Npc_1_20_2;
@@ -177,7 +175,6 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
case "1.20.3", "1.20.4" -> npcAdapter = Npc_1_20_4::new;
case "1.20.2" -> npcAdapter = Npc_1_20_2::new;
case "1.20.1", "1.20" -> npcAdapter = Npc_1_20_1::new;
case "1.19.4" -> npcAdapter = Npc_1_19_4::new;
default -> npcAdapter = null;
}
@@ -194,7 +191,7 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
fancyLogger.error("Unsupported minecraft server version.");
getLogger().warning("--------------------------------------------------");
getLogger().warning("Unsupported minecraft server version.");
getLogger().warning("This plugin only supports 1.19.4 - 1.21.11");
getLogger().warning("This plugin only supports 1.20- 1.21.11");
getLogger().warning("Disabling the FancyNpcs plugin.");
getLogger().warning("--------------------------------------------------");
pluginManager.disablePlugin(this);
@@ -286,7 +283,6 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
// use packet injection method
switch (mcVersion) {
case "1.19.4" -> pluginManager.registerEvents(new PacketReader_1_19_4(), instance);
case "1.20" -> pluginManager.registerEvents(new PacketReader_1_20(), instance);
default -> pluginManager.registerEvents(new PlayerUseUnknownEntityListener(), instance);
}

View File

@@ -4,7 +4,6 @@ import com.destroystokyo.paper.profile.ProfileProperty;
import de.oliver.fancynpcs.FancyNpcs;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.skins.SkinData;
import de.oliver.fancynpcs.v1_19_4.PacketReader_1_19_4;
import de.oliver.fancynpcs.v1_20.PacketReader_1_20;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
@@ -16,9 +15,7 @@ public class PlayerJoinListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
String mcVersion = Bukkit.getMinecraftVersion();
if (mcVersion.equals("1.19.4")) {
PacketReader_1_19_4.inject(event.getPlayer());
} else if (mcVersion.equals("1.20")) {
if (mcVersion.equals("1.20")) {
PacketReader_1_20.inject(event.getPlayer());
}

View File

@@ -14,14 +14,12 @@ include(":plugins:fancynpcs:implementation_1_20_4")
include(":plugins:fancynpcs:implementation_1_20_2")
include(":plugins:fancynpcs:implementation_1_20_1")
include(":plugins:fancynpcs:implementation_1_20")
include(":plugins:fancynpcs:implementation_1_19_4")
include(":plugins:fancyholograms-v2")
include(":plugins:fancyholograms-v2:api")
include(":plugins:fancyholograms-v2:implementation_1_20_4")
include(":plugins:fancyholograms-v2:implementation_1_20_2")
include(":plugins:fancyholograms-v2:implementation_1_20_1")
include(":plugins:fancyholograms-v2:implementation_1_19_4")
include(":plugins:fancyholograms")
include(":plugins:fancyholograms:fh-api")