Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional for plugin functions #142

Closed
GuckTubeYT opened this issue Feb 15, 2023 · 9 comments
Closed

Additional for plugin functions #142

GuckTubeYT opened this issue Feb 15, 2023 · 9 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@GuckTubeYT
Copy link

Is it possible to make file reader on Plugin? is it possible, how do i make file reader on Plugin?

@krlvm
Copy link
Owner

krlvm commented Feb 15, 2023

Yes, standard interfaces are fully available to you, and you can call readTextFile from your plugin's main class to read any file in configs directory, like it is used here.

Didn't really think of a way to obtain configuration directory at runtime, I will add a method for that in the next version, you can just hardcode it at the moment.

@GuckTubeYT
Copy link
Author

Yes, standard interfaces are fully available to you, and you can call readTextFile from your plugin's main class to read any file in configs directory, like it is used here.

Didn't really think of a way to obtain configuration directory at runtime, I will add a method for that in the next version, you can just hardcode it at the moment.

oh okay okay thanks, and, can you make Error Messagebox for Plugins please

@GuckTubeYT GuckTubeYT changed the title [Question] Is it possible to make file reader on Plugin Additional for plugin functions Feb 15, 2023
@GuckTubeYT
Copy link
Author

GuckTubeYT commented Feb 15, 2023

example, if user didnt put anything at user input, it will show error messagebox on android, or when user press start button, the app wil show error message

@GuckTubeYT
Copy link
Author

Yes, standard interfaces are fully available to you, and you can call readTextFile from your plugin's main class to read any file in configs directory, like it is used here.

Didn't really think of a way to obtain configuration directory at runtime, I will add a method for that in the next version, you can just hardcode it at the moment.

oh yeah, btw, i mean like file user interface, so user can select the file

@krlvm
Copy link
Owner

krlvm commented Feb 15, 2023

example, if user didnt put anything at user input, it will show error messagebox on android, or when user press start button, the app wil show error message

You can throw an exception and its message will be shown to user

oh yeah, btw, i mean like file user interface, so user can select the file

I intended this as a tool primarily for an advanced users, but I'll consider adding such feature.
If you a built-in text file editor, you can declare additional config files in plugin manifest like this, and then long-press a gear in plugin list to access it.

@GuckTubeYT
Copy link
Author

GuckTubeYT commented Feb 15, 2023

You can throw an exception and its message will be shown to user

Sorry, can you make the example code?

Thanks

@krlvm
Copy link
Owner

krlvm commented Feb 15, 2023

public class MyPlugin extends PowerTunnelPlugin {

    @Override
    public void onProxyInitialization(@NotNull ProxyServer proxy) {
        // ...
        if (somethingIsWrong) {
            throw new Exception("Error message");
        }
        // ...
    }

}

@GuckTubeYT
Copy link
Author

ohh okay okay, and it will show the dialog error?

@GuckTubeYT
Copy link
Author

okay okay thanks

@krlvm krlvm added documentation Improvements or additions to documentation question Further information is requested labels Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants