Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inventory Name doesn't work (2.4) #2069

Closed
Moderocky opened this issue May 19, 2019 · 6 comments
Closed

Inventory Name doesn't work (2.4) #2069

Moderocky opened this issue May 19, 2019 · 6 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).

Comments

@Moderocky
Copy link
Member

Moderocky commented May 19, 2019

Description

The name of player's current inventory returns <none> in the current skript version, in an inventory-click event.
I believe that getting the inventory type is also not working.

Bug reproduced by Runakai also.

Steps to Reproduce

on inventory click:
    broadcast name of player's current inventory

Expected Behavior

It should return the name.

Errors / Screenshots

Server Information

  • Server version/platform: Paper 1.14.1 -28
  • Skript version: 2.4 Alpha

Additional Context

You can fix this in Skript-Mirror using the following:

  set {_i} to event.getView()
  set {_n} to {_i}.getTitle()
  set {_t} to {_i}.getType().toString()

In this, {_n} returns the uncoloured name, and {_t} returns the type as a text.

@TheBentoBox TheBentoBox added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation). labels May 19, 2019
@TheBentoBox
Copy link
Member

The way inventory names are retrieved was changed in 1.14, as stated here you need to call getTitle() on the inventory view now. The expression will need to be updated to reflect this API difference when running in 1.14.

@bensku
Copy link
Member

bensku commented May 20, 2019

Inventories don't have names in 1.14. Their views do, but there is no reliable way to get a view from an inventory. We might be able to silently patch all inventories in Skript to actually be inventory views under the hood, but that is a bit risky.

@TheBentoBox
Copy link
Member

We should likely update that inventory name property condition of inventories to error out if used on 1.14+ and instead recommend to use an inventory name property condition on players, which we would have to add and which would use player.getOpenInventory().getTitle().

@Moderocky
Copy link
Member Author

Moderocky commented May 20, 2019

Under an "inventory event" situation, .getView().getTitle() would work fine, wouldn't it? You could then use name of event-inventory in inventory clicks, etc. to satisfy those occasions.

I just see it as being important to have some way of getting the name (especially in click events), since the majority of people using Skript GUIs seem to use the name in the on inventory click event to identify when to cancel, what to do, etc.

Edit: While working on something today I noticed that the containers themselves seem to hold a title/name. Perhaps something with getHolder() could assist?

@FranKusmiruk
Copy link
Member

@Moderocky in the inventory event, we can add an event-string event value or make an expression that takes a player as input instead. And the holder wouldn't work since holder =/= the viewer, and holder can be null in occasions.

@Moderocky
Copy link
Member Author

Oh yes you are right. I would offer to try and do it myself, but it sounds like you have a better idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).
Projects
None yet
Development

No branches or pull requests

6 participants