OpenInv

4M Downloads

Improve compatibility with other player data providers

Koyorice opened this issue · 3 comments

commented

chinese:
當我使用openinv插件並運行/open 玩家名(此玩家不在線上) 打開該玩家背包,並拿取他的一些物品,但是更改完畢後,玩家進入伺服器後會馬上死掉,並且將背包上的物品回復至運行 /open 玩家名 並拿取他的一些物品前的狀態
我想這應該是PlayerSQL的問題,因為原MYSQL上的玩家背包資料與更動後不同,所以導致強制玩家死亡,並將他背包的物品回復至玩家離開時的狀態(MYSQL儲存的狀態)
如果可以的話請將openinv的原代碼放置到此插件上,這樣就可以直接使用/open編輯PlayerSQL在MYSQL儲存的玩家資料
english:
When I use the openinv plug-in and run /open player name (the player is not online) to open the player’s backpack and take some of his items, but after the change is completed, the player will die immediately after entering the server, and the player’s name The item returns to the state before running/open the player name and taking some of his items
I think this should be a problem with PlayerSQL, because the player’s backpack information on the original MYSQL is different from that after the change, which leads to forcing the player to die and restoring the contents of his backpack to the state when the player left (the state stored in MYSQL)

commented

Unfortunately OpenInv does not have a way to account for external inventory storage. If you're running a plugin that changes inventory storage, that plugin needs to be responsible for offline viewing and modification.

To help avoid accidents you should consider negating the node OpenInv.openoffline.

You can also use the config node settings.disable-saving to prevent OpenInv from saving changes to offline players. Note that this will not prevent OpenInv modifying inventory contents on login if the player has been recently modified and is in the cache. OpenInv runs on lowest priority to attempt better compatibility with other inventory modification plugins (anticheats that filter items, etc.) so ideally PlayerSQL should overwrite any changes made by OpenInv in the mirroring process.

Related to lishid#171, need a way to more completely disable offline access.

commented

Not sure how technical you are @YTiceice but the solution we are using for exactly the same problem is to build our own version of OpenInv with this patch:

+++ b/plugin/src/main/java/com/lishid/openinv/OpenInv.java
@@ -447,12 +447,23 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
         // Replace stored player with our own version
         this.playerCache.put(key, this.accessor.getPlayerDataManager().inject(player));

+        /* Remove the cached entry if it exists */
+        this.playerCache.invalidate(key);
+
         if (this.inventories.containsKey(key)) {
-            this.inventories.get(key).setPlayerOffline();
+            Iterator<HumanEntity> iterator = this.inventories.remove(key).getBukkitInventory().getViewers().iterator();
+            while (iterator.hasNext()) {
+                HumanEntity human = iterator.next();
+                human.closeInventory();
+            }
         }

         if (this.enderChests.containsKey(key)) {
-            this.enderChests.get(key).setPlayerOffline();
+            Iterator<HumanEntity> iterator = this.enderChests.remove(key).getBukkitInventory().getViewers().iterator();
+            while (iterator.hasNext()) {
+                HumanEntity human = iterator.next();
+                human.closeInventory();
+            }
         }
     }

I would someday still like a config option to do something like this so I don't have to build my own OpenInv plugin every time there's a new MC version.

Similarly to YTiceice, we are using a separate database for player data storage.

commented

Ok