Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
94 changes: 0 additions & 94 deletions build.gradle

This file was deleted.

108 changes: 108 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
`java-library`
`maven-publish`
alias(libs.plugins.shadow)
alias(libs.plugins.run.paper)
}

repositories {
mavenLocal()
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.skriptlang.org/releases")
maven("https://jitpack.io")
}

java {
disableAutoTargetJvm()
toolchain.languageVersion = JavaLanguageVersion.of(21)
}

description = "A skript addon that aims to bring more to linking ItemsAdder and Skript"
group = "me.asleepp"
version = "1.6"

dependencies {
compileOnly(libs.paper.api)
compileOnly(libs.lombok)
compileOnly(libs.itemsadder)
compileOnly(libs.skript)
annotationProcessor(libs.lombok)
}


tasks {
jar {
enabled = false
}

shadowJar {
archiveFileName = "${rootProject.name}-${project.version}.jar"
archiveClassifier = null

manifest {
attributes["Implementation-Version"] = rootProject.version
}

configurations = listOf(project.configurations.shadow.get())
minimize()
}

assemble {
dependsOn(shadowJar)
}

withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release = 17
}

withType<Javadoc>() {
options.encoding = Charsets.UTF_8.name()
}

processResources {
filter<ReplaceTokens>("tokens" to mapOf("version" to project.version))
inputs.property("version", project.version)

filesMatching("plugin.yml") {
expand(
"version" to rootProject.version,
)
}
}

defaultTasks("build")

// 1.8.8 - 1.16.5 = Java 8
// 1.17 = Java 16
// 1.18 - 1.20.4 = Java 17
// 1-20.5+ = Java 21
val version = "1.20.4"
val javaVersion = JavaLanguageVersion.of(17)

val jvmArgsExternal = listOf(
"-Dcom.mojang.eula.agree=true"
)

runServer {
minecraftVersion(version)
runDirectory = rootDir.resolve("run/paper/$version")

javaLauncher = project.javaToolchains.launcherFor {
languageVersion = javaVersion
}

downloadPlugins {
url("https://download.luckperms.net/1552/bukkit/loader/LuckPerms-Bukkit-5.4.137.jar")
url("https://github.com/SkriptLang/Skript/releases/download/2.9.1/Skript-2.9.1.jar")
url("https://github.com/dmulloy2/ProtocolLib/releases/download/5.2.0/ProtocolLib.jar")
url("https://github.com/LoneDev6/SpigotUtilities/raw/master/LoneLibs.jar")
}

jvmArgs = jvmArgsExternal
}
}

3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon=true
17 changes: 17 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[versions]
paper-api = "1.21-R0.1-SNAPSHOT"
lombok = "1.18.34"
shadow = "8.1.8"
run-paper = "2.3.0"
skript = "2.7.1"
itemsadder = "3.6.1"

[libraries]
paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paper-api" }
lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" }
skript = { group = "com.github.SkriptLang", name = "Skript", version.ref = "skript"}
itemsadder = { group = "com.github.LoneDev6", name = "API-ItemsAdder", version.ref = "itemsadder"}

[plugins]
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" }
shadow = { id = "io.github.goooler.shadow", version.ref = "shadow" }
1 change: 0 additions & 1 deletion settings.gradle

This file was deleted.

12 changes: 12 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

rootProject.name = "skript-itemsadder"
56 changes: 47 additions & 9 deletions src/main/java/me/asleepp/SkriptItemsAdder/SkriptItemsAdder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

import java.io.IOException;


import ch.njol.skript.util.Version;
import lombok.Getter;
import me.asleepp.SkriptItemsAdder.aliases.AliasesGenerator;
import me.asleepp.SkriptItemsAdder.listeners.ItemsAdderEventListener;
import me.asleepp.SkriptItemsAdder.util.Metrics;
import me.asleepp.SkriptItemsAdder.util.SkriptItemsAdderCommand;
import me.asleepp.SkriptItemsAdder.util.UpdateChecker;
import me.asleepp.SkriptItemsAdder.util.Util;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -13,57 +19,89 @@

import javax.annotation.Nullable;

@SuppressWarnings("ALL")
public class SkriptItemsAdder extends JavaPlugin {

private static SkriptAddon addon;

private static SkriptItemsAdder instance;
@Getter
private AliasesGenerator aliasesGenerator;

@Nullable
public static SkriptItemsAdder getInstance() {
return instance;
}

@Nullable
public static SkriptAddon getAddonInstance() {
return addon;
}

private final PluginManager manager = this.getServer().getPluginManager();

@Override
public void onEnable() {
// Let's get this show on the road.
final PluginManager manager = this.getServer().getPluginManager();
long start = System.currentTimeMillis();
final Plugin skript = manager.getPlugin("Skript");
if (skript == null || !skript.isEnabled()) {
getLogger().severe("Could not find Skript! Disabling...");
manager.disablePlugin(this);
return;
} else if (Skript.getVersion().compareTo(new Version(2, 7, 0)) < 0) {
getLogger().warning("You are running an unsupported version of Skript. Disabling...");
} else if (Skript.getVersion().isSmallerThan(new Version(2, 7, 0))) {
getLogger().severe("You are running an unsupported version of Skript. Disabling...");
manager.disablePlugin(this);
return;
}
if (!Skript.isAcceptRegistrations()) {
getLogger().severe("The plugin can't load when it's already loaded! Disabling...");
manager.disablePlugin(this);
return;
}

final Plugin itemsadder = manager.getPlugin("ItemsAdder");
if (itemsadder == null || !itemsadder.isEnabled()) {
getLogger().severe("Could not find ItemsAdder! Disabling...");
manager.disablePlugin(this);
return;
}

this.aliasesGenerator = new AliasesGenerator(this);

final SkriptItemsAdder plugin = this;

// Pass the aliasesGenerator to the event listener
ItemsAdderEventListener eventListener = new ItemsAdderEventListener(plugin, aliasesGenerator);
manager.registerEvents(eventListener, plugin);

int pluginId = 20971;
Metrics metrics = new Metrics(this, pluginId);
metrics.addCustomChart(new Metrics.SimplePie("skript_version", () -> Skript.getVersion().toString()));
metrics.addCustomChart(new Metrics.SimplePie("itemsadder_version", () -> Util.getPluginVersion("ItemsAdder")));
instance = this;
addon = Skript.registerAddon(this);
addon.setLanguageFileDirectory("lang");
new SkriptItemsAdderCommand(this);

saveDefaultConfig();

try {
addon.loadClasses("me.asleepp.SkriptItemsAdder");
addon.loadClasses("me.asleepp.SkriptItemsAdder", "elements");
} catch (IOException error) {
error.printStackTrace();
manager.disablePlugin(this);
return;
}

if (getConfig().getBoolean("check-for-updates", true))
new UpdateChecker(this);

long finish = System.currentTimeMillis() - start;
getLogger().info("Successfully loaded skript-itemsadder in " + finish + "ms!");
eventListener.generateAliases();
}


}
@Override
public void onDisable() {
aliasesGenerator.saveAliases();
}
}
Loading