Compare commits

...
51 Commits
Author SHA1 Message Date
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
61 changed files with 884 additions and 470 deletions

No files matched your search

+2 -2
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'
+56 -2
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.3+
- Velocity 3.1.2+
- Krypton
## Commands:
### Velocity
`/vminiplaceholders <parse|help> <me|player> <player-to-parse>`
### Paper
`/miniplaceholders <parse|help> <me|player> <player-to-parse>`
## 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) -> {
return Tag.selfClosingInserting(aud.getName());
})
.globalPlaceholder("tps", (ctx, queue) -> {
return Tag.inserting(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.jitpack.io/com/github/4drian3d/MiniPlaceholders/latest/javadoc/index.html)
Or check the wiki [here](https://github.com/4drian3d/MiniPlaceholders/wiki)
Or check the developer wiki [here](https://github.com/MiniPlaceholders/MiniPlaceholders/wiki/Developer-Getting-Started)
+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.12.0")
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.12.0")
}
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,15 +1,14 @@
package me.dreamerzero.miniplaceholders.api;
package io.github.miniplaceholders.api;
import java.util.Collections;
import java.util.HashSet;
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;
@@ -74,7 +73,6 @@ 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) {
requireNonNull(audience, "audience cannot be null");
@@ -88,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>
@@ -98,7 +96,6 @@ 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) {
requireNonNull(audience, "audience cannot be null");
requireNonNull(otherAudience, "otherAudience cannot be null");
@@ -132,7 +129,6 @@ 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) {
requireNonNull(audience, "audience cannot be null");
final TagResolver.Builder builder = TagResolver.builder();
@@ -146,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>
@@ -166,7 +162,6 @@ 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) {
requireNonNull(audience, "audience cannot be null");
requireNonNull(otherAudience, "otherAudience cannot be null");
@@ -182,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,4 +1,4 @@
package me.dreamerzero.miniplaceholders.api.enums;
package io.github.miniplaceholders.api.enums;
/**Platforms on which MiniPlaceholders can be used */
public enum Platform {
@@ -7,5 +7,5 @@ public enum Platform {
/**Velocity Platform */
VELOCITY,
/**Krypton Platform */
KRYPTON;
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;
+9 -8
View File
@@ -1,13 +1,14 @@
/** MiniPlaceholdes API Module */
open module me.dreamerzero.miniplaceholders.api {
/** MiniPlaceholders API Module */
open module io.github.miniplaceholders.api {
requires net.kyori.adventure;
requires net.kyori.examination.api;
requires net.kyori.adventure.text.minimessage;
requires net.kyori.examination.api;
requires static org.jetbrains.annotations;
requires me.dreamerzero.miniplaceholders.connect;
requires io.github.miniplaceholders.connect;
requires net.kyori.adventure.text.serializer.legacy;
exports me.dreamerzero.miniplaceholders.api;
exports me.dreamerzero.miniplaceholders.api.enums;
exports me.dreamerzero.miniplaceholders.api.utils;
exports me.dreamerzero.miniplaceholders.api.placeholder;
exports io.github.miniplaceholders.api;
exports io.github.miniplaceholders.api.enums;
exports io.github.miniplaceholders.api.utils;
exports io.github.miniplaceholders.api.placeholder;
}
@@ -1,12 +1,12 @@
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;
class ExpansionsTest {
@Test
@@ -1,13 +1,13 @@
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;
@@ -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;
@@ -23,7 +23,7 @@ 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 @@ 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 @@ 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,13 +8,15 @@ 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;
//yea... it is intended xd
@SuppressWarnings("DataFlowIssue")
class ThrowableTest {
@Test
@DisplayName("Nullable Exception")
@@ -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()
}
+6 -11
View File
@@ -1,8 +1,7 @@
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.10" apply false
}
allprojects {
@@ -10,12 +9,9 @@ allprojects {
}
dependencies {
shadow(project(":miniplaceholders-connect"))
shadow(project(":miniplaceholders-api"))
shadow(project(":miniplaceholders-common"))
shadow(project(":miniplaceholders-velocity"))
shadow(project(":miniplaceholders-paper", "reobf"))
shadow(project(":miniplaceholders-krypton"))
implementation(projects.miniplaceholdersVelocity)
implementation(project(":miniplaceholders-paper", "reobf"))
implementation(projects.miniplaceholdersKrypton)
}
subprojects {
@@ -28,9 +24,8 @@ subprojects {
tasks {
shadowJar {
archiveFileName.set("MiniPlaceholders-$version.jar")
archiveFileName.set("MiniPlaceholders-${project.version}.jar")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations = listOf(project.configurations.shadow.get())
}
build {
dependsOn(shadowJar)
+13 -9
View File
@@ -1,33 +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}", project.version)
replaceTokenIn("src/main/java/me/dreamerzero/miniplaceholders/common/PluginConstants.java")
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 "me.dreamerzero.miniplaceholders.common")
attributes("Automatic-Module-Name" to "io.github.miniplaceholders.common")
}
}
}
@@ -1,6 +1,7 @@
package me.dreamerzero.miniplaceholders.common;
package io.github.miniplaceholders.common;
import java.util.Collection;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -12,8 +13,8 @@ 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 io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.MiniPlaceholders;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.text.Component;
@@ -27,21 +28,40 @@ 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 BiPredicate<A, String> hasPermission = null;
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){
public PlaceholdersCommand(
@NotNull Supplier<Collection<String>> playersSuggestions,
@NotNull 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){
public PlaceholdersCommand(
Supplier<Collection<String>> playersSuggestions,
Function<@NotNull String, @Nullable Audience> toAudience,
Function<A, Audience> fromAToAudience
) {
this(playersSuggestions, toAudience);
this.fromAToAudience = fromAToAudience;
}
public PlaceholdersCommand(
Supplier<Collection<String>> playersSuggestions,
Function<@NotNull String, @Nullable Audience> toAudience,
Function<A, Audience> fromAToAudience,
BiPredicate<A, String> hasPermission
) {
this(playersSuggestions, toAudience, fromAToAudience);
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>");
@@ -50,7 +70,7 @@ public class PlaceholdersCommand<A> {
.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")){
if (hasPermission(cmd.getSource(), "miniplaceholders.command")) {
source.sendMessage(
Component.text()
.append(HEADER).append(Component.newline())
@@ -70,6 +90,7 @@ public class PlaceholdersCommand<A> {
return 1;
})
.then(LiteralArgumentBuilder.<A>literal("help")
.requires(src -> hasPermission(src, "miniplaceholders.command.help"))
.executes(cmd -> {
getAudience(cmd.getSource()).sendMessage(
Component.text()
@@ -84,10 +105,11 @@ public class PlaceholdersCommand<A> {
})
)
.then(LiteralArgumentBuilder.<A>literal("parse")
.requires(cmd -> hasPermission(cmd, "miniplaceholders.command.parse"))
.then(LiteralArgumentBuilder.<A>literal("me")
.then(RequiredArgumentBuilder.<A, String>argument("selfStringToParse", StringArgumentType.string())
.then(RequiredArgumentBuilder.<A, String>argument("string", StringArgumentType.string())
.executes(cmd -> {
String stringToParse = cmd.getArgument("selfStringToParse", String.class);
String stringToParse = cmd.getArgument("string", String.class);
Component parsed = this.parseGlobal(stringToParse, getAudience(cmd.getSource()));
getAudience(cmd.getSource()).sendMessage(parsed);
return 1;
@@ -100,7 +122,7 @@ public class PlaceholdersCommand<A> {
playersSuggestions.get().forEach(builder::suggest);
return builder.buildFuture();
})
.then(RequiredArgumentBuilder.<A, String>argument("playerStringToParse", StringArgumentType.string())
.then(RequiredArgumentBuilder.<A, String>argument("string", StringArgumentType.string())
.executes(cmd -> {
Audience objetive = toAudience.apply(cmd.getArgument("source", String.class));
if(objetive == null){
@@ -134,10 +156,20 @@ public class PlaceholdersCommand<A> {
}
private Audience getAudience(A possibleAudience){
if(possibleAudience instanceof Audience audience){
if (possibleAudience instanceof Audience audience){
return audience;
}
Audience audience = fromAToAudience.apply(possibleAudience);
return audience != null ? audience : Audience.empty();
}
private boolean hasPermission(A source, String permission) {
if (hasPermission != null) {
return hasPermission.test(source, permission);
}
return getAudience(source)
.get(PermissionChecker.POINTER)
.map(checker -> checker.test(permission))
.orElse(false);
}
}
@@ -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,4 +1,4 @@
package me.dreamerzero.miniplaceholders.connect;
package io.github.miniplaceholders.connect;
public enum InternalPlatform {
+2 -2
View File
@@ -1,3 +1,3 @@
module me.dreamerzero.miniplaceholders.connect {
exports me.dreamerzero.miniplaceholders.connect;
module io.github.miniplaceholders.connect {
exports io.github.miniplaceholders.connect;
}
+3 -3
View File
@@ -1,3 +1,3 @@
group = me.dreamerzero.miniplaceholders
version = 1.3.0
description = MiniPlaceholders
group = io.github.miniplaceholders
version = 2.0.0
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.3-R0.1-SNAPSHOT"
krypton = "7f7a457cdf"
runtask = "2.0.1"
pluginyml = "0.5.3"
userdev = "1.5.1"
blossom = "1.3.1"
indra = "3.0.1"
shadow = "8.0.0"
jmh = "0.7.0"
dokka = "1.7.20"
adventure = "4.12.0"
brigadier = "1.0.18"
kotlin="1.8.10"
[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 = "gradle.plugin.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.7.20"
[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.1-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)
}
}
+19 -5
View File
@@ -1,3 +1,9 @@
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/")
@@ -5,9 +11,17 @@ repositories {
}
dependencies {
compileOnly("org.kryptonmc:krypton-server:0.66.3")
annotationProcessor("org.kryptonmc:annotation-processor:0.66.2")
compileOnly(project(":miniplaceholders-common"))
compileOnly(project(":miniplaceholders-api"))
compileOnly(project(":miniplaceholders-connect"))
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"
}
}
@@ -1,97 +0,0 @@
package me.dreamerzero.miniplaceholders.krypton;
import org.apache.logging.log4j.Logger;
import org.kryptonmc.api.Server;
import org.kryptonmc.api.command.BrigadierCommand;
import org.kryptonmc.api.command.Sender;
import org.kryptonmc.api.entity.player.Player;
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 net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import com.google.inject.Inject;
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.common.PluginConstants;
import me.dreamerzero.miniplaceholders.connect.InternalPlatform;
import me.lucko.spark.api.statistic.StatisticWindow;
@Plugin(
name = "MiniPlaceholders",
id = "miniplaceholders",
version = PluginConstants.VERSION,
authors = {"4drian3d"}
)
public class JavaKryptonPlugin implements PlaceholdersPlugin {
private final KryptonServer server;
private final Logger logger;
@Inject
public JavaKryptonPlugin(Server server, Logger logger) {
this.logger = logger;
this.server = (KryptonServer)server;
}
@Listener
public void onServerStart(ServerStartEvent event) {
logger.info("Starting MiniPlaceholders Krypton");
InternalPlatform.platform(InternalPlatform.KRYPTON);
this.loadDefaultExpansions();
this.registerPlatformCommand();
}
@Override
public void loadDefaultExpansions() {
Expansion.builder("server")
.globalPlaceholder("total_entities", (queue, ctx) -> {
int entityCount = 0;
for (var entry : server.getWorldManager().getWorlds().entrySet()) {
entityCount += entry.getValue().entities().size();
}
return TagsUtils.staticTag(Component.text(entityCount));
})
.globalPlaceholder("total_chunks", (queque, ctx) -> {
int chunkCount = 0;
for(var entry : server.getWorldManager().getWorlds().entrySet()) {
chunkCount += entry.getValue().chunks().size();
}
return TagsUtils.staticTag(Component.text(chunkCount));
})
.globalPlaceholder("name", TagsUtils.staticTag(server.getPlatform().getName()))
.globalPlaceholder("online", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getPlayers().size())))
.globalPlaceholder("version", TagsUtils.staticTag(server.getPlatform().getVersion()))
.globalPlaceholder("max_players", TagsUtils.staticTag(Component.text(server.getMaxPlayers())))
.globalPlaceholder("has_whitelist", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getPlayerManager().getWhitelistEnabled())))
.globalPlaceholder("tps_1", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().tps().poll(StatisticWindow.TicksPerSecond.MINUTES_1))))
.globalPlaceholder("tps_5", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().tps().poll(StatisticWindow.TicksPerSecond.MINUTES_5))))
.globalPlaceholder("tps_15", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().tps().poll(StatisticWindow.TicksPerSecond.MINUTES_15))))
.globalPlaceholder("mspt", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().mspt().poll(StatisticWindow.MillisPerTick.SECONDS_10).mean())))
.build()
.register();
}
private static final PlainTextComponentSerializer SERIALIZER = PlainTextComponentSerializer.plainText();
@Override
public void registerPlatformCommand() {
final PlaceholdersCommand<Sender> command = new PlaceholdersCommand<>(
() -> server.getPlayers()
.stream()
.map(Player::name)
.map(SERIALIZER::serialize)
.toList(),
server::player);
final BrigadierCommand brigadierCMD = BrigadierCommand.of(command.placeholderTestCommand("miniplaceholders"));
server.getCommandManager().register(brigadierCMD);
}
}
@@ -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<CommandExecutionContext>(
{ server.players.map { it.name } },
{ server.getPlayer(it) },
{ it.sender }
)
val brigadierCMD = BrigadierCommand.of(command.placeholderTestCommand("miniplaceholders"))
val meta = KryptonCommandMeta.Builder("miniplaceholders").build()
server.commandManager.register(brigadierCMD, meta)
}
}
+14 -18
View File
@@ -1,23 +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")
}
bukkit {
name = "MiniPlaceholders"
main = "me.dreamerzero.miniplaceholders.paper.PaperPlugin"
apiVersion = "1.18"
website = "https://github.com/4drian3d/MiniPlaceholders"
authors = listOf("4drian3d")
version = project.version as String
paperweight.paperDevBundle(libs.versions.paper.get())
implementation(projects.miniplaceholdersCommon)
implementation(projects.miniplaceholdersApi)
implementation(projects.miniplaceholdersConnect)
}
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
@@ -32,11 +23,16 @@ tasks {
options.release.set(17)
}
runServer {
minecraftVersion("1.19.1")
minecraftVersion("1.19.3")
}
jar {
manifest {
attributes("Automatic-Module-Name" to "me.dreamerzero.miniplaceholders.paper")
attributes("Automatic-Module-Name" to "io.github.miniplaceholders.paper")
}
}
processResources {
filesMatching("paper-plugin.yml") {
expand("version" to project.version)
}
}
}
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.paper;
package io.github.miniplaceholders.paper;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@@ -8,17 +8,18 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
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 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 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;
@SuppressWarnings("unused")
public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin {
private final DecimalFormat tpsFormat = new DecimalFormat("###.##");
private final DecimalFormat msptFormat = new DecimalFormat("###.###");
@@ -75,15 +76,16 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin
}
@Override
@SuppressWarnings({"sonarlint(java:s1874)", /*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
CommandSourceStack::getBukkitSender,
(source, permission) -> source.getBukkitSender().hasPermission(permission)
).placeholderTestBuilder("miniplaceholders")
);
}
@@ -0,0 +1,5 @@
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'
+6
View File
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}
+18 -9
View File
@@ -1,16 +1,25 @@
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", "krypton")
pluginManagement {
@Suppress("UnstableApiUsage")
includeBuild("build-logic")
repositories {
gradlePluginPortal()
mavenCentral()
}
}
modules.forEach {
arrayOf(
"connect",
"api",
"kotlin-ext",
"common",
"paper",
"velocity",
"krypton"
).forEach {
include("miniplaceholders-$it")
project(":miniplaceholders-$it").projectDir = file(it)
}
+15 -6
View File
@@ -1,9 +1,14 @@
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))
@@ -17,7 +22,11 @@ tasks {
jar {
manifest {
attributes("Automatic-Module-Name" to "me.dreamerzero.miniplaceholders.velocity")
attributes("Automatic-Module-Name" to "io.github.miniplaceholders.velocity")
}
}
runVelocity {
velocityVersion(libs.versions.velocity.get())
}
}
@@ -1,4 +1,4 @@
package me.dreamerzero.miniplaceholders.velocity;
package io.github.miniplaceholders.velocity;
import com.google.inject.Inject;
import com.velocitypowered.api.command.BrigadierCommand;
@@ -11,13 +11,13 @@ 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 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;