diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b32c976..482e564 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,13 @@
-
+
+
+
+
+
+
+
@@ -64,9 +70,12 @@
+
+
+
@@ -87,39 +96,39 @@
- {
- "keyToString": {
- "Downloaded.Files.Path.Enabled": "false",
- "Gradle.Build EntityLib.executor": "Run",
- "Gradle.EntityLib [dependencies].executor": "Run",
- "Gradle.EntityLib [publish].executor": "Run",
- "Gradle.EntityLib:code-gen [:code-gen:Main.main()].executor": "Run",
- "Gradle.EntityLib:test-plugin [publish].executor": "Run",
- "Gradle.EntityLib:test-plugin [runServer].executor": "Run",
- "Gradle.EntityLib:test-plugin [shadowJar].executor": "Run",
- "Repository.Attach.Annotations": "false",
- "Repository.Attach.JavaDocs": "false",
- "Repository.Attach.Sources": "false",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "WebServerToolWindowFactoryState": "false",
- "git-widget-placeholder": "master",
- "ignore.virus.scanning.warn.message": "true",
- "jdk.selected.JAVA_MODULE": "corretto-17",
- "kotlin-language-version-configured": "true",
- "last_opened_file_path": "D:/Github/EntityLib/api/src/main/java/me/tofaa/entitylib/extras",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "project.structure.last.edited": "Project",
- "project.structure.proportion": "0.15",
- "project.structure.side.proportion": "0.2",
- "settings.editor.selected.configurable": "preferences.pluginManager",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
@@ -312,6 +321,12 @@
+
+
+
+
+
+
diff --git a/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java b/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
index 8d58ddc..ad32f32 100644
--- a/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
+++ b/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
@@ -13,11 +13,13 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEn
import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.extras.InvalidVersionException;
import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
@@ -111,6 +113,18 @@ public class EntityMeta implements EntityMetadataProvider {
return getMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT);
}
+ public boolean isGlowing() {
+ return hasGlowingEffect();
+ }
+
+ public void setHasGlowingEffect(boolean value) {
+ setMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT, value);
+ }
+
+ public void setGlowing(boolean value) {
+ setHasGlowingEffect(value);
+ }
+
public boolean isSwimming() {
return getMaskBit(OFFSET, SWIMMING_BIT);
}
@@ -119,10 +133,6 @@ public class EntityMeta implements EntityMetadataProvider {
setMaskBit(OFFSET, SWIMMING_BIT, value);
}
- public void setHasGlowingEffect(boolean value) {
- setMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT, value);
- }
-
public boolean isFlyingWithElytra() {
return getMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT);
}
@@ -140,11 +150,12 @@ public class EntityMeta implements EntityMetadataProvider {
}
public Component getCustomName() {
- return this.metadata.getIndex(customNameOffset(), null);
+ Optional component = this.metadata.getIndex(customNameOffset(), null);
+ return component.orElse(null);
}
public void setCustomName(Component value) {
- this.metadata.setIndex(customNameOffset(), EntityDataTypes.ADV_COMPONENT, value);
+ this.metadata.setIndex(customNameOffset(), EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value));
}
public boolean isCustomNameVisible() {
diff --git a/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java b/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java
index 31177c2..d42f79e 100644
--- a/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java
+++ b/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java
@@ -1,5 +1,9 @@
package me.tofaa.entitylib.wrapper;
+import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
+import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType;
+import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
+import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
import com.github.retrooper.packetevents.protocol.player.User;
import com.github.retrooper.packetevents.protocol.world.Location;
@@ -44,7 +48,6 @@ public class WrapperEntity implements Tickable, TrackedEntity {
this.passengers = ConcurrentHashMap.newKeySet();
}
-
public boolean spawn(Location location) {
if (spawned) return false;
this.location = location;
diff --git a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/InternalRegistryListener.java b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/InternalRegistryListener.java
index 80c3cd4..8334b97 100644
--- a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/InternalRegistryListener.java
+++ b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/InternalRegistryListener.java
@@ -28,6 +28,7 @@ final class InternalRegistryListener extends PacketListenerAbstract implements L
public void onPacketSend(PacketSendEvent event) {
final User user = event.getUser();
final PacketTypeCommon type = event.getPacketType();
+
if (type == PacketType.Play.Server.DESTROY_ENTITIES) {
WrapperPlayServerDestroyEntities packet = new WrapperPlayServerDestroyEntities(event);
int[] ids = packet.getEntityIds();
diff --git a/test-plugin/src/main/java/me/tofaa/testentitylib/TestPlayerCommand.java b/test-plugin/src/main/java/me/tofaa/testentitylib/TestPlayerCommand.java
index accfc0d..a3adc94 100644
--- a/test-plugin/src/main/java/me/tofaa/testentitylib/TestPlayerCommand.java
+++ b/test-plugin/src/main/java/me/tofaa/testentitylib/TestPlayerCommand.java
@@ -38,37 +38,39 @@ public class TestPlayerCommand extends BukkitCommand {
return false;
}
String arg = strings[0].toLowerCase();
- if (arg.equals("spawn")) {
- UserProfile profile = new UserProfile(UUID.randomUUID(), "randomname", new ArrayList<>());
- p = new WrapperPlayer(profile, EntityLib.getPlatform().getEntityIdProvider().provide(profile.getUUID(), EntityTypes.PLAYER));
- p.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
- p.addViewer(player.getUniqueId());
- ItemStack stack = ItemStack.builder().type(ItemTypes.DIAMOND_BOOTS).build();
- p.getEquipment().setBoots(stack);
- }
- else if (arg.equals( "texture")) {
- p.setTextureProperties(ExtraConversionUtil.getProfileFromBukkitPlayer(player).getTextureProperties());
- player.sendMessage("texture");
- }
- else if (arg.equals( "ping")) {
- p.setLatency(1000);
- player.sendMessage("Pong");
- }
- else if (arg.equals( "gamemode")) {
- p.setGameMode(GameMode.CREATIVE);
- player.sendMessage("Gamemode set to creative");
- }
- else if (arg.equals( "displayname")) {
- p.setDisplayName(Component.text("Hello"));
- player.sendMessage("Display name set to Hello");
- }
- else if (arg.equals( "tablist")) {
- p.setInTablist(!p.isInTablist());
- player.sendMessage("Tablist " + (p.isInTablist() ? "enabled" : "disabled"));
- }
- else if (arg.equals("remove")) {
- p.remove();
- player.sendMessage("Entity removed");
+ switch (arg) {
+ case "spawn":
+ UserProfile profile = new UserProfile(UUID.randomUUID(), "randomname", new ArrayList<>());
+ p = new WrapperPlayer(profile, EntityLib.getPlatform().getEntityIdProvider().provide(profile.getUUID(), EntityTypes.PLAYER));
+ p.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
+ p.addViewer(player.getUniqueId());
+ ItemStack stack = ItemStack.builder().type(ItemTypes.DIAMOND_BOOTS).build();
+ p.getEquipment().setBoots(stack);
+ break;
+ case "texture":
+ p.setTextureProperties(ExtraConversionUtil.getProfileFromBukkitPlayer(player).getTextureProperties());
+ player.sendMessage("texture");
+ break;
+ case "ping":
+ p.setLatency(1000);
+ player.sendMessage("Pong");
+ break;
+ case "gamemode":
+ p.setGameMode(GameMode.CREATIVE);
+ player.sendMessage("Gamemode set to creative");
+ break;
+ case "displayname":
+ p.setDisplayName(Component.text("Hello"));
+ player.sendMessage("Display name set to Hello");
+ break;
+ case "tablist":
+ p.setInTablist(!p.isInTablist());
+ player.sendMessage("Tablist " + (p.isInTablist() ? "enabled" : "disabled"));
+ break;
+ case "remove":
+ p.remove();
+ player.sendMessage("Entity removed");
+ break;
}
return true;
}
@@ -77,7 +79,7 @@ public class TestPlayerCommand extends BukkitCommand {
@Override
public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
if (args.length == 1) {
- return Arrays.asList(new String[]{"spawn", "texture", "ping", "gamemode", "displayname", "tablist", "remove"});
+ return Arrays.asList("spawn", "texture", "ping", "gamemode", "displayname", "tablist", "remove", "sneak");
}
return Collections.emptyList();
}
diff --git a/test-plugin/src/main/java/me/tofaa/testentitylib/TestTextDisplayCommand.java b/test-plugin/src/main/java/me/tofaa/testentitylib/TestTextDisplayCommand.java
index e547767..641bec3 100644
--- a/test-plugin/src/main/java/me/tofaa/testentitylib/TestTextDisplayCommand.java
+++ b/test-plugin/src/main/java/me/tofaa/testentitylib/TestTextDisplayCommand.java
@@ -4,6 +4,7 @@ import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.meta.display.TextDisplayMeta;
+import me.tofaa.entitylib.meta.mobs.passive.PigMeta;
import me.tofaa.entitylib.wrapper.WrapperEntity;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
@@ -24,18 +25,15 @@ public class TestTextDisplayCommand extends BukkitCommand {
if (!(commandSender instanceof Player)) return true;
Player player = (Player) commandSender;
if (e == null) {
- e = EntityLib.getApi().createEntity(EntityTypes.TEXT_DISPLAY);
- if (e == null) {
- player.sendMessage("Failed to spawn entity");
- return true;
- }
+ e = EntityLib.getApi().createEntity(EntityTypes.PIG);
e.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
e.addViewer(player.getUniqueId());
player.sendMessage("Spawned");
}
String msg = String.join(" ", strings);
- TextDisplayMeta meta = (TextDisplayMeta) e.getEntityMeta();
- meta.setText(Component.text(msg));
+ PigMeta meta = (PigMeta) e.getEntityMeta();
+ meta.setCustomNameVisible(true);
+ meta.setCustomName(Component.text(msg));
player.sendMessage("Set text to: " + msg);
return true;
}