PotatoCraft-Studio / QuickShop-Reremake

QuickShop-Reremake is a **FREE** shop plugin that allows players to easily sell/buy any items from a chest without any commands. In fact, none of the commands that QuickShop-Reremake provides are ever needed by a player.
GNU General Public License v3.0
69 stars 78 forks source link

[BUG] `setSignText()` problem #322

Closed twseer67875 closed 1 year ago

twseer67875 commented 1 year ago

Description

I used the following code to try to change the second line of the Sign but failed to change it

                    List<ComponentPackage> sign_list = event.getShop().getSignText("zh_tw");
                    if (sign_list.get(1).getComponents().length > 1){
                        BaseComponent[] baseComponents = sign_list.get(1).getComponents();

                        String message = baseComponents[1].toPlainText();

                        TextComponent textComponent = new TextComponent(message + " §4(購買限制)");

                        BaseComponent[] newBaseComponents = {
                                baseComponents[0],
                                textComponent
                        };

                        ComponentPackage componentPackage = new ComponentPackage(newBaseComponents);

                        sign_list.set(1, componentPackage);

                        event.getShop().setSignText(sign_list);
                    }

Steps to reproduce

  1. Use getSignText() to get original Sign content
  2. Try setSignText() to change Sign
  3. nothing happened

Expected Behaviour

Successfully changed the Sign and changed it to 出售 1個 §4(購買限制) according to the following code

Screenshots

image

/qs paste URL

https://paste.helpch.at/raw/uteyibisuz

Additional Context

This server is running Paper version git-Paper-307 (MC: 1.19.2) (Implementing API version 1.19.2-R0.1-SNAPSHOT) (Git: 476ef25)

Issues-translate-bot commented 1 year ago

Bot detected the issue body's language is not English, translate it automatically. Please use English next time.


Title: [BUG] setSignText() problem

sandtechnology commented 1 year ago

It's not the right way to change sign text, please listen to ShopSignUpdateEvent then change the sign directly

twseer67875 commented 1 year ago

It's not the right way to change sign text, please listen to ShopSignUpdateEvent then change the sign directly

Problem solved, thanks