Compare commits

...

3 Commits

Author SHA1 Message Date
Kyoukawa Meishin
a29f0473af 与PlayerExpSystem集成 2025-10-17 15:33:59 +08:00
Kyoukawa Meishin
67362ee1d2 增加版本号 2025-10-17 15:33:50 +08:00
Kyoukawa Meishin
c3ef2ee5ef 增加版本号 2025-10-17 15:33:45 +08:00
4 changed files with 67 additions and 13 deletions

20
pom.xml
View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mmlsystem</groupId>
<artifactId>StatusSystem</artifactId>
<version>1.1.1</version>
<version>1.2.1</version>
<repositories>
<repository>
@ -18,6 +18,18 @@
<url>https://jitpack.io/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
@ -38,5 +50,11 @@
<version>24.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.mmlsystem</groupId>
<artifactId>PlayerExpSystem</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -5,9 +5,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerJoinListener implements Listener {
private final Foundation plugin;
private final StatusFoundation plugin;
public PlayerJoinListener(Foundation plugin) {
public PlayerJoinListener(StatusFoundation plugin) {
this.plugin = plugin;
}

View File

@ -8,9 +8,16 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.*;
import com.mmlsystem.PlayerExpSystem.Foundation;
import com.mmlsystem.PlayerExpSystem.ExpAPI;
public class Foundation extends JavaPlugin {
import java.time.Duration;
import java.util.Objects;
public class StatusFoundation extends JavaPlugin {
public static Economy econ;
public static ExpAPI api;
public int totalTime;
@Override
public void onEnable() {
@ -23,6 +30,8 @@ public class Foundation extends JavaPlugin {
return;
}
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Foundation foundation = (Foundation) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("PlayerExpSystem"));
api = new ExpAPI(foundation);
getLogger().info("插件启用成功。");
}
@ -50,11 +59,15 @@ public class Foundation extends JavaPlugin {
Objective objective = board.registerNewObjective("info", "dummy", ChatColor.GOLD + "✦ 统计数据 ✦");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.getScore(ChatColor.AQUA + "金币").setScore(7);
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(6);
objective.getScore(ChatColor.AQUA + "金币").setScore(10);
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(9);
objective.getScore(" ").setScore(8);
objective.getScore(ChatColor.AQUA + "当前在线人数").setScore(7);
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(6);
objective.getScore(" ").setScore(5);
objective.getScore(ChatColor.AQUA + "当前在线人数").setScore(4);
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(3);
getTime(player);
objective.getScore(ChatColor.AQUA + "在线时长").setScore(4);
objective.getScore(ChatColor.GREEN + " " + getTimeString()).setScore(3);
objective.getScore("").setScore(2);
objective.getScore(ChatColor.GRAY + "mymc.life").setScore(1);
@ -72,9 +85,31 @@ public class Foundation extends JavaPlugin {
board.resetScores(entry);
}
}
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(6);
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(3);
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(9);
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(6);
getTime(player);
objective.getScore(ChatColor.GREEN + " " + getTimeString()).setScore(3);
}
}.runTaskTimer(this, 0L, 100L);
}
public void setTime(int time) {
this.totalTime = time / 1000;
}
public void getTime(Player player) {
api.getPlayerOnlineTime(player, this::setTime);
}
public String getTimeString() {
if (totalTime == -1) {
return "未知错误";
}
long hour;
long minute;
Duration duration = Duration.ofSeconds(totalTime);
hour = duration.toHours();
minute = duration.toMinutesPart();
return String.format("%d:%02d", hour, minute);
}
}

View File

@ -1,6 +1,7 @@
name: StatusSystem
main: com.mmlsystem.StatusSystem.Foundation
version: 1.1
main: com.mmlsystem.StatusSystem.StatusFoundation
version: 1.2.1
api-version: 1.21
author: 杏川铭心
description: 提供服务器计分板UI功能。
description: 提供服务器计分板UI功能。
depend: [PlayerExpSystem, Vault]