File tree Expand file tree Collapse file tree
src/main/java/net/coreprotect/utility Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,15 +112,32 @@ public static boolean isBranch(String branch) {
112112 }
113113
114114 public static boolean validDonationKey () {
115- // 强制返回 true,绕过捐赠密钥验证
116- return true ;
115+ return NetworkHandler .donationKey () != null ;
116+
117+
117118 }
118119
119120 public static String getBranch () {
120121 String branch = "" ;
121122 try {
122123 CoreProtect instance = CoreProtect .getInstance ();
123124 if (instance == null ) {
125+ // Fallback: read plugin.yml directly from classpath when instance is not yet available
126+ try (InputStreamReader fallbackReader = new InputStreamReader (VersionUtils .class .getResourceAsStream ("/plugin.yml" ))) {
127+ String fallbackBranch = YamlConfiguration .loadConfiguration (fallbackReader ).getString ("branch" );
128+ if (fallbackBranch != null && !fallbackBranch .equals ("${project.branch}" )) {
129+ if (fallbackBranch .startsWith ("-" )) {
130+ fallbackBranch = fallbackBranch .substring (1 );
131+ }
132+ if (fallbackBranch .length () > 0 ) {
133+ fallbackBranch = "-" + fallbackBranch ;
134+ }
135+ return fallbackBranch ;
136+ }
137+ }
138+ catch (Exception ignored ) {
139+ // ignored
140+ }
124141 return "" ;
125142 }
126143
You can’t perform that action at this time.
0 commit comments