[Skript-API] How to get some strings from my event?

Discussion in 'Plugin Development' started by bfgbfggf, Jan 30, 2014.

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

    bfgbfggf

    How to create own Skript-event and get some strings/ints etc... from it?
    I actually only know how to register player as variable, but... how about strings?

    PS: event is based on protocolLib

    So.... I created my own Script-event (or maybe listener is better word) based on my own event:
    Code:
    Skript.registerEvent("Ping", SimpleEvent.class, PlayerPingEvent.class, new String[] { "ping" });
    And then I can use it in skript
    Code:
    on ping:
        send "bla bla bla" to console
    Yeach... works great. But... I also need get some variables from that event, and change it.
    Something like that:
    Code:
    on ping:
        set myVar to "Hello this is your new myVar"
    but i only know how to add player:
    Code:
                EventValues.registerEventValue(PlayerPingEvent.class, Player.class, new SerializableGetter<Player, PlayerPingEvent>() {
                    public Player get(PlayerPingEvent event) {
                        return event.getPlayer();
                    }
                }, 0);
    Skript has build-in player variable, so that works for every player-event

    Show Spoiler

    so, after that I "can" also use:
    Code:
    on ping:
        send "bla bla bla" to [B]player[/B]
    PS: I can't because that ping-event and player is only temp, but variable works :p



    But I need own variable, and possibility to edit it.

    EG: I have
    event.getInfo().getMyVar();

    and how to add possibility to use and edit this variable from skript-event.


    Ok.... I can't write that better :D
    Sorry for horrible English :<


    all code if someone need....
    Code:
    https://github.com/BukkitSmerf/FakeServer/tree/dev/OwnSlotInfo/src/com/gmail/bukkitSmerf/fakeServer
    You can also download working.jar or something...

    Some more important classes:
    Event that I want to add:
    https://github.com/BukkitSmerf/Fake...kkitSmerf/fakeServer/api/PlayerPingEvent.java

    Event what I use in my code: (from protocol)
    https://github.com/BukkitSmerf/Fake.../gmail/bukkitSmerf/fakeServer/PlayerList.java

    ServerInfo class where I store all data for each IP
    https://github.com/BukkitSmerf/Fake.../gmail/bukkitSmerf/fakeServer/ServerInfo.java



    So... anyone can help ;/?
    I trying for two days... and i still get only error, or working but only with player.
     
  2. Offline

    L33m4n123

    I have to admit. I got no Idea what you mean

    Define what you mean you mean with

    as this is like the biggest point I don't get it. Might be that I should get some sleep that I do not get it.
     
  3. Offline

    bfgbfggf

    L33m4n123

    Hyyym...

    So.... I created my own Script-event (or maybe listener is better word) based on my own event:
    Code:
    Skript.registerEvent("Ping", SimpleEvent.class, PlayerPingEvent.class, new String[] { "ping" });
    And then I can use it in skript
    Code:
    on ping:
        send "bla bla bla" to console
    Yeach... works great. But... I also need get some variables from that event, and change it.
    Something like that:
    Code:
    on ping:
        set myVar to "Hello this is your new myVar"
    but i only know how to add player:
    Code:
                EventValues.registerEventValue(PlayerPingEvent.class, Player.class, new SerializableGetter<Player, PlayerPingEvent>() {
                    public Player get(PlayerPingEvent event) {
                        return event.getPlayer();
                    }
                }, 0);
    Skript has build-in player variable, so that works for every player-event
    Show Spoiler

    so, after that I "can" also use:
    Code:
    on ping:
        send "bla bla bla" to [B]player[/B]
    PS: I can't because that ping-event and player is only temp, but variable works :p


    But I need own variable, and possibility to edit it.

    EG: I have
    event.getInfo().getMyVar();

    and how to add possibility to use and edit this variable from skript-event.


    Ok.... I can't write that better :D
    Sorry for horrible English :<

    PS: I add this to main post...
     
  4. Offline

    itzrobotix

    Doesn't Skript have their own site for this stuff? I know it is a Bukkit plugin but wouldn't you receive more help there?
     
  5. Offline

    bfgbfggf

    yeach... extra

    On skript page:
    Go do bukkit dev.

    On bukkit dev:
    Go to skript


    :< why?
     
  6. Offline

    itzrobotix

    Just seemed more plausible.
     
  7. Offline

    bfgbfggf

    Any ideas? :<
     
  8. Offline

    Maurdekye

    bfgbfggf Even if they point to eachother, I'd just push through and go with the forum thats most related, AKA the Skript forums. If they tell you to get off and go somewhere else, then just tell them that mom told you to come talk to dad, even though dad told you it was mom's problem.
     
  9. Offline

    bfgbfggf


    Maurdekye

    Yeach... but I have also thread in Skript-forum, but... :D
    Nobody know the answer :>
    Why my problems are always too hard :<
     
  10. Offline

    Maurdekye

    bfgbfggf Don't complain to me, I don't know a thing about Skript.
     
  11. Offline

    bfgbfggf

    any idea?
     
  12. Offline

    Njol

    You have to use an Expression for this purpose (use SimpleExpression, with the pattern "myVar") and override its acceptChange and change methods. Take a look at ExprBiome for an example.
     
Thread Status:
Not open for further replies.

Share This Page