Just a few questions...

Discussion in 'Plugin Development' started by Zaros, Oct 28, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Zaros

    Alright. My first question is simple. How do you get mobs within a certain radius and kill them(no drops).
    ---------------------------------------------
    Second question: PlayerChatEvent
    I want to be able to grab variables out of the chat relative to a specific key term. For example

    "I am going to ban Zaros for Hacking"

    Looking for the keyword ban, I want to grab the word after it and the third word after it("Zaros" and "Hacking")
    ---------------------------------------------
    Third question should be very simple:

    Some users want my plugin eMob to have multiworld support. After doing a little research, I learned from the wiki that "... mobs have a spawning cycle once every game tick (1/20th of a second)". If I am reading this correctly, that means that approximately 20 creatures spawn every second. Now considering multiworld support. If one world has 20~ creatures spawning a second, couldn't checking 3-5 world become extremely laggy/intense?

    Edit: Formatted to please my OCD.
     
  2. A radius starting from...?
    Hint: Split the String...
    I don't know about mob spawning rate, but your plugin still checks all mobs in all worlds... What your users want is a per-world configuration, because right now the configuration is the same for all worlds.
     
  3. Offline

    Zaros

    1: Radius starting from the player position.

    2:
    Code:java
    1. String chattext = "I am going to ban Zaros for Hacking";
    2. String delims = "[ ]";
    3. String[] tokens = chattext.split(delims);

    Then tokens[6] & tokens[8]? Still new(er) to Java.


    3: Ah I see now. They want control over world checks to decrease lag/gain seperate control. It wouldn't hurt anymore than it does now... *facepalm*
     
  4. 1. player.getNearbyEntites(...) (I believe) You of course need to filter if the entity is instanceof a Mob.
    2. just do .split(" "). Without brackets.
    3. There aren't actually spawning 20 mobs, that would be huge. It is just that at every tick, it is attempted to spawn a mob at a random position (with limitations of maximum amount, then the frequency somehow decreases).
    Now since most of the world consists of either solid stone or lots of air without ground, it fails most of the time.
    CreateSpawnEvent is only fired when spawning succeeded.
     
  5. Offline

    Zaros

    1: So filter them out by checking if 'Entity instanceof Mob' is true.

    2: So just String[] tokens = chattext.split(" ");

    3: Ahh I see. 20 is the max mob spawn attempts per second, but the actual spawn rate is much much lower. Really worried about lag with my plugin, but seeing as it already controls all worlds together it could only be improved.
     
Thread Status:
Not open for further replies.

Share This Page