1.14.4 Custom Summon Command

Discussion in 'Spigot Plugin Development' started by Th3Wh1teG0d, Jan 24, 2020.

  1. Hello, i want to create a Command where you can Spawn All Entitys and you can enter an amount.

    Example:

    /sm list -> Shows a List of all Entitys
    /sm <EntityName> <Amount> -> Spawns Entitys
    /sm remove <Radius> -> Removes all Entitys in the Following Radius

    The thing is i dont know How to send the Player a list of all Entitys (Example Viedeo (4:47)) and i dont know how to make that the player really removes the Entitys in this Radius.

    Thanks to all Helps.
     
  2. 1) get a List of Entities:
    Code (Java):
    Player#getNearbyEntities(x, y, z);
    2) remove entities:
    Code (Java):
    nearbyEntities.forEach(Entity::remove);
     
  3. I dont want to get Nearby Entitys i want to get a list of all aviable entitys in minecraft like in the example viedeo
     
  4. Code (Text):
    EntityType.values()
    ?
     
  5. In this viedeo he uses this:

    Code (Java):

     String text = ""; byte b; int i; EnumParticle[] arrayOfEnumParticle;
        for (i = (arrayOfEnumParticle = EnumParticle.values()).length, b = 0; b < i; ) { EnumParticle pa = arrayOfEnumParticle[b];
          if (text.equals("")) {
            text = pa.name();
          } else {
            text = String.valueOf(text) + ", " + pa.name();
          }  b++; }
     
    And i want to use it like this but instead of Particle names Entity Names
     
  6. yes, EntityType.values() is what you are looking for
     
  7. You need to wrap it using Arrays#toString to print a readable String:
    Code (Java):
    p.sendMessage("Entity Liste: " + Arrays.toString(EntityType.values()));
     
  8. I got it, but i have thinked i know how to spawn the Entity that i Type in the chat but i dont know it makes an error and how does i set the amount ?

    I have used this: p.getWorld().spawnEntity(p.getLocation(), args[0]);
     
  9. To the best of my knowledge you need to loop however many times you'd like to spawn entities. Also you need to cast args[0] to an EntityType (or Entity, forget which offhand)
     
    #10 darthteddy1, Jan 24, 2020
    Last edited: Jan 24, 2020
  10. EntityType entity = args[0];
    p.getWorld().spawnEntity(p.getLocation(), entity);

    Eclipse tell me: Type mismatch: cannot convert from String to EntityType
     
  11. You need to cast it to an EntityType (or Entity, again forget which offhand). You cannot set an EntityType = to a string. I recommend you take a basic Java course and look through this thread too
     
  12. Casting is a bad idea. Use EntityType#valueOf
     
    • Agree Agree x 1
  13. Can you please tell me what i can do that this is goind to function
     
  14. This^

    What I meant but no idea why I wrote cast lmao
     
  15. *Sigh* there's everything you need already here...
    Code (Java):
    p.getWorld().spawnEntity(p.getLocation(), EntityType.valueOf(args[0]));
     
  16. Ok a BIG thanks for that! :D
    Now i have a problem. I looked over the Javadoc and im not able to find a way to define the amount of entitys that be spawn.
     
  17. Sorry for that we post it at the same time ^^
     
  18. You need to make a for loop with the spawn entity code in it
     
    • Agree Agree x 1
  19. Sorry for the dumb question but how do i do a loop for a certain amount of times ?