Skip to content

Commit

Permalink
Team command: prefix/suffix: use paper for advanced text
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 7, 2023
1 parent 9a25e78 commit 39ac5e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.*;
import org.bukkit.potion.PotionBrewer;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Consumer;

import java.util.*;
Expand Down Expand Up @@ -268,4 +269,14 @@ public <T extends Entity> T spawnEntity(Location location, Class<T> type, Consum
return super.spawnEntity(location, type, configure, reason);
}
}

@Override
public void setTeamPrefix(Team team, String prefix) {
team.prefix(PaperModule.parseFormattedText(prefix, ChatColor.WHITE));
}

@Override
public void setTeamSuffix(Team team, String suffix) {
team.suffix(PaperModule.parseFormattedText(suffix, ChatColor.WHITE));
}
}
@@ -1,6 +1,7 @@
package com.denizenscript.denizen.scripts.commands.player;

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizen.utilities.ScoreboardHelper;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizen.objects.PlayerTag;
Expand Down Expand Up @@ -37,7 +38,6 @@ public TeamCommand() {
// The Team command allows you to control a scoreboard team.
//
// Use the "prefix" or "suffix" arguments to modify a team's playername prefix and suffix.
// NOTE: Prefixes and suffixes cannot be longer than 16 characters!
//
// The "entry" value can be a player's name to affect that player, or an entity's UUID to affect that entity.
// You can alternately input a raw PlayerTag or EntityTag, and they will be automatically translated to the name/UUID internally.
Expand Down Expand Up @@ -223,10 +223,10 @@ else if (optName.equals("see_invisible")) {
}
}
if (prefix != null) {
team.setPrefix(prefix.asString());
PaperAPITools.instance.setTeamPrefix(team, prefix.asString());
}
if (suffix != null) {
team.setSuffix(suffix.asString());
PaperAPITools.instance.setTeamSuffix(team, suffix.asString());
}
if (color != null) {
team.setColor(ChatColor.valueOf(color.asString().toUpperCase()));
Expand Down
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Consumer;

public class PaperAPITools {
Expand Down Expand Up @@ -139,4 +140,12 @@ public void setSkinBlob(Player player, String blob) {
public <T extends Entity> T spawnEntity(Location location, Class<T> type, Consumer<T> configure, CreatureSpawnEvent.SpawnReason reason) {
return location.getWorld().spawn(location, type, configure);
}

public void setTeamPrefix(Team team, String prefix) {
team.setPrefix(prefix);
}

public void setTeamSuffix(Team team, String suffix) {
team.setSuffix(suffix);
}
}

0 comments on commit 39ac5e8

Please sign in to comment.