Skip to content

Commit

Permalink
feat: Implement logic
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed Apr 23, 2023
1 parent 559a677 commit 7827262
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 141 deletions.
17 changes: 1 addition & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@ plugins {
}

dependencies {
implementation(projects.exampleExpansionVelocity)
implementation(projects.exampleExpansionPaper)
}

subprojects {
apply<JavaPlugin>()
repositories {
maven("https://papermc.io/repo/repository/maven-public/")
}
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
}
implementation(project(":placeholderapi-expansion-paper"))
}

tasks {
Expand Down
6 changes: 0 additions & 6 deletions common/build.gradle.kts

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group = io.github.miniplaceholders
version = 1.0.0
description = Example-Expansion
description = PlaceholderAPI-Expansion
5 changes: 1 addition & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ adventure = "4.13.1"

[libraries]

velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }

adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
adventure-minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
placeholderapi = { group = "me.clip", name = "placeholderapi", version = "2.11.3" }

[plugins]

Expand Down
17 changes: 16 additions & 1 deletion paper/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
plugins {
java
}

repositories {
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}

dependencies {
compileOnly(libs.paper.api)
compileOnly(libs.miniplaceholders)
implementation(projects.exampleExpansionCommon)
compileOnly(libs.placeholderapi)
}

tasks {
Expand All @@ -10,4 +19,10 @@ tasks {
expand("version" to project.version)
}
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.github.miniplaceholders.expansion.placeholderapi.paper;

import io.github.miniplaceholders.api.utils.LegacyUtils;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import io.github.miniplaceholders.api.Expansion;
import net.kyori.adventure.text.minimessage.tag.Tag;

import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.*;

public final class PaperPlugin extends JavaPlugin {

@Override
public void onEnable(){
this.getSLF4JLogger().info("Starting PlaceholderAPI Expansion for MiniPlaceholders Paper");

Expansion.builder("placeholderapi")
.filter(Player.class)
.globalPlaceholder("global", (queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final String papiParsed = PlaceholderAPI.setPlaceholders(
null,
argument
).replace(SECTION_CHAR, AMPERSAND_CHAR);

return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
})
.audiencePlaceholder("player", (aud, queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final String papiParsed = PlaceholderAPI.setPlaceholders(
(Player)aud,
argument
).replace(SECTION_CHAR, AMPERSAND_CHAR);

return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
})
.relationalPlaceholder("relational", (player, toShow, queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final String papiParsed = PlaceholderAPI.setRelationalPlaceholders(
(Player) player,
(Player) toShow,
argument
).replace(SECTION_CHAR, AMPERSAND_CHAR);

return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
})
.build()
.register();
}
}
9 changes: 4 additions & 5 deletions paper/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Example-Expansion
name: PlaceholderAPI-Expansion
version: '${version}'
author: 4drian3d
main: io.github.miniplaceholders.expansion.example.paper.PaperPlugin
main: io.github.miniplaceholders.expansion.placeholderapi.paper.PaperPlugin
api-version: '1.19'
folia-supported: true
dependencies:
- name: MiniPlaceholders
required: true
# Add some plugin dependency
#- name: spark
# required: true
- name: PlaceholderAPI
required: true
8 changes: 4 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

rootProject.name = "Example-Expansion"
rootProject.name = "PlaceholderAPI-Expansion"

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

arrayOf("common", "paper", "velocity").forEach {
include("example-expansion-$it")
arrayOf("paper").forEach {
include("placeholderapi-expansion-$it")

project(":example-expansion-$it").projectDir = file(it)
project(":placeholderapi-expansion-$it").projectDir = file(it)
}

15 changes: 0 additions & 15 deletions velocity/build.gradle.kts

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 7827262

Please sign in to comment.