Skip to content

Commit

Permalink
新子模块
Browse files Browse the repository at this point in the history
  • Loading branch information
Kloping committed Nov 16, 2021
1 parent 82e572f commit 6f78205
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,4 @@ public static String[] parseDyImgs(String url) {
}
return null;
}

// public static synchronized Image createImageInGroup(Contact group, String path) {
// try {
// if (path.startsWith("http")) {
// return Contact.uploadImage(group, new URL(path).openStream());
// } else if (path.startsWith("{")) {
// return Image.fromId(path);
// } else {
// Image image = null;
// image = Contact.uploadImage(group, new File(path));
// return image;
// }
// } catch (IOException e) {
// System.err.println(path + "加载重试");
// try {
// return Contact.uploadImage(group, new URL(path).openStream());
// } catch (IOException ioException) {
// ioException.printStackTrace();
// return null;
// }
// }
// }
}
11 changes: 3 additions & 8 deletions Lsys-Score1/src/main/java/cn/kloping/lsys/sc1/Methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@
import java.io.*;

import static cn.kloping.lsys.utils.MessageUtils.random;
import static cn.kloping.lsys.workers.Methods.*;

public class Methods {
public static final Result state1 = new Result(new Object[]{}, 1);
public static final Result state2 = new Result(new Object[]{}, 2);
public static final Result state3 = new Result(new Object[]{}, 3);
public static final Result state4 = new Result(new Object[]{}, 4);
public static final Result state5 = new Result(new Object[]{}, 5);

public static final Function2<User, Request, Result> rob = (user, request) -> {
long q2 = MessageUtils.getAtFromRequest(request);
if (q2 == -1) return state1;
Expand Down Expand Up @@ -87,11 +82,11 @@ public class Methods {
switch (m1.Reff(m2)) {
case 0:
return new Result(new Object[]{m2.getValue()}, 2);
case 1:
case -1:
user.addP(num);
user.apply();
return new Result(new Object[]{m2.getValue(), num}, 1);
case -1:
case 1:
user.addP(-num);
user.apply();
return new Result(new Object[]{m2.getValue(), num}, 0);
Expand Down
19 changes: 19 additions & 0 deletions Lsys-Score2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>MiraiLSys</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>Lsys-Score2</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

</project>
13 changes: 13 additions & 0 deletions Lsys-Score2/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### MiraiLsys 子插件

###积分相关的操作
下载

- 积分相关的 [z5-Lsys-Score2 ](https://github.com/Kloping/MiraiLsys/releases)
- 同样若无极端情况请不要修改文件名 否则将无法正常工作

### 其命令

1. 积分侦查@xx
2. 积分转让@xx(xx)
3. 打工@xx
50 changes: 50 additions & 0 deletions Lsys-Score2/src/main/java/cn/kloping/lsys/sc2/Methods.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cn.kloping.lsys.sc2;

import cn.kloping.judge.Judge;
import cn.kloping.lsys.entitys.Request;
import cn.kloping.lsys.entitys.Result;
import cn.kloping.lsys.entitys.User;
import cn.kloping.lsys.utils.MessageUtils;
import cn.kloping.number.NumberUtils;
import kotlin.jvm.functions.Function2;

import static cn.kloping.lsys.savers.PutGetter.get;
import static cn.kloping.lsys.workers.Methods.*;

public class Methods {

public static final Function2<User, Request, Result> transTo = (user, request) -> {
long q2 = MessageUtils.getAtFromRequest(request);
if (q2 == -1) return state3;
User u2 = get(q2);
if (u2 == null) return state2;
String nStr = NumberUtils.findNumberFromString(request.getStr()).replace(q2+"","");
if (Judge.isEmpty(nStr)) return state4;
long n = Long.parseLong(nStr);
if (user.getP() < n) return state1;
u2.addP(n);
user.addP(-n);
return state0;
};
public static final Function2<User, Request, Result> LongTimeWork = (user, request) -> {
long k1 = user.getK1();
if (k1 >= System.currentTimeMillis()) {
String tips = (k1 - System.currentTimeMillis()) / 1000 / 60 + "分钟之后";
return new Result(new Object[]{tips}, 0);
}
int r = MessageUtils.random.nextInt(20) + 40;
user.addP(r);
int rt = (MessageUtils.random.nextInt(5) + 6);
user.setK1(System.currentTimeMillis() + rt * 1000 * 60);
user.apply();
return new Result(new Object[]{rt, r}, 1);
};
public static final Function2<User, Request, Result> lookSc = (user, request) -> {
long q2 = MessageUtils.getAtFromRequest(request);
if (q2 == -1) return state2;
User u2 = get(q2);
if (u2 == null) return state1;
return new Result(new Object[]{u2.getP()}, 0);
};

}
41 changes: 41 additions & 0 deletions Lsys-Score2/src/main/java/cn/kloping/lsys/sc2/PluginMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cn.kloping.lsys.sc2;

import com.sun.istack.internal.NotNull;
import net.mamoe.mirai.console.extension.PluginComponentStorage;
import net.mamoe.mirai.console.plugin.PluginManager;
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin;
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder;


public class PluginMain extends JavaPlugin {
public static final PluginMain INSTANCE = new PluginMain();

private PluginMain() {
super(new JvmPluginDescriptionBuilder("cn.kloping.lsys.sco2.PluginMain", "0.1")
.name("插件_8 Author => HRS LSys sco2 Loaded")
.info("插件")
.author("HRS")
.build());
}

@Override
public void onLoad(@NotNull PluginComponentStorage $this$onLoad) {
if (!Utils.isExits()) {
getLogger().error("欲使用sco2插件 必须安装 Lsys 插件");
getLogger().error("欲使用sco2插件 必须安装 Lsys 插件");
getLogger().error("欲使用sco2插件 必须安装 Lsys 插件");
PluginManager.INSTANCE.disablePlugin(INSTANCE);
return;
}
try {
sc2.start();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void onEnable() {
getLogger().info("");
}
}
19 changes: 19 additions & 0 deletions Lsys-Score2/src/main/java/cn/kloping/lsys/sc2/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cn.kloping.lsys.sc2;

import net.mamoe.mirai.console.plugin.Plugin;
import net.mamoe.mirai.console.plugin.PluginManager;
import net.mamoe.mirai.console.plugin.description.PluginDescription;
import net.mamoe.mirai.console.plugin.loader.PluginLoader;

public class Utils {
public static boolean isExits() {
for (Plugin plugin : PluginManager.INSTANCE.getPlugins()) {
PluginLoader<Plugin, PluginDescription> loader = (PluginLoader<Plugin, PluginDescription>) plugin.getLoader();
String id = loader.getPluginDescription(plugin).getId();
if (id.equals("cn.kloping.Lsys")) {
return true;
}
}
return false;
}
}
42 changes: 42 additions & 0 deletions Lsys-Score2/src/main/java/cn/kloping/lsys/sc2/sc2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cn.kloping.lsys.sc2;

import cn.kloping.lsys.Resource;
import cn.kloping.lsys.entitys.InvokeGroup;
import cn.kloping.lsys.workers.Methods;

import static cn.kloping.lsys.sc2.Methods.*;

public class sc2 {
public static void start() {
InvokeGroup invokeGroup = new InvokeGroup("sco2");

invokeGroup.getInvokes().put("积分转让.*", "transTo");
invokeGroup.getInvokesAfter().put("积分转让.*", new String[]{"<At = ?>\n积分转让成功"
, "<At = ?>\n积分不足"
, "<At = ?>\nta还没有注册呢"
, "<At = ?>\nta转给谁呢"
, "<At = ?>\n转多少呢"
});
Methods.invokes.put("transTo", transTo);
//=打劫end
invokeGroup.getInvokes().put("积分侦查.*", "lookSc");
invokeGroup.getInvokesAfter().put("积分侦查.*", new String[]{"<At = ?>\nta剩的积分:$1"
, "<At = ?>\nta还没有注册"
, "<At = ?>\n侦查谁"
});
Methods.invokes.put("lookSc", lookSc);
//=签到end
invokeGroup.getInvokes().put("打工.*", "LongTimeWork");
invokeGroup.getInvokesAfter().put("打工.*", new String[]{"<At = ?>\n冷却时间未到:$1"
, "<At = ?>\n您花费了$1分钟,打工赚了 $2 积分"
});
Methods.invokes.put("LongTimeWork", LongTimeWork);
//=猜拳end

Resource.loadConfAfter.add(() -> {
if (!Resource.conf.getInvokeGroups().containsKey(invokeGroup.getId()))
Resource.conf.getInvokeGroups().put(invokeGroup.getId(), invokeGroup);
});
Resource.i1();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cn.kloping.lsys.sc2.PluginMain
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<module>Lsys-PartN</module>
<module>Lsys-PicParser</module>
<module>Lsys-Score1</module>
<module>Lsys-Score2</module>
</modules>

<properties>
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
- 发图的[z2-Lsys-GetPic ](https://github.com/Kloping/MiraiLsys/tree/master/Lsys-GetPic)
- 解析图片[Lsys-PicParser](https://github.com/Kloping/MiraiLsys/tree/master/Lsys-PicParser)
- 积分相关操作的1[Lsys-Score1](https://github.com/Kloping/MiraiLsys/tree/master/Lsys-Score1)
- 积分相关操作的2[Lsys-Score2](https://github.com/Kloping/MiraiLsys/tree/master/Lsys-Score2)
-
- (后续将继续更新)

#### 值得注意的是 若 未安装 主插件
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/kloping/lsys/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlin.coroutines.CoroutineContext
class PluginMain : KotlinPlugin {

constructor() : super(
JvmPluginDescriptionBuilder("cn.kloping.Lsys", "0.2.2")
JvmPluginDescriptionBuilder("cn.kloping.Lsys", "0.2.5")
.name("插件_ Author => HRS LSys Loaded")
.info("插件")
.author("HRS")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/kloping/lsys/Resource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object Resource {
val invokeGroupMap = ConcurrentHashMap<String, InvokeGroup>().apply {
put(invokeGroup.id, invokeGroup)
}
conf = Conf("$rootPath/data/LSys", -1, arrayOf(-1), invokeGroupMap, false)
conf = Conf("$rootPath/data/LSys", -1, HashSet(), invokeGroupMap, false)
}

@OptIn(ConsoleFrontEndImplementation::class)
Expand Down
32 changes: 2 additions & 30 deletions src/main/java/cn/kloping/lsys/entitys/Conf.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import java.util.concurrent.ConcurrentHashMap
data class Conf(
val path: String,
var qq: Number,
var opens: Array<Number>,
var opens: java.util.HashSet<Number>,
val invokeGroups: ConcurrentHashMap<String, InvokeGroup>,
var prK: Boolean
) : Entity {

constructor() : this("", -1, arrayOf(-1), ConcurrentHashMap<String, InvokeGroup>(), false);
constructor() : this("", -1, HashSet(), ConcurrentHashMap<String, InvokeGroup>(), false);

@JSONField(serialize = false)
val invokes = ConcurrentHashMap<String, String>();
Expand All @@ -33,32 +33,4 @@ data class Conf(
override fun apply() {
FileInitializeValue.putValues(File("$rootPath/", "conf/LSys/conf.json").absolutePath, Resource.conf, true)
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Conf

if (path != other.path) return false
if (qq != other.qq) return false
if (!opens.contentEquals(other.opens)) return false
if (invokeGroups != other.invokeGroups) return false
if (prK != other.prK) return false
if (invokes != other.invokes) return false
if (invokesAfter != other.invokesAfter) return false

return true
}

override fun hashCode(): Int {
var result = path.hashCode()
result = 31 * result + qq.hashCode()
result = 31 * result + opens.contentHashCode()
result = 31 * result + invokeGroups.hashCode()
result = 31 * result + prK.hashCode()
result = 31 * result + invokes.hashCode()
result = 31 * result + invokesAfter.hashCode()
return result
}
}
6 changes: 6 additions & 0 deletions src/main/java/cn/kloping/lsys/entitys/Request.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package cn.kloping.lsys.entitys

import net.mamoe.mirai.event.events.MessageEvent

/**
* str: 原话
* oStr: 匹配到的语句
* sendId: 发送人Id
* gId: 群Id 若存在
*/
data class Request(
val str:String,
val oStr:String,
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/cn/kloping/lsys/entitys/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ data class User(
/**
* qq
*/
val qq: Number,
val qq: Number=-1,
/**
* 积分
*/
var p: Long,
var p: Long=1000,
/**
* 存的积分
*/
var p2: Long,
var p2: Long=200,
/**
* 犯罪指数
*/
var pf: Long,
var pf: Long=0,
/**
* 上次注册天
*/
var ur: Int
var ur: Int=0,
/**
* 打工冷却
*/
var k1: Long =0,
) : Entity {

constructor() : this(-1, 0, 0, 0, 0)
constructor() : this(-1, 0, 0, 0, 0,0)

fun getP2(n: Long): Boolean {
if (n <= this.p2) {
Expand Down
Loading

0 comments on commit 6f78205

Please sign in to comment.