mirror of
https://github.com/CodedRed-Spigot/PlayTimes.git
synced 2026-11-06 01:32:33 -05:00
Compare commits
11
Commits
1.6.2
..
production
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52e989b6b0 | ||
|
|
393000c8db | ||
|
|
0bfb51e9a1 | ||
|
|
d8ae3aca1e | ||
|
|
d8245aa23f | ||
|
|
cdead9f0f8 | ||
|
|
ff0670c65c | ||
|
|
deb86b6772 | ||
|
|
afe66090f9 | ||
|
|
cbc8b632e0 | ||
|
|
8630c14648 |
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'dev.codedred'
|
||||
version = '1.6.2'
|
||||
version = '1.6.2b'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
NEW_VERSION="1.6.2b"
|
||||
|
||||
git checkout main
|
||||
git pull origin main
|
||||
|
||||
git tag -a $NEW_VERSION -m "Release version $NEW_VERSION"
|
||||
|
||||
git push origin $NEW_VERSION
|
||||
|
||||
git checkout production
|
||||
git pull origin production
|
||||
|
||||
git merge main -m "Release $NEW_VERSION"
|
||||
|
||||
git push origin production
|
||||
|
||||
echo "Release $NEW_VERSION completed and merged into production."
|
||||
read -p "Press any key to continue... "
|
||||
@@ -31,9 +31,13 @@ public class UpdateChecker {
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setUseCaches(true);
|
||||
|
||||
latestVersion =
|
||||
new BufferedReader(new InputStreamReader(connection.getInputStream()))
|
||||
.readLine();
|
||||
try (
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream())
|
||||
)
|
||||
) {
|
||||
latestVersion = reader.readLine();
|
||||
}
|
||||
|
||||
if (latestVersion == null || latestVersion.isEmpty()) {
|
||||
throw new IOException("Failed to retrieve latest version.");
|
||||
|
||||
@@ -31,14 +31,18 @@ public class CustomConfig {
|
||||
|
||||
this.dataConfig = YamlConfiguration.loadConfiguration(this.dataConfigFile);
|
||||
|
||||
if (name == "config.yml") checkAndAddDefaults();
|
||||
if ("config.yml".equals(name)) checkAndAddDefaults();
|
||||
|
||||
InputStream defConfigStream = this.plugin.getResource(name);
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(
|
||||
new InputStreamReader(defConfigStream)
|
||||
);
|
||||
this.dataConfig.setDefaults(defConfig);
|
||||
try (InputStream defConfigStream = this.plugin.getResource(name)) {
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(
|
||||
new InputStreamReader(defConfigStream)
|
||||
);
|
||||
this.dataConfig.setDefaults(defConfig);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
this.plugin.getLogger()
|
||||
.log(Level.SEVERE, "Error reading default config", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +159,7 @@ public class CustomConfig {
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
if ((this.dataConfig == null) || (this.dataConfigFile == null)) return;
|
||||
if (this.dataConfig == null || this.dataConfigFile == null) return;
|
||||
try {
|
||||
getConfig().save(this.dataConfigFile);
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.codedred.playtimes.listeners;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import me.codedred.playtimes.afk.AFKManager;
|
||||
import me.codedred.playtimes.data.DataManager;
|
||||
import me.codedred.playtimes.data.database.manager.DatabaseManager;
|
||||
@@ -19,27 +20,25 @@ public class Quit implements Listener {
|
||||
|
||||
// Database
|
||||
if (data.hasDatabase()) {
|
||||
DatabaseManager dbManager = DatabaseManager.getInstance();
|
||||
dbManager.updatePlaytime(
|
||||
uuid,
|
||||
StatManager
|
||||
.getInstance()
|
||||
.getPlayerStat(
|
||||
event.getPlayer().getUniqueId(),
|
||||
StatisticType.PLAYTIME
|
||||
) /
|
||||
20,
|
||||
AFKManager.getInstance().getAFKTime(event.getPlayer().getUniqueId())
|
||||
);
|
||||
} else {
|
||||
// save afktime in data.yml
|
||||
data
|
||||
.getData()
|
||||
.set(
|
||||
"afktime." + uuid,
|
||||
AFKManager.getInstance().getAFKTime(event.getPlayer().getUniqueId())
|
||||
CompletableFuture.runAsync(() -> {
|
||||
DatabaseManager dbManager = DatabaseManager.getInstance();
|
||||
dbManager.updatePlaytime(
|
||||
uuid,
|
||||
StatManager
|
||||
.getInstance()
|
||||
.getPlayerStat(uuid, StatisticType.PLAYTIME) /
|
||||
20,
|
||||
AFKManager.getInstance().getAFKTime(uuid)
|
||||
);
|
||||
data.saveData();
|
||||
});
|
||||
} else {
|
||||
// Save AFK time in data.yml
|
||||
CompletableFuture.runAsync(() -> {
|
||||
data
|
||||
.getData()
|
||||
.set("afktime." + uuid, AFKManager.getInstance().getAFKTime(uuid));
|
||||
data.saveData();
|
||||
});
|
||||
}
|
||||
|
||||
// Leaderboard
|
||||
@@ -48,18 +47,19 @@ public class Quit implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
StatManager statManager = StatManager.getInstance();
|
||||
long playtime = statManager.getPlayerStat(uuid, StatisticType.PLAYTIME);
|
||||
if (
|
||||
!data.getConfig().getBoolean("top-playtime.track-rawtime", false) &&
|
||||
data.hasAfkEnabled()
|
||||
) {
|
||||
playtime -=
|
||||
AFKManager.getInstance().getAFKTime(event.getPlayer().getUniqueId()) *
|
||||
20;
|
||||
}
|
||||
// Run leaderboard update
|
||||
CompletableFuture.runAsync(() -> {
|
||||
StatManager statManager = StatManager.getInstance();
|
||||
long playtime = statManager.getPlayerStat(uuid, StatisticType.PLAYTIME);
|
||||
if (
|
||||
!data.getConfig().getBoolean("top-playtime.track-rawtime", false) &&
|
||||
data.hasAfkEnabled()
|
||||
) {
|
||||
playtime -= AFKManager.getInstance().getAFKTime(uuid) * 20;
|
||||
}
|
||||
|
||||
data.getData().set("leaderboard." + uuid, playtime);
|
||||
data.saveData();
|
||||
data.getData().set("leaderboard." + uuid, playtime);
|
||||
data.saveData();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -10,25 +10,28 @@ public class HexUtil {
|
||||
|
||||
public static String hex(String message) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int index = 0;
|
||||
int length = message.length();
|
||||
|
||||
while (index < message.length()) {
|
||||
int colorCodeStart = message.indexOf("<#", index);
|
||||
if (colorCodeStart != -1) {
|
||||
int colorCodeEnd = message.indexOf(">", colorCodeStart + 2);
|
||||
if (colorCodeEnd != -1) {
|
||||
builder.append(message, index, colorCodeStart);
|
||||
String hexCode = message.substring(colorCodeStart + 2, colorCodeEnd);
|
||||
ChatColor hexColor = ChatColor.of('#' + hexCode);
|
||||
builder.append(hexColor);
|
||||
index = colorCodeEnd + 1;
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (
|
||||
message.charAt(i) == '<' &&
|
||||
i + 8 < length &&
|
||||
message.charAt(i + 1) == '#'
|
||||
) {
|
||||
String hexCode = message.substring(i + 2, i + 8);
|
||||
if (message.charAt(i + 8) == '>' && isValidHexCode(hexCode)) {
|
||||
builder.append(ChatColor.of('#' + hexCode));
|
||||
i += 8; // Skip the processed hex code and the '>'
|
||||
continue;
|
||||
}
|
||||
}
|
||||
builder.append(message.substring(index));
|
||||
break;
|
||||
builder.append(message.charAt(i));
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', builder.toString());
|
||||
}
|
||||
|
||||
private static boolean isValidHexCode(String hexCode) {
|
||||
return hexCode.matches("^[a-fA-F0-9]{6}$");
|
||||
}
|
||||
}
|
||||
@@ -36,16 +36,36 @@ public class ServerUtils {
|
||||
* @return true if so
|
||||
*/
|
||||
public static boolean isRisenVersion() {
|
||||
String[] versionParts = Bukkit.getServer().getVersion().split("\\.");
|
||||
String version = Bukkit.getServer().getVersion();
|
||||
String mcVersion = null;
|
||||
|
||||
int majorVersion = Integer.parseInt(
|
||||
versionParts[1].replaceAll("[^0-9]", "")
|
||||
);
|
||||
int minorVersion = 0;
|
||||
if (versionParts.length >= 3) minorVersion =
|
||||
Integer.parseInt(versionParts[2].replaceAll("[^0-9]", ""));
|
||||
if (version.contains("(MC:")) {
|
||||
int startIndex = version.indexOf("(MC:") + 5;
|
||||
int endIndex = version.indexOf(")", startIndex);
|
||||
mcVersion = version.substring(startIndex, endIndex).trim();
|
||||
}
|
||||
|
||||
return majorVersion >= 17 && minorVersion >= 0;
|
||||
if (mcVersion == null) {
|
||||
Bukkit
|
||||
.getLogger()
|
||||
.warning("PlayTimes failed to extract Minecraft version: " + version);
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] versionParts = mcVersion.split("\\.");
|
||||
|
||||
try {
|
||||
int minorVersion = versionParts.length >= 2
|
||||
? Integer.parseInt(versionParts[1])
|
||||
: 0;
|
||||
|
||||
return minorVersion >= 17;
|
||||
} catch (NumberFormatException e) {
|
||||
Bukkit
|
||||
.getLogger()
|
||||
.warning("PlayTimes failed to parse Minecraft version: " + mcVersion);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasPAPI() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
name: Playtimes
|
||||
version: "${version}"
|
||||
main: me.codedred.playtimes.PlayTimes
|
||||
api-version: 1.19
|
||||
author: Cmaaxx
|
||||
authors: [CodedRed]
|
||||
softdepend: [PlaceholderAPI]
|
||||
|
||||
Reference in new issue
Block a user