diff --git a/README.MD b/README.MD index 170d2d17..e6549f3c 100644 --- a/README.MD +++ b/README.MD @@ -4,9 +4,10 @@ This fork of OpenInv was created when the lag caused by offline player lookups p ### Changes of Note - Removed updater - Removed wand +- New configuration option `DisableSaving`: Inventory edits will not be saved unless the user is online. ## Previous Versions -Any version of Minecraft this fork has been existent for should have a [release](https://github.com/Jikoo/OpenInv/releases) tagged. Features are not backported, however. +This fork supports any version after 1.4.5. Binaries are available in the [releases tab](https://github.com/Jikoo/OpenInv/releases). Please allow a brief period after the release of a new version for updates. ## License ``` diff --git a/src/main/java/com/lishid/openinv/OpenInv.java b/src/main/java/com/lishid/openinv/OpenInv.java index 8af86d49..3e6c20ea 100644 --- a/src/main/java/com/lishid/openinv/OpenInv.java +++ b/src/main/java/com/lishid/openinv/OpenInv.java @@ -34,10 +34,10 @@ import com.lishid.openinv.commands.SilentChestPluginCommand; import com.lishid.openinv.internal.IAnySilentChest; import com.lishid.openinv.internal.IInventoryAccess; -import com.lishid.openinv.internal.IPlayerDataManager; import com.lishid.openinv.internal.ISpecialEnderChest; import com.lishid.openinv.internal.ISpecialPlayerInventory; import com.lishid.openinv.internal.InternalAccessor; +import com.lishid.openinv.internal.PlayerDataManager; /** * Open other player's inventory @@ -50,7 +50,7 @@ public class OpenInv extends JavaPlugin { private final Map enderChests = new HashMap(); private InternalAccessor accessor; - private IPlayerDataManager playerLoader; + private PlayerDataManager playerLoader; private IInventoryAccess inventoryAccess; private IAnySilentChest anySilentChest; @@ -73,12 +73,26 @@ public void onEnable() { anySilentChest = accessor.newAnySilentChest(); FileConfiguration config = getConfig(); - config.set("NotifySilentChest", config.getBoolean("NotifySilentChest", true)); - config.set("NotifyAnyChest", config.getBoolean("NotifyAnyChest", true)); + boolean dirtyConfig = false; + if (!config.isBoolean("NotifySilentChest")) { + config.set("NotifySilentChest", true); + dirtyConfig = true; + } + if (!config.isBoolean("NotifyAnyChest")) { + config.set("NotifyAnyChest", true); + dirtyConfig = true; + } + if (!config.isBoolean("DisableSaving")) { + config.set("DisableSaving", false); + dirtyConfig = true; + } config.addDefault("NotifySilentChest", true); config.addDefault("NotifyAnyChest", true); + config.addDefault("DisableSaving", false); config.options().copyDefaults(true); - saveConfig(); + if (dirtyConfig) { + saveConfig(); + } pm.registerEvents(new OpenInvPlayerListener(this), this); pm.registerEvents(new OpenInvInventoryListener(this), this); @@ -95,7 +109,7 @@ public InternalAccessor getInternalAccessor() { return this.accessor; } - public IPlayerDataManager getPlayerLoader() { + public PlayerDataManager getPlayerLoader() { return this.playerLoader; } @@ -115,12 +129,12 @@ public ISpecialPlayerInventory getInventoryFor(Player player) { return null; } - public ISpecialPlayerInventory getOrCreateInventoryFor(Player player, boolean offline) { + public ISpecialPlayerInventory getOrCreateInventoryFor(Player player, boolean online) { String id = getPlayerLoader().getPlayerDataID(player); if (inventories.containsKey(id)) { return inventories.get(id); } - ISpecialPlayerInventory inv = getInternalAccessor().newSpecialPlayerInventory(player, offline); + ISpecialPlayerInventory inv = getInternalAccessor().newSpecialPlayerInventory(player, online); inventories.put(id, inv); return inv; } @@ -140,12 +154,12 @@ public ISpecialEnderChest getEnderChestFor(Player player) { return null; } - public ISpecialEnderChest getOrCreateEnderChestFor(Player player, boolean offline) { + public ISpecialEnderChest getOrCreateEnderChestFor(Player player, boolean online) { String id = getPlayerLoader().getPlayerDataID(player); if (enderChests.containsKey(id)) { return enderChests.get(id); } - ISpecialEnderChest inv = getInternalAccessor().newSpecialEnderChest(player, offline); + ISpecialEnderChest inv = getInternalAccessor().newSpecialEnderChest(player, online); enderChests.put(id, inv); return inv; } @@ -157,6 +171,10 @@ public void removeLoadedEnderChest(Player player) { } } + public boolean disableSaving() { + return getConfig().getBoolean("DisableSaving", false); + } + public boolean notifySilentChest() { return getConfig().getBoolean("NotifySilentChest", true); } diff --git a/src/main/java/com/lishid/openinv/OpenInvInventoryListener.java b/src/main/java/com/lishid/openinv/OpenInvInventoryListener.java index 9b2ef0f9..7bf30cc0 100644 --- a/src/main/java/com/lishid/openinv/OpenInvInventoryListener.java +++ b/src/main/java/com/lishid/openinv/OpenInvInventoryListener.java @@ -32,13 +32,9 @@ public OpenInvInventoryListener(OpenInv plugin) { @EventHandler(priority = EventPriority.NORMAL) public void onInventoryClick(InventoryClickEvent event) { - // If this is the top inventory - // if (event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot()) - // { if (!plugin.getInventoryAccess().check(event.getInventory(), event.getWhoClicked())) { event.setCancelled(true); } - // } } @EventHandler(priority = EventPriority.NORMAL) diff --git a/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java b/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java index 19b35aca..4ff24fa6 100644 --- a/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java @@ -107,7 +107,9 @@ public void run() { private void openInventory(Player player, OfflinePlayer target) { Player onlineTarget; - if (!target.isOnline()) { + boolean online = target.isOnline(); + + if (!online) { // Try loading the player's data onlineTarget = plugin.getPlayerLoader().loadPlayer(target); @@ -129,7 +131,7 @@ private void openInventory(Player player, OfflinePlayer target) { openEnderHistory.put(player, onlineTarget.getName()); // Create the inventory - ISpecialEnderChest chest = plugin.getOrCreateEnderChestFor(onlineTarget, !target.isOnline()); + ISpecialEnderChest chest = plugin.getOrCreateEnderChestFor(onlineTarget, online); // Open the inventory player.openInventory(chest.getBukkitInventory()); diff --git a/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java b/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java index cf243be8..2a97a07f 100644 --- a/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java @@ -108,8 +108,9 @@ private void openInventory(Player player, OfflinePlayer target) { Player onlineTarget; + boolean online = target.isOnline(); - if (!target.isOnline()) { + if (!online) { // Try loading the player's data onlineTarget = plugin.getPlayerLoader().loadPlayer(target); @@ -143,7 +144,7 @@ private void openInventory(Player player, OfflinePlayer target) { openInvHistory.put(player, onlineTarget.getName()); // Create the inventory - ISpecialPlayerInventory inv = plugin.getOrCreateInventoryFor(onlineTarget, !target.isOnline()); + ISpecialPlayerInventory inv = plugin.getOrCreateInventoryFor(onlineTarget, online); // Open the inventory player.openInventory(inv.getBukkitInventory()); diff --git a/src/main/java/com/lishid/openinv/internal/InternalAccessor.java b/src/main/java/com/lishid/openinv/internal/InternalAccessor.java index 8ed39698..3e524509 100644 --- a/src/main/java/com/lishid/openinv/internal/InternalAccessor.java +++ b/src/main/java/com/lishid/openinv/internal/InternalAccessor.java @@ -55,8 +55,8 @@ private void printErrorMessage() { plugin.getLogger().warning("OpenInv encountered an error with the CraftBukkit version \"" + version + "\". Please look for an updated version of OpenInv."); } - public IPlayerDataManager newPlayerDataManager() { - return (IPlayerDataManager) createObject(IPlayerDataManager.class, "PlayerDataManager"); + public PlayerDataManager newPlayerDataManager() { + return (PlayerDataManager) createObject(PlayerDataManager.class, "PlayerDataManager"); } public IInventoryAccess newInventoryAccess() { @@ -71,7 +71,9 @@ public ISpecialPlayerInventory newSpecialPlayerInventory(Player player, boolean try { Class internalClass = Class.forName("com.lishid.openinv.internal." + version + ".SpecialPlayerInventory"); if (ISpecialPlayerInventory.class.isAssignableFrom(internalClass)) { - return (ISpecialPlayerInventory) internalClass.getConstructor(Player.class, Boolean.class).newInstance(player, offline); + return (ISpecialPlayerInventory) internalClass + .getConstructor(OpenInv.class, Player.class, Boolean.class) + .newInstance(this.plugin, player, offline); } } catch (Exception e) { @@ -86,7 +88,9 @@ public ISpecialEnderChest newSpecialEnderChest(Player player, boolean offline) { try { Class internalClass = Class.forName("com.lishid.openinv.internal." + version + ".SpecialEnderChest"); if (ISpecialEnderChest.class.isAssignableFrom(internalClass)) { - return (ISpecialEnderChest) internalClass.getConstructor(Player.class, Boolean.class).newInstance(player, offline); + return (ISpecialEnderChest) internalClass + .getConstructor(OpenInv.class, Player.class, Boolean.class) + .newInstance(this.plugin, player, offline); } } catch (Exception e) { diff --git a/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/PlayerDataManager.java similarity index 96% rename from src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java rename to src/main/java/com/lishid/openinv/internal/PlayerDataManager.java index a8dd4e2f..d61cb4a7 100644 --- a/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/PlayerDataManager.java @@ -19,7 +19,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -public abstract class IPlayerDataManager { +public abstract class PlayerDataManager { public final Player loadPlayer(OfflinePlayer offline) { if (offline.isOnline()) { return offline.getPlayer(); diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java index d5c7061c..ece75858 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_4_5.EntityPlayer; import net.minecraft.server.v1_4_5.ItemInWorldManager; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_4_5.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java index c34b5340..b9c43ade 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_4_5.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java index 41c7ecf9..486568a2 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_4_5.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java index 604e6d8a..706cdf8e 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_4_6.EntityPlayer; import net.minecraft.server.v1_4_6.MinecraftServer; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_4_6.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java index ad2edbd3..d5107fd9 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_4_6.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java index cd5f667b..1d8114d3 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_4_6.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java index 21b2c5ad..41a3bbd2 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - import net.minecraft.server.v1_4_R1.EntityPlayer; import net.minecraft.server.v1_4_R1.MinecraftServer; import net.minecraft.server.v1_4_R1.PlayerInteractManager; @@ -30,7 +28,7 @@ import org.bukkit.craftbukkit.v1_4_R1.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java index 28f59d77..8ce73569 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; // Volatile import com.lishid.openinv.internal.ISpecialEnderChest; @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_4_R1.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java index 52614a90..7d3064c0 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; import net.minecraft.server.v1_4_R1.EntityHuman; @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_4_R1.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java index 59d14d8f..1eb2e372 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_5_R2.EntityPlayer; import net.minecraft.server.v1_5_R2.MinecraftServer; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_5_R2.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java index f6a7da48..1676c70c 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_5_R2.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java index d90f3bfe..b679046b 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_5_R2.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java index 3f6589c3..b902c3cb 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_5_R3.EntityPlayer; import net.minecraft.server.v1_5_R3.MinecraftServer; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_5_R3.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java index 055472c6..c7383579 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_5_R3.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java index 0796b8b1..4e7445f5 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_5_R3.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java index e0f2b73e..ee2ae258 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_6_R1.EntityPlayer; import net.minecraft.server.v1_6_R1.MinecraftServer; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_6_R1.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java index 404e3134..242cebe2 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_6_R1.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java index 85ee0a4e..aa34c547 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -32,13 +33,16 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -53,7 +57,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java index 5256ea62..ec810fcd 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_6_R2.EntityPlayer; import net.minecraft.server.v1_6_R2.MinecraftServer; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_6_R2.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java index f113e689..608e30c9 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java index 99c94051..0f3bbae8 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java index c96aea2f..f5fa7d1f 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_6_R3.EntityPlayer; import net.minecraft.server.v1_6_R3.MinecraftServer; @@ -29,7 +27,7 @@ import org.bukkit.craftbukkit.v1_6_R3.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java index bbcc1ac0..3c5763f2 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java index fb17a425..b13a5ed7 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java index d9d173a9..7f336199 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_7_R1.EntityPlayer; import net.minecraft.server.v1_7_R1.MinecraftServer; @@ -30,7 +28,7 @@ import org.bukkit.craftbukkit.v1_7_R1.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java index e33d914e..a3fc7483 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java index d3f0771e..3e6beb29 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java index c262a0ab..57b899c1 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - //Volatile import net.minecraft.server.v1_7_R2.EntityPlayer; import net.minecraft.server.v1_7_R2.MinecraftServer; @@ -30,7 +28,7 @@ import org.bukkit.craftbukkit.v1_7_R2.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java index 64c7b264..14c67cc9 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java index c8b9b0d3..ab19a620 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java index 7ccc30eb..e16bb46b 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_7_R3.EntityPlayer; import net.minecraft.server.v1_7_R3.MinecraftServer; @@ -30,7 +28,7 @@ import org.bukkit.craftbukkit.v1_7_R3.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java index 5f8d441a..7b369a46 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java index fd7f3e4f..97468319 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java index c9d7b438..a0c28dbd 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java @@ -20,8 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; - // Volatile import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.MinecraftServer; @@ -30,7 +28,7 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java index e63bb69e..2634a7ff 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; //Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java index d8463e80..637952fa 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java index 4364ae46..823fba12 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java @@ -20,7 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; import com.mojang.authlib.GameProfile; import net.minecraft.server.v1_8_R1.EntityPlayer; @@ -30,7 +29,7 @@ //Volatile import org.bukkit.craftbukkit.v1_8_R1.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java index 29d96617..1d9c891f 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; import net.minecraft.server.v1_8_R1.EntityHuman; @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().hasCustomName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java index fcded9d2..24e8fdf1 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; import net.minecraft.server.v1_8_R1.EntityHuman; @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java index 0b61df40..b724cb1e 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java @@ -20,7 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; import com.mojang.authlib.GameProfile; // Volatile @@ -30,7 +29,7 @@ import org.bukkit.craftbukkit.v1_8_R2.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java index c45ea1c1..2a9a2df6 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().hasCustomName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java index 60b22ed5..603377aa 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java index e3f2dd4f..cb449fe3 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java @@ -20,7 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; import com.mojang.authlib.GameProfile; import net.minecraft.server.v1_8_R3.EntityPlayer; @@ -30,7 +29,7 @@ //Volatile import org.bukkit.craftbukkit.v1_8_R3.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java index 92142ba7..ee41e9ae 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().hasCustomName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java index e0ed3cbe..a5af339a 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; //Volatile @@ -31,13 +32,16 @@ import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[5]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; this.items = player.inventory.items; @@ -52,7 +56,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java index b6aa87c9..83bedd8f 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java +++ b/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java @@ -20,7 +20,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import com.lishid.openinv.internal.IPlayerDataManager; import com.mojang.authlib.GameProfile; // Volatile @@ -30,7 +29,7 @@ import org.bukkit.craftbukkit.v1_9_R1.CraftServer; -public class PlayerDataManager extends IPlayerDataManager { +public class PlayerDataManager extends com.lishid.openinv.internal.PlayerDataManager { @Override public Player loadOfflinePlayer(OfflinePlayer offline) { diff --git a/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialEnderChest.java index 34abfeed..a52391b5 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialEnderChest.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; // Volatile @@ -39,15 +40,18 @@ import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftInventory; public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest { + + private final OpenInv plugin; + private final InventoryEnderChest enderChest; + private final CraftInventory inventory = new CraftInventory(this); public List transaction = new ArrayList(); public boolean playerOnline = false; private CraftPlayer owner; - private final InventoryEnderChest enderChest; private int maxStack = MAX_STACK; - private final CraftInventory inventory = new CraftInventory(this); - public SpecialEnderChest(Player p, Boolean online) { + public SpecialEnderChest(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().hasCustomName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize()); + this.plugin = plugin; CraftPlayer player = (CraftPlayer) p; this.enderChest = player.getHandle().getEnderChest(); this.owner = player; @@ -62,7 +66,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java index 880eaa85..4b49371e 100644 --- a/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/v1_9_R1/SpecialPlayerInventory.java @@ -22,6 +22,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialPlayerInventory; // Volatile @@ -34,13 +35,16 @@ import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftInventory; public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory { - CraftPlayer owner; - public boolean playerOnline = false; + + private final OpenInv plugin; private final ItemStack[] extra = new ItemStack[4]; private final CraftInventory inventory = new CraftInventory(this); + private CraftPlayer owner; + private boolean playerOnline = false; - public SpecialPlayerInventory(Player p, Boolean online) { + public SpecialPlayerInventory(OpenInv plugin, Player p, Boolean online) { super(((CraftPlayer) p).getHandle()); + this.plugin = plugin; this.owner = ((CraftPlayer) p); this.playerOnline = online; setItemArrays(this, player.inventory.items, player.inventory.armor, player.inventory.extraSlots); @@ -91,7 +95,7 @@ public Inventory getBukkitInventory() { @Override public boolean inventoryRemovalCheck(boolean save) { boolean offline = transaction.isEmpty() && !playerOnline; - if (offline && save) { + if (offline && save && !plugin.disableSaving()) { owner.saveData(); } return offline; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2c03b6e7..0b8dadf3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: OpenInv main: com.lishid.openinv.OpenInv -version: 2.4.3 +version: 2.4.4 author: lishid authors: [Jikoo] description: >