From 5f3af49f50ac6892fedffd559cb8864c21be5586 Mon Sep 17 00:00:00 2001 From: caver Date: Sat, 4 Oct 2014 16:36:03 +0700 Subject: [PATCH] Fix conflict with other inventory modification plugins (like JSNONAPI) in offline mode. Double null check removed. --- .../openinv/commands/OpenInvPluginCommand.java | 18 ++++++++---------- .../v1_7_R1/SpecialPlayerInventory.java | 9 +++++---- .../v1_7_R2/SpecialPlayerInventory.java | 9 +++++---- .../v1_7_R3/SpecialPlayerInventory.java | 9 +++++---- .../v1_7_R4/SpecialPlayerInventory.java | 9 +++++---- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/com/lishid/openinv/commands/OpenInvPluginCommand.java b/src/com/lishid/openinv/commands/OpenInvPluginCommand.java index 4457cde..fcd00c1 100644 --- a/src/com/lishid/openinv/commands/OpenInvPluginCommand.java +++ b/src/com/lishid/openinv/commands/OpenInvPluginCommand.java @@ -1,15 +1,15 @@ /* * Copyright (C) 2011-2014 lishid. All rights reserved. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -79,14 +79,12 @@ public class OpenInvPluginCommand implements CommandExecutor { target = this.plugin.getServer().getPlayer(name); if (target == null) { - if (target == null) { - // Try loading the player's data - target = OpenInv.playerLoader.loadPlayer(name); + // Try loading the player's data + target = OpenInv.playerLoader.loadPlayer(name); - if (target == null) { - sender.sendMessage(ChatColor.RED + "Player " + name + " not found!"); - return true; - } + if (target == null) { + sender.sendMessage(ChatColor.RED + "Player " + name + " not found!"); + return true; } } diff --git a/src/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java b/src/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java index 7229487..6b758c7 100644 --- a/src/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java +++ b/src/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java @@ -1,15 +1,15 @@ /* * Copyright (C) 2011-2014 lishid. All rights reserved. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -50,7 +50,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP @Override public void InventoryRemovalCheck() { owner.saveData(); - if (transaction.isEmpty() && !playerOnline) { + // Conflict with other Offline inventory modification plugins like JSONAPI + if (transaction.isEmpty() || !playerOnline) { OpenInv.inventories.remove(owner.getName().toLowerCase()); } } diff --git a/src/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java b/src/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java index d3e0160..d741345 100644 --- a/src/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java +++ b/src/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java @@ -1,15 +1,15 @@ /* * Copyright (C) 2011-2014 lishid. All rights reserved. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -50,7 +50,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP @Override public void InventoryRemovalCheck() { owner.saveData(); - if (transaction.isEmpty() && !playerOnline) { + // Conflict with other Offline inventory modification plugins like JSONAPI + if (transaction.isEmpty() || !playerOnline) { OpenInv.inventories.remove(owner.getName().toLowerCase()); } } diff --git a/src/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java b/src/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java index 98a8cf1..b000072 100644 --- a/src/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java +++ b/src/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java @@ -1,15 +1,15 @@ /* * Copyright (C) 2011-2014 lishid. All rights reserved. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -50,7 +50,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP @Override public void InventoryRemovalCheck() { owner.saveData(); - if (transaction.isEmpty() && !playerOnline) { + // Conflict with other Offline inventory modification plugins like JSONAPI + if (transaction.isEmpty() || !playerOnline) { OpenInv.inventories.remove(owner.getName().toLowerCase()); } } diff --git a/src/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java b/src/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java index b36388b..b7befdc 100644 --- a/src/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java +++ b/src/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java @@ -1,15 +1,15 @@ /* * Copyright (C) 2011-2014 lishid. All rights reserved. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -50,7 +50,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP @Override public void InventoryRemovalCheck() { owner.saveData(); - if (transaction.isEmpty() && !playerOnline) { + // Conflict with other Offline inventory modification plugins like JSONAPI + if (transaction.isEmpty() || !playerOnline) { OpenInv.inventories.remove(owner.getName().toLowerCase()); } }