Allow public access for javaPluginBridge
miresru opened this issue ยท 10 comments
Hi!
I am trying to make my own plugin.
How I can use TR API?
For example, how I can read and write TR vars?
I found VariblesManager class and it has get() and put() methods. But I didn't undersantd how to use it.
Can you give me some examles of code?
At this point, TR doesn't have a dedicated API.
But you may access them like how you do right now.
the get() or put() method works exactly like the Map interface.
you can retrieve value by
manager.get("theKey")
or update it by
manager.put("theKey", someNewValue)
Yes, but how to create manager
?
I mean how to connect TR plugin and VariableManager to mine and use it right.
This is my code:
import io.github.wysohn.triggerreactor.bukkit.manager.VariableManager;
-----
VariableManager vm;
String str = vm.get("myKey").toString();
And it doesnt work.
Can you give me code examle?
You shouldn't make a new instance but use the one already created.
It's similar to how you access other plugins in TR script. You have to get the plugin instance of TriggerReactor
TriggerReactor tr = (TriggerReactor) Bukkit.getPluginManager().getPlugin("TriggerReactor")
VariableManager vm = tr.getVariableManager()
This is just an example
It gives me error:
error: cannot find symbol VariableManager vm = tr.getVariableManager(); symbol: method getVariableManager() location: variable tr of type TriggerReactor
This is the class you are using as the 'tr' variable
Notice that there is no such method called 'getVariableManager()'
And I just realized that the javaPluginBridge is a private field.
Hmm, you may need to use reflection in that case