-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from UltiKits/alpha
2023/12/26更新 API版本6.0.2
- Loading branch information
Showing
5 changed files
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
UltiTools-API/src/main/java/com/ultikits/ultitools/utils/CommonUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.ultikits.ultitools.utils; | ||
|
||
import cn.hutool.core.util.IdUtil; | ||
import cn.hutool.json.JSON; | ||
import cn.hutool.json.JSONUtil; | ||
import com.ultikits.ultitools.UltiTools; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class CommonUtils { | ||
|
||
/** | ||
* get UltiTools UUID | ||
* | ||
* @return UUID | ||
* @throws IOException if an I/O error occurs | ||
*/ | ||
public static String getUltiToolsUUID() throws IOException { | ||
File dataFile = new File(UltiTools.getInstance().getDataFolder(), "data.json"); | ||
JSON json = new cn.hutool.json.JSONObject(); | ||
if (dataFile.exists()) { | ||
json = JSONUtil.readJSON(dataFile, StandardCharsets.UTF_8); | ||
} else { | ||
json.putByPath("uuid", IdUtil.simpleUUID()); | ||
json.write(new FileWriter(dataFile)); | ||
} | ||
return json.getByPath("uuid").toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters