#Reflections issue

11 messages · Page 1 of 1 (latest)

sharp frost
#

I have that code and I that's my first attempt at using reflections. So
I want to execute specific code if players are in the same team and FTB Teams even has method for this but when I execute that code it gives error:

[04:07:20] [ERROR] ! Other.js#8: Error in 'BlockEvents.rightClicked': Java class "dev.ftb.mods.ftbteams.api.TeamManager" has no public instance field or method named "arePlayersInSameTeam".
[04:07:20] [ERROR] ! …rhino.EvaluatorException: Java class "dev.ftb.mods.ftbteams.api.TeamManager" has no public instance field or method named "arePlayersInSameTeam". (server_scripts:Other.js#8)
let $Team = Java.loadClass('dev.ftb.mods.ftbteams.api.Team')
let $TeamManager = Java.loadClass('dev.ftb.mods.ftbteams.api.TeamManager')

BlockEvents.rightClicked(event => {

    //$Team.getId() // how to use it like 'player.team.getID() ??

    console.log($TeamManager.arePlayersInSameTeam(event.player.getUuid(),event.player.getUuid()))

})
hybrid whaleBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

tranquil junco
#

@sharp frost are you using ProbeJS? if so, do a /probejs dump
and your loaded classes will now have auto completion so you don't miss the arguments/methods

sharp frost
#

ProbeJS shows it and still I get this error

tranquil junco
#

what is the signature?

sharp frost
#

you mean this?

static glade
#

you need to get the team manager from the api, not call directly on the class

let $TeamsAPI = Java.loadClass('dev.ftb.mods.ftbteams.api.FTBTeamsAPI')

BlockEvents.rightClicked(event => {
  let TeamManager = $TeamsAPI.api().getManager()
    //$Team.getId() // how to use it like 'player.team.getID() ??

    console.log(TeamManager.arePlayersInSameTeam(event.player.getUuid(),event.player.getUuid()))
sharp frost
#

Thanks for help. Everything works now.
But I cant see api in vscode suggestions so how did you found it?

#

Or the only way is to look in the source code?

static glade
#

source code is love, source code is life