TriggerReactor

TriggerReactor

24.6k Downloads

Allow public access for javaPluginBridge

miresru opened this issue ยท 10 comments

commented

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?

commented

you can either wait for an update or use reflection to access the private field

commented

Can you give me example with reflection?
I have never use it before :-(

commented

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)

commented

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?

commented

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

commented

It gives me error:
error: cannot find symbol VariableManager vm = tr.getVariableManager(); symbol: method getVariableManager() location: variable tr of type TriggerReactor

commented

https://github.com/wysohn/TriggerReactor/blob/master/src/main/java/io/github/wysohn/triggerreactor/bukkit/main/TriggerReactor.java

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

commented

So, do I need to wait for TR update or there is a way to do it now?

commented

implemented in release 2.2.0