Skip to content

Commit

Permalink
sign_update: Paper component support
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 19, 2021
1 parent 75e6914 commit 2074ee4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
Expand Up @@ -7,13 +7,17 @@
import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;

import java.util.ArrayList;
import java.util.List;

public class PaperAdvancedTextImpl extends AdvancedTextImpl {

@Override
Expand Down Expand Up @@ -76,4 +80,13 @@ public void sendResourcePack(Player player, String url, String hash, boolean for
player.setResourcePack(url, CoreUtilities.toLowerCase(hash), forced, PaperModule.parseFormattedText(prompt, ChatColor.WHITE));
}
}

@Override
public void sendSignUpdate(Player player, Location loc, String[] text) {
List<Component> components = new ArrayList<>();
for (String line : text) {
components.add(PaperModule.parseFormattedText(line, ChatColor.BLACK));
}
player.sendSignChange(loc, components);
}
}
Expand Up @@ -3373,7 +3373,8 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
String[] split = mechanism.getValue().asString().split("\\|", 2);
if (LocationTag.matches(split[0]) && split.length > 1) {
ListTag lines = ListTag.valueOf(split[1], mechanism.context);
getPlayerEntity().sendSignChange(LocationTag.valueOf(split[0], mechanism.context), lines.toArray(new String[4]));
LocationTag location = LocationTag.valueOf(split[0], mechanism.context);
AdvancedTextImpl.instance.sendSignUpdate(getPlayerEntity(), location, lines.toArray(new String[4]));
}
else {
Debug.echoError("Must specify a valid location and at least one sign line!");
Expand Down
Expand Up @@ -54,7 +54,7 @@ public AgeCommand() {
//
// @Usage
// Use to mature some animals so that they are old enough to breed.
// - age <player.location.find.entities.within[20]> adult
// - age <player.location.find_entities.within[20]> adult
// -->

private enum AgeType {ADULT, BABY}
Expand Down
Expand Up @@ -63,7 +63,7 @@ public EquipCommand() {
//
// @Usage
// Use to equip a saddle on all nearby pigs.
// - equip <player.location.find.entities[pig].within[10]> saddle:saddle
// - equip <player.location.find_entities[pig].within[10]> saddle:saddle
// -->

@Override
Expand Down
Expand Up @@ -51,7 +51,7 @@ public LeashCommand() {
//
// @Usage
// Use to attach the closest cow in 10 blocks to the fence the player is looking at.
// - leash <player.location.find.entities[cow].within[10].first> holder:<player.cursor_on>
// - leash <player.location.find_entities[cow].within[10].first> holder:<player.cursor_on>
//
// @Usage
// Use to release the target entity.
Expand Down
Expand Up @@ -51,7 +51,7 @@ public RemoveCommand() {
//
// @Usage
// Use to remove all nearby entities around the player, excluding the player itself.
// - remove <player.location.find.entities.within[10].exclude[<player>]>
// - remove <player.location.find_entities.within[10].exclude[<player>]>
//
// @Usage
// Use to remove all dropped items in the world called cookies.
Expand Down
Expand Up @@ -2,6 +2,7 @@

import com.denizenscript.denizen.nms.NMSHandler;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -56,4 +57,8 @@ public void sendResourcePack(Player player, String url, String hash, boolean for
}
player.setResourcePack(url, hashData);
}

public void sendSignUpdate(Player player, Location loc, String[] text) {
player.sendSignChange(loc, text);
}
}

0 comments on commit 2074ee4

Please sign in to comment.