Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1roCu committed Apr 24, 2022
1 parent f6b83bd commit 5ddc31c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "ao.sh1rocu"
version = "1.0"
version = "1.0.1"

repositories {
maven("https://maven.aliyun.com/repository/public")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ao/sh1rocu/mirai/bcr/BCRMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class BCRMain extends JavaPlugin {
private BCRMain() {
super(new JvmPluginDescriptionBuilder(
"ao.sh1rocu.mirai.bcr",
"1.0")
"1.0.1")
.name("Sh1roCu-BCR")
.author("Sh1roCu")
.build());
Expand Down
21 changes: 3 additions & 18 deletions src/main/java/ao/sh1rocu/mirai/bcr/task/ClanBattleWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.contact.Group;

import java.util.HashMap;
import java.util.Map;
import java.util.TimerTask;

Expand All @@ -33,16 +32,10 @@
*/
public class ClanBattleWatcher extends TimerTask {
/**
* 暂存boss信息的时间戳
* 暂存出刀信息的时间戳
*/
static long damage_time_stamp = 0;
/**
* 暂存每个群对应的最新的boss信息的时间戳
*/
static Map<Long, Long> clan_battle_timestamp = new HashMap<>();
/**
* The Api.
*/

static final Map<String, String> API = ClanBattleInfoSearch.CLAN_BATTLE_API;

@Override
Expand All @@ -57,7 +50,6 @@ public void run() {
/*获取最新一位成员的出刀信息*/
JsonObject damageInfo = getJson(API.get("clan_day_timeline_report"), group).get("data").getAsJsonObject()
.get("list").getAsJsonArray().get(0).getAsJsonObject();
long newTimeStamp = info.get("server_time").getAsLong();
long newDamageTimeStamp = damageInfo.get("datetime").getAsLong();
if (damage_time_stamp == 0) {
damage_time_stamp = newDamageTimeStamp;
Expand All @@ -80,17 +72,10 @@ public void run() {
damageMessage += "并击破";
}
group.sendMessage(damageMessage);
/*更新时间戳*/
damage_time_stamp = newDamageTimeStamp;
}
if (!clan_battle_timestamp.containsKey(group.getId())) {
clan_battle_timestamp.put(group.getId(), newTimeStamp);
} else if (clan_battle_timestamp.get(group.getId()) < newTimeStamp) {
/*检测到boss状态改变,发送boss新状态*/
String bossStatus = ClanBattleInfoSearch.getBossStatus(group);
group.sendMessage(bossStatus);
/*更新时间戳*/
clan_battle_timestamp.put(group.getId(), newTimeStamp);
damage_time_stamp = newDamageTimeStamp;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static String getJsonResource(String api, Group group) {
CloseableHttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
String resource = EntityUtils.toString(entity);
entity.close();
response.close();
httpClient.close();
return resource;
Expand Down Expand Up @@ -293,7 +294,7 @@ public static String getBossStatus(Group group) {
}
StringBuilder stringBuilder = new StringBuilder();
JsonObject info = data.get("data").getAsJsonObject();
JsonObject bossInfo = info.get("bossInfo").getAsJsonObject();
JsonObject bossInfo = info.get("boss_info").getAsJsonObject();
return stringBuilder.append("当前BOSS状态-->\n")
.append("第").append(bossInfo.get("lap_num").getAsInt()).append("周目-")
.append(bossInfo.get("name").getAsString()).append("[").append(bossInfo.get("current_life").getAsString())
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/ao/sh1rocu/mirai/bcr/util/SearchUPer.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static void searchUPer(String uid, Contact sender) {
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultHeaders(headers)
.build();
HttpGet httpGet = new HttpGet("https://api.bilibili.com/x/relation/stat?vmid=" + uid); //返回关注和粉丝数
/*返回关注和粉丝数*/
HttpGet httpGet = new HttpGet("https://api.bilibili.com/x/relation/stat?vmid=" + uid);
CloseableHttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
String resource = EntityUtils.toString(entity);
Expand Down Expand Up @@ -138,11 +139,12 @@ public static void searchUPer(String uid, Contact sender) {

/**
* 获取头像
* @param faceUrl 头像的url
*
* @param faceUrl 头像的url
* @param faceResponse api返回的响应
* @param uid UP主的UID
* @param sender 群组或用户(好友,群成员
* @return 返回头像
* @param uid UP主的UID
* @param sender 群组或用户(好友,群成员
* @return 返回头像
*/
private static Image getFace(String faceUrl, CloseableHttpResponse faceResponse, String uid, Contact sender) throws IOException {
/*分割获取图片类型*/
Expand Down

0 comments on commit 5ddc31c

Please sign in to comment.