Compare commits
3 Commits
c372c0ae29
...
a29f0473af
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a29f0473af | ||
|
|
67362ee1d2 | ||
|
|
c3ef2ee5ef |
20
pom.xml
20
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.mmlsystem</groupId>
|
<groupId>com.mmlsystem</groupId>
|
||||||
<artifactId>StatusSystem</artifactId>
|
<artifactId>StatusSystem</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.2.1</version>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@ -18,6 +18,18 @@
|
|||||||
<url>https://jitpack.io/</url>
|
<url>https://jitpack.io/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -38,5 +50,11 @@
|
|||||||
<version>24.1.0</version>
|
<version>24.1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mmlsystem</groupId>
|
||||||
|
<artifactId>PlayerExpSystem</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class PlayerJoinListener implements Listener {
|
public class PlayerJoinListener implements Listener {
|
||||||
private final Foundation plugin;
|
private final StatusFoundation plugin;
|
||||||
|
|
||||||
public PlayerJoinListener(Foundation plugin) {
|
public PlayerJoinListener(StatusFoundation plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,9 +8,16 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scoreboard.*;
|
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 Economy econ;
|
||||||
|
public static ExpAPI api;
|
||||||
|
public int totalTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -23,6 +30,8 @@ public class Foundation extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
|
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
|
||||||
|
Foundation foundation = (Foundation) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("PlayerExpSystem"));
|
||||||
|
api = new ExpAPI(foundation);
|
||||||
getLogger().info("插件启用成功。");
|
getLogger().info("插件启用成功。");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,11 +59,15 @@ public class Foundation extends JavaPlugin {
|
|||||||
Objective objective = board.registerNewObjective("info", "dummy", ChatColor.GOLD + "✦ 统计数据 ✦");
|
Objective objective = board.registerNewObjective("info", "dummy", ChatColor.GOLD + "✦ 统计数据 ✦");
|
||||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
|
||||||
objective.getScore(ChatColor.AQUA + "金币").setScore(7);
|
objective.getScore(ChatColor.AQUA + "金币").setScore(10);
|
||||||
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(6);
|
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(" ").setScore(5);
|
||||||
objective.getScore(ChatColor.AQUA + "当前在线人数").setScore(4);
|
getTime(player);
|
||||||
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(3);
|
objective.getScore(ChatColor.AQUA + "在线时长").setScore(4);
|
||||||
|
objective.getScore(ChatColor.GREEN + " " + getTimeString()).setScore(3);
|
||||||
objective.getScore("").setScore(2);
|
objective.getScore("").setScore(2);
|
||||||
objective.getScore(ChatColor.GRAY + "mymc.life").setScore(1);
|
objective.getScore(ChatColor.GRAY + "mymc.life").setScore(1);
|
||||||
|
|
||||||
@ -72,9 +85,31 @@ public class Foundation extends JavaPlugin {
|
|||||||
board.resetScores(entry);
|
board.resetScores(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(6);
|
objective.getScore(ChatColor.RED + " " + econ.getBalance(player) ).setScore(9);
|
||||||
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(3);
|
objective.getScore(ChatColor.GREEN + " " + Bukkit.getOnlinePlayers().size()).setScore(6);
|
||||||
|
getTime(player);
|
||||||
|
objective.getScore(ChatColor.GREEN + " " + getTimeString()).setScore(3);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this, 0L, 100L);
|
}.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
name: StatusSystem
|
name: StatusSystem
|
||||||
main: com.mmlsystem.StatusSystem.Foundation
|
main: com.mmlsystem.StatusSystem.StatusFoundation
|
||||||
version: 1.1
|
version: 1.2.1
|
||||||
api-version: 1.21
|
api-version: 1.21
|
||||||
author: 杏川铭心
|
author: 杏川铭心
|
||||||
description: 提供服务器计分板UI功能。
|
description: 提供服务器计分板UI功能。
|
||||||
|
depend: [PlayerExpSystem, Vault]
|
||||||
Loading…
x
Reference in New Issue
Block a user