LoginSystem/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java
games647 86ff20b6c9 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
2015-10-03 10:48:40 +02:00

59 lines
1.4 KiB
Java

package fr.xephi.authme.events;
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.
*
* @author Xephi59
*/
public class ProtectInventoryEvent extends CustomEvent {
private ItemStack[] storedinventory;
private ItemStack[] storedarmor;
private ItemStack[] emptyInventory = null;
private ItemStack[] emptyArmor = null;
private Player player;
public ProtectInventoryEvent(Player player) {
super(true);
this.player = player;
this.storedinventory = player.getInventory().getContents();
this.storedarmor = player.getInventory().getArmorContents();
this.emptyInventory = new ItemStack[36];
this.emptyArmor = new ItemStack[4];
}
public ItemStack[] getStoredInventory() {
return this.storedinventory;
}
public ItemStack[] getStoredArmor() {
return this.storedarmor;
}
public Player getPlayer() {
return this.player;
}
public void setNewInventory(ItemStack[] emptyInventory) {
this.emptyInventory = emptyInventory;
}
public ItemStack[] getEmptyInventory() {
return this.emptyInventory;
}
public void setNewArmor(ItemStack[] emptyArmor) {
this.emptyArmor = emptyArmor;
}
public ItemStack[] getEmptyArmor() {
return this.emptyArmor;
}
}