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

Add query modifier for checking acting player info #751

Merged
merged 1 commit into from
Dec 31, 2020

Conversation

Pugzy
Copy link
Contributor

@Pugzy Pugzy commented Dec 22, 2020

Let's say you wanted to prevent a player from opening chests unless they're in a specific region (the wool room maybe).

The current way of filtering location on a block-break or use event target the location of the physical block (which is always in the wool room). In this instance, I want to query the location of the actor (player) rather than the block in question.

For this, I have created a PlayerBlockQueryModifier which sets focus on the player in the event vs the block. This also slightly modifies the newly created base QueryModifier class allowing for unmodified queries to abstain by returning null. In this case, the player within the PlayerQuery can be null (when offline) so a fallback was required.

See the example below where the player can only use items within the yellow wool room if they too are in that region.

<!--- filter with region -->
<player id="player-in-yellow-wool">
    <rectangle id="yellow-wool-room" min="534.5,-354" max="544,-339"/>
</player>

<!--- application -->
<apply use="player-in-yellow-wool" region="yellow-wool-room" message="You can not interact with this from here."/>

Open to suggestions if this can be completed an alternative way (existing XML or improved implementation).
Discussed with Pablo and Simon in Discord so ty for help.

Signed-off-by: Pugzy <pugzy@mail.com>
@Pablete1234 Pablete1234 added the feature New feature or request label Dec 27, 2020
Copy link
Member

@Electroid Electroid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Excited to see the use-cases

@Electroid Electroid merged commit 1266cfd into PGMDev:dev Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

Successfully merging this pull request may close these issues.

4 participants