Skip to content

Commit

Permalink
feat: Update Example Expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed Aug 31, 2023
1 parent bec5743 commit 3797f29
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ subprojects {

tasks {
shadowJar {
archiveFileName.set("${rootProject.name}-${project.version}.jar")
archiveFileName.set("MiniPlaceholders-${rootProject.name}-${project.version}.jar")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import io.github.miniplaceholders.api.Expansion;

public final class CommonExpansion {
public static void register() {
Expansion.builder("example")
.build()
.register();
public static Expansion.Builder builder() {
return Expansion.builder("example")
.globalPlaceholder("some_placeholder", (queue, ctx) -> null);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group = io.github.miniplaceholders
version = 1.0.0
description = Example-Expansion
description = MiniPlaceholders Example Expansion
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

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

@SuppressWarnings("unused")
public final class PaperPlugin extends JavaPlugin {

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

CommonExpansion.register();

Expansion.builder("example")
.filter(Player.class)
.audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((Player)aud).getName())))
.build()
.register();
CommonExpansion.builder()
.filter(Player.class)
.build()
.register();
}
}
11 changes: 6 additions & 5 deletions paper/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Example-Expansion
name: MiniPlaceholdersExample-Expansion
version: '${version}'
author: 4drian3d
main: io.github.miniplaceholders.expansion.example.paper.PaperPlugin
api-version: '1.19'
folia-supported: true
dependencies:
- name: MiniPlaceholders
required: true
server:
MiniPlaceholders:
required: true
# Add some plugin dependency
#- name: spark
# required: true
# spark:
# required: true
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

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

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
Expand Down
9 changes: 7 additions & 2 deletions sponge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ sponge {
name(PluginLoaders.JAVA_PLAIN)
version("1.0")
}
plugin("example-expansion") {
displayName("Example-Expansion")
plugin("miniplaceholders-example-expansion") {
displayName("MiniPlaceholders-Example-Expansion")
entrypoint("io.github.miniplaceholders.expansion.example.sponge.SpongePlugin")
description(project.description)
links {
Expand All @@ -38,5 +38,10 @@ sponge {
optional(false)
version("2.2.0")
}
dependency("some_plugin") {
loadOrder(PluginDependency.LoadOrder.AFTER)
optional(false)
version("1.0.0")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
import io.github.miniplaceholders.expansion.example.common.CommonExpansion;
import org.apache.logging.log4j.Logger;
import org.spongepowered.api.Server;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
import org.spongepowered.plugin.builtin.jvm.Plugin;

@Plugin("example-expansion")
@Plugin("miniplaceholders-example-expansion")
public class SpongePlugin {
@Inject
private Logger logger;

@Listener
public void onServerStart(final StartingEngineEvent<Server> event) {
logger.info("Starting Example Expansion for Sponge");
this.logger.info("Starting Example Expansion for Sponge");

CommonExpansion.register();
CommonExpansion.builder()
.filter(ServerPlayer.class)
.build()
.register();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.Player;

import io.github.miniplaceholders.expansion.example.common.CommonExpansion;
import org.slf4j.Logger;

import io.github.miniplaceholders.api.Expansion;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;

@Plugin(
name = "Example-Expansion",
id = "example-expansion",
name = "MiniPlaceholders-Example-Expansion",
id = "miniplaceholders-example-expansion",
version = Constants.VERSION,
authors = {"4drian3d"},
dependencies = {
Expand All @@ -29,20 +23,17 @@ public final class VelocityPlugin {
private final Logger logger;

@Inject
public VelocityPlugin(Logger logger) {
public VelocityPlugin(final Logger logger) {
this.logger = logger;
}

@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
public void onProxyInitialize(final ProxyInitializeEvent event) {
logger.info("Starting Example Expansion for Velocity");

CommonExpansion.register();

Expansion.builder("example")
.filter(Player.class)
.audiencePlaceholder("name", (aud, queue, ctx) -> Tag.selfClosingInserting(Component.text(((Player)aud).getUsername())))
.build()
.register();
CommonExpansion.builder()
.filter(Player.class)
.build()
.register();
}
}

0 comments on commit 3797f29

Please sign in to comment.