Replacing old inventory protecting with safe packet modifications using ProtocolLib.
Instead of clearing the inventory of players and storing it's contents in a file, we now prevent the server from sending the inventory packet if the player is not logged in. The player will see a empty inventory, but has still his items stored on the server. Therefore we don't need to modify the player's inventory and we won't make any inventory corrupted. Fixes Xephi/AuthMeReloaded#203, Fixes Xephi/AuthMeReloaded#193, Fixes Xephi/AuthMeReloaded#191, Fixes Xephi/AuthMeReloaded#148 Remove dead code + Fix empty inventory on the unregister command Fix NPE if ProtocolLib isn't enabled or installed
This commit is contained in:
@@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* This event is call just after store inventory into cache and will empty the
|
||||
* player inventory.
|
||||
*
|
||||
@@ -18,12 +18,11 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
private ItemStack[] emptyArmor = null;
|
||||
private Player player;
|
||||
|
||||
public ProtectInventoryEvent(Player player, ItemStack[] storedinventory,
|
||||
ItemStack[] storedarmor) {
|
||||
public ProtectInventoryEvent(Player player) {
|
||||
super(true);
|
||||
this.player = player;
|
||||
this.storedinventory = storedinventory;
|
||||
this.storedarmor = storedarmor;
|
||||
this.storedinventory = player.getInventory().getContents();
|
||||
this.storedarmor = player.getInventory().getArmorContents();
|
||||
this.emptyInventory = new ItemStack[36];
|
||||
this.emptyArmor = new ItemStack[4];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user