Compare commits

...

10 Commits

Author SHA1 Message Date
Len c82144c4bc Add Jenkinsfile 2024-08-04 22:33:02 +02:00
Len 61eed83d5e Fix IllegalArgumentException 2024-07-21 15:36:49 +02:00
Len 0d7258c35c Switch to DecentHolograms 2024-07-21 15:21:59 +02:00
Len 15c3d5dc26 Update 1.21 2024-07-21 00:40:13 +02:00
Len 3df5070cbd Update version 2023-12-18 19:19:15 +01:00
Len c7f65afbc7 Fix NPE 2023-07-21 22:32:40 +02:00
Len fd89f29064 Switch to mysql in TagConnection.java 2023-07-21 22:26:03 +02:00
Len fc9030037c Update holographicdisplays api usage 2023-07-21 22:25:42 +02:00
Len f2e08b6234 Change some gradle stuff 2023-07-21 22:16:36 +02:00
Len 7337217e7d Fix depends in plugin.yml 2023-07-21 22:15:10 +02:00
8 changed files with 112 additions and 36 deletions

20
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,20 @@
pipeline {
agent any
stages {
stage('Gradle') {
steps {
sh './gradlew build'
}
}
stage('Archive') {
steps {
archiveArtifacts artifacts: 'build/libs/', followSymlinks: false
}
}
stage('discord') {
steps {
discordSend description: "Build: ${BUILD_NUMBER}", showChangeset: true, result: currentBuild.currentResult, title: currentBuild.fullProjectName, webhookURL: env.discordwebhook
}
}
}
}

View File

@ -1,26 +1,32 @@
import java.io.ByteArrayOutputStream
import java.io.FileOutputStream
import java.net.URL
plugins {
`java-library`
`maven-publish`
id("xyz.jpenilla.run-paper") version "2.3.0"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
}
dependencies {
compileOnly("com.alttd:Galaxy-API:1.20.1-R0.1-SNAPSHOT") {
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") {
isChanging = true
}
compileOnly("com.alttd:AltitudeAPI:LATEST")
compileOnly("me.filoghost.holographicdisplays:holographicdisplays-api:3.0.0")
compileOnly("com.alttd:AltitudeAPI:0.0.2")
compileOnly("com.github.decentsoftware-eu:decentholograms:2.8.9")
compileOnly("org.jetbrains:annotations:16.0.2")
testImplementation("org.powermock:powermock-module-junit4:1.7.4")
testImplementation("org.powermock:powermock-api-mockito2:1.7.4")
}
group = "com.alttd"
version = "1.0.6"
group = "com.alttd.altitudetag"
version = System.getenv("BUILD_NUMBER") ?: gitCommit()
description = "AltitudeTag"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
}
}
@ -51,4 +57,54 @@ tasks {
withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}
jar {
archiveFileName.set("${rootProject.name}.jar")
}
runServer {
val dir = File(System.getProperty("user.home") + "/share/devserver/")
if (!dir.parentFile.exists()) {
dir.parentFile.mkdirs()
}
runDirectory.set(dir)
val fileName = "/galaxy.jar"
val file = File(dir.path + fileName)
if (!file.parentFile.exists()) {
file.parentFile.mkdirs()
}
if (!file.exists()) {
download("https://repo.destro.xyz/private/com/alttd/Galaxy-Server/Galaxy-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar", file)
}
serverJar(file)
minecraftVersion("1.20.4")
}
}
fun download(link: String, path: File) {
URL(link).openStream().use { input ->
FileOutputStream(path).use { output ->
input.copyTo(output)
}
}
}
fun gitCommit(): String {
val os = ByteArrayOutputStream()
project.exec {
commandLine = "git rev-parse --short HEAD".split(" ")
standardOutput = os
}
return String(os.toByteArray()).trim()
}
bukkit {
name = rootProject.name
main = "$group.${rootProject.name}"
version = "${rootProject.version}"
apiVersion = "1.21"
authors = listOf("Michael Ziluck", "destro174")
depend = listOf("AltitudeAPI", "DecentHolograms")
}

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -2,9 +2,11 @@ rootProject.name = "AltitudeTag"
dependencyResolutionManagement {
repositories {
mavenLocal()
mavenCentral()
maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
maven("https://repo.codemc.io/repository/maven-public/")
maven("https://jitpack.io/")
maven("https://repo.maven.apache.org/maven2/")
}
}

View File

@ -38,9 +38,9 @@ public class AltitudeTag extends JavaPlugin
{
instance = this;
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays"))
if (!Bukkit.getPluginManager().isPluginEnabled("DecentHolograms"))
{
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
getLogger().severe("*** DecentHolograms is not installed or not enabled. ***");
getLogger().severe("*** This plugin will be disabled. ***");
this.setEnabled(false);
return;
@ -63,6 +63,7 @@ public class AltitudeTag extends JavaPlugin
{
getLogger().severe("*** Could not connect to the database. ***");
getLogger().severe("*** This plugin will be disabled. ***");
ex.printStackTrace();
this.setEnabled(false);
return;
}
@ -123,7 +124,7 @@ public class AltitudeTag extends JavaPlugin
*/
public static void setTagger(UUID tagger, TagCause cause)
{
Player previousPlayer = Bukkit.getPlayer(instance.tagger);
Player previousPlayer = instance.tagger == null ? null : Bukkit.getPlayer(instance.tagger);
if (tagger != null)
{
@ -191,4 +192,5 @@ public class AltitudeTag extends JavaPlugin
{
return instance;
}
}

View File

@ -10,9 +10,8 @@ import java.util.function.Consumer;
import com.alttd.altitudetag.configuration.Config;
import com.alttd.altitudetag.configuration.Lang;
import com.gmail.filoghost.holographicdisplays.api.Hologram;
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
import eu.decentsoftware.holograms.api.DHAPI;
import eu.decentsoftware.holograms.api.holograms.Hologram;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
@ -134,7 +133,7 @@ public class Leaderboard
config.set("leaderboard.location.z", Config.LEADERBOARD_LOCATION_Z.getValue());
AltitudeTag.getInstance().saveConfig();
hologram.teleport(location);
hologram.setLocation(location);
refreshLeaderboard();
}
@ -142,17 +141,15 @@ public class Leaderboard
{
if (Config.LEADERBOARD_ENABLED.getValue())
{
hologram = HologramsAPI.createHologram(AltitudeTag.getInstance(),
new Location(Bukkit.getWorld(Config.LEADERBOARD_LOCATION_WORLD.getValue()),
Config.LEADERBOARD_LOCATION_X.getValue(),
Config.LEADERBOARD_LOCATION_Y.getValue(),
Config.LEADERBOARD_LOCATION_Z.getValue()));
hologram.appendTextLine(Config.LEADERBOARD_TITLE.getValue());
for (int i = 0; i < Config.LEADERBOARD_TOP.getValue(); i++)
hologram = getOrCreateHologram(new Location(Bukkit.getWorld(Config.LEADERBOARD_LOCATION_WORLD.getValue()),
Config.LEADERBOARD_LOCATION_X.getValue(),
Config.LEADERBOARD_LOCATION_Y.getValue(),
Config.LEADERBOARD_LOCATION_Z.getValue()));
for (int i = 0; i < Config.LEADERBOARD_TOP.getValue() + 1; i++)
{
hologram.appendTextLine("");
DHAPI.addHologramLine(hologram, "");
}
DHAPI.setHologramLine(hologram, 0, Config.LEADERBOARD_TITLE.getValue());
refreshLeaderboard();
}
@ -167,7 +164,7 @@ public class Leaderboard
Objects.requireNonNull(hologram);
Bukkit.getScheduler().runTaskAsynchronously(AltitudeTag.getInstance(), () ->
Bukkit.getScheduler().runTask(AltitudeTag.getInstance(), () -> // should become async again
{
String sql = "SELECT player_uuid, player_tags FROM Player ORDER BY player_tags DESC LIMIT ?";
try (PreparedStatement ps = TagConnection.getConnection().prepareStatement(sql))
@ -176,7 +173,6 @@ public class Leaderboard
ResultSet rs = ps.executeQuery();
for (int i = 0; i < Config.LEADERBOARD_TOP.getValue(); i++)
{
final int finalInt = i;
String text;
if (rs != null && rs.next())
{
@ -189,10 +185,7 @@ public class Leaderboard
{
text = "";
}
if (!((TextLine) hologram.getLine(finalInt + 1)).getText().equals(text))
{
Bukkit.getScheduler().runTask(AltitudeTag.getInstance(), () -> ((TextLine) hologram.getLine(finalInt + 1)).setText(text));
}
DHAPI.setHologramLine(hologram, 1 + i, text);
}
}
catch (SQLException ex)
@ -202,4 +195,12 @@ public class Leaderboard
});
}
public static Hologram getOrCreateHologram(Location location) {
Hologram hologram1 = DHAPI.getHologram("TagLeaderBoard");
if (hologram1 != null)
return hologram1;
return DHAPI.createHologram("TagLeaderBoard", location);
}
}

View File

@ -46,8 +46,8 @@ public class TagConnection
{
return;
}
Class.forName("org.mariadb.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mariadb://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password);
// Class.forName("org.mariadb.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password);
}
}

View File

@ -1,5 +0,0 @@
main: com.alttd.altitudetag.AltitudeTag
name: AltitudeTag
version: ${project.version}
author: Michael Ziluck
softdepend: [HolographicDisplays]