Compare commits

..
102 Commits
Author SHA1 Message Date
Adrian 5adadcbbcb release: Version 2.0.2 2023-04-11 11:41:50 -05:00
Adrian 4c1739f3b0 feat: Added Folia Support 2023-04-11 11:38:52 -05:00
Adrian dcfd2a6fe1 Merge pull request #49 from MiniPlaceholders/renovate/net.kyori-adventure-text-serializer-plain-4.x
fix(deps): update dependency net.kyori:adventure-text-serializer-plain to v4.13.1
2023-04-09 21:38:18 -05:00
renovate[bot] b7a56198f4 fix(deps): update dependency net.kyori:adventure-text-serializer-plain to v4.13.1 2023-04-10 02:18:01 +00:00
Adrian 2d9fdaccc2 Merge pull request #48 from MiniPlaceholders/renovate/net.kyori-adventure-text-serializer-legacy-4.x
fix(deps): update dependency net.kyori:adventure-text-serializer-legacy to v4.13.1
2023-04-09 21:17:49 -05:00
Adrian 4f63f55d11 Merge pull request #47 from MiniPlaceholders/renovate/adventure
fix(deps): update adventure to v4.13.1
2023-04-09 21:17:33 -05:00
renovate[bot] 5495f5f57a fix(deps): update dependency net.kyori:adventure-text-serializer-legacy to v4.13.1 2023-04-10 01:56:07 +00:00
renovate[bot] d33e98714a fix(deps): update adventure to v4.13.1 2023-04-10 01:56:02 +00:00
Adrian e6e98c9852 Merge pull request #45 from MiniPlaceholders/renovate/kotlin-monorepo
fix(deps): update kotlin monorepo to v1.8.20
2023-04-06 18:16:14 -05:00
renovate[bot] 6f9abbefc9 fix(deps): update kotlin monorepo to v1.8.20 2023-04-06 23:06:12 +00:00
Adrian 7ee6dcb1b7 Merge pull request #46 from MiniPlaceholders/renovate/userdev
chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.4
2023-04-04 22:44:55 -05:00
renovate[bot] db37d4ae66 chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.4 2023-04-05 02:25:46 +00:00
Adrian 38b707d091 Merge pull request #43 from MiniPlaceholders/renovate/shadow
chore(deps): update shadow to v8.1.1
2023-03-20 17:50:22 -05:00
renovate[bot] 6737e63232 chore(deps): update shadow to v8.1.1 2023-03-20 21:45:41 +00:00
Adrian 5f9c42c5d7 release: version 2.0.1 2023-03-15 15:59:07 -05:00
Adrian f97665fe47 fix: updated to Paper 1.19.4 2023-03-15 15:56:12 -05:00
Adrian 202782e053 Merge pull request #41 from MiniPlaceholders/renovate/net.kyori-adventure-text-serializer-plain-4.x
fix(deps): update dependency net.kyori:adventure-text-serializer-plain to v4.13.0
2023-03-14 12:21:38 -05:00
Adrian 20da844129 Merge pull request #40 from MiniPlaceholders/renovate/net.kyori-adventure-text-serializer-legacy-4.x
fix(deps): update dependency net.kyori:adventure-text-serializer-legacy to v4.13.0
2023-03-14 12:21:30 -05:00
renovate[bot] e98b222250 fix(deps): update dependency net.kyori:adventure-text-serializer-plain to v4.13.0 2023-03-14 12:40:00 +00:00
Adrian 430c483f39 Merge pull request #39 from MiniPlaceholders/renovate/adventure
fix(deps): update adventure to v4.13.0
2023-03-14 07:39:26 -05:00
renovate[bot] 92798a38c7 fix(deps): update dependency net.kyori:adventure-text-serializer-legacy to v4.13.0 2023-03-14 09:30:17 +00:00
renovate[bot] 5f491e9553 fix(deps): update adventure to v4.13.0 2023-03-14 09:30:11 +00:00
Adrian 1a862fce44 Merge pull request #37 from MiniPlaceholders/renovate/org.jetbrains.dokka
fix(deps): update dependency org.jetbrains.dokka:dokka-gradle-plugin to v1.8.10
2023-03-04 11:43:25 -05:00
Adrian da965a7b4a Merge pull request #36 from MiniPlaceholders/renovate/dokka
chore(deps): update dependency org.jetbrains.dokka to v1.8.10
2023-03-04 11:43:14 -05:00
renovate[bot] d3cd42c076 fix(deps): update dependency org.jetbrains.dokka:dokka-gradle-plugin to v1.8.10 2023-03-04 08:51:25 +00:00
renovate[bot] 4a3572d39c chore(deps): update dependency org.jetbrains.dokka to v1.8.10 2023-03-04 08:51:19 +00:00
Adrian 8f5baf7757 Merge pull request #35 from MiniPlaceholders/renovate/userdev
chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.3
2023-03-03 22:56:36 -05:00
Adrian 5a98d82c49 Merge pull request #34 from MiniPlaceholders/renovate/gradle-8.x
chore(deps): update dependency gradle to v8.0.2
2023-03-03 22:56:28 -05:00
renovate[bot] 984ef05ffb chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.3 2023-03-04 03:17:51 +00:00
renovate[bot] db2a723c57 chore(deps): update dependency gradle to v8.0.2 2023-03-04 03:17:45 +00:00
Adrian 5187a74a06 [ci skip] fix(deps): also ignore krypton-server 2023-03-02 12:18:29 -05:00
Adrian 4b7a003c27 fix(deps): ignore renovate krypton updates
The Krypton versioning system is based on commits, so Renovate does not work correctly
2023-03-02 12:16:59 -05:00
Adrian 1a673997e0 Merge remote-tracking branch 'origin/main' 2023-03-02 11:58:58 -05:00
Adrian 2364f306a8 fix(deps): manually updated shadow plugin
closes #33
2023-03-02 11:58:31 -05:00
Adrian 23b21eb921 Merge pull request #29 from MiniPlaceholders/renovate/brigadier
fix(deps): update dependency com.mojang:brigadier to v1.0.500
2023-03-02 11:41:45 -05:00
Adrian 6e71e33bf8 Merge remote-tracking branch 'origin/main' 2023-03-02 11:35:28 -05:00
Adrian 1164d4551f feat: improved command registration
fix: fixed player argument
2023-03-02 11:30:51 -05:00
Adrian de562d1bae Merge pull request #32 from MiniPlaceholders/renovate/userdev
chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.2
2023-03-01 17:40:36 -05:00
renovate[bot] 9c117b156b fix(deps): update dependency com.mojang:brigadier to v1.0.500 2023-03-01 22:35:26 +00:00
renovate[bot] 4a9b90ed95 chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.2 2023-03-01 22:35:21 +00:00
Adrian de095dd900 chore: updated javadocs link 2023-03-01 17:07:02 -05:00
Adrian 05af305d50 release: version 2.0.0 2023-03-01 16:46:15 -05:00
Adrian c9a9783e8a chore: added kotlin examples 2023-03-01 16:34:30 -05:00
Adrian 5835fb3d45 chore: updated readme 2023-03-01 16:30:35 -05:00
Adrian 914275b16d feat: migrate to paper plugins
fix: fixed permission check on paper
2023-03-01 16:30:12 -05:00
Adrian a98aa93fb4 fix: fixed krypton annotation processor 2023-03-01 14:55:46 -05:00
Adrian f0fd8148ad feat: updated krypton module 2023-03-01 14:50:34 -05:00
Adrian 045cb01911 feat: publish extra kotlin javadocs
feat: implement build logic
2023-03-01 14:20:08 -05:00
Adrian 40ba7593a6 refactor!: changed package
bump to 2.0.0
2023-02-26 11:00:20 -05:00
Adrian 978e63c8dc build: migrate to versions catalog 2023-02-26 10:46:52 -05:00
Adrian 9b04b58f50 Merge pull request #20 from MiniPlaceholders/renovate/xyz.jpenilla.run-paper-2.x
chore(deps): update plugin xyz.jpenilla.run-paper to v2
2023-02-26 10:24:05 -05:00
renovate[bot] 9f7eaf1614 chore(deps): update plugin xyz.jpenilla.run-paper to v2 2023-02-26 15:18:45 +00:00
Adrian 9286751bd0 Merge pull request #27 from MiniPlaceholders/renovate/xyz.jpenilla.run-paper-1.x
chore(deps): update plugin xyz.jpenilla.run-paper to v1.1.0
2023-02-26 10:18:21 -05:00
Adrian 16783494ad Merge pull request #26 from MiniPlaceholders/renovate/me.champeau.jmh-0.x
chore(deps): update plugin me.champeau.jmh to v0.7.0
2023-02-26 10:17:23 -05:00
Adrian 9050aed7a3 Merge pull request #25 from MiniPlaceholders/renovate/gradle-8.x
chore(deps): update dependency gradle to v8
2023-02-26 10:17:14 -05:00
renovate[bot] 9ef9b1b3c6 chore(deps): update plugin xyz.jpenilla.run-paper to v1.1.0 2023-02-26 14:49:29 +00:00
renovate[bot] 8290c946df chore(deps): update plugin me.champeau.jmh to v0.7.0 2023-02-26 14:49:23 +00:00
Adrian 5057fe4817 Merge pull request #16 from MiniPlaceholders/renovate/kotlin-monorepo
chore(deps): update plugin org.jetbrains.kotlin.jvm to v1.8.10
2023-02-26 09:48:59 -05:00
renovate[bot] c43debe9bb chore(deps): update plugin org.jetbrains.kotlin.jvm to v1.8.10 2023-02-26 13:51:48 +00:00
Adrian 15d9f527eb Merge pull request #19 from MiniPlaceholders/renovate/com.github.johnrengelman.shadow-8.x
chore(deps): update plugin com.github.johnrengelman.shadow to v8
2023-02-26 08:51:21 -05:00
renovate[bot] 68dd632c69 chore(deps): update dependency gradle to v8 2023-02-26 13:51:15 +00:00
Adrian b0da895025 Merge pull request #21 from MiniPlaceholders/renovate/io.papermc.paperweight.userdev-1.x
chore(deps): update plugin io.papermc.paperweight.userdev to v1.5.1
2023-02-26 08:50:28 -05:00
Adrian 29dcd5bcdf Merge pull request #22 from MiniPlaceholders/renovate/junit5-monorepo
fix(deps): update dependency org.junit:junit-bom to v5.9.2
2023-02-26 08:49:56 -05:00
Adrian f156f48c54 Merge pull request #23 from MiniPlaceholders/renovate/actions-checkout-3.x
chore(deps): update actions/checkout action to v3
2023-02-26 08:49:06 -05:00
Adrian a1b1118aa2 Merge pull request #24 from MiniPlaceholders/renovate/actions-setup-java-3.x
chore(deps): update actions/setup-java action to v3
2023-02-26 08:48:48 -05:00
renovate[bot] 5e716cb6d9 chore(deps): update actions/setup-java action to v3 2023-02-26 13:43:53 +00:00
renovate[bot] ebe04a3ede chore(deps): update actions/checkout action to v3 2023-02-26 13:43:47 +00:00
renovate[bot] 5e97666be7 fix(deps): update dependency org.junit:junit-bom to v5.9.2 2023-02-26 13:43:41 +00:00
renovate[bot] aa8a36c92b chore(deps): update plugin io.papermc.paperweight.userdev to v1.5.1 2023-02-26 13:43:35 +00:00
renovate[bot] c3fac7a11a chore(deps): update plugin com.github.johnrengelman.shadow to v8 2023-02-26 13:42:58 +00:00
Adrian a12c37bc97 Merge pull request #15 from MiniPlaceholders/renovate/configure
Configure Renovate
2023-02-26 08:39:59 -05:00
Adrian e83bc3d8f6 Merge branch 'main' into renovate/configure 2023-02-26 08:33:36 -05:00
Adrian e0767d9bff Merge pull request #14 from MiniPlaceholders/feat/kotlin
Implement Kotlin Extensions
2023-02-26 08:32:47 -05:00
Adrian 70e8d8925d fix: update plugin-yml plugin 2023-02-26 00:10:44 -05:00
Adrian ea9213bf2d fix: removed version catalog declaration 2023-02-26 00:06:24 -05:00
Adrian fc6bc5c728 fix: fixed actions compilation 2023-02-25 23:55:16 -05:00
Adrian 007fe3279d feat: publish to maven central 2023-02-25 23:53:36 -05:00
Adrian 9976b9bf89 chore: updated gradle wrapper 2023-02-25 23:48:18 -05:00
renovate[bot] b9035fe504 Add renovate.json 2023-02-26 04:25:38 +00:00
Adrian cff2aee3d6 feat: Test KDocs javadoc format 2023-02-02 16:35:15 -05:00
Adrian b45d8be1e5 feat: Update to Kotlin 1.8.10 2023-02-02 16:25:39 -05:00
Adrian b4fcf85b07 chore: Some format changes 2023-02-02 16:10:20 -05:00
Adrian 7363571d91 feat: Improved javadocs 2023-02-02 16:09:20 -05:00
4drian3d d6c883edf4 misc: Bump Snapshot version 2022-12-08 17:06:49 -05:00
4drian3d 6a011c0699 feat(kotlin-ext): Replace javadocs with KDocs 2022-12-08 16:45:47 -05:00
4drian3d 4779fb9f69 fix(kotlin-ext): Fixed javadoc publication 2022-12-08 16:28:04 -05:00
4drian3d f97650ef1f fix(kotlin-ext): Fixed maven publication 2022-12-08 15:50:25 -05:00
4drian3d 98e280e01b feat(kotlin-ext): Correctly Implemented Dokka 2022-12-08 15:36:08 -05:00
4drian3d d35892d964 feat: Implement kotlin-ext module 2022-12-08 14:35:21 -05:00
4drian3d 9263698139 misc: Migrate KryptonPlugin implementation to Kotlin 2022-12-08 10:46:34 -05:00
4drian3d 194801df6b release: 1.3.1 Version 2022-08-26 17:09:36 +00:00
4drian3d 06e927045e fix: Fixed subcommands permissions
resolves #13
2022-08-26 17:09:10 +00:00
4drian3d 5e8a881b51 release: 1.3.0 Version
misc(paper): Removed unnecesary Listener implementation
2022-08-25 14:13:16 +00:00
4drian3d 8bb9bafb8b feat(krypton): Implement TPS and MSPT placeholders 2022-08-25 00:57:52 +00:00
Adrian 74f14f139c Merge pull request #8 from MiniPlaceholders/feat/krypton-implementation 2022-08-24 16:10:15 -05:00
Adrian 45b2fbe977 Merge branch 'main' into feat/krypton-implementation 2022-08-24 16:08:01 -05:00
4drian3d df04f51d60 feat: Finish Krypton implementation 2022-08-24 21:04:51 +00:00
4drian3d 5b35094d27 release: Version 1.2.1 2022-08-22 15:06:24 +00:00
Adrian3d04 e8635bc6c8 test: Remove unnecesary public modifier 2022-08-18 02:17:22 +00:00
Adrian3d04 a1e95295cc feat: Added java 9 Modules Support 2022-08-18 02:16:50 +00:00
Adrian3d04 927563f749 feat(krypton): Try Kotlin plugin implementation 2022-07-31 17:36:57 +00:00
Adrian3d04 225bafeaaa feat: Implement Krypton Platform 2022-07-30 21:15:11 +00:00
63 changed files with 1244 additions and 615 deletions

No files matched your search

+4 -4
View File
@@ -8,10 +8,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
@@ -25,7 +25,7 @@ jobs:
command: gradle build
- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: MiniPlaceholders
path: build/libs/MiniPlaceholders.jar
path: build/libs/MiniPlaceholders-*.jar
+58 -4
View File
@@ -1,13 +1,67 @@
# MiniPlaceholders
# MiniPlaceholders ![WorkFlow](https://img.shields.io/github/actions/workflow/status/MiniPlaceholders/MiniPlaceholders/build.yml?style=flat-square) [![Discord](https://img.shields.io/discord/899740810956910683?color=7289da&label=Discord)](https://discord.gg/5NMMzK5mAn)
MiniMessage Component-based Placeholders for PaperMC and Velocity platforms
## Compatibility
- Paper 1.19.4+
- Velocity 3.1.2+
- Krypton
## Commands:
### Velocity
`/vminiplaceholders <parse|help> <me|player> <player-to-parse>`
### Paper
`/miniplaceholders <parse|help> <me|player> <player-to-parse>`
## API
Check the available javadocs [here](https://javadoc.jitpack.io/com/github/4drian3d/MiniPlaceholders/latest/javadoc/index.html)
## Usage
Check our usage wiki [here](https://github.com/MiniPlaceholders/MiniPlaceholders/wiki/User-Getting-Started)
## API
### Java
```java
class Main {
public static void registerExpansion() {
Expansion expansion = Expansion.builder("my-expansion")
.filter(Player.class)
.audiencePlaceholder("name", (aud, ctx, queue) ->
Tag.selfClosingInserting(aud.getName())
)
.globalPlaceholder("tps", (ctx, queue) ->
Tag.selfClosingInserting(Component.text(Bukkit.getTps()[0]))
).build;
expansion.register();
Player player;
player.sendMessage(miniMessage().deserialize("Player Name: <my-expansion_name>", MiniPlaceholders.getAudiencePlaceholders(player)));
}
}
```
### Kotlin
```kotlin
fun register() {
val expansion = expansion("my-expansion") {
audiencePlaceholder("name") { aud, _, _ ->
aud.getName().asClosingTag()
}
globalPlaceholder("tps") { _, _ ->
Component.text(Bukkit.getTps()[0]).asInsertingTag()
}
}
expansion.register()
val player: Player
player.sendMessage(miniMessage().deserialize("Player Name: <my-expansion_name>", MiniPlaceholders.getAudiencePlaceholders(player)))
}
```
Check the available javadocs [here](https://javadoc.io/doc/io.github.miniplaceholders/miniplaceholders-api)
Or check the developer wiki [here](https://github.com/MiniPlaceholders/MiniPlaceholders/wiki/Developer-Getting-Started)
Or check the wiki [here](https://github.com/4drian3d/MiniPlaceholders/wiki)
+20 -33
View File
@@ -1,18 +1,19 @@
plugins {
id("me.champeau.jmh") version "0.6.6"
`maven-publish`
alias(libs.plugins.jmh)
id("miniplaceholders.publish")
}
dependencies {
compileOnly("net.kyori:adventure-api:4.11.0")
compileOnly("net.kyori:adventure-text-minimessage:4.11.0")
compileOnly("net.kyori:adventure-text-serializer-legacy:4.11.0")
compileOnly(project(":miniplaceholders-connect"))
testImplementation(platform("org.junit:junit-bom:5.8.1"))
compileOnly(libs.adventure.api)
compileOnly(libs.adventure.minimesssage)
compileOnly("net.kyori:adventure-text-serializer-legacy:4.13.1")
compileOnly(projects.miniplaceholdersConnect)
testImplementation(platform("org.junit:junit-bom:5.9.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("net.kyori:adventure-api:4.11.0")
testImplementation("net.kyori:adventure-text-minimessage:4.11.0")
testImplementation("net.kyori:adventure-text-serializer-plain:4.11.0")
testImplementation(libs.adventure.api)
testImplementation(libs.adventure.minimesssage)
testImplementation("net.kyori:adventure-text-serializer-plain:4.13.1")
}
tasks {
@@ -31,30 +32,12 @@ jmh {
}
java {
withSourcesJar()
withJavadocJar()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
val projectGroup: String = project.group as String
val projectVersion: String = project.version as String
publishing {
publications {
create<MavenPublication>("maven") {
groupId = projectGroup
artifactId = project.name
version = projectVersion
from(components["java"])
}
}
}
tasks.withType<Javadoc> {
(options as StandardJavadocDocletOptions).links(
"https://jd.adventure.kyori.net/api/4.10.0/",
"https://jd.adventure.kyori.net/text-minimessage/4.11.0/"
)
repositories {
mavenCentral()
}
tasks {
@@ -63,10 +46,14 @@ tasks {
options.release.set(11)
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
javadoc {
options.encoding = Charsets.UTF_8.name()
(options as StandardJavadocDocletOptions).links(
"https://jd.advntr.dev/api/${libs.versions.adventure.get()}/",
"https://jd.advntr.dev/text-minimessage/${libs.versions.adventure.get()}/"
)
}
}
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders;
package io.github.miniplaceholders.jmh;
import java.util.UUID;
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders;
package io.github.miniplaceholders.jmh;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
@@ -9,8 +9,8 @@ import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.MiniPlaceholders;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.MiniPlaceholders;
@State(Scope.Benchmark)
public class PlaceholderBenchmark {
@@ -1,5 +1,7 @@
package me.dreamerzero.miniplaceholders.api;
package io.github.miniplaceholders.api;
import io.github.miniplaceholders.api.placeholder.AudiencePlaceholder;
import io.github.miniplaceholders.api.placeholder.RelationalPlaceholder;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -7,8 +9,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import me.dreamerzero.miniplaceholders.api.placeholder.AudiencePlaceholder;
import me.dreamerzero.miniplaceholders.api.placeholder.RelationalPlaceholder;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.builder.AbstractBuilder;
import net.kyori.adventure.text.minimessage.Context;
@@ -49,7 +49,6 @@ public interface Expansion {
* @return A TagResolver with variable placeholders of an Audience
* @since 1.0.0
*/
@Contract("null -> fail; !null -> !null")
@NotNull TagResolver audiencePlaceholders(final @NotNull Audience audience);
/**
@@ -63,7 +62,6 @@ public interface Expansion {
* @return A TagResolver with variable placeholders between 2 {@link Audience}s
* @since 1.0.0
*/
@Contract("_, null -> fail, null, _ -> fail; !null, !null -> !null")
@NotNull TagResolver relationalPlaceholders(final @NotNull Audience audience, final @NotNull Audience otherAudience);
/**
@@ -85,7 +83,7 @@ public interface Expansion {
* @return a new expansion builder
* @since 1.0.0
*/
public static @NotNull Expansion.Builder builder(final @NotNull String name){
static @NotNull Expansion.Builder builder(final @NotNull String name){
return new ExpansionImpl.Builder(name);
}
@@ -111,7 +109,7 @@ public interface Expansion {
*
* @since 1.0.0
*/
public static interface Builder extends AbstractBuilder<Expansion> {
interface Builder extends AbstractBuilder<Expansion> {
/**
* Adds an audience placeholder
*
@@ -124,7 +122,6 @@ public interface Expansion {
* @return the {@link Builder} itself
* @since 1.0.0
*/
@Contract("null, _ -> fail; _, null -> fail; !null, !null -> this")
@NotNull Builder audiencePlaceholder(final @NotNull String key, final @NotNull AudiencePlaceholder audiencePlaceholder);
/**
@@ -143,7 +140,6 @@ public interface Expansion {
* @return the {@link Builder} itself
* @since 1.0.0
*/
@Contract("null, _ -> fail; _, null -> fail; !null, !null -> this")
@NotNull Builder relationalPlaceholder(final @NotNull String key, final @NotNull RelationalPlaceholder relationalPlaceholder);
/**
@@ -156,7 +152,6 @@ public interface Expansion {
* @return the {@link Builder} itself
* @since 1.0.0
*/
@Contract("null, _ -> fail; _, null -> fail; !null, !null -> this")
@NotNull Builder globalPlaceholder(final @NotNull String key, final @NotNull BiFunction<@NotNull ArgumentQueue, @NotNull Context, @Nullable Tag> function);
/**
@@ -168,7 +163,6 @@ public interface Expansion {
* @return the {@link Builder} itself
* @since 1.1.0
*/
@Contract("null, _ -> fail; _, null -> fail; !null, !null -> this")
@NotNull Builder globalPlaceholder(final @NotNull String key, final @NotNull Tag tag);
/**
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api;
package io.github.miniplaceholders.api;
import java.util.Collection;
import java.util.HashSet;
@@ -6,15 +6,15 @@ import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import io.github.miniplaceholders.api.placeholder.AudiencePlaceholder;
import io.github.miniplaceholders.api.placeholder.RelationalPlaceholder;
import io.github.miniplaceholders.api.utils.Conditions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import me.dreamerzero.miniplaceholders.api.placeholder.AudiencePlaceholder;
import me.dreamerzero.miniplaceholders.api.placeholder.RelationalPlaceholder;
import me.dreamerzero.miniplaceholders.api.utils.Conditions;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.minimessage.Context;
import net.kyori.adventure.text.minimessage.tag.Tag;
@@ -51,7 +51,7 @@ final class ExpansionImpl implements Expansion {
}
@Override
public String name(){
public @NotNull String name(){
return this.name;
}
@@ -59,7 +59,7 @@ final class ExpansionImpl implements Expansion {
public @NotNull TagResolver audiencePlaceholders(@NotNull final Audience audience){
if(audiencePlaceholders.length == 0) return TagResolver.empty();
Objects.requireNonNull(audience, () -> "the audience cannot be null");
Objects.requireNonNull(audience, "the audience cannot be null");
if(this.singleFilter(audience)) return TagResolver.empty();
@@ -79,13 +79,13 @@ final class ExpansionImpl implements Expansion {
public @NotNull TagResolver relationalPlaceholders(@NotNull final Audience audience, @NotNull final Audience otherAudience){
if(relationalPlaceholders.length == 0) return TagResolver.empty();
Objects.requireNonNull(audience, () -> "the audience cannot be null");
Objects.requireNonNull(otherAudience, () -> "the other audience cannot be null");
Objects.requireNonNull(audience, "the audience cannot be null");
Objects.requireNonNull(otherAudience, "the other audience cannot be null");
if(this.relationalFilter(audience, otherAudience)) return TagResolver.empty();
if (this.relationalFilter(audience, otherAudience)) return TagResolver.empty();
final TagResolver.Builder placeholders = TagResolver.builder();
for(final Tags.Relational pl : this.relationalPlaceholders){
for (final Tags.Relational pl : this.relationalPlaceholders){
placeholders.resolver(pl.of(audience, otherAudience));
}
return placeholders.build();
@@ -120,31 +120,31 @@ final class ExpansionImpl implements Expansion {
}
@Override
public Builder audiencePlaceholder(@NotNull final String key, @NotNull final AudiencePlaceholder audiencePlaceholder){
public @NotNull Builder audiencePlaceholder(@NotNull final String key, @NotNull final AudiencePlaceholder audiencePlaceholder){
Conditions.nonNullOrEmptyString(key, () -> "placeholder key");
Objects.requireNonNull(audiencePlaceholder, () -> "the audience placeholder cannot be null");
Objects.requireNonNull(audiencePlaceholder, "the audience placeholder cannot be null");
if(this.audiencePlaceholders == null) this.audiencePlaceholders = new HashSet<>(5);
if (this.audiencePlaceholders == null) this.audiencePlaceholders = new HashSet<>(5);
this.audiencePlaceholders.add(Tags.single(expansionName+key, audiencePlaceholder));
return this;
}
@Override
public Builder relationalPlaceholder(@NotNull final String key, @NotNull final RelationalPlaceholder relationalPlaceholder){
public @NotNull Builder relationalPlaceholder(@NotNull final String key, @NotNull final RelationalPlaceholder relationalPlaceholder){
Conditions.nonNullOrEmptyString(key, () -> "placeholder key");
Objects.requireNonNull(relationalPlaceholder, () -> "the relational placeholder cannot be null");
Objects.requireNonNull(relationalPlaceholder, "the relational placeholder cannot be null");
if(this.relationalPlaceholders == null) this.relationalPlaceholders = new HashSet<>(4);
if (this.relationalPlaceholders == null) this.relationalPlaceholders = new HashSet<>(4);
this.relationalPlaceholders.add(Tags.relational(expansionName+"rel_"+key, relationalPlaceholder));
return this;
}
@Override
public Builder globalPlaceholder(@NotNull final String key, @NotNull final BiFunction<ArgumentQueue, Context, Tag> function){
public @NotNull Builder globalPlaceholder(@NotNull final String key, @NotNull final BiFunction<ArgumentQueue, Context, Tag> function){
Conditions.nonNullOrEmptyString(key, () -> "placeholder key");
Objects.requireNonNull(function, () -> "the global placeholder cannot be null");
Objects.requireNonNull(function, "the global placeholder cannot be null");
if(this.globalPlaceholders == null) this.globalPlaceholders = TagResolver.builder();
@@ -153,9 +153,9 @@ final class ExpansionImpl implements Expansion {
}
@Override
public Builder globalPlaceholder(@NotNull final String key, @NotNull final Tag tag){
public @NotNull Builder globalPlaceholder(@NotNull final String key, @NotNull final Tag tag){
Conditions.nonNullOrEmptyString(key, () -> "placeholder key");
Objects.requireNonNull(tag, () -> "the tag cannot be null");
Objects.requireNonNull(tag, "the tag cannot be null");
if(this.globalPlaceholders == null) this.globalPlaceholders = TagResolver.builder();
@@ -164,13 +164,13 @@ final class ExpansionImpl implements Expansion {
}
@Override
public Builder filter(@Nullable final Class<? extends Audience> clazz) {
public @NotNull Builder filter(@Nullable final Class<? extends Audience> clazz) {
this.filterClass = clazz;
return this;
}
@Override
public Builder filter(@Nullable final Predicate<Audience> predicate){
public @NotNull Builder filter(@Nullable final Predicate<Audience> predicate){
this.predicateFilter = predicate;
return this;
}
@@ -190,8 +190,8 @@ final class ExpansionImpl implements Expansion {
@Override
public boolean equals(Object o){
if(this==o) return true;
if(o == null || o.getClass() != ExpansionImpl.class) return false;
if (this==o) return true;
if (o == null || o.getClass() != ExpansionImpl.class) return false;
return ((ExpansionImpl)o).name.equals(this.name);
}
@@ -1,19 +1,19 @@
package me.dreamerzero.miniplaceholders.api;
package io.github.miniplaceholders.api;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import org.jetbrains.annotations.Contract;
import io.github.miniplaceholders.api.enums.Platform;
import io.github.miniplaceholders.api.utils.Resolvers;
import org.jetbrains.annotations.NotNull;
import me.dreamerzero.miniplaceholders.api.enums.Platform;
import me.dreamerzero.miniplaceholders.api.utils.Resolvers;
import me.dreamerzero.miniplaceholders.connect.InternalPlatform;
import io.github.miniplaceholders.connect.InternalPlatform;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import static java.util.Objects.requireNonNull;
/**
* MiniPlaceholders
*
@@ -36,9 +36,11 @@ public final class MiniPlaceholders {
* @since 1.0.0
*/
public static @NotNull Platform getPlatform() {
return InternalPlatform.platform() == InternalPlatform.PAPER
? Platform.PAPER
: Platform.VELOCITY;
switch (InternalPlatform.platform()) {
case PAPER: return Platform.PAPER;
case VELOCITY: return Platform.VELOCITY;
default: return Platform.KRYPTON;
}
}
/**
@@ -71,9 +73,8 @@ public final class MiniPlaceholders {
* @return {@link TagResolver} with placeholders based on an audience
* @since 1.0.0
*/
@Contract("null -> fail, !null -> !null")
public static @NotNull TagResolver getAudiencePlaceholders(final @NotNull Audience audience) {
Objects.requireNonNull(audience, () -> "audience cannot be null");
requireNonNull(audience, "audience cannot be null");
final TagResolver.Builder resolvers = TagResolver.builder();
for (Expansion expansion : expansions) {
@@ -85,7 +86,7 @@ public final class MiniPlaceholders {
}
/**
* Get the relationals placeholders based on two audiences
* Get the relational placeholders based on two audiences
*
* <pre>TagResolver resolver = MiniPlaceholders.getRelationalPlaceholders({@link Audience}, {@link Audience});
* Component messageParsed = MiniMessage.miniMessage().deserialize({@link String}, resolver);</pre>
@@ -95,10 +96,9 @@ public final class MiniPlaceholders {
* @return placeholders based on two audiences
* @since 1.0.0
*/
@Contract("_, null -> fail; null, _ -> fail; !null, !null -> !null")
public static @NotNull TagResolver getRelationalPlaceholders(final @NotNull Audience audience, final @NotNull Audience otherAudience) {
Objects.requireNonNull(audience, () -> "audience cannot be null");
Objects.requireNonNull(otherAudience, () -> "otherAudience cannot be null");
requireNonNull(audience, "audience cannot be null");
requireNonNull(otherAudience, "otherAudience cannot be null");
final TagResolver.Builder builder = TagResolver.builder();
for (final Expansion expansion : expansions) {
@@ -129,9 +129,8 @@ public final class MiniPlaceholders {
* @return {@link TagResolver} with placeholders based on an audience and the global placeholders
* @since 1.1.0
*/
@Contract("_, null -> fail; null, _ -> fail; !null, !null -> !null")
public static @NotNull TagResolver getAudienceGlobalPlaceholders(final @NotNull Audience audience) {
Objects.requireNonNull(audience, () -> "audience cannot be null");
requireNonNull(audience, "audience cannot be null");
final TagResolver.Builder builder = TagResolver.builder();
for (final Expansion expansion : expansions) {
@@ -143,7 +142,7 @@ public final class MiniPlaceholders {
}
/**
* Get the relationals placeholders based on two audiences, based on the first audience,
* Get the relational placeholders based on two audiences, based on the first audience,
* and the global placeholders
*
* <pre>
@@ -163,10 +162,9 @@ public final class MiniPlaceholders {
* @return the placeholders based on two audiences, placeholders based on the first audience and the global placeholders
* @since 1.1.0
*/
@Contract("_, null -> fail; null, _ -> fail; !null, !null -> !null")
public static @NotNull TagResolver getRelationalGlobalPlaceholders(final @NotNull Audience audience, final @NotNull Audience otherAudience) {
Objects.requireNonNull(audience, () -> "audience cannot be null");
Objects.requireNonNull(otherAudience, () -> "otherAudience cannot be null");
requireNonNull(audience, "audience cannot be null");
requireNonNull(otherAudience, "otherAudience cannot be null");
final TagResolver.Builder builder = TagResolver.builder();
for (final Expansion expansion : expansions) {
@@ -179,23 +177,11 @@ public final class MiniPlaceholders {
}
/**
* Get the ammount of expansion registered
* @return the ammount of expansions registered
* Get the amount of expansion registered
* @return the amount of expansions registered
* @since 1.0.0
*/
public static int getExpansionCount(){
return expansions.size();
}
/**
* Set the platform
* @param platform the platform
* @deprecated dont use this, INTERNAL
* @since 1.0.0
*/
@Deprecated(forRemoval = true, since = "1.1.0")
@org.jetbrains.annotations.ApiStatus.Internal
public static void setPlatform(Platform platform){
throw new UnsupportedOperationException("Cannot set platform twice");
}
}
@@ -1,12 +1,12 @@
package me.dreamerzero.miniplaceholders.api;
package io.github.miniplaceholders.api;
import java.util.Objects;
import io.github.miniplaceholders.api.placeholder.AudiencePlaceholder;
import io.github.miniplaceholders.api.placeholder.RelationalPlaceholder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import me.dreamerzero.miniplaceholders.api.placeholder.AudiencePlaceholder;
import me.dreamerzero.miniplaceholders.api.placeholder.RelationalPlaceholder;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.minimessage.Context;
import net.kyori.adventure.text.minimessage.ParsingException;
@@ -1,9 +1,11 @@
package me.dreamerzero.miniplaceholders.api.enums;
package io.github.miniplaceholders.api.enums;
/**Platforms on which MiniPlaceholders can be used */
public enum Platform {
/**Paper Platform */
PAPER,
/**Velocity Platform */
VELOCITY
VELOCITY,
/**Krypton Platform */
KRYPTON
}
@@ -0,0 +1,2 @@
/**Plugin enums */
package io.github.miniplaceholders.api.enums;
@@ -0,0 +1,4 @@
/**
* MiniPlaceholders core package
*/
package io.github.miniplaceholders.api;
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api.placeholder;
package io.github.miniplaceholders.api.placeholder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api.placeholder;
package io.github.miniplaceholders.api.placeholder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1,4 +1,4 @@
/**
* Placeholders available based on information obtained from Audiences
*/
package me.dreamerzero.miniplaceholders.api.placeholder;
package io.github.miniplaceholders.api.placeholder;
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api.utils;
package io.github.miniplaceholders.api.utils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api.utils;
package io.github.miniplaceholders.api.utils;
import java.util.function.Supplier;
@@ -14,9 +14,9 @@ public final class Conditions {
* @since 1.0.0
*/
public static String nonNullOrEmptyString(String string, Supplier<String> name){
if(string == null)
if (string == null)
throw new NullPointerException("the " + name.get() + " cannot be null");
if(string.isBlank())
if (string.isBlank())
throw new IllegalStateException("the " + name.get() + "cannot be an empty string");
return string;
}
@@ -29,7 +29,7 @@ public final class Conditions {
* @since 1.0.0
*/
public static String nonEmptyString(String string, Supplier<String> reason){
if(string.isBlank())
if (string.isBlank())
throw new IllegalStateException(reason.get());
return string;
}
@@ -1,10 +1,9 @@
package me.dreamerzero.miniplaceholders.api.utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
package io.github.miniplaceholders.api.utils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
@@ -12,30 +11,31 @@ import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
* Legacy utils
*/
public final class LegacyUtils {
private LegacyUtils(){}
private LegacyUtils() {
}
/**
* Legacy serializer with hex support
*
* Use this as the last available alternative,
* it is recommended to use MiniMessage instead of this serializer
* <p>Use this as the last available alternative,
* it is recommended to use MiniMessage instead of this serializer</p>
*/
public static final LegacyComponentSerializer LEGACY_HEX_SERIALIZER = LegacyComponentSerializer.builder()
.character('&')
.hexColors()
.build();
.character('&')
.hexColors()
.build();
/**
* Parse a string with possible legacy symbols
*
* @param string the string
* @return a parsed string
* @since 1.0.0
*/
public static @NotNull Component parsePossibleLegacy(@Nullable String string) {
if(string == null || string.isBlank()) return Component.empty();
if(string.indexOf('&') != 0){
if (string == null || string.isBlank()) return Component.empty();
if (string.indexOf('&') != 0) {
return miniMessage().deserialize(
miniMessage().serialize(LEGACY_HEX_SERIALIZER.deserialize(string))
miniMessage().serialize(LEGACY_HEX_SERIALIZER.deserialize(string))
);
} else {
return miniMessage().deserialize(string);
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api.utils;
package io.github.miniplaceholders.api.utils;
import org.jetbrains.annotations.NotNull;
@@ -1,9 +1,9 @@
package me.dreamerzero.miniplaceholders.api.utils;
package io.github.miniplaceholders.api.utils;
import io.github.miniplaceholders.api.placeholder.AudiencePlaceholder;
import io.github.miniplaceholders.api.placeholder.RelationalPlaceholder;
import org.jetbrains.annotations.NotNull;
import me.dreamerzero.miniplaceholders.api.placeholder.AudiencePlaceholder;
import me.dreamerzero.miniplaceholders.api.placeholder.RelationalPlaceholder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
@@ -2,4 +2,4 @@
* General Utilities
* Here you will find utilities that will help you in the development of expansions
*/
package me.dreamerzero.miniplaceholders.api.utils;
package io.github.miniplaceholders.api.utils;
@@ -1,2 +0,0 @@
/**Plugin enums */
package me.dreamerzero.miniplaceholders.api.enums;
@@ -1,4 +0,0 @@
/**
* MiniPlaceholders core package
*/
package me.dreamerzero.miniplaceholders.api;
+14
View File
@@ -0,0 +1,14 @@
/** MiniPlaceholders API Module */
open module io.github.miniplaceholders.api {
requires net.kyori.adventure;
requires net.kyori.adventure.text.minimessage;
requires net.kyori.examination.api;
requires static org.jetbrains.annotations;
requires io.github.miniplaceholders.connect;
requires net.kyori.adventure.text.serializer.legacy;
exports io.github.miniplaceholders.api;
exports io.github.miniplaceholders.api.enums;
exports io.github.miniplaceholders.api.utils;
exports io.github.miniplaceholders.api.placeholder;
}
@@ -1,14 +1,14 @@
package me.dreamerzero.miniplaceholders;
package io.github.miniplaceholders.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.utils.TagsUtils;
public class ExpansionsTest {
class ExpansionsTest {
@Test
@DisplayName("Expansion Equality")
void equalsExpansions(){
@@ -1,17 +1,17 @@
package me.dreamerzero.miniplaceholders;
package io.github.miniplaceholders.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.MiniPlaceholders;
import me.dreamerzero.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.MiniPlaceholders;
import io.github.miniplaceholders.api.utils.TagsUtils;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
public class MiniPlaceholdersTest {
class MiniPlaceholdersTest {
@Test
@Disabled("Cannot correctly calculate the equity of 2 TagResolvers obtained in different ways")
void methodEquality(){
@@ -1,13 +1,13 @@
package me.dreamerzero.miniplaceholders;
package io.github.miniplaceholders.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import io.github.miniplaceholders.test.testobjects.TestAudience;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.DisplayName;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.MiniPlaceholders;
import me.dreamerzero.miniplaceholders.testobjects.TestAudience;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.MiniPlaceholders;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -15,7 +15,7 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
public class PlaceholderTest {
class PlaceholderTest {
@Test
@DisplayName("Audience Placeholder Test")
@@ -23,7 +23,7 @@ public class PlaceholderTest {
TestAudience player = new TestAudience("4drian3d");
Expansion expansion = Expansion.builder("example")
.audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((TestAudience)aud).getName()))).build();
.audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((TestAudience)aud).name()))).build();
final Component expected = Component.text("Player Name: 4drian3d");
final Component result = MiniMessage.miniMessage().deserialize("Player Name: <example_name>", expansion.audiencePlaceholders(player));
@@ -80,7 +80,7 @@ public class PlaceholderTest {
@DisplayName("Filtered Expansion")
void filteredExpansion(){
Expansion expansion = Expansion.builder("filter")
.audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((TestAudience)aud).getName())))
.audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((TestAudience)aud).name())))
.filter(TestAudience.class)
.build();
@@ -106,7 +106,7 @@ public class PlaceholderTest {
}
private boolean isEnemy(TestAudience a1, TestAudience a2){
return a1.getName().equals("PlayerOne") && a2.getName().equals("PlayerTwo");
return a1.name().equals("PlayerOne") && a2.name().equals("PlayerTwo");
}
}
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders;
package io.github.miniplaceholders.test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -8,14 +8,16 @@ import java.util.function.BiFunction;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.MiniPlaceholders;
import me.dreamerzero.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.MiniPlaceholders;
import io.github.miniplaceholders.api.utils.TagsUtils;
import net.kyori.adventure.text.minimessage.Context;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
public class ThrowableTest {
//yea... it is intended xd
@SuppressWarnings("DataFlowIssue")
class ThrowableTest {
@Test
@DisplayName("Nullable Exception")
void throwOnNull(){
@@ -0,0 +1,7 @@
package io.github.miniplaceholders.test.testobjects;
import org.jetbrains.annotations.NotNull;
import net.kyori.adventure.audience.Audience;
public record TestAudience(@NotNull String name) implements Audience {}
@@ -1,16 +0,0 @@
package me.dreamerzero.miniplaceholders.testobjects;
import org.jetbrains.annotations.NotNull;
import net.kyori.adventure.audience.Audience;
public final class TestAudience implements Audience {
private final String name;
public TestAudience(String name) {
this.name = name;
}
public @NotNull String getName(){
return this.name;
}
}
+19
View File
@@ -0,0 +1,19 @@
plugins {
`kotlin-dsl`
}
dependencies {
implementation(libs.plugin.shadow)
implementation(libs.plugin.kotlin)
implementation(libs.plugin.dokka)
}
repositories {
gradlePluginPortal()
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
+15
View File
@@ -0,0 +1,15 @@
rootProject.name = "build-logic"
dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
gradlePluginPortal()
mavenCentral()
}
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
@@ -0,0 +1,80 @@
plugins {
kotlin("jvm")
`java-library`
`maven-publish`
signing
id("org.jetbrains.dokka")
}
/*
val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}
publishing {
publications {
create<MavenPublication>("maven") {
artifact(tasks["dokkaHtmlJar"])
repositories {
maven {
credentials(PasswordCredentials::class)
val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
if (project.version.toString().endsWith("SNAPSHOT")) {
name = "SonatypeSnapshots"
setUrl(snapshots)
} else {
name = "OSSRH"
setUrl(central)
}
}
}
from(components["java"])
pom {
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
licenses {
license {
name.set("GNU General Public License version 3 or later")
url.set("https://opensource.org/licenses/GPL-3.0")
}
}
scm {
connection.set("scm:git:https://github.com/MiniPlaceholders/MiniPlaceholders.git")
developerConnection.set("scm:git:ssh://git@github.com/MiniPlaceholders/MiniPlaceholders.git")
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
}
developers {
developer {
id.set("4drian3d")
name.set("Adrian Gonzales")
email.set("adriangonzalesval@gmail.com")
}
}
issueManagement {
name.set("GitHub")
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/issues")
}
ciManagement {
name.set("GitHub Actions")
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/actions")
}
name.set(project.name)
description.set(project.description)
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
}
}
}
}
signing {
useGpgCmd()
sign(configurations.archives.get())
sign(publishing.publications["maven"])
sign(tasks["dokkaHtmlJar"])
}
java {
withSourcesJar()
}*/
@@ -0,0 +1,71 @@
plugins {
`java-library`
`maven-publish`
signing
}
/*
publishing {
publications {
create<MavenPublication>("maven") {
repositories {
maven {
credentials(PasswordCredentials::class)
val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
if (project.version.toString().endsWith("SNAPSHOT")) {
name = "SonatypeSnapshots"
setUrl(snapshots)
} else {
name = "OSSRH"
setUrl(central)
}
}
}
from(components["java"])
pom {
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
licenses {
license {
name.set("GNU General Public License version 3 or later")
url.set("https://opensource.org/licenses/GPL-3.0")
}
}
scm {
connection.set("scm:git:https://github.com/MiniPlaceholders/MiniPlaceholders.git")
developerConnection.set("scm:git:ssh://git@github.com/MiniPlaceholders/MiniPlaceholders.git")
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
}
developers {
developer {
id.set("4drian3d")
name.set("Adrian Gonzales")
email.set("adriangonzalesval@gmail.com")
}
}
issueManagement {
name.set("GitHub")
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/issues")
}
ciManagement {
name.set("GitHub Actions")
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/actions")
}
name.set(project.name)
description.set(project.description)
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
}
}
}
}
signing {
useGpgCmd()
sign(configurations.archives.get())
sign(publishing.publications["maven"])
}*/
java {
withSourcesJar()
}
+7 -14
View File
@@ -1,23 +1,17 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
java
id("com.github.johnrengelman.shadow") version "7.1.2"
alias(libs.plugins.shadow)
kotlin("jvm") version "1.8.20" apply false
}
allprojects {
apply(plugin = "java")
group = "me.dreamerzero.miniplaceholders"
version = "1.2.0"
description = "MiniPlaceholders"
apply<JavaPlugin>()
}
dependencies {
shadow(project(":miniplaceholders-connect"))
shadow(project(":miniplaceholders-api"))
shadow(project(":miniplaceholders-common"))
shadow(project(":miniplaceholders-velocity"))
shadow(project(":miniplaceholders-paper", "reobf"))
implementation(projects.miniplaceholdersVelocity)
implementation(project(":miniplaceholders-paper", "reobf"))
implementation(projects.miniplaceholdersKrypton)
}
subprojects {
@@ -30,9 +24,8 @@ subprojects {
tasks {
shadowJar {
archiveFileName.set("MiniPlaceholders.jar")
archiveFileName.set("MiniPlaceholders-${project.version}.jar")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations = listOf(project.configurations.shadow.get())
}
build {
dependsOn(shadowJar)
+20 -10
View File
@@ -1,27 +1,37 @@
plugins {
id("net.kyori.blossom") version "1.3.1"
alias(libs.plugins.blossom)
}
repositories {
maven("https://libraries.minecraft.net");
maven("https://libraries.minecraft.net") {
mavenContent {
includeGroup("com.mojang")
}
}
mavenCentral()
}
dependencies {
implementation(project(":miniplaceholders-api"))
compileOnly("net.kyori:adventure-api:4.11.0")
compileOnly("net.kyori:adventure-text-minimessage:4.11.0")
compileOnly("com.mojang:brigadier:1.0.18")
implementation(projects.miniplaceholdersApi)
compileOnly(libs.adventure.api)
compileOnly(libs.adventure.minimesssage)
compileOnly(libs.brigadier)
}
blossom{
replaceToken("{version}", version)
replaceTokenIn("src/main/java/me/dreamerzero/miniplaceholders/common/PluginConstants.java")
replaceToken("{version}", project.version)
replaceTokenIn("src/main/java/io/github/miniplaceholders/common/PluginConstants.java")
}
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
}
jar {
manifest {
attributes("Automatic-Module-Name" to "io.github.miniplaceholders.common")
}
}
}
@@ -0,0 +1,227 @@
package io.github.miniplaceholders.common;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.MiniPlaceholders;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.builder.AbstractBuilder;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Supplier;
import static com.mojang.brigadier.arguments.StringArgumentType.*;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
public final class PlaceholdersCommand<A> {
private final Supplier<Collection<String>> playersSuggestions;
private final Function<String, Audience> toAudience;
private final Function<A, Audience> sourceToAudience;
private final BiPredicate<A, String> hasPermission;
private final Expansion commandExpansion = Expansion.builder("placeholders")
.globalPlaceholder("count", (queue, ctx) -> Tag.selfClosingInserting(text(MiniPlaceholders.getExpansionCount())))
.globalPlaceholder("version", (queue, ctx) -> Tag.selfClosingInserting(text(PluginConstants.VERSION)))
.build();
private PlaceholdersCommand(
final Supplier<Collection<String>> playersSuggestions,
final Function<String, Audience> toAudience,
final Function<A, Audience> sourceToAudience,
final BiPredicate<A, String> hasPermission
) {
this.playersSuggestions = playersSuggestions;
this.toAudience = toAudience;
this.sourceToAudience = sourceToAudience;
this.hasPermission = hasPermission;
}
private static final Component HEADER = miniMessage()
.deserialize("<gradient:aqua:white:aqua>---------- <gradient:#4d8bff:#a4ff96>MiniPlaceholders</gradient> -----------</gradient>");
private static final Component FOOTER = miniMessage()
.deserialize("<gradient:aqua:white:aqua> --------------- ---------------</gradient>");
public LiteralArgumentBuilder<A> asBuilder(String commandName){
return LiteralArgumentBuilder.<A>literal(commandName)
.requires(a -> getAudience(a).pointers().supports(PermissionChecker.POINTER))
.executes(cmd -> {
Audience source = getAudience(cmd.getSource());
if (hasPermission(cmd.getSource(), "miniplaceholders.command")) {
source.sendMessage(
text()
.append(HEADER)
.append(Component.newline())
.append(miniMessage()
.deserialize(
"<gradient:aqua:#918fff>Placeholders Available:</gradient> <aqua><placeholders_count></aqua>",
commandExpansion.globalPlaceholders()
)).append(Component.newline())
.append(FOOTER)
.build()
);
} else {
source.sendMessage(
text()
.append(HEADER)
.append(Component.newline())
.append(miniMessage()
.deserialize(
"<gradient:#8693AB:#BDD4E7>Version: <placeholders_version>",
commandExpansion.globalPlaceholders()
)).append(Component.newline())
.append(FOOTER)
.build()
);
}
return 1;
})
.then(LiteralArgumentBuilder.<A>literal("help")
.requires(src -> hasPermission(src, "miniplaceholders.command.help"))
.executes(cmd -> {
getAudience(cmd.getSource()).sendMessage(
text()
.append(HEADER)
.append(Component.newline())
.append(miniMessage()
.deserialize(
"<gradient:#9694ff:#5269ff>Commands:</gradient>"))
.append(Component.newline())
.append(miniMessage()
.deserialize(
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>help</aqua>"))
.append(Component.newline())
.append(miniMessage()
.deserialize(
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>parse</aqua> <#8fadff><player|me></#8fadff> <#99ffb6><player></#99ffb6>"))
.append(Component.newline())
.append(FOOTER)
.build()
);
return Command.SINGLE_SUCCESS;
})
)
.then(LiteralArgumentBuilder.<A>literal("parse")
.requires(cmd -> hasPermission(cmd, "miniplaceholders.command.parse"))
.then(LiteralArgumentBuilder.<A>literal("me")
.then(RequiredArgumentBuilder.<A, String>argument("string", string())
.executes(cmd -> {
final String toParse = getString(cmd, "string");
final Component parsed = parseGlobal(toParse, getAudience(cmd.getSource()));
getAudience(cmd.getSource()).sendMessage(parsed);
return Command.SINGLE_SUCCESS;
})
)
)
.then(LiteralArgumentBuilder.<A>literal("player")
.then(RequiredArgumentBuilder.<A, String>argument("source", word())
.suggests((argument, builder) -> supplyAsync(() -> {
playersSuggestions.get().forEach(builder::suggest);
return builder.build();
}))
.then(RequiredArgumentBuilder.<A, String>argument("string", string())
.executes(cmd -> {
final Audience objective = toAudience.apply(getString(cmd, "source"));
if (objective == null){
getAudience(cmd.getSource()).sendMessage(text("You must specify a valid player", RED));
return -1;
}
final String toParse = cmd.getArgument("string", String.class);
final Component parsed = parseGlobal(toParse, objective);
getAudience(cmd.getSource()).sendMessage(parsed);
return Command.SINGLE_SUCCESS;
})
)
)
)
);
}
public LiteralCommandNode<A> asNode(String command) {
return asBuilder(command).build();
}
private Component parseGlobal(final String string, final Audience audience) {
return miniMessage().deserialize(
string,
TagResolver.resolver(
MiniPlaceholders.getGlobalPlaceholders(),
MiniPlaceholders.getAudiencePlaceholders(audience)
)
);
}
private Audience getAudience(final A possibleAudience) {
if (possibleAudience instanceof Audience audience){
return audience;
}
final Audience audience = sourceToAudience.apply(possibleAudience);
return audience != null ? audience : Audience.empty();
}
private boolean hasPermission(final A source, final String permission) {
if (hasPermission != null) {
return hasPermission.test(source, permission);
}
return getAudience(source)
.get(PermissionChecker.POINTER)
.map(checker -> checker.test(permission))
.orElse(false);
}
public static <A> Builder<A> builder() {
return new Builder<>();
}
public final static class Builder<A> implements AbstractBuilder<PlaceholdersCommand<A>> {
private Supplier<Collection<String>> playersSuggestions;
private Function<String, Audience> toAudience;
private Function<A, Audience> fromAToAudience = a -> Audience.empty();
private BiPredicate<A, String> hasPermission;
private Builder() {}
public Builder<A> playerSuggestions(final Supplier<@NotNull Collection<@NotNull String>> playersSuggestions) {
this.playersSuggestions = playersSuggestions;
return this;
}
public Builder<A> toAudience(final @NotNull Function<@NotNull String, @Nullable Audience> argumentToAudience) {
this.toAudience = argumentToAudience;
return this;
}
public Builder<A> fromSourceToAudience(final @NotNull Function<@NotNull A, @Nullable Audience> sourceToAudience) {
this.fromAToAudience = sourceToAudience;
return this;
}
public Builder<A> hasPermissionCheck(final @NotNull BiPredicate<@NotNull A, @NotNull String> hasPermission) {
this.hasPermission = hasPermission;
return this;
}
@Override
public @NotNull PlaceholdersCommand<A> build() {
return new PlaceholdersCommand<>(
requireNonNull(playersSuggestions),
requireNonNull(toAudience),
requireNonNull(fromAToAudience),
hasPermission
);
}
}
}
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.common;
package io.github.miniplaceholders.common;
public interface PlaceholdersPlugin {
void loadDefaultExpansions();
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.common;
package io.github.miniplaceholders.common;
public final class PluginConstants {
public static final String VERSION = "{version}";
@@ -1,143 +0,0 @@
package me.dreamerzero.miniplaceholders.common;
import java.util.Collection;
import java.util.function.Function;
import java.util.function.Supplier;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.MiniPlaceholders;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
public class PlaceholdersCommand<A> {
private final @NotNull Supplier<@NotNull Collection<@NotNull String>> playersSuggestions;
private final @NotNull Function<@NotNull String, @Nullable Audience> toAudience;
private Function<A, Audience> fromAToAudience = a -> Audience.empty();
private final Expansion commandExpansion = Expansion.builder("placeholders")
.globalPlaceholder("count", (queue, ctx) -> Tag.selfClosingInserting(Component.text(MiniPlaceholders.getExpansionCount())))
.globalPlaceholder("version", (queue, ctx) -> Tag.selfClosingInserting(Component.text(PluginConstants.VERSION)))
.build();
public PlaceholdersCommand(Supplier<Collection<String>> playersSuggestions, Function<@NotNull String, @Nullable Audience> toAudience){
this.playersSuggestions = playersSuggestions;
this.toAudience = toAudience;
}
public PlaceholdersCommand(Supplier<Collection<String>> playersSuggestions, Function<@NotNull String, @Nullable Audience> toAudience, Function<A, Audience> fromAToAudience){
this(playersSuggestions, toAudience);
this.fromAToAudience = fromAToAudience;
}
private static final Component HEADER = miniMessage().deserialize("<gradient:aqua:white:aqua>---------- <gradient:#4d8bff:#a4ff96>MiniPlaceholders</gradient> -----------</gradient>");
private static final Component FOOTER = miniMessage().deserialize("<gradient:aqua:white:aqua> --------------- ---------------</gradient>");
public LiteralArgumentBuilder<A> placeholderTestBuilder(String commandName){
return LiteralArgumentBuilder.<A>literal(commandName)
.requires(a -> getAudience(a).pointers().supports(PermissionChecker.POINTER))
.executes(cmd -> {
Audience source = getAudience(cmd.getSource());
if(source.pointers().get(PermissionChecker.POINTER).orElse(null).test("miniplaceholders.command")){
source.sendMessage(
Component.text()
.append(HEADER).append(Component.newline())
.append(miniMessage().deserialize("<gradient:aqua:#918fff>Placeholders Available:</gradient> <aqua><placeholders_count></aqua>", commandExpansion.globalPlaceholders())).append(Component.newline())
.append(FOOTER)
.build()
);
} else {
source.sendMessage(
Component.text()
.append(HEADER).append(Component.newline())
.append(miniMessage().deserialize("<gradient:red:dark_red>Version: <placeholders_version>", commandExpansion.globalPlaceholders())).append(Component.newline())
.append(FOOTER)
.build()
);
}
return 1;
})
.then(LiteralArgumentBuilder.<A>literal("help")
.executes(cmd -> {
getAudience(cmd.getSource()).sendMessage(
Component.text()
.append(HEADER).append(Component.newline())
.append(miniMessage().deserialize("<gradient:#9694ff:#5269ff>Commands:</gradient>")).append(Component.newline())
.append(miniMessage().deserialize("<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>help</aqua>")).append(Component.newline())
.append(miniMessage().deserialize("<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>parse</aqua> <color:#8fadff><player:me></color> <color:#99ffb6><player></color>")).append(Component.newline())
.append(FOOTER)
.build()
);
return 1;
})
)
.then(LiteralArgumentBuilder.<A>literal("parse")
.then(LiteralArgumentBuilder.<A>literal("me")
.then(RequiredArgumentBuilder.<A, String>argument("selfStringToParse", StringArgumentType.string())
.executes(cmd -> {
String stringToParse = cmd.getArgument("selfStringToParse", String.class);
Component parsed = this.parseGlobal(stringToParse, getAudience(cmd.getSource()));
getAudience(cmd.getSource()).sendMessage(parsed);
return 1;
})
)
)
.then(LiteralArgumentBuilder.<A>literal("player")
.then(RequiredArgumentBuilder.<A, String>argument("source", StringArgumentType.word())
.suggests((argument, builder) -> {
playersSuggestions.get().forEach(builder::suggest);
return builder.buildFuture();
})
.then(RequiredArgumentBuilder.<A, String>argument("playerStringToParse", StringArgumentType.string())
.executes(cmd -> {
Audience objetive = toAudience.apply(cmd.getArgument("source", String.class));
if(objetive == null){
getAudience(cmd.getSource()).sendMessage(Component.text("You must specify a valid player", NamedTextColor.RED));
return 1;
}
String stringToParse = cmd.getArgument("playerStringToParse", String.class);
Component parsed = this.parseGlobal(stringToParse, objetive);
getAudience(cmd.getSource()).sendMessage(parsed);
return 1;
})
)
)
)
);
}
public LiteralCommandNode<A> placeholderTestCommand(String command){
return this.placeholderTestBuilder(command).build();
}
private Component parseGlobal(String string, Audience audience){
return miniMessage().deserialize(
string,
TagResolver.resolver(
MiniPlaceholders.getGlobalPlaceholders(),
MiniPlaceholders.getAudiencePlaceholders(audience)
)
);
}
private Audience getAudience(A possibleAudience){
if(possibleAudience instanceof Audience audience){
return audience;
}
Audience audience = fromAToAudience.apply(possibleAudience);
return audience != null ? audience : Audience.empty();
}
}
@@ -1,8 +1,8 @@
package me.dreamerzero.miniplaceholders.connect;
package io.github.miniplaceholders.connect;
public enum InternalPlatform {
PAPER, VELOCITY;
PAPER, VELOCITY, KRYPTON;
private static InternalPlatform actualPlatform;
+3
View File
@@ -0,0 +1,3 @@
module io.github.miniplaceholders.connect {
exports io.github.miniplaceholders.connect;
}
+3
View File
@@ -0,0 +1,3 @@
group = io.github.miniplaceholders
version = 2.0.2
description = MiniMessage Component-based Placeholders for PaperMC, Krypton and Velocity platforms
+51
View File
@@ -0,0 +1,51 @@
metadata.format.version = "1.1"
[versions]
velocity = "3.2.0-SNAPSHOT"
paper = "1.19.4-R0.1-SNAPSHOT"
krypton = "7f7a457cdf"
runtask = "2.0.1"
pluginyml = "0.5.3"
userdev = "1.5.4"
blossom = "1.3.1"
indra = "3.0.1"
shadow = "8.1.1"
jmh = "0.7.0"
dokka = "1.8.10"
adventure = "4.13.1"
brigadier = "1.0.500"
kotlin="1.8.20"
[libraries]
velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
krypton-server = { group = "org.kryptonmc", name = "krypton-server", version.ref = "krypton" }
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
adventure-minimesssage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
brigadier = { group = "com.mojang", name = "brigadier", version.ref = "brigadier" }
krypton-annotation = { group = "org.kryptonmc", name = "krypton-annotation-processor", version.ref = "krypton" }
plugin-shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
plugin-indra-common = { module = "net.kyori:indra-common", version.ref = "indra" }
plugin-indra-spotless = { module = "net.kyori:indra-licenser-spotless", version.ref = "indra" }
plugin-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.8.10"
[plugins]
pluginyml = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }
userdev = { id = "io.papermc.paperweight.userdev", version.ref = "userdev" }
runpaper = { id = "xyz.jpenilla.run-paper", version.ref = "runtask" }
runvelocity = { id = "xyz.jpenilla.run-velocity", version.ref = "runtask" }
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
jmh = { id = "me.champeau.jmh", version.ref = "jmh" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
Binary file not shown.
+2 -1
View File
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+19 -9
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,10 +80,10 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Vendored
+92 -89
View File
@@ -1,89 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+19
View File
@@ -0,0 +1,19 @@
plugins {
kotlin("jvm")
id("miniplaceholders.kotlin.publish")
}
dependencies {
compileOnly(kotlin("stdlib"))
compileOnly(libs.adventure.api)
compileOnly(libs.adventure.minimesssage)
compileOnlyApi(projects.miniplaceholdersApi)
}
kotlin {
explicitApi()
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
@@ -0,0 +1,16 @@
package io.github.miniplaceholders.kotlin
import io.github.miniplaceholders.api.Expansion
/**
* Create a new Expansion
*
* @param name the expansion name
* @param builder a builder-like function to create an Expansion from a builder
* @return a new expansion
* @since 1.4.0
* @see Expansion.builder
* @see Expansion.Builder.build
* */
public fun expansion(name: String, builder: Expansion.Builder.() -> Expansion.Builder): Expansion
= builder(Expansion.builder(name)).build()
@@ -0,0 +1,25 @@
package io.github.miniplaceholders.kotlin
import net.kyori.adventure.text.ComponentLike
import net.kyori.adventure.text.minimessage.tag.Tag
/**
* Converts a [ComponentLike] to a [Tag] of type selfClosingInserting
*
* @see Tag.selfClosingInserting
*/
public fun ComponentLike.asClosingTag(): Tag = Tag.selfClosingInserting(this)
/**
* Converts a [ComponentLike] to a [Tag] of type inserting
*
* @see Tag.inserting
*/
public fun ComponentLike.asInsertingTag(): Tag = Tag.inserting(this)
/**
* Converts a [ComponentLike] to a [Tag] of type preProcessParsed
*
* @see Tag.preProcessParsed
*/
public fun String.asPreProcessTag(): Tag = Tag.preProcessParsed(this)
@@ -0,0 +1,32 @@
package io.github.miniplaceholders.kotlin
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
/**
* Check if this TagResolver is an instance of TagResolver.empty(),
* that is, it will always return null
* @return true if the TagResolver is the same as TagResolver.empty(), else false
* @since 1.4.0
* @see TagResolver.empty
*/
public fun TagResolver.isEmpty(): Boolean = this == TagResolver.empty()
/**
* Checks if this TagResolver is not a TagResolver.empty()
* @return false if the TagResolver is the same as TagResolver.empty(), else true
* @since 1.4.0
* @see TagResolver.empty
*/
public fun TagResolver.isNotEmpty(): Boolean = this != TagResolver.empty()
/**
* Applies a TagResolver to a TagResolver.Builder in case it is not a TagResolver.empty()
* @param resolver the resolver to check
* @since 1.4.0
* @see TagResolver.isNotEmpty
*/
public fun TagResolver.Builder.applyIfNotEmpty(resolver: TagResolver) {
if (resolver.isNotEmpty()) {
resolver(resolver)
}
}
+27
View File
@@ -0,0 +1,27 @@
plugins {
kotlin("jvm")
kotlin("kapt")
alias(libs.plugins.shadow)
}
repositories {
maven("https://repo.kryptonmc.org/releases")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.kryptonmc.org/snapshots")
}
dependencies {
compileOnly(libs.krypton.server)
compileOnly(kotlin("stdlib"))
kapt(libs.krypton.annotation)
implementation(projects.miniplaceholdersCommon)
implementation(projects.miniplaceholdersApi)
implementation(projects.miniplaceholdersConnect)
implementation(projects.miniplaceholdersKotlinExt)
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
}
@@ -0,0 +1,85 @@
package io.github.miniplaceholders.krypton
import com.google.inject.Inject
import io.github.miniplaceholders.api.utils.TagsUtils
import io.github.miniplaceholders.common.PlaceholdersCommand
import io.github.miniplaceholders.common.PlaceholdersPlugin
import io.github.miniplaceholders.common.PluginConstants
import io.github.miniplaceholders.connect.InternalPlatform
import io.github.miniplaceholders.kotlin.asClosingTag
import io.github.miniplaceholders.kotlin.expansion
import net.kyori.adventure.text.Component
import org.apache.logging.log4j.Logger
import org.kryptonmc.api.command.BrigadierCommand
import org.kryptonmc.api.command.CommandExecutionContext
import org.kryptonmc.api.event.Listener
import org.kryptonmc.api.event.server.ServerStartEvent
import org.kryptonmc.api.plugin.annotation.Plugin
import org.kryptonmc.krypton.KryptonServer
import org.kryptonmc.krypton.command.KryptonCommandMeta
@Plugin(
name = "MiniPlaceholders",
id = "miniplaceholders",
version = PluginConstants.VERSION,
authors = ["4drian3d"]
)
class KotlinKryptonPlugin @Inject constructor(
private val server: KryptonServer,
private val logger: Logger
) : PlaceholdersPlugin {
init {
InternalPlatform.platform(InternalPlatform.KRYPTON)
}
@Listener
@Suppress("UNUSED")
fun onServerStart(event: ServerStartEvent) {
logger.info("Starting MiniPlaceholders Krypton")
this.loadDefaultExpansions()
this.registerPlatformCommand()
}
override fun loadDefaultExpansions() {
expansion("server") {
globalPlaceholder("total_entities") { _, _ ->
var entityCount = 0
for ((_, value) in server.worldManager.worlds) {
entityCount += value.entities.size
}
Component.text(entityCount).asClosingTag()
}
globalPlaceholder("total_chunks") { _, _ ->
var chunkCount = 0
for ((_, value) in server.worldManager.worlds) {
chunkCount += value.chunks.size
}
Component.text(chunkCount).asClosingTag()
}
globalPlaceholder("name", TagsUtils.staticTag(server.platform.name))
globalPlaceholder("online") { queue, _ ->
if (queue.hasNext()) {
val worldName = queue.pop().value()
val players = server.players.filter { it.world.name == worldName }
return@globalPlaceholder Component.text(players.joinToString(", ")).asClosingTag()
}
Component.text(server.players.size).asClosingTag()
}
globalPlaceholder("version", TagsUtils.staticTag(server.platform.version))
globalPlaceholder("max_players", Component.text(server.config.maxPlayers).asClosingTag())
}.register()
}
override fun registerPlatformCommand() {
val command = PlaceholdersCommand.builder<CommandExecutionContext>()
.fromSourceToAudience { it.sender }
.playerSuggestions { server.players.map { it.name } }
.toAudience { server.getPlayer(it) }
.build()
val brigadierCMD = BrigadierCommand.of(command.asNode("miniplaceholders"))
val meta = KryptonCommandMeta.Builder("miniplaceholders").build()
server.commandManager.register(brigadierCMD, meta)
}
}
+18 -19
View File
@@ -1,25 +1,14 @@
plugins {
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
id("io.papermc.paperweight.userdev") version "1.3.8"
id("xyz.jpenilla.run-paper") version "1.0.6"
alias(libs.plugins.userdev)
alias(libs.plugins.runpaper)
alias(libs.plugins.shadow)
}
dependencies {
compileOnly(project(":miniplaceholders-common"))
compileOnly(project(":miniplaceholders-api"))
compileOnly(project(":miniplaceholders-connect"))
paperDevBundle("1.19.1-R0.1-SNAPSHOT")
}
val pluginVersion: String = version as String
bukkit {
name = "MiniPlaceholders"
main = "me.dreamerzero.miniplaceholders.paper.PaperPlugin"
apiVersion = "1.18"
website = "https://github.com/4drian3d/MiniPlaceholders"
authors = listOf("4drian3d")
version = pluginVersion
paperweight.paperDevBundle(libs.versions.paper.get())
implementation(projects.miniplaceholdersCommon)
implementation(projects.miniplaceholdersApi)
implementation(projects.miniplaceholdersConnect)
}
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
@@ -34,7 +23,17 @@ tasks {
options.release.set(17)
}
runServer {
minecraftVersion("1.19.1")
minecraftVersion("1.19.4")
}
jar {
manifest {
attributes("Automatic-Module-Name" to "io.github.miniplaceholders.paper")
}
}
processResources {
filesMatching("paper-plugin.yml") {
expand("version" to project.version)
}
}
}
@@ -1,38 +1,37 @@
package me.dreamerzero.miniplaceholders.paper;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
package io.github.miniplaceholders.paper;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.common.PlaceholdersCommand;
import io.github.miniplaceholders.common.PlaceholdersPlugin;
import io.github.miniplaceholders.connect.InternalPlatform;
import io.papermc.paper.datapack.Datapack;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.utils.TagsUtils;
import me.dreamerzero.miniplaceholders.common.PlaceholdersCommand;
import me.dreamerzero.miniplaceholders.common.PlaceholdersPlugin;
import me.dreamerzero.miniplaceholders.connect.InternalPlatform;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.MinecraftServer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin, Listener {
private final DecimalFormat tpsFormat = new DecimalFormat("###.##");
private final DecimalFormat msptFormat = new DecimalFormat("###.###");
import java.math.RoundingMode;
import java.text.DecimalFormat;
@SuppressWarnings("unused")
public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin {
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("###.##");
private static final DecimalFormat MSPT_FORMAT = new DecimalFormat("###.###");
static {
InternalPlatform.platform(InternalPlatform.PAPER);
TPS_FORMAT.setRoundingMode(RoundingMode.HALF_UP);
MSPT_FORMAT.setRoundingMode(RoundingMode.HALF_UP);
}
@Override
public void onEnable(){
this.getSLF4JLogger().info("Starting MiniPlaceholders Paper");
InternalPlatform.platform(InternalPlatform.PAPER);
this.getServer().getPluginManager().registerEvents(this, this);
tpsFormat.setRoundingMode(RoundingMode.HALF_UP);
msptFormat.setRoundingMode(RoundingMode.HALF_UP);
this.loadDefaultExpansions();
this.registerPlatformCommand();
}
@@ -45,28 +44,28 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin,
.globalPlaceholder("version", TagsUtils.staticTag(this.getServer().getVersion()))
.globalPlaceholder("max_players", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().getMaxPlayers())))
.globalPlaceholder("unique_joins", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().getOfflinePlayers().length)))
.globalPlaceholder("tps_1", (queue, ctx) -> TagsUtils.staticTag(tpsFormat.format(this.getServer().getTPS()[0])))
.globalPlaceholder("tps_5", (queue, ctx) -> TagsUtils.staticTag(tpsFormat.format(this.getServer().getTPS()[1])))
.globalPlaceholder("tps_15", (queue, ctx) -> TagsUtils.staticTag(tpsFormat.format(this.getServer().getTPS()[2])))
.globalPlaceholder("tps_1", (queue, ctx) -> TagsUtils.staticTag(TPS_FORMAT.format(this.getServer().getTPS()[0])))
.globalPlaceholder("tps_5", (queue, ctx) -> TagsUtils.staticTag(TPS_FORMAT.format(this.getServer().getTPS()[1])))
.globalPlaceholder("tps_15", (queue, ctx) -> TagsUtils.staticTag(TPS_FORMAT.format(this.getServer().getTPS()[2])))
.globalPlaceholder("has_whitelist", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().hasWhitelist())))
.globalPlaceholder("total_chunks", (queue, ctx) -> {
int chunkCount = 0;
for(World world : this.getServer().getWorlds()){
for (World world : this.getServer().getWorlds()){
chunkCount += world.getLoadedChunks().length;
}
return TagsUtils.staticTag(Component.text(chunkCount));
})
.globalPlaceholder("total_entities", (queue, ctx) -> {
int entityCount = 0;
for(World world : this.getServer().getWorlds()){
for (World world : this.getServer().getWorlds()){
entityCount += world.getEntityCount();
}
return TagsUtils.staticTag(Component.text(entityCount));
})
.globalPlaceholder("mspt", (queue, ctx) -> TagsUtils.staticTag(msptFormat.format(this.getServer().getAverageTickTime())))
.globalPlaceholder("mspt", (queue, ctx) -> TagsUtils.staticTag(MSPT_FORMAT.format(this.getServer().getAverageTickTime())))
.globalPlaceholder("datapack_list", (queue, ctx) -> {
TextComponent.Builder builder = Component.text();
for(Datapack datapack : this.getServer().getDatapackManager().getEnabledPacks()){
final TextComponent.Builder builder = Component.text();
for (Datapack datapack : this.getServer().getDatapackManager().getEnabledPacks()){
builder.append(Component.text("[").append(Component.text(datapack.getName()).append(Component.text("] "))));
}
return Tag.selfClosingInserting(builder.build());
@@ -77,16 +76,21 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin,
}
@Override
@SuppressWarnings({"sonarlint(java:s1874)", "deprecation", /*TODO: replace with Java(536871800) */ "all"})
@SuppressWarnings({"sonarlint(java:s1874)"})
public void registerPlatformCommand() {
MinecraftServer.getServer()
.vanillaCommandDispatcher
.getCommands()
.getDispatcher()
.register(new PlaceholdersCommand<>(
() -> this.getServer().getOnlinePlayers().stream().map(Player::getName).toList(),
(String st) -> this.getServer().getPlayer(st),
CommandSourceStack::getBukkitSender
).placeholderTestBuilder("miniplaceholders")
.register(PlaceholdersCommand.<CommandSourceStack>builder()
.playerSuggestions(() -> getServer().getOnlinePlayers()
.stream()
.map(Player::getName)
.toList())
.toAudience(st -> getServer().getPlayer(st))
.hasPermissionCheck((source, permission) -> source.getBukkitSender().hasPermission(permission))
.fromSourceToAudience(CommandSourceStack::getBukkitSender)
.build()
.asBuilder("miniplaceholders")
);
}
}
@@ -0,0 +1,6 @@
name: MiniPlaceholders
version: '${version}'
main: io.github.miniplaceholders.paper.PaperPlugin
description: MiniMessage Component-based Placeholders for PaperMC, Krypton and Velocity platforms
api-version: '1.19'
folia-supported: true
+7
View File
@@ -0,0 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"ignoreDeps": ["krypton", "krypton-api", "krypton-annotation-processor", "krypton-server"]
}
+22 -9
View File
@@ -1,16 +1,29 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven("https://papermc.io/repo/repository/maven-public/")
}
}
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
rootProject.name = "miniplaceholders-parent"
val modules = listOf("connect", "api", "common", "paper", "velocity")
pluginManagement {
@Suppress("UnstableApiUsage")
includeBuild("build-logic")
repositories {
gradlePluginPortal()
mavenCentral()
}
}
modules.forEach {
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
}
arrayOf(
"connect",
"api",
"kotlin-ext",
"common",
"paper",
"velocity",
"krypton"
).forEach {
include("miniplaceholders-$it")
project(":miniplaceholders-$it").projectDir = file(it)
}
+2
View File
@@ -0,0 +1,2 @@
#run velocity files
/run
+26 -9
View File
@@ -1,15 +1,32 @@
plugins {
alias(libs.plugins.runvelocity)
alias(libs.plugins.shadow)
}
dependencies {
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
compileOnly(project(":miniplaceholders-common"))
compileOnly(project(":miniplaceholders-api"))
compileOnly(project(":miniplaceholders-connect"))
compileOnly(libs.velocity)
annotationProcessor(libs.velocity)
implementation(projects.miniplaceholdersCommon)
implementation(projects.miniplaceholdersApi)
implementation(projects.miniplaceholdersConnect)
}
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
tasks.compileJava {
options.encoding = Charsets.UTF_8.name()
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
options.release.set(17)
}
jar {
manifest {
attributes("Automatic-Module-Name" to "io.github.miniplaceholders.velocity")
}
}
runVelocity {
velocityVersion(libs.versions.velocity.get())
}
}
@@ -0,0 +1,83 @@
package io.github.miniplaceholders.velocity;
import com.google.inject.Inject;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.utils.Components;
import io.github.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.common.PlaceholdersCommand;
import io.github.miniplaceholders.common.PlaceholdersPlugin;
import io.github.miniplaceholders.common.PluginConstants;
import io.github.miniplaceholders.connect.InternalPlatform;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import org.slf4j.Logger;
@Plugin(
name = "MiniPlaceholders",
id = "miniplaceholders",
version = PluginConstants.VERSION,
authors = {"4drian3d"}
)
public final class VelocityPlugin implements PlaceholdersPlugin {
private final Logger logger;
private final ProxyServer proxy;
@Inject
public VelocityPlugin(final Logger logger, final ProxyServer proxy) {
this.logger = logger;
this.proxy = proxy;
}
@Subscribe
public void onProxyInitialize(final ProxyInitializeEvent event) {
logger.info("Starting MiniPlaceholders Velocity");
InternalPlatform.platform(InternalPlatform.VELOCITY);
this.loadDefaultExpansions();
this.registerPlatformCommand();
}
@Override
public void loadDefaultExpansions() {
Expansion.builder("proxy")
.globalPlaceholder("online_players", (queue, ctx) -> {
if (queue.hasNext()) {
String server = queue.pop().value();
return Tag.selfClosingInserting(Component.text(proxy.getServer(server).map(sv -> sv.getPlayersConnected().size()).orElse(0)));
}
return Tag.selfClosingInserting(Component.text(proxy.getPlayerCount()));
})
.globalPlaceholder("server_count", (queue, ctx) -> Tag.selfClosingInserting(Component.text(proxy.getAllServers().size())))
.globalPlaceholder("is_player_online", (queue, ctx) -> {
String playerName = queue.popOr(() -> "you need to introduce an argument").value();
return TagsUtils.staticTag(proxy.getPlayer(playerName).isPresent() ? Components.YES_COMPONENT : Components.NO_COMPONENT);
})
.globalPlaceholder("version", TagsUtils.staticTag(proxy.getVersion().getVersion()))
.build()
.register();
}
@Override
public void registerPlatformCommand() {
final BrigadierCommand brigadierCMD = new BrigadierCommand(
PlaceholdersCommand.<CommandSource>builder()
.playerSuggestions(() -> proxy.getAllPlayers()
.stream()
.map(Player::getUsername)
.toList())
.toAudience(st -> proxy.getPlayer(st).orElse(null))
.build()
.asNode("vminiplaceholders")
);
proxy.getCommandManager().register(brigadierCMD);
}
}
@@ -1,79 +0,0 @@
package me.dreamerzero.miniplaceholders.velocity;
import com.google.inject.Inject;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import org.slf4j.Logger;
import me.dreamerzero.miniplaceholders.api.Expansion;
import me.dreamerzero.miniplaceholders.api.utils.Components;
import me.dreamerzero.miniplaceholders.api.utils.TagsUtils;
import me.dreamerzero.miniplaceholders.common.PlaceholdersCommand;
import me.dreamerzero.miniplaceholders.common.PlaceholdersPlugin;
import me.dreamerzero.miniplaceholders.common.PluginConstants;
import me.dreamerzero.miniplaceholders.connect.InternalPlatform;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
@Plugin(
name = "MiniPlaceholders",
id = "miniplaceholders",
version = PluginConstants.VERSION,
authors = {"4drian3d"}
)
public final class VelocityPlugin implements PlaceholdersPlugin {
private final Logger logger;
private final ProxyServer proxy;
@Inject
public VelocityPlugin(final Logger logger, final ProxyServer proxy) {
this.logger = logger;
this.proxy = proxy;
}
@Subscribe
public void onProxyInitialize(final ProxyInitializeEvent event) {
logger.info("Starting MiniPlaceholders Velocity");
InternalPlatform.platform(InternalPlatform.VELOCITY);
this.loadDefaultExpansions();
this.registerPlatformCommand();
}
@Override
public void loadDefaultExpansions() {
Expansion.builder("proxy")
.globalPlaceholder("online_players", (queue, ctx) -> {
if(queue.hasNext()){
String server = queue.pop().value();
return Tag.selfClosingInserting(Component.text(proxy.getServer(server).map(sv -> sv.getPlayersConnected().size()).orElse(0)));
}
return Tag.selfClosingInserting(Component.text(proxy.getPlayerCount()));
})
.globalPlaceholder("server_count", (queue, ctx) -> Tag.selfClosingInserting(Component.text(proxy.getAllServers().size())))
.globalPlaceholder("is_player_online", (queue, ctx) -> {
String playerName = queue.popOr(() -> "you need to introduce an argument").value();
return TagsUtils.staticTag(proxy.getPlayer(playerName).isPresent() ? Components.YES_COMPONENT : Components.NO_COMPONENT);
})
.globalPlaceholder("version", TagsUtils.staticTag(proxy.getVersion().getVersion()))
.build()
.register();
}
@Override
public void registerPlatformCommand() {
final BrigadierCommand brigadierCMD = new BrigadierCommand(
new PlaceholdersCommand<CommandSource>(
() -> proxy.getAllPlayers().stream().map(Player::getUsername).toList(),
(String st) -> proxy.getPlayer(st).orElse(null))
.placeholderTestCommand("vminiplaceholders"));
proxy.getCommandManager().register(brigadierCMD);
}
}