event player

A big new update is now available, introducing biomes, caves and much more!
Latest hotfix: 0.7.0.3 (2024-02-21)
  • Ok I have a code that has a timer on it after an event. Problem is if someone does another event then the event tag in another plugin seems to change for event.player. Can I just make the event name unique?? That is as follows:


    public void onObjectInteraction(PlayerObjectInteractionEvent tcevent)


    Instead of
    public void onObjectInteraction(PlayerObjectInteractionEvent vent)


    Or is it better to assign a different variable to the player in


    playerreal = Player player = tcevent.getPlayer();


    versus
    Player player = event.getPlayer();


    or do is it best to capture the UID during the timer so it is not interfered with by another player? Looking for best safe form.. not necessarily making a big DB read/write to insure the timer executes with the correct player name

  • public void onObjectInteraction(PlayerObjectInteractionEvent tcevent)


    and


    public void onObjectInteraction(PlayerObjectInteractionEvent vent)


    are totally equivalent.


    playerreal = Player player = tcevent.getPlayer();


    is non-syntactical: you would not even be able to compile it.

    Problem is if someone does another event then the event tag in another plugin seems to change for event.player.

    What you mean by "event tag"? In another plug-in? It seems hard to figure out what you are trying to do and then what might be wrong.


    Some code excerpt would also help in understanding...

  • ok well made everything private ... thanks anyway.

  • So basically the question is this. If I have a plugin that as a variable <player> and another plugin has a variable public <player> can my player be overwritten by the other plugin's player if both are event driven?

  • So basically the question is this. If I have a plugin that as a variable <player> and another plugin has a variable public <player> can my player be overwritten by the other plugin's player if both are event driven?

    Not by itself. Particularly if the two plug-ins are in different packages, you have to code explicitly the first plug-in to be reachable (classes must be public, variables must be public and possibly static, and so on) and the other plug-in to look for it (using the first plug-in name with the Plugin.getPluginByName() API method) and write into the first plug-in variable explicitly.


    Whether plug-ins are event-driven or not is largely irrelevant (in a sense, almost all plug-ins are event-driven); what matter are scopes and access levels; and Java does a rather good job in avoiding casual inter-package accesses.

  • Not by itself. Particularly if the two plug-ins are in different packages, you have to code explicitly the first plug-in to be reachable (classes must be public, variables must be public and possibly static, and so on) and the other plug-in to look for it (using the first plug-in name with the Plugin.getPluginByName() API method) and write into the first plug-in variable explicitly.
    Whether plug-ins are event-driven or not is largely irrelevant (in a sense, almost all plug-ins are event-driven); what matter are scopes and access levels; and Java does a rather good job in avoiding casual inter-package accesses.

    ok will these events changed the name of player and they were in different plugins. When the timer finishes player had changed and was now the new player. This same thing happens when you use onconnect. The second player is now player and the message broadcasts not the with first player in the timer but the second player. Now that example is the same plugin so it is not exactly the same. I changed the routine to onSpawn and it went away.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!