mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Implement cbarber's player data glitch and online/offline event changes
This commit is contained in:
parent
99a7359be3
commit
c7f38adb3f
5 changed files with 24 additions and 11 deletions
4
pom.xml
4
pom.xml
|
@ -23,14 +23,14 @@
|
|||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -106,6 +106,7 @@ public class OpenInvCommand implements CommandExecutor {
|
|||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
openInventory(player, target);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -51,7 +51,6 @@ public class SpecialEnderChest extends InventorySubcontainer {
|
|||
private void saveOnExit() {
|
||||
if (transaction.isEmpty() && !playerOnline) {
|
||||
owner.saveData();
|
||||
OpenInv.enderChests.remove(owner.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +81,7 @@ public class SpecialEnderChest extends InventorySubcontainer {
|
|||
public void onClose(CraftHumanEntity who) {
|
||||
super.onClose(who);
|
||||
saveOnExit();
|
||||
OpenInv.enderChests.remove(owner.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,15 +35,14 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
|
||||
private final CraftInventory inventory = new CraftInventory(this);
|
||||
private final ItemStack[] extra = new ItemStack[4];
|
||||
private final ItemStack[][] arrays;
|
||||
private final CraftPlayer owner;
|
||||
private ItemStack[][] arrays;
|
||||
private boolean playerOnline;
|
||||
|
||||
public SpecialPlayerInventory(Player p, boolean online) {
|
||||
super(((CraftPlayer) p).getHandle());
|
||||
this.owner = (CraftPlayer) p;
|
||||
reflectContents(getClass().getSuperclass(), player.inventory, this);
|
||||
this.arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
|
||||
this.playerOnline = online;
|
||||
OpenInv.inventories.put(owner.getUniqueId(), this);
|
||||
}
|
||||
|
@ -70,6 +69,8 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
arrays = new ItemStack[][] { this.items, this.armor, this.extraSlots, this.extra };
|
||||
}
|
||||
|
||||
public Inventory getBukkitInventory() {
|
||||
|
@ -79,7 +80,6 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
private void saveOnExit() {
|
||||
if (transaction.isEmpty() && !playerOnline) {
|
||||
owner.saveData();
|
||||
OpenInv.inventories.remove(owner.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
|||
public void onClose(CraftHumanEntity who) {
|
||||
super.onClose(who);
|
||||
this.saveOnExit();
|
||||
OpenInv.inventories.remove(owner.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.bukkit.event.block.Action;
|
|||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.lishid.openinv.OpenInv;
|
||||
import com.lishid.openinv.Permissions;
|
||||
|
@ -62,18 +63,28 @@ public class OpenInvPlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
|
||||
final SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
|
||||
if (inventory != null) {
|
||||
inventory.playerOffline();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
inventory.playerOffline();
|
||||
}
|
||||
}.runTaskLater(plugin, 1);
|
||||
}
|
||||
|
||||
SpecialEnderChest enderChest = OpenInv.enderChests.get(player.getUniqueId());
|
||||
final SpecialEnderChest enderChest = OpenInv.enderChests.get(player.getUniqueId());
|
||||
if (enderChest != null) {
|
||||
enderChest.playerOffline();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
enderChest.playerOffline();
|
||||
}
|
||||
}.runTaskLater(plugin, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue