Listener per world

Discussion in 'Plugin Development' started by bars96, Jun 28, 2014.

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

    bars96

    Hello forum members, I have a question: how to separate plugin listeners per world without heavy load and small lags? I will glad to see your answers. Thanks!
     
  2. Offline

    NoLiver92

    Sorry im a bit confused, what are you trying to do?
     
  3. Offline

    Gerov

    I think he means a listener to listen for a certain event or events in each world.
     
    bars96 likes this.
  4. Offline

    bars96

    Yes. It is.

    For example, WorldListener.java, NetherListener.java, EndListener.java, MyCustomWorldListener.java, etc.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    1Rogue

    just compare the world type within the event:

    Code:java
    1. public void onEvent(YourWorldRelatedEvent event) {
    2. World w = /* get world from event */;
    3. if (w.getEnvironment() == World.Environment.NETHER) { //for example
    4. //do rest of event
    5. }
    6. }
     
  6. Offline

    Gerov

    I think you could do that.

    Define the listeners like

    public WorldListener wl = new WorldListener();

    public NetherListener nl = new NetherListener();

    public EndListener el = new EndListener();


    And then register the events and in each listener make sure the event takes place in the right world.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  7. Offline

    bars96

    I make server with own mini-games and I don't understand how to do it with less CPU/RAM usage. How I can do this? This is what I came up with:
    1. BungeeCord/LilyPad:you're able to make a server with plugin for each mini-game with no problems, but it requires to run too much Bukkits
    2. Separated worlds for each mini-game
    3. All mini-games in one world: [creeper]
     
  8. Offline

    RingOfStorms

    In the end a separate server is much better and ends up being infinitely more scaleable than trying to put all your games onto one server. It is easier to do, so might as well do it. If your computer can't handle a few server instances then you may not want to be hosting a server anyways.
     
  9. Offline

    NoLiver92


    why not just keep it in one listener rather than making three the same but checking the world and running something in it. but like RingOfStorms said seperate servers for different games is alot better than trying to make plugins only work on a certain world
     
  10. Offline

    bars96

    Okay, but:
    1. How many RAM/CPU requires every game on every server?
    2. How many RAM/CPU requires every game in one server?

    Then we can talk about what is better.
     
Thread Status:
Not open for further replies.

Share This Page