12 Commits
Author SHA1 Message Date
CodedRed b4b899b031 version update 2023-07-27 16:40:33 -05:00
CodedRed 3f2fe03fff added old api back 2023-07-27 16:39:35 -05:00
CodedRed 71917d811d fixed block command bug 2023-07-12 21:11:56 -05:00
CodedRed 185510320b text fix 2023-07-12 21:02:31 -05:00
CodedRed bf320aca14 version update 2023-07-12 20:58:52 -05:00
CodedRed 4497848cc5 removing this for now 2023-07-12 20:58:21 -05:00
CodedRed 8ff6cd3a33 updated version number 2023-07-12 20:57:53 -05:00
CodedRed ab497b8157 fixed bug again 2023-07-12 20:51:06 -05:00
CodedRed a13fdba083 another bug fix 2023-07-12 20:33:01 -05:00
CodedRed 044c4c8f13 wip last joined placeholder 2023-07-12 20:24:33 -05:00
CodedRed 2d6501dbfc potential bug fix for version issue 2023-07-12 20:22:38 -05:00
Christopher 3435ac4fdd Update README.md 2023-07-11 16:20:22 -05:00
10 changed files with 155 additions and 8 deletions

No files matched your search

+7 -1
View File
@@ -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
View File
@@ -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");
+1 -1
View File
@@ -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: