Searchinventory / searchechest for all offline players. #114

Closed
opened 2019-10-22 17:28:42 -04:00 by ghost · 10 comments
ghost commented 2019-10-22 17:28:42 -04:00 (Migrated from github.com)

This would change these commands from barely used to super useful for finding ALL illegal items!
If you think that would be too laggy just use a task timer to loop through all offline players and do it asynchronously.

**This would change these commands from barely used to super useful for finding ALL illegal items!** If you think that would be too laggy just use a task timer to loop through all offline players and do it asynchronously.
RoboMWM commented 2019-10-22 19:46:20 -04:00 (Migrated from github.com)

At that point I'd rather have a tool you can run offline instead.

At that point I'd rather have a tool you can run offline instead.
Jikoo commented 2019-10-22 21:19:52 -04:00 (Migrated from github.com)

To me this feels like a feature that is made obsolete by a decent item fixer and logger. In my eyes, you're talking 2 basic scenarios:

  • Joe steals Frank's sweet sword.
    • With proper admin tools:
      • Logging plugin records theft.
      • You roll back the thief with the logging plugin.
      • You ensure the sword is not duplicated in Joe's inventory or ender chest with OpenInv.
    • Without proper admin tools:
      • You search for the sword using OpenInv. As long as Joe didn't do anything too tricky with it, you might succeed. However, if Joe elected to move it to a remote chest, rename it, any number of things, you may not be able to determine that the sword he has is actually the correct item if you ever manage to locate it at all.
  • Joe spawns 50 diamond swords with Sharpness 32767 and distributes them.
    • With proper admin tools:
      • Item fixer automatically corrects enchantment levels or removes items outright whenever they are detected.
      • Logging plugin hopefully helps you ferret out and plug whatever hole Joe managed to use to obtain illegal items.
    • Without proper admin tools:
      • You search for and successfully find many of the swords over a period of a couple days as users bring them out of hiding. You manually remove each one as you find it. Who knows if you got them all? Next week, Joe comes back on a different account and spawns twice as many swords.

You're welcome to submit a PR, but I'm not willing to devote my time to something I can only see encouraging inefficient administrative workflows.

I'll leave this open for a little while for discussion, I would like to hear what use cases you think this feature has that would not be a waste of your own time.

To me this feels like a feature that is made obsolete by a decent item fixer and logger. In my eyes, you're talking 2 basic scenarios: * Joe steals Frank's sweet sword. * With proper admin tools: * Logging plugin records theft. * You roll back the thief with the logging plugin. * You ensure the sword is not duplicated in Joe's inventory or ender chest with OpenInv. * Without proper admin tools: * You search for the sword using OpenInv. As long as Joe didn't do anything too tricky with it, you might succeed. However, if Joe elected to move it to a remote chest, rename it, any number of things, you may not be able to determine that the sword he has is actually the correct item if you ever manage to locate it at all. * Joe spawns 50 diamond swords with Sharpness 32767 and distributes them. * With proper admin tools: * Item fixer automatically corrects enchantment levels or removes items outright whenever they are detected. * Logging plugin hopefully helps you ferret out and plug whatever hole Joe managed to use to obtain illegal items. * Without proper admin tools: * You search for and successfully find many of the swords over a period of a couple days as users bring them out of hiding. You manually remove each one as you find it. Who knows if you got them all? Next week, Joe comes back on a different account and spawns twice as many swords. You're welcome to submit a PR, but I'm not willing to devote my time to something I can only see encouraging inefficient administrative workflows. I'll leave this open for a little while for discussion, I would like to hear what use cases you think this feature has that would not be a waste of your own time.
ghost commented 2019-10-24 17:44:08 -04:00 (Migrated from github.com)

Atleast add an api to get the inventory/echest of an offline player, it would be extremely useful

Atleast add an api to get the inventory/echest of an offline player, it would be extremely useful
Jikoo commented 2019-10-24 19:01:51 -04:00 (Migrated from github.com)

Already exists.

Already exists.
ghost commented 2019-10-24 19:02:25 -04:00 (Migrated from github.com)
Ok On Fri, 25 Oct 2019, 00:01 Adam, <notifications@github.com> wrote: > Already exists. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/lishid/OpenInv/issues/114?email_source=notifications&email_token=AK5UGIBIV6F3RNH2NHI6HI3QQISOBA5CNFSM4JDXWFS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECGV6VI#issuecomment-546135893>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AK5UGID6IHFF5E5IWKNLE6LQQISOBANCNFSM4JDXWFSQ> > . >
Jikoo commented 2019-10-24 19:20:41 -04:00 (Migrated from github.com)

For clarity:
Use OpenInv to load a Player from an OfflinePlayer.
Use the loaded Player object to obtain a player inventory or ender chest from OpenInv for a user-friendly openable inventory.

If you plan on caching and continuously manipulating a player you must notify OpenInv that your plugin will be in use of it so OpenInv does not read a new object from storage and potentially save over your modifications.
Additionally, if you are manipulating any other aspects of the player such as location, OpenInv does not currently cause those aspects to persist if the player logs in before being removed from the cache, so you must manually save after manipulation if the player is not currently online. Various methods also may not work offline - potion and gamemode manipulation used to attempt to send packets, causing issues because an offline player has a null connection.

For clarity: Use OpenInv to load a Player from an OfflinePlayer. Use the loaded Player object to obtain a player inventory or ender chest from OpenInv for a user-friendly openable inventory. If you plan on caching and continuously manipulating a player you must notify OpenInv that your plugin will be in use of it so OpenInv does not read a new object from storage and potentially save over your modifications. Additionally, if you are manipulating any other aspects of the player such as location, OpenInv does not currently cause those aspects to persist if the player logs in before being removed from the cache, so you must manually save after manipulation if the player is not currently online. Various methods also may not work offline - potion and gamemode manipulation used to attempt to send packets, causing issues because an offline player has a null connection.
ghost commented 2019-11-01 21:32:25 -04:00 (Migrated from github.com)

Ok so im making a plugin that has shared double enderchests between players, could i just get player from offlineplayer and get enderchest? What steps would I need to take to save the data/prevent item duplication? Thank you very much.

Ok so im making a plugin that has shared double enderchests between players, could i just get player from offlineplayer and get enderchest? What steps would I need to take to save the data/prevent item duplication? Thank you very much.
Jikoo commented 2019-11-02 04:39:09 -04:00 (Migrated from github.com)

So you're planning to add a system where 2 27-slot ender chests are opened as a single 54-slot inventory?

You'll need to indicate to OpenInv that you're still using the Player object loaded using IOpenInv#retainPlayer(Player, Plugin). You also need to replace your Player object with the freshly joined Player if they come online while the inventory is open. When you're done with the Player (i.e. when the inventory is closed, assuming neither owner of the dual inventory has it open any more), call IOpenInv#releasePlayer(Player, Plugin) so OpenInv doesn't keep the object cached forever.

Beyond that you may have trouble with conflicts with auto-drop-pickup plugins that support moving items to ender chests, ender chest modifications, things of that nature. Under normal circumstances it's not possible for an ender chest to be manipulated without inventory events firing, but the reason OpenInv takes a version-dependent approach is that there is no event fired when an item is directly added to an inventory by a plugin or command. You could combat this with features like a configurable list of commands that would trigger a refresh of inventories or a scheduler periodically checking contents, but it's hard to guarantee success using only the Bukkit API.

So you're planning to add a system where 2 27-slot ender chests are opened as a single 54-slot inventory? You'll need to indicate to OpenInv that you're still using the Player object loaded using `IOpenInv#retainPlayer(Player, Plugin)`. You also need to replace your Player object with the freshly joined Player if they come online while the inventory is open. When you're done with the Player (i.e. when the inventory is closed, assuming neither owner of the dual inventory has it open any more), call `IOpenInv#releasePlayer(Player, Plugin)` so OpenInv doesn't keep the object cached forever. Beyond that you may have trouble with conflicts with auto-drop-pickup plugins that support moving items to ender chests, ender chest modifications, things of that nature. Under normal circumstances it's not possible for an ender chest to be manipulated without inventory events firing, but the reason OpenInv takes a version-dependent approach is that there is no event fired when an item is directly added to an inventory by a plugin or command. You could combat this with features like a configurable list of commands that would trigger a refresh of inventories or a scheduler periodically checking contents, but it's hard to guarantee success using only the Bukkit API.
ghost commented 2019-11-03 08:45:44 -05:00 (Migrated from github.com)

Ok, I think I'm gonna wussy out and store the ender chest contents in a yaml file instead as I am a little concerned with the issues involving players logging in and out etc. For example I remember a bug with openinv where if you viewed a players inventory and they logged out their armor would sometimes be flipped? It was rather strange. The only drawback using yaml for my players would be that both of them cant open the ender chest at once (because it saves when it is closed). Tell me if you think that is the best course of action.

Ok, I think I'm gonna wussy out and store the ender chest contents in a yaml file instead as I am a little concerned with the issues involving players logging in and out etc. For example I remember a bug with openinv where if you viewed a players inventory and they logged out their armor would sometimes be flipped? It was rather strange. The only drawback using yaml for my players would be that both of them cant open the ender chest at once (because it saves when it is closed). Tell me if you think that is the best course of action.
Jikoo commented 2019-11-05 04:55:40 -05:00 (Migrated from github.com)

Why can't two players view an inventory simultaneously? Just don't re-load it if it's already loaded.

That particular OpenInv bug was due to a mistake I made when adding Java 9+ support, it would have been entirely avoidable with thorough enough testing.

I'm gonna close this because we've now strayed pretty far from the original feature request, but if you want to discuss your idea further here that's fine. I'm also available as Jikoo on Spigot, feel free to ping me from a thread in the plugin development forum.

Why can't two players view an inventory simultaneously? Just don't re-load it if it's already loaded. That particular OpenInv bug was due to a mistake I made when adding Java 9+ support, it would have been entirely avoidable with thorough enough testing. I'm gonna close this because we've now strayed pretty far from the original feature request, but if you want to discuss your idea further here that's fine. I'm also available as Jikoo on Spigot, feel free to ping me from a thread in the plugin development forum.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: minster586/OpenInv#114
No description provided.