Skip to content

Commit 2c340a3

Browse files
Refactor validDonationKey to validate donation key
Updated validDonationKey method to check for a valid donation key instead of always returning true.
1 parent 9454b22 commit 2c340a3

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/main/java/net/coreprotect/utility/VersionUtils.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)