mirror of
https://github.com/CodedRed-Spigot/PlayTimes.git
synced 2026-11-07 10:02:36 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4b899b031 | ||
|
|
3f2fe03fff | ||
|
|
71917d811d | ||
|
|
185510320b | ||
|
|
bf320aca14 | ||
|
|
4497848cc5 | ||
|
|
8ff6cd3a33 | ||
|
|
ab497b8157 | ||
|
|
a13fdba083 | ||
|
|
044c4c8f13 | ||
|
|
2d6501dbfc | ||
|
|
3435ac4fdd |
No files matched your search
@@ -22,7 +22,13 @@
|
||||
|
||||
## About The Project
|
||||
|
||||
PlayTimes is your ideal plugin for gamified competition! It enables players to compete for the most time played, with leaderboards for showing off achievements. Beyond player time, you can also monitor server uptime. Future plans include introducing PlayTime Rewards, Ranks, and Shop! Start using PlayTimes today to add an exciting dimension to your server.
|
||||
Introducing PlayTimes, the ultimate plugin for your server! Elevate the gaming experience by allowing players to showcase their skills and compete for top positions on the prestigious playtime leaderboards. Not only can you effortlessly monitor the playtime of online and offline players, but you can also keep track of the server's uptime for maximum efficiency. But that's not all! Brace yourself for an array of exciting features that are on the horizon, including PlayTime Rewards, PlayTime Ranks, and the immersive PlayTime Shop. Get ready to take your server to the next level with PlayTimes!
|
||||
|
||||
<img src="https://imgur.com/KebViUJ.gif"> <img src="https://imgur.com/v6ErIo9.gif">
|
||||
|
||||
<img src="https://imgur.com/VGZ0iuV.gif"> <img src="https://imgur.com/f4A5LRY.gif">
|
||||
|
||||
<img src="https://imgur.com/kOy8YSx.gif"> <img src="https://imgur.com/gNYsU00.gif">
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
|
||||
group = 'dev.codedred'
|
||||
version = '1.5'
|
||||
version = '1.5.2'
|
||||
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -69,9 +69,9 @@ public class PlayTimes extends JavaPlugin {
|
||||
UpdateChecker updater = new UpdateChecker(this, 58858);
|
||||
try {
|
||||
if (!updater.checkForUpdates()) {
|
||||
getLogger().warning(ChatUtil.format("&eYou are using an older version of PlayTimes!"));
|
||||
getLogger().info(ChatUtil.format("&eDownload the newest version here:"));
|
||||
getLogger().info(ChatUtil.format("&bhttps://www.spigotmc.org/resources/58858/"));
|
||||
getLogger().warning(ChatUtil.format("You are using an older version of PlayTimes!"));
|
||||
getLogger().info(ChatUtil.format("Download the newest version here:"));
|
||||
getLogger().info(ChatUtil.format("https://www.spigotmc.org/resources/58858/"));
|
||||
} else {
|
||||
getLogger().info("[PlayTimes] Plugin is up to date! - " + getDescription().getVersion());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.codedred.playtimes.api;
|
||||
|
||||
import me.codedred.playtimes.statistics.StatisticType;
|
||||
import me.codedred.playtimes.time.TimeManager;
|
||||
import me.codedred.playtimes.statistics.StatManager;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TimelessPlayer
|
||||
{
|
||||
private final UUID uuid;
|
||||
private final StatManager stats;
|
||||
private final TimeManager timings;
|
||||
|
||||
public TimelessPlayer(final Player player) {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.stats = StatManager.getInstance();
|
||||
this.timings = TimeManager.getInstance();
|
||||
}
|
||||
|
||||
public TimelessPlayer(final UUID player) {
|
||||
this.uuid = player;
|
||||
this.stats = StatManager.getInstance();
|
||||
this.timings = TimeManager.getInstance();
|
||||
}
|
||||
|
||||
public String getPlayTime() {
|
||||
return this.timings.buildFormat(this.stats.getPlayerStat(this.uuid, StatisticType.PLAYTIME) / 20L);
|
||||
}
|
||||
|
||||
public long getRawPlayTimeInSeconds() {
|
||||
return this.stats.getPlayerStat(this.uuid, StatisticType.PLAYTIME) / 20L;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package me.codedred.playtimes.api;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.codedred.playtimes.statistics.StatManager;
|
||||
import java.util.Map;
|
||||
import me.codedred.playtimes.models.Leaderboard;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.List;
|
||||
|
||||
public class TimelessServer {
|
||||
public List<UUID> getTop10Players() {
|
||||
final List<UUID> players = new ArrayList<>();
|
||||
final Leaderboard board = new Leaderboard();
|
||||
final Map<String, Integer> map = board.getTopTen();
|
||||
final Object[] array = map.keySet().toArray();
|
||||
for (int i = 0; i < map.size(); ++i) {
|
||||
players.add(UUID.fromString(array[i].toString()));
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public List<Integer> getTop10Times() {
|
||||
final List<Integer> players = new ArrayList<>();
|
||||
final Leaderboard board = new Leaderboard();
|
||||
final Map<String, Integer> map = board.getTopTen();
|
||||
final Object[] array = map.values().toArray();
|
||||
for (int i = 0; i < map.size(); ++i) {
|
||||
players.add(Integer.parseInt(array[i].toString()) / 20);
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getTopMap() {
|
||||
final Leaderboard board = new Leaderboard();
|
||||
return board.getTopTen();
|
||||
}
|
||||
|
||||
public UUID getNumberOne() {
|
||||
return this.getTop10Players().get(0);
|
||||
}
|
||||
|
||||
public UUID getNumberTwo() {
|
||||
return this.getTop10Players().get(1);
|
||||
}
|
||||
|
||||
public UUID getNumberThree() {
|
||||
return this.getTop10Players().get(2);
|
||||
}
|
||||
|
||||
public UUID getNumberFour() {
|
||||
return this.getTop10Players().get(3);
|
||||
}
|
||||
|
||||
public UUID getNumberFive() {
|
||||
return this.getTop10Players().get(4);
|
||||
}
|
||||
|
||||
public UUID getNumberSix() {
|
||||
return this.getTop10Players().get(5);
|
||||
}
|
||||
|
||||
public UUID getNumberSeven() {
|
||||
return this.getTop10Players().get(6);
|
||||
}
|
||||
|
||||
public UUID getNumberEight() {
|
||||
return this.getTop10Players().get(7);
|
||||
}
|
||||
|
||||
public UUID getNumberNine() {
|
||||
return this.getTop10Players().get(8);
|
||||
}
|
||||
|
||||
public UUID getNumberTen() {
|
||||
return this.getTop10Players().get(9);
|
||||
}
|
||||
|
||||
public String getUptime() {
|
||||
return StatManager.getInstance().getUptime();
|
||||
}
|
||||
|
||||
public long getUptimeInSeconds() {
|
||||
return TimeUnit.MILLISECONDS.toSeconds(ManagementFactory.getRuntimeMXBean().getUptime());
|
||||
}
|
||||
}
|
||||
@@ -133,6 +133,10 @@ public class Time implements CommandExecutor {
|
||||
} else {
|
||||
uuid = Objects.requireNonNull(Bukkit.getPlayer(playerName)).getUniqueId();
|
||||
}
|
||||
if (uuid == null) {
|
||||
sender.sendMessage(ChatUtil.formatWithPrefix("&c&lUser not found."));
|
||||
return;
|
||||
}
|
||||
if (block) {
|
||||
data.getData().set(blockedKey, uuid.toString());
|
||||
if (data.getData().contains("leaderboard." + uuid)) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
//import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Join implements Listener {
|
||||
@@ -32,6 +33,11 @@ public class Join implements Listener {
|
||||
|
||||
long time = StatManager.getInstance().getPlayerStat(uuid, StatisticType.PLAYTIME);
|
||||
leaderboardSection.set(uuid.toString(), time);
|
||||
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
// String lastPlayed = now.toString();
|
||||
// data.getData().set("last_played." + uuid, lastPlayed);
|
||||
|
||||
data.saveData();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
//import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Quit implements Listener {
|
||||
@@ -23,6 +24,10 @@ public class Quit implements Listener {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
long playtime = statManager.getPlayerStat(uuid, StatisticType.PLAYTIME);
|
||||
data.getData().set("leaderboard." + uuid, playtime);
|
||||
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
// String lastPlayed = now.toString();
|
||||
// data.getData().set("last_played." + uuid, lastPlayed);
|
||||
data.saveData();
|
||||
}
|
||||
}
|
||||
@@ -34,12 +34,17 @@ public class ServerUtils {
|
||||
*/
|
||||
public static boolean isRisenVersion() {
|
||||
String[] versionParts = Bukkit.getServer().getVersion().split("\\.");
|
||||
int majorVersion = Integer.parseInt(versionParts[1]);
|
||||
int minorVersion = Integer.parseInt(versionParts[2].replaceAll("[^0-9]", ""));
|
||||
|
||||
int majorVersion = Integer.parseInt(versionParts[1].replaceAll("[^0-9]", ""));
|
||||
int minorVersion = 0;
|
||||
if (versionParts.length >= 3)
|
||||
minorVersion = Integer.parseInt(versionParts[2].replaceAll("[^0-9]", ""));
|
||||
|
||||
return majorVersion >= 17 && minorVersion >= 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean hasPAPI() {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null)
|
||||
return DataManager.getInstance().getConfig().getBoolean("use-papi-placeholders");
|
||||
|
||||
@@ -3,7 +3,7 @@ main: me.codedred.playtimes.PlayTimes
|
||||
# Keeping 'Cmaaxx' as author for Metric purposes.
|
||||
author: Cmaaxx
|
||||
authors: [CodedRed]
|
||||
version: 1.5
|
||||
version: 1.5.2
|
||||
softdepend: [PlaceholderAPI]
|
||||
|
||||
commands:
|
||||
|
||||
Reference in new issue
Block a user