minecraft-initiative / UniversalFriends

A library that aims at having friends that are the same for each client.
Other
19 stars 3 forks source link

Individual person data by server #21

Open IronException opened 4 years ago

IronException commented 4 years ago

maybe that won't be as easy. but IMO it should be possible to have different friends for different servers. I get that not many players need this but when there are players that play on multiple servers and maybe go full hostile on one it might not be great to have marked your friend as an enemy on another server where you want to be more friendly.

zeroeightysix commented 4 years ago

I feel like this might be out of scope for the library, and should be implemented by the developer using this library, using metadata.

IronException commented 4 years ago

How can this be implemented by the client dev? I would think about solving this issue by saving the friends in folders specific to the server.

zeroeightysix commented 4 years ago

How can this be implemented by the client dev?

In the metadata, and by performing checks on the metadata when determining if some is a friend or not.

I would think about solving this issue by saving the friends in folders specific to the server.

No. There's no good way to retain compatibility between clients without either forcing the server-based system on them, making the entire library depend on minecraft and having the user install a separate mod for the mixins needed for this. Just no.

IronException commented 4 years ago

Okay I get what you mean now. Saving that in meta data will just get way too complicated. Maybe we could add a way for the client to say what server this is. Of course most clients wont use this (mainly because only 2b clients might see this library). But imo we should make this usable for more utility clients then 2b ones. And it is very likely that when you dont play on 2b that you play on other servers where this might be useful.

Use case: players play on other servers then 2b2t and have friends on some server that are enemies on other servers.

zeroeightysix commented 4 years ago

Maybe we could add a way for the client to say what server this is.

In the metadata. It won't get too complicated. In fact, it's extremely easy to do:

// this code is called when a new friend is added
JsonObject meta = new JsonObject();
meta.add("server", Minecraft.getMinecraft().currentServerData.address);
GameProfilePerson person = new GameProfilePerson(gameProfile, value, meta);
UniversalFriends.addPerson(person);
// when looping through friends
UniversalFriends.selector().metadata(meta -> {
    if (meta.has("server") {
        return meta.get("server").getAsString().equals(Minecraft.getMinecraft().currentServerData.address);
    }
    return false;
}.selectMatchingAll().forEach(person -> {
    // perform some action on this person
});
IronException commented 4 years ago

I didn't mean hard to implement. I meant complicated if you store even more values. Of course a client can implement that but my train of thought is that certain attributs have a hirachy. Merging the hirachy might complicate things since you might loose data for example.

use case: 1.server: you have a friend and give him a note (this note is saved in meta data (could be somewhere else too but this is to proove the point since there are more variables then this)). on the

  1. server: this player is your enemy. But also you have another note about him (since it is another environment).

By complicated I mean the way you would be trying to fix this issue. For instance you could save the meta data in a hirachy too. But other clients dont have that. And where would you store variables such as lifetime. Putting it within the sub metadata will make it disappear for other clients when they dont adapt.

Besides this will make it hard to oversee what metadata variables exist.

I also just notice that this might be a bigger problem than just stated.