MineColonies

MineColonies

53M Downloads

QUESTION : trusting a fake player inside a colony

gd71 opened this issue · 29 comments

commented

Hello,
trying to have an ender IO killer joe working for a kind of mob farm
(in the sewers of course... ;) )
I read that a fake player name is implemented within ender io (EioKillera) but didn't found any way to add it in the permissions settings of my townHall.
This should allow it to make damages to mobs

commented

I think our current system only works for real players. And names who were never online do not work.

Supporting fake players is a good idea though

commented
commented

A fakeplayer is also a custom class in forge, so a simple instance of might do the trick

commented
commented

Understood that forge definitely got the power :)
They should implement a kind of register method for all kind of fakeplayers (even subclass) storing at least owner UUID's...
This way, enderIO or other mods could get rid of their getOwner like methods thanks to forge providing a common way to identify these objects
Not sure to be skilled enough to convince them as I probably miss some other side effects (and unfortunately I'm not a java developer)
Anyway, very interesting discussion but doesn't answer for now on how to interact efficiently with other mods
I would suggest the compromise with kind of generic instanceOf and getMethod in the mean time but it is up to the Minecolonies guys to decide about

commented

Entity.getUniqueID() all you need and no extra custom API. Modder just need to set it correctly when they make their fake players.

commented
commented

The name is good enough, well the entity. You can get the UUID which is what people should be saving from the entity if they saved it right.
As I said in the other thread you could also just have the damn thing checking the permissions GIVE YOU THE UUID or some method of whatever it indexes its permissions by.

But, the FakePlayer for the block SHOULD use the UUID of the person who placed it so then you just need to give yourself permission not any random fake player username.

commented
commented

Hello after some discussion etc we decided to not implement this feature.
If you allow a fakePlayer to your colony you have to add it to your colony but that means that every other player can use that fakePlayer to grief you.

EnderIO should actually implement the fakePlayer with the placers name to support this kind of behavior.

Please report this to enderIO.

commented

hmmm,
yep you're definitely right, I had no thought about this case.
Thanks anyway for taking the time to think about it!

commented
commented

done it ;)

commented

Ender IO supports the Forge permission system for all its machines. In addition, all fake players have a getter for the owning player (that API was proposed some time ago for Forge, but nobody wanted to actually PR it...).

commented

A bit more complex but still feasible ?

commented

Forge doesn't really like FakePlayers with static names.

MinecraftForge/MinecraftForge#3723 (comment)

They feel like all FakePlayers should have the name of the owner to recognize them.

commented

Typical Lex. Ask the wrong thing and he won't be helpful.

He's right. You don't need a list of all fake player usernames. That list does not give you any more information than an instanceof check. Also, that list is not complete. It will only contain fake players that are not subclassing Forge's fake player and as such can be generated by the factory. But many fake players will need to override some methods, so they will not be in that list.

If you want to know which real player a fake player belongs to, then you need the player's UUID. The username is useless for that; it should absolutely never used for anything (except looking up the UUID when an admin enters it as part of e.g. a command). Usernames can be changed nowadays, that's why we have UUIDs now.

commented
commented

We actually store the UUID and username in the colony as "trustable" and update the username if the user changes it. But how can we get the UUID of the fakePlayer when the player enters it in the gui?

commented

Yes, exactly. That's why Ender IO provides the UUID of the owner: https://github.com/SleepyTrousers/EnderIO/blob/1.10/src/main/java/crazypants/enderio/machine/FakePlayerEIO.java#L55-L59

Just one nitpicking: If a user didn't want a block they placed to work, they wouldn't have placed it in the first place, would they?

commented

Feel free to PR this code (I'd recommend to either have a UUID field and a setter or return null be default, the first one will work with factory fake players, the later requires subclassing) to the Forge fake player.

commented
commented
commented

@LexManos Am I understanding that correctly that FakePlayer.getUniqueID() should return the owners UUID?

commented

@LexManos The preferred way would definitely be what you are suggesting. The question is: If we have a fakeplayer, how do we get the owners UUID? How do we do this consistently and not on a mod by mod basis? What would forge recommend there?

commented

I can be wrong but seems like enderIO is not instantiating FakePlayer the way Forge aim to.
Not using the FakePlayerFactory which provide registering and mapping of a gameprofile given in parameter ... leading to possible inconsistent getUniqueID
I may be wrong and don't want to pollute more the discussion

commented

As I wrote above...:

It will only contain fake players that are not subclassing Forge's fake player and as such can be generated by the factory. But many fake players will need to override some methods, so they will not be in that list.

commented

@HenryLoenwind we made some additional tests.
[16:58:54] [Server thread/INFO]: Couldn't get player of FakePlayer: [Wissi's Killer Joe] with UUID: 3baa66fa-a69a-11e4-89d3-123b93f75cba Owner Id is: b5a93d5b-38fc-4df2-98a7-0b3c7cd7cd0c

The Id of the KillerJoe is different than the ID of its owner. As far as I understood lex, the id of the killerJoe should be the same in order to identify him correctly?

commented

@LexManos can you help us with that?