diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java index eb39249..6068cde 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java @@ -22,15 +22,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; @@ -361,7 +357,7 @@ public void reload() { ((YamlMap) excs.get(cmd)).getString("card"))); } commands.put("/msp", (ev, args) -> { - if (!matcher.match(new MatchInfo(args[0], ev.getSender(), true)).and(matcher.match(new MatchInfo(args[0] + "." + args[1], ev.getSender(), true))).isForceAllowed()) + if (!matcher.match(new MatchInfo(args[0], ev.getSender(), true).mustMatchCommand()).and(matcher.match(new MatchInfo(args[0] + "." + args[1], ev.getSender(), true).mustMatchCommand())).isForceAllowed()) return; if (args[1].equals("reload")) { diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/LocalFileSource.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/LocalFileSource.java index d0cea36..d624f84 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/LocalFileSource.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/LocalFileSource.java @@ -18,7 +18,6 @@ package com.khjxiaogu.MiraiSongPlugin.musicsource; import java.io.FileReader; -import java.net.URLDecoder; import com.google.gson.JsonArray; import com.google.gson.JsonElement; diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java index 94d79e4..56a7ad6 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java @@ -22,7 +22,6 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import com.google.gson.JsonArray; diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/BotMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/BotMatcher.java index a9b6f2e..2232271 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/BotMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/BotMatcher.java @@ -38,8 +38,14 @@ public class BotMatcher implements PermissionMatcher { @Override public PermissionResult match(MatchInfo info) { + if(info.mustMatchCommand) { + PermissionMatcher pmc = commands.get(info.cmd); + if(pmc!=null) + return pmc.match(info); + return PermissionResult.UNSPECIFIED; + } PermissionResult pr = wildcard; - + for (PermissionMatcher pm : restricted.values()) { pr = pr.and(pm.match(info)); } diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/CommandMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/CommandMatcher.java index 549e9ec..4e1f3c3 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/CommandMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/CommandMatcher.java @@ -24,9 +24,7 @@ import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; -import net.mamoe.mirai.contact.Member; import net.mamoe.mirai.contact.MemberPermission; -import net.mamoe.mirai.contact.User; public class CommandMatcher implements PermissionMatcher { PermissionResult wildcard = PermissionResult.UNSPECIFIED; diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/FriendMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/FriendMatcher.java index 21c3cb7..bb7ea6f 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/FriendMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/FriendMatcher.java @@ -20,8 +20,6 @@ import java.util.Arrays; import java.util.List; -import net.mamoe.mirai.contact.User; - public class FriendMatcher implements PermissionMatcher { PermissionResult result; @Override diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GlobalMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GlobalMatcher.java index 4e25b11..6e25fb8 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GlobalMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GlobalMatcher.java @@ -32,8 +32,6 @@ import net.mamoe.mirai.Bot; import net.mamoe.mirai.contact.Group; -import net.mamoe.mirai.contact.Member; -import net.mamoe.mirai.contact.User; public class GlobalMatcher implements PermissionMatcher { BotMatcher global; diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GroupMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GroupMatcher.java index be253d8..8ca4627 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GroupMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/GroupMatcher.java @@ -26,9 +26,6 @@ import com.khjxiaogu.MiraiSongPlugin.permission.CommandMatcher.PermissionFactory; -import net.mamoe.mirai.contact.Member; -import net.mamoe.mirai.contact.User; - public class GroupMatcher implements PermissionMatcher { PermissionResult wildcard=PermissionResult.UNSPECIFIED; LinkedHashMap restricted=new LinkedHashMap<>(5); diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MatchInfo.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MatchInfo.java index 7c43e3c..fee8771 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MatchInfo.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MatchInfo.java @@ -10,6 +10,7 @@ public class MatchInfo { long groupid; String cmd; boolean isTemp; + boolean mustMatchCommand; public MatchInfo() { } public MatchInfo(String cmd,long memberid,long groupid,Bot bot) { @@ -27,4 +28,8 @@ public MatchInfo(String cmd,User u,boolean temp) { this(cmd,u.getId(),0,u.getBot()); this.isTemp=temp; } + public MatchInfo mustMatchCommand() { + mustMatchCommand=true; + return this; + } } diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MemberPermissionMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MemberPermissionMatcher.java index 07266ba..0edc761 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MemberPermissionMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/MemberPermissionMatcher.java @@ -22,7 +22,6 @@ import net.mamoe.mirai.contact.Group; import net.mamoe.mirai.contact.Member; -import net.mamoe.mirai.contact.User; public class MemberPermissionMatcher implements PermissionMatcher { PermissionResult result; diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/NullOperationMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/NullOperationMatcher.java index 5fe064b..2d6873f 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/NullOperationMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/NullOperationMatcher.java @@ -20,9 +20,6 @@ import java.util.Arrays; import java.util.List; -import net.mamoe.mirai.contact.Member; -import net.mamoe.mirai.contact.User; - public final class NullOperationMatcher implements PermissionMatcher { public static final NullOperationMatcher INSTANCE=new NullOperationMatcher(); diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/PermissionMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/PermissionMatcher.java index 4dc0b77..51a3a93 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/PermissionMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/PermissionMatcher.java @@ -19,9 +19,6 @@ import java.util.List; -import net.mamoe.mirai.contact.Member; -import net.mamoe.mirai.contact.User; - public interface PermissionMatcher { PermissionResult match(MatchInfo info); diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/StrangerMatcher.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/StrangerMatcher.java index c145b10..9b14052 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/StrangerMatcher.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/permission/StrangerMatcher.java @@ -20,9 +20,6 @@ import java.util.Arrays; import java.util.List; -import net.mamoe.mirai.contact.Member; -import net.mamoe.mirai.contact.User; - public class StrangerMatcher implements PermissionMatcher { PermissionResult result; @Override