Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
Update Placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
gmitch215 committed Dec 10, 2023
1 parent fbb2cf6 commit 682812b
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package me.gamercoder215.starcosmetics.placeholders;

import com.google.common.collect.ImmutableMap;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.gamercoder215.starcosmetics.StarCosmetics;
import me.gamercoder215.starcosmetics.api.cosmetics.capes.Cape;
import me.gamercoder215.starcosmetics.api.cosmetics.gadget.Gadget;
import me.gamercoder215.starcosmetics.api.cosmetics.hat.Hat;
import me.gamercoder215.starcosmetics.api.cosmetics.trail.TrailType;
import me.gamercoder215.starcosmetics.api.player.StarPlayer;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
Expand All @@ -22,14 +25,18 @@ public StarPlaceholders(StarCosmetics plugin) {
register();
}

private static final Map<String, Function<StarPlayer, String>> OFFLINE_PH = new HashMap<String, Function<StarPlayer, String>>() {{
put("name", StarPlayer::getName);
put("uuid", p -> p.getUniqueId().toString());
put("projectile_trail", p -> p.getSelectedTrail(TrailType.PROJECTILE).getFullKey());
put("ground_trail", p -> p.getSelectedTrail(TrailType.GROUND).getFullKey());
put("sound_trail", p -> p.getSelectedTrail(TrailType.PROJECTILE_SOUND).getFullKey());
put("hologram", StarPlayer::getHologramMessage);
}};
private static final Map<String, Function<StarPlayer, Object>> OFFLINE_PH = ImmutableMap.<String, Function<StarPlayer, Object>>builder()
.put("name", StarPlayer::getName)
.put("uuid", StarPlayer::getUniqueId)
.put("projectile_trail", p -> p.getSelectedTrail(TrailType.PROJECTILE).getFullKey())
.put("ground_trail", p -> p.getSelectedTrail(TrailType.GROUND).getFullKey())
.put("sound_trail", p -> p.getSelectedTrail(TrailType.PROJECTILE_SOUND).getFullKey())
.put("hat", p -> p.getSelectedCosmetic(Hat.class).getFullKey())
.put("hologram", StarPlayer::getHologramMessage)
.put("cape", p -> p.getSelectedCosmetic(Cape.class).getFullKey())
.put("gadget", p -> p.getSelectedCosmetic(Gadget.class).getFullKey())
.put("selection_limit", StarPlayer::getSelectionLimit)
.build();

@Override
public @NotNull String getIdentifier() {
Expand All @@ -38,12 +45,12 @@ public StarPlaceholders(StarCosmetics plugin) {

@Override
public @NotNull String getAuthor() {
return "gamercoder215";
return plugin.getDescription().getAuthors().get(0);
}

@Override
public @NotNull String getVersion() {
return "1.2.1";
return plugin.getDescription().getVersion();
}

// Impl
Expand All @@ -55,7 +62,7 @@ public List<String> getPlaceholders() {

@Override
public String onRequest(OfflinePlayer p, String arg) {
if (OFFLINE_PH.containsKey(arg)) return OFFLINE_PH.get(arg).apply(new StarPlayer(p));
if (OFFLINE_PH.containsKey(arg)) return String.valueOf(OFFLINE_PH.get(arg).apply(new StarPlayer(p)));
return null;
}

Expand Down

0 comments on commit 682812b

Please sign in to comment.