Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# settings.gradle.kts picks this checkout up as an included build. Keep the path
# in sync with the candidates listed there, otherwise the build cannot resolve it.
- name: Checkout CyberCore dependency
uses: actions/checkout@v4
with:
repository: BitAspire/CyberCore
path: CyberCore

- name: Set up JDK (Temurin 21)
uses: actions/setup-java@v4
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0

# settings.gradle.kts picks this checkout up as an included build. Keep the path
# in sync with the candidates listed there, otherwise the build cannot resolve it.
- name: Checkout CyberCore dependency

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pin the CyberCore checkout to the ref that matches the 2.1.0 coordinate so releases aren't built against an unrelated HEAD.

Suggested change
- name: Checkout CyberCore dependency
- name: Checkout CyberCore dependency
uses: actions/checkout@v4
with:
repository: BitAspire/CyberCore
ref: 2.1.0
path: CyberCore

uses: actions/checkout@v4
with:
repository: BitAspire/CyberCore
path: CyberCore

- name: Set up Java
uses: actions/setup-java@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "com.bitaspire"
version = "1.2.9"
version = "1.3.0"

repositories {
mavenLocal()
Expand All @@ -37,7 +37,7 @@ dependencies {
// Spigot API
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")

implementation(files("libraries/CyberCore-2.0.0.jar"))
implementation("com.bitaspire:CyberCore:2.1.0")

compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly(files("libraries/RivalHarvesterHoesAPI.jar"))
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
Expand Down
Binary file removed libraries/CyberCore-2.0.0.jar
Binary file not shown.
11 changes: 11 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
rootProject.name = "CyberLevels"

// Builds these from source and substitutes them for their com.bitaspire coordinates, so this
// plugin can be developed against unpublished changes. Locally the checkouts are sibling folders;
// CI checks them out inside this repository instead. They are not on any maven repository, so the
// checkout is required rather than a fallback.
listOf("CyberCore").forEach { dependency ->

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fail fast when no CyberCore checkout is found so a fresh clone doesn't fall through to Maven Central and produce a confusing resolution error.

Suggested change
listOf("CyberCore").forEach { dependency ->
listOf("CyberCore").forEach { dependency ->
val included = listOf("../$dependency", dependency)
.map(::file)
.firstOrNull { it.resolve("settings.gradle.kts").isFile }
checkNotNull(included) {
"Cannot locate a local checkout of '$dependency'. Expected a sibling folder or './$dependency' containing settings.gradle.kts."
}
includeBuild(included)
}

listOf("../$dependency", dependency)
.map(::file)
.firstOrNull { it.resolve("settings.gradle.kts").isFile }
?.let(::includeBuild)
}
3 changes: 2 additions & 1 deletion src/main/java/com/bitaspire/cyberlevels/CyberLevels.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bitaspire.cyberlevels;

import com.bitaspire.cybercore.TextLibrary;
import com.bitaspire.libs.common.CollectionBuilder;
import com.bitaspire.libs.vnc.VNC;
import com.bitaspire.cybercore.CoreSettings;
Expand Down Expand Up @@ -279,7 +280,7 @@ public double serverVersion() {
*
* @return active Takion library facade
*/
public TakionLib library() {
public TextLibrary library() {
return core.getLibrary();
}

Expand Down
64 changes: 41 additions & 23 deletions src/main/java/com/bitaspire/cyberlevels/command/CLVCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import com.bitaspire.cyberlevels.CyberLevels;
import com.bitaspire.cyberlevels.cache.Lang;
import com.bitaspire.cyberlevels.level.LevelSystem;
import com.bitaspire.cyberlevels.user.Database;
import com.bitaspire.cyberlevels.user.LevelUser;
import com.bitaspire.libs.common.util.ReplaceUtils;
import com.bitaspire.libs.prismatic.PrismaticAPI;
import com.bitaspire.libs.vnc.VNC;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -90,23 +91,7 @@ public boolean onCommand(
switch (sub) {
case "about":
if (isRestricted(player, "player.about")) return true;
if (player == null) {
main.logger(
" &d&lCyber&f&lLevels &fv" +
main.getDescription().getVersion() +
" &7(&7&nhttps://bit.ly/2YSlqYq&7).",
" &fDeveloped by &d" + main.getAuthors() + "&f.",
" A leveling system plugin with MySQL support and custom events."
);
return true;
}
return main.createSender(player).send(
" &d&lCyber&f&lLevels &fv" +
main.getDescription().getVersion() +
" &7(&7&nhttps://bit.ly/2YSlqYq&7).",
" &fDeveloped by &d" + main.getAuthors() + "&f.",
" A leveling system plugin with MySQL support and custom events."
);
return sendAbout(sender, player);
case "reload":
if (isRestricted(player, "admin.reload")) return true;

Expand Down Expand Up @@ -281,6 +266,35 @@ public boolean onCommand(
return sendLangMessage(sender, player, Lang::getNoPermission);
}

private boolean sendAbout(CommandSender sender, Player player) {
Database<?> database = main.userManager() == null ?
null :
main.userManager().getDatabase();
boolean databaseEnabled = main.cache().config().database().isEnabled();
boolean databaseConnected = database != null && database.isConnected();

String[] lines = new String[] {
" &d&lCyber&f&lLevels &fv" + main.getDescription().getVersion() + "&7.",
" &7Server: &f" + serverInfo(),
" &7Authors: &f" + main.getAuthors(),
" &7Database: &f" + databaseConnected + " &7(enabled: &f" + databaseEnabled +

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the disconnected state visually obvious so operators can spot a broken DB at a glance.

Suggested change
" &7Database: &f" + databaseConnected + " &7(enabled: &f" + databaseEnabled +
" &7Database: &f" + (databaseConnected ? "&aconnected" : "&cdisconnected") +
" &7(enabled: &f" + databaseEnabled +
"&7, type: &f" + main.cache().config().database().getType() + "&7)",

"&7, type: &f" + main.cache().config().database().getType() + "&7)",
" &7Config: &fauto-save " + main.cache().config().isAutoSaveEnabled() +
" / " + main.cache().config().getAutoSaveInterval() + "s&7, &fleaderboard " +
main.cache().config().isLeaderboardEnabled() + " / " +
main.cache().config().getLeaderboardMaxPositions() + " positions",
" &7Engine: &f" + (main.cache().config().useBigDecimalSystem() ? "BigDecimal" : "Double") +
"&7, &fEXP integer-only " + main.cache().config().isExpIntegerOnly()
};

if (player == null) {
main.logger(lines);
return true;
}

return main.createSender(player).send(lines);
}

private boolean sendLangMessage(
CommandSender cmdSender,
Player player,
Expand All @@ -297,7 +311,7 @@ private boolean sendLangMessage(
String out = stripConsoleChannels(line);
if (!out.isEmpty()) {
cmdSender.sendMessage(
ChatColor.translateAlternateColorCodes('&', out)
PrismaticAPI.colorize(out)
);
}
}
Expand Down Expand Up @@ -348,7 +362,7 @@ private boolean sendLangMessage(
out = stripConsoleChannels(out);
if (!out.isEmpty()) {
cmdSender.sendMessage(
ChatColor.translateAlternateColorCodes('&', out)
PrismaticAPI.colorize(out)
);
}
}
Expand All @@ -369,15 +383,19 @@ private LevelUser<?> resolveUserByName(String name) {
LevelUser<?> user = main.userManager().getUser(name);
if (user != null) return user;

Player online = Bukkit.getPlayerExact(name);
Player online = main.getServer().getPlayerExact(name);
if (online != null) return main.userManager().getUser(online);

OfflinePlayer offline = Bukkit.getOfflinePlayer(name);
OfflinePlayer offline = main.getServer().getOfflinePlayer(name);
if (!offline.hasPlayedBefore() && !offline.isOnline()) return null;

return main.userManager().getUser(offline.getUniqueId());
}

private static String serverInfo() {
return VNC.SERVER != null ? VNC.SERVER.getImplementationVersion() : "Unknown";
}

private boolean sendLevelInfo(Player player) {
if (player == null) return true;

Expand Down
Loading