File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
core/src/main/java/com/minekube/connect/module Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -157,14 +157,19 @@ private static class Token {
157
157
@ SerializedName ("token" ) final String token ;
158
158
159
159
static Optional <String > load (Path tokenFile ) throws IOException {
160
- if (Files .exists (tokenFile )) {
161
- // Read existing token file
162
- try (Reader reader = Files .newBufferedReader (tokenFile )) {
163
- return Optional .ofNullable (new Gson ().fromJson (reader , Token .class ))
164
- .map (t -> t .token );
160
+ String TOKEN_ENV = System .getenv ("CONNECT_TOKEN" );
161
+ if (TOKEN_ENV != null && !TOKEN_ENV .isEmpty ()) {
162
+ return Optional .of (TOKEN_ENV );
163
+ } else {
164
+ if (Files .exists (tokenFile )) {
165
+ // Read existing token file
166
+ try (Reader reader = Files .newBufferedReader (tokenFile )) {
167
+ return Optional .ofNullable (new Gson ().fromJson (reader , Token .class ))
168
+ .map (t -> t .token );
169
+ }
165
170
}
171
+ return Optional .empty ();
166
172
}
167
- return Optional .empty ();
168
173
}
169
174
170
175
static void save (Path tokenFile , String token ) throws IOException {
You can’t perform that action at this time.
0 commit comments