Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 4 additions & 440 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ dependencies {
compileOnly("org.projectlombok:lombok:1.18.42")
annotationProcessor("org.projectlombok:lombok:1.18.42")

compileOnly("io.github.miniplaceholders:miniplaceholders-api:3.1.0")

implementation("org.yaml:snakeyaml:2.5")
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/top/ourisland/invertotimer/InvertoTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
Expand All @@ -24,7 +25,10 @@
version = BuildConstants.VERSION,
description = "A Velocity countdown timer plugin.",
url = "https://github.com/Our-Island/invertoTimer",
authors = {"Chiloven945"}
authors = {"Our-Island", "Chiloven945"},
dependencies = {
@Dependency(id = "miniplaceholders", optional = true)
}
)
public class InvertoTimer {
private final ProxyServer proxy;
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/top/ourisland/invertotimer/action/CommandAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@ public String description() {

@Override
public void execute() {
final String cmd = ctx.renderString(command).trim();
if (cmd.isBlank()) return;

switch (executor) {
case CONSOLE -> ctx.proxy().getCommandManager().executeAsync(
ctx.proxy().getConsoleCommandSource(), trimLeadingSlash(cmd)
);
case CONSOLE -> {
final String cmd = ctx.renderString(command).trim();
if (cmd.isBlank()) return;
ctx.proxy().getCommandManager().executeAsync(
ctx.proxy().getConsoleCommandSource(), trimLeadingSlash(cmd)
);
}
case PLAYER -> ctx.players().stream()
.filter(ctx::allowed)
.filter(p -> match == null || match.matcher(p.getUsername()).matches())
.forEach(p -> p.spoofChatInput(cmd));
.forEach(p -> {
final String cmd = ctx.renderString(p, command).trim();
if (cmd.isBlank()) return;
p.spoofChatInput(cmd);
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ public void execute() {
if (!ctx.allowed(p)) continue;

switch (textType) {
case ACTIONBAR -> p.sendActionBar(ctx.render(info));
case MESSAGE -> p.sendMessage(ctx.render(info));
case ACTIONBAR -> p.sendActionBar(ctx.render(p, info));
case MESSAGE -> p.sendMessage(ctx.render(p, info));
case TITLE, SUBTITLE -> {
Component t = ctx.render(title);
Component s = ctx.render(subtitle);
Component t = ctx.render(p, title);
Component s = ctx.render(p, subtitle);

if (fadeIn != null || stay != null || fadeOut != null) {
Duration fi = fadeIn != null ? fadeIn : Duration.of(0, ChronoUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static AnimationConfig fromYaml(final String id, final Map<?, ?> m) {
if (!(o instanceof Map<?, ?> fm)) continue;

double durSec = YamlUtil.getDouble(fm, "duration", 1.0);
long durMs = Math.max(1, (long) Math.round(durSec * 1000.0));
long durMs = Math.max(1, Math.round(durSec * 1000.0));
String text = YamlUtil.getString(fm, "text", "");

frames.add(new Frame(durMs, text));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package top.ourisland.invertotimer.runtime;

import io.github.miniplaceholders.api.MiniPlaceholders;
import lombok.Getter;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;

/**
* Optional integration with MiniPlaceholders.
* <p>
* This class intentionally contains the only direct references to the MiniPlaceholders API. It must only be loaded/used
* when the MiniPlaceholders plugin is present at runtime.
*/
@Getter
public final class MiniPlaceholdersHook {

private final TagResolver global;
private final TagResolver audience;

public MiniPlaceholdersHook() {
this.global = MiniPlaceholders.globalPlaceholders();
this.audience = MiniPlaceholders.audiencePlaceholders();
}
}
Loading
Loading