Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmakila committed Oct 30, 2024
1 parent baa13e9 commit 65478f4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fi.fabianadrian.webhooklogger.common.WebhookLogger;
import fi.fabianadrian.webhooklogger.common.config.section.PlaceholderConfigSection;
import fi.fabianadrian.webhooklogger.common.dependency.Dependency;
import fi.fabianadrian.webhooklogger.common.platform.Player;
import fi.fabianadrian.webhooklogger.common.platform.PlatformPlayer;
import io.github.miniplaceholders.api.MiniPlaceholders;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identity;
Expand Down Expand Up @@ -43,7 +43,7 @@ public TagResolver cancelled(boolean cancelled) {
return Placeholder.unparsed("cancelled", cancelledString);
}

public TagResolver player(Player player) {
public TagResolver player(PlatformPlayer player) {
List<TagResolver> resolvers = new ArrayList<>();

resolvers.add(audience(player));
Expand All @@ -53,13 +53,11 @@ public TagResolver player(Player player) {

Component location = miniMessage.deserialize(
config.locationFormat(),
Placeholder.unparsed("x", String.valueOf(player.location().x())),
Placeholder.unparsed("y", String.valueOf(player.location().y())),
Placeholder.unparsed("z", String.valueOf(player.location().z()))
player.location().tagResolver()
);
resolvers.add(Placeholder.component("location", location));

return TagResolver.builder().resolvers(resolvers).build();
return TagResolver.resolver(resolvers);
}

public TagResolver audience(Audience audience) {
Expand All @@ -78,7 +76,7 @@ public TagResolver audience(Audience audience) {
resolvers.add(MiniPlaceholders.getAudienceGlobalPlaceholders(audience));
}

return TagResolver.builder().resolvers(resolvers).build();
return TagResolver.resolver(resolvers);
}

public TagResolver message(Component message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
package fi.fabianadrian.webhooklogger.common.platform;

import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;

public record Location(int x, int y, int z) {
public TagResolver tagResolver() {
return TagResolver.resolver(
Placeholder.unparsed("x", String.valueOf(x)),
Placeholder.unparsed("y", String.valueOf(y)),
Placeholder.unparsed("z", String.valueOf(z))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.net.InetSocketAddress;

public interface Player extends ForwardingAudience.Single {
public interface PlatformPlayer extends ForwardingAudience.Single {
InetSocketAddress address();
Location location();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package fi.fabianadrian.webhooklogger.paper.platform;

import fi.fabianadrian.webhooklogger.common.platform.Location;
import fi.fabianadrian.webhooklogger.common.platform.Player;
import fi.fabianadrian.webhooklogger.common.platform.PlatformPlayer;
import net.kyori.adventure.audience.Audience;
import org.jetbrains.annotations.NotNull;

import java.net.InetSocketAddress;

public final class PaperPlayer implements Player {
public final class PaperPlayer implements PlatformPlayer {
private final org.bukkit.entity.Player player;

public PaperPlayer(org.bukkit.entity.Player player) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package fi.fabianadrian.webhooklogger.sponge.platform;

import fi.fabianadrian.webhooklogger.common.platform.Location;
import fi.fabianadrian.webhooklogger.common.platform.Player;
import fi.fabianadrian.webhooklogger.common.platform.PlatformPlayer;
import net.kyori.adventure.audience.Audience;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;

import java.net.InetSocketAddress;

public final class SpongePlayer implements Player {
public final class SpongePlayer implements PlatformPlayer {
private final ServerPlayer player;

public SpongePlayer(ServerPlayer player) {
Expand Down

0 comments on commit 65478f4

Please sign in to comment.