This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
generated from MiraiMC/MiraiMC-Template
-
-
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.
- Loading branch information
XiaMoHuaHuo-CN
committed
Jun 2, 2022
1 parent
2aeafdd
commit 8e84aad
Showing
7 changed files
with
185 additions
and
54 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
38 changes: 38 additions & 0 deletions
38
src/main/java/moe/xmcn/catsero/events/listeners/GetTPS/OnQQGroupMessage.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,38 @@ | ||
package moe.xmcn.catsero.events.listeners.GetTPS; | ||
|
||
import me.dreamvoid.miraimc.api.MiraiBot; | ||
import me.dreamvoid.miraimc.bukkit.event.MiraiGroupMessageEvent; | ||
import moe.xmcn.catsero.utils.Config; | ||
import moe.xmcn.catsero.utils.ServerTPS; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
import java.util.Arrays; | ||
import java.util.NoSuchElementException; | ||
import java.util.Objects; | ||
|
||
public class OnQQGroupMessage implements Listener { | ||
|
||
@EventHandler | ||
public void onMiraiGroupMessageEvent(MiraiGroupMessageEvent event) { | ||
|
||
String message = event.getMessage(); | ||
String[] args = message.split(" "); | ||
if (Objects.equals(args[0], "catsero") && Objects.equals(args[1], "kick") && Config.INSTANCE.getUsesConfig().getBoolean("tps.enabled") && event.getGroupID() == Config.INSTANCE.getUse_Group() && event.getBotID() == Config.INSTANCE.getUse_Bot()) { | ||
if (event.getSenderID() == Config.INSTANCE.getQQ_OP()) { | ||
try { | ||
MiraiBot.getBot(Config.INSTANCE.getUse_Bot()).getGroup(Config.INSTANCE.getUse_Group()).sendMessageMirai(String.valueOf(ServerTPS.getTPS())); | ||
} catch (NoSuchElementException nse) { | ||
Config.INSTANCE.getPlugin().getLogger().warning(Config.INSTANCE.getMsgByMsID("general.send-message-qq.error").replace("%error%", nse + Arrays.toString(nse.getStackTrace()))); | ||
} | ||
} else { | ||
try { | ||
MiraiBot.getBot(Config.INSTANCE.getUse_Bot()).getGroup(Config.INSTANCE.getUse_Group()).sendMessageMirai(Config.INSTANCE.getPrefix_QQ() + Config.INSTANCE.getMsgByMsID("qq.no-permission")); | ||
} catch (NoSuchElementException nse) { | ||
Config.INSTANCE.getPlugin().getLogger().warning(Config.INSTANCE.getMsgByMsID("general.send-message-qq.error").replace("%error%", nse + Arrays.toString(nse.getStackTrace()))); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.