EssentialsX

EssentialsX

2M Downloads

give spawn_egg show null in minecraft chat

l12436 opened this issue · 11 comments

commented

This BUG is trigger by the EntityType that pass to SpawnEggRefl is possible null.
cause set type crash.
I fix it by add a if at SpawnEggRefl.java:98 and variable relative it.

EssentialsX version (/essentials):
2.0.1-bSNAPSHOT
Server software (/version):
This server is running CraftBukkit version git-Spigot-00128b5-d063cd0 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
Server (logs/latest.log):
https://gist.github.com/l12436/c3cad99ec2b08043e565710fd8ff939f
EssentialsX config (if applicable):

commented

@l12436 What's the command you use to get the error?

commented

/give minecraft:spawn_egg 1 0 {EntityTag:{id:"minecraft:villager"}}

commented

@l12436 Try to update to the recent builds of EssentialsX.
While this command doesn't execute successfully for me (it says "Error: null"), the data values work for getting the spawn egg. It's possible that there needs to be a re-evaluation of this for spawn eggs. I'm not entirely sure that the command will provide support for JSON, though.

If you need to, you can utilize /minecraft:give to successfully execute your command.

commented

I already know why and where the BUG is, and have patched by myself, Did I need to offer that patch that I fixed?
As I remembered, this BUG also occur when I did not add data, (aka. /give minecraft:spawn_egg 1 0)

commented

@l12436 Feel free to submit a pull request if you feel that you've fixed the issue.

commented

@l12436 Do you still have your patch for this issue?

commented

Sorry for the late response.

You can try this patch,I extract from my commit. This should be the fix of spawnegg null issue.

diff --git b/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java a/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java
index 186b031f..acbaf338 100644
--- b/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java
+++ a/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java
@@ -94,12 +94,14 @@ public class SpawnEggRefl {
         Object id = NBTTagCompoundConstructor.newInstance();
         Method tagSetString = ReflUtil.getMethodCached(NBTTagCompoundClass, "setString", String.class, String.class);
         
-        String idString = type.getName();
-        if (ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_11_R1)) {
-            // 1.11 requires domain prefix of minecraft.
-            idString = "minecraft:" + idString;
+        if (type != null) {
+	        String idString = type.getName();
+	        if (ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_11_R1)) {
+	            // 1.11 requires domain prefix of minecraft.
+	            idString = "minecraft:" + idString;
+	        }
+	        tagSetString.invoke(id, "id", idString);
         }
-        tagSetString.invoke(id, "id", idString);
 
         Method tagSetTag = ReflUtil.getMethodCached(NBTTagCompoundClass, "set", String.class, NBTTagCompoundClass.getSuperclass());
         tagSetTag.invoke(tagCompound, "EntityTag", id);
commented

I can't replicate this on current builds of EssentialsX with 1.8.8.

commented

I almost forget I have submit this issue before.

the new command that is tested.
/give player minecraft:spawn_egg 1 0 {EntityTag:{id:"minecraft:rabbit"}}

EssentialsX version (/essentials):
[21:46:13 INFO]: EssentialsX 2.17.1.16
Server software (/version):
This server is running CraftBukkit version git-Spigot-e8ded36-acbc348 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT

now the error become no item name as spawn_egg. I need to use monster_egg to spawn it.
image
and if I change to monster_egg, the error appear
image
image

Hope this will help you

commented

As far as I know, if you use NBT then the SpawnEggProvider shouldn't even be involved. The providers aren't necessary when you use NBT, so it looks like the provider is being called when it shouldn't be. If anyone could look into this, I'd appreciate it - I'm a bit busy at the moment.

commented

Unable to reproduce this issue. If it's still present, please feel free to make a PR for it (or explain how it can be replicated on a newer version of Essentials).