-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Pointers #352
Pointers #352
Conversation
LGTM, would be something I use. |
It was suggested to me by @lucko when I first opened this pull request, to add the following - thoughts? AudienceKey<HasPermission> HAS_PERMISSION = key(HasPermission.class, Key.key("adventure", "uuid"));
interface HasPermission {
TriState hasPermission(final String permission);
} |
I can't say for certain if I think it belongs in Audience as a default key, but I would make use of it. Edit: my primary usage of Audiences/ForwardingAudiences is in platform abstracted Player objects, so the 3 proposed keys are all ones I'd use. |
aceb4a7
to
247493b
Compare
* @param <T> the type | ||
* @since 4.8.0 | ||
*/ | ||
public interface AudienceKey<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this implement Keyed
?
Some other keys that would be useful (for my uses):
Permission hook would be v. useful too, but I think |
247493b
to
76af976
Compare
I think it might make more sense if the actual keys ( Also, I love the idea of the permissions test thing - alongside some sort of enum to work out "what" the audience is, it would be nice to have some tests to work out "where" the audience is (world, server, etc). |
76af976
to
0464759
Compare
I get what this is about - you want to reduce the amount of platform specific stuff people have to do to, say, determine whether an I definately acknowledge that this is a problem you're going to have on some platforms, taking Sponge and Paper as two platforms they have vastly different philosphies. In fact, you have a key like system from Sponge which will probably look somewhat out of place on Paper, but a nullable return type that will look out of place on Sponge with our optional centric design. Other platforms may vary and I leave it to them to comment futher from their perspective. A comment on the Perhaps have an Certainly don't throw an exception on it though if you absolutely must do it this way. That's just a bad idea because you don't want an I know that some of what I say might not be popular, I truly do (I've certainly been at the receiving end of it before, indeed, had my comments twisted and warped over it), but Adventure needs to be careful to not upset the various platforms by imposing methods etc. that are inconsistent with the the way their hosts work. Having a more modular approach where cross platform developers can typecheck feels like it might be a solution here (plus it makes a lot more sense to pull out a "key holder" from its audience, especially if such an approach may get used elsewhere later). I am not against what you're trying to do here, not at all, I just think that a bit of discussion and thought from the platforms and how they implement this will be warranted. |
Oh, I was asked to comment on something else as well:
Permissions hooks... well that feels like that's splitting out from keys itself as I'd expect a key to return some data, not a function. I'd argue that if something like that really belongs in Adventure (and I am not convinced it does as permissions are a platform specific thing in the first place, Sponge implicit vs Paper explicit inheritance comes to mind, but other impls might not use dot separated permissions) then that needs to be a separate interface altogether. |
I think it might help if I clarify the reasoning for all of this... (at least from my perspective) @kashike's vision right at the start of the adventure design process was that people would be able to use At the moment, It is very hard to implement a generic "user interface" (be that a command handler, or whatever) using just Individual plugins are left to do this abstraction themselves (see here for an example from spark) - yet the whole idea was that this wouldn't be necessary. It's a shame that Sponge / other platforms might not be on board with this idea - but as far as I'm concerned this was always the plan from the start... and I assumed also the reason why multiple platforms would want to all adopt the same library. |
@lucko is correct. Here are some initial thoughts of mine:
I originally had this system using an
The problem here lies with what @lucko mentioned - having people casting for very common operations would become annoying, fast, for people who write cross-platform plugins (WorldEdit, LuckPerms, etc).
We would probably go with it being a |
I'd prefer a more generic REMOTE over RCON, since Discord bridges are becoming increasingly more common now.
The design of the feature as is already says the value may or may not be present, having to check the presence of the feature on top of the values it may provide is just extra work for little gain from my perspective.
Then don't have worlds return a value for that key. That being said it may be better to move the default keys into AudienceKey, to better convey this.
If each design decision is going to look weird on some platform, then it may not be the best idea to dwell on the fact for too long. |
0464759
to
2742e6d
Compare
Standard keys have been extracted to an |
I suspect what you're after is a Let me be clear, the goal here is something I can support, I just don't think this is the right design choice for the reasons I've given above. The problem is the API side of it for the simple reason of the platforms who are using this library in good faith have significant and somewhat irreconcilable differences in style and function. Adventure is in the tricky situation where it's trying to satisfy every platform but it's trying to do so via a monolithic interface that the native platforms must implement alongside their "native" methods. My point is not "we don't support the goal", it's one of what it looks like within those platforms. In Sponge, what will happen on the // Adventure Audience
@Nullable T get(AudienceKey<T> key);
// Sponge ValueContainer
Optional<T> get(Key<? extends Value<T>> key);
// Sponge ValueContainer
@Nullable T getOrNull(Key<? extends Value<T>> key); Now, I'm not saying that Adventure should not use This is what I'm mindful of.
I agree.
I knew it wasn't going to be popular.
I think we need to be clear here - we choose to adopt Adventure, but that doesn't mean Adventure should be free to do what it likes because there are limits to what the platforms are going to accept. We accept the library on the terms that were apparent to us at the time, and not anything different. The relationship between Adventure and platforms is not the same as a standard library - for a start, @kashike is on most of, if not all of, the platform teams that are using it - the relationship here is not the same as a standard library. Hell, @kashike specifically asked me to comment on this PR - probably because I suspect they knew I was going to be more critical than others (yes, I'm that guy). For what it's worth, I'm somewhat accepting of what's going to happen here - it's not the end of the world complaining over an optional and as I've said countless times, Sponge (the platform I have an interest in) is not the only platform. You're right, Adventure is not under the control of other platforms but there is an element of trust and good faith here that has to be there. I see this as something that platforms just need to look at and nod their head, voice concerns, whatever - we should not blindly accept changes but scrutinise and challenge because we are going to defend how we see things fit in our own platforms. That is what I'm doing here. I'm not against this change. I'm critical of it, but not against it. |
My point there wasn't that "adventure should do what it pleases", just that if any design it chooses in this scenario leads to some platform being unhappy, it's not the healthiest to obsess about the design in that context. |
I think we should be careful not to change If we want to expose more information about players, I think the way to go is with We could then expose APIs that allow customizing a All in all, I think the |
Take this back a step. If you were to do this again for Adventure 5, with the ability to break everything, how would you do it? |
I've thought about this for the past day, and I keep coming back to what was in this PR prior to my latest commit as the best solution. The only other things that I have thought of, would be cross-platform incompatible (due to return types). |
I think this is what you need to do then. I don't see any other way that supports this any better given where we are in the way people want it (something else came to mind which I'll talk about below, but I suspect it's only maginally better than the other casting suggestions). It's clear the casting solution doesn't have support - and let's face it, who can blame anyone for that stance? On @Electroid's point about not using keys - @kashike's point this is the ultimate problem with Adventure when considering APIs and why a key system is actually likely the best option. Adventure doesn't control the platforms, to an extent, Adventure must be considerate of the platforms, it needs to be out of the way as much as possible for the host platforms can do what they want to do. A key system minimises its footprint on other methods in a way that won't affect other methods on the target platform, but I do accept it's a break from how people that use Paper use methods. It does afford flexibility though - Adventure can just provide new keys when it wants to and the host platform won't care - it'll be totally outside of the purview of the host platform. Now, I concur that in theory these keys are better suited to the With that in mind, the only other way I see this working is by having a Either way, rock and a hard place and something that may very well have a better solution in Adventure 5. For Adventure 4, the hand that has been dealt is limited, let's make the best of what we can.
I just want to comment here - careful about the scope of Adventure here and how other platforms might want to interact with this. Sponge, for example, has plans to be able to make the display name different based on who is viewing a player via Contextual Data. Now I can't say if this will ever come to pass, but such a method would directly clash with such a system. Adventure could use this internally, but Adventure must be careful to NOT tread on the toes of the platforms, for fear of inconsistencies occurring. |
e276141
to
2adda49
Compare
* | ||
* @since 4.8.0 | ||
*/ | ||
public interface HasPermission { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a better name for this would be PermissionHolder
rather than HasPermission
?
Edit: My backside is this outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A plain ol' Predicate<String>
would be better.
f76cbea
to
b93dd67
Compare
997d75e
to
7dc7855
Compare
7dc7855
to
4ff0a92
Compare
No description provided.