Skip to content

Commit 4e0bed3

Browse files
authored
Add files via upload
1 parent 22591be commit 4e0bed3

File tree

14 files changed

+153
-0
lines changed

14 files changed

+153
-0
lines changed

TIPS.iml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>SPIGOT</platformType>
8+
</autoDetectTypes>
9+
<projectReimportVersion>1</projectReimportVersion>
10+
</configuration>
11+
</facet>
12+
</component>
13+
</module>

pom.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>sensen1234.sencraft</groupId>
8+
<artifactId>TIPS</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>TIPS</name>
13+
14+
<properties>
15+
<java.version>1.8</java.version>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<groupId>org.apache.maven.plugins</groupId>
23+
<artifactId>maven-compiler-plugin</artifactId>
24+
<version>3.8.1</version>
25+
<configuration>
26+
<source>${java.version}</source>
27+
<target>${java.version}</target>
28+
</configuration>
29+
</plugin>
30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-shade-plugin</artifactId>
33+
<version>3.2.4</version>
34+
<executions>
35+
<execution>
36+
<phase>package</phase>
37+
<goals>
38+
<goal>shade</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
</plugin>
43+
</plugins>
44+
<resources>
45+
<resource>
46+
<directory>src/main/resources</directory>
47+
<filtering>true</filtering>
48+
</resource>
49+
</resources>
50+
</build>
51+
52+
<repositories>
53+
<repository>
54+
<id>spigotmc-repo</id>
55+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
56+
</repository>
57+
<repository>
58+
<id>sonatype</id>
59+
<url>https://oss.sonatype.org/content/groups/public/</url>
60+
</repository>
61+
</repositories>
62+
63+
<dependencies>
64+
<dependency>
65+
<groupId>org.spigotmc</groupId>
66+
<artifactId>spigot-api</artifactId>
67+
<version>1.13-R0.1-SNAPSHOT</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
</dependencies>
71+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package sensen1234.sencraft.tips;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.configuration.file.FileConfiguration;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
import org.bukkit.scheduler.BukkitRunnable;
7+
8+
import java.util.List;
9+
import java.util.Random;
10+
11+
public class TIPS extends JavaPlugin {
12+
13+
private List<String> tips;
14+
private Random random;
15+
16+
@Override
17+
public void onEnable() {
18+
saveDefaultConfig(); // 保存默认配置文件
19+
loadConfig(); // 加载配置文件
20+
startTipTask(); // 启动定时任务
21+
}
22+
23+
private void loadConfig() {
24+
FileConfiguration config = getConfig();
25+
tips = config.getStringList("tips");
26+
random = new Random();
27+
}
28+
29+
private void startTipTask() {
30+
int interval = getConfig().getInt("tipInterval", 600); // 获取间隔时间,默认为600秒(10分钟)
31+
new BukkitRunnable() {
32+
@Override
33+
public void run() {
34+
sendRandomTip();
35+
}
36+
}.runTaskTimer(this, interval * 20, interval * 20); // 以ticks为单位,每个tick为1/20秒
37+
}
38+
39+
private void sendRandomTip() {
40+
if (!tips.isEmpty()) {
41+
String tip = tips.get(random.nextInt(tips.size()));
42+
Bukkit.broadcastMessage("[TIPS] " + tip); // 发送小提示到公屏
43+
}
44+
}
45+
}

src/main/resources/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tips:
2+
- "Remember to drink water!"
3+
- "Don't forget to stretch your legs!"
4+
- "Stay hydrated and take breaks!"
5+
tipInterval: 600 # 小提示间隔时间(秒)

src/main/resources/plugin.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: TIPS
2+
version: '${project.version}'
3+
main: sensen1234.sencraft.tips.TIPS
4+
api-version: '1.13'

target/TIPS-1.0-SNAPSHOT.jar

4.48 KB
Binary file not shown.

target/classes/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tips:
2+
- "Remember to drink water!"
3+
- "Don't forget to stretch your legs!"
4+
- "Stay hydrated and take breaks!"
5+
tipInterval: 600 # 小提示间隔时间(秒)

target/classes/plugin.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: TIPS
2+
version: '1.0-SNAPSHOT'
3+
main: sensen1234.sencraft.tips.TIPS
4+
api-version: '1.13'
634 Bytes
Binary file not shown.
2.06 KB
Binary file not shown.

0 commit comments

Comments
 (0)