Update plugin to jikoo/master - numerous fixes and changes
* Added permissions to commands in plugin.yml
* Removed item wand functionality - see 3549431fbc
for reasoning
* Changed a lot of player loading logic
* Added config option DisableSaving - see Jikoo#6
* Fixed closing SilentChest not dropping item on cursor
* Added SilentChest support for shulker boxes
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.lishid.openinv.internal;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IAnySilentContainer}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IAnySilentChest {
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IAnySilentContainer#activateContainer(Player, boolean, Block)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IAnySilentContainer#isAnyContainerNeeded(Player, Block)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isAnyChestNeeded(Player player, int x, int y, int z);
|
||||
|
||||
}
|
@@ -3,8 +3,7 @@ package com.lishid.openinv.internal;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface IAnySilentContainer extends IAnySilentChest {
|
||||
public interface IAnySilentContainer {
|
||||
|
||||
/**
|
||||
* Checks if the given block is a container which can be unblocked or silenced.
|
||||
|
@@ -16,18 +16,42 @@
|
||||
|
||||
package com.lishid.openinv.internal;
|
||||
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public interface IInventoryAccess {
|
||||
|
||||
/**
|
||||
* Check if an entity has permission to modify the contents of an inventory.
|
||||
* Check if an Inventory is an ISpecialPlayerInventory implementation.
|
||||
*
|
||||
* @param inventory the Inventory
|
||||
* @param player the HumanEntity
|
||||
* @return true if the HumanEntity can modify the Inventory
|
||||
* @return true if the Inventory is backed by an ISpecialPlayerInventory
|
||||
*/
|
||||
public boolean check(Inventory inventory, HumanEntity player);
|
||||
public boolean isSpecialPlayerInventory(Inventory inventory);
|
||||
|
||||
/**
|
||||
* Gets an ISpecialPlayerInventory from an Inventory or null if the Inventory is not backed by
|
||||
* an ISpecialPlayerInventory.
|
||||
*
|
||||
* @param inventory the Inventory
|
||||
* @return the ISpecialPlayerInventory or null
|
||||
*/
|
||||
public ISpecialPlayerInventory getSpecialPlayerInventory(Inventory inventory);
|
||||
|
||||
/**
|
||||
* Check if an Inventory is an ISpecialEnderChest implementation.
|
||||
*
|
||||
* @param inventory the Inventory
|
||||
* @return true if the Inventory is backed by an ISpecialEnderChest
|
||||
*/
|
||||
public boolean isSpecialEnderChest(Inventory inventory);
|
||||
|
||||
/**
|
||||
* Gets an ISpecialEnderChest from an Inventory or null if the Inventory is not backed by an
|
||||
* ISpecialEnderChest.
|
||||
*
|
||||
* @param inventory the Inventory
|
||||
* @return the ISpecialEnderChest or null
|
||||
*/
|
||||
public ISpecialEnderChest getSpecialEnderChest(Inventory inventory);
|
||||
|
||||
}
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.lishid.openinv.internal;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -33,12 +31,6 @@ public interface IPlayerDataManager {
|
||||
*/
|
||||
public Player loadPlayer(OfflinePlayer offline);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #loadPlayer(OfflinePlayer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Player loadPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets a unique identifying string for an OfflinePlayer.
|
||||
*
|
||||
|
@@ -35,23 +35,11 @@ public interface ISpecialEnderChest {
|
||||
*/
|
||||
public void setPlayerOnline(Player player);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setPlayerOnline(Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void playerOnline(Player player);
|
||||
|
||||
/**
|
||||
* Sets the Player associated with this ISpecialEnderChest offline.
|
||||
*/
|
||||
public void setPlayerOffline();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setPlayerOffline()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void playerOffline();
|
||||
|
||||
/**
|
||||
* Gets whether or not this ISpecialEnderChest is in use.
|
||||
*
|
||||
|
@@ -35,23 +35,11 @@ public interface ISpecialPlayerInventory {
|
||||
*/
|
||||
public void setPlayerOnline(Player player);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setPlayerOnline(Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void playerOnline(Player player);
|
||||
|
||||
/**
|
||||
* Sets the Player associated with this ISpecialPlayerInventory offline.
|
||||
*/
|
||||
public void setPlayerOffline();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setPlayerOffline()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void playerOffline();
|
||||
|
||||
/**
|
||||
* Gets whether or not this ISpecialPlayerInventory is in use.
|
||||
*
|
||||
|
@@ -17,8 +17,8 @@
|
||||
package com.lishid.openinv.internal;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -26,30 +26,19 @@ public class InternalAccessor {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
private String version;
|
||||
private final String version;
|
||||
private boolean supported = false;
|
||||
|
||||
public InternalAccessor(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current server version is supported, and, if it is, prepare to load version-specific code.
|
||||
*
|
||||
* @param server the Server
|
||||
*
|
||||
* @return true if supported
|
||||
*/
|
||||
public boolean initialize(Server server) {
|
||||
String packageName = server.getClass().getPackage().getName();
|
||||
String packageName = plugin.getServer().getClass().getPackage().getName();
|
||||
version = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
|
||||
try {
|
||||
Class.forName("com.lishid.openinv.internal." + version + ".PlayerDataManager");
|
||||
return (supported = true);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
supported = true;
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,15 +90,6 @@ public class InternalAccessor {
|
||||
return createObject(IAnySilentContainer.class, "AnySilentContainer");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #newAnySilentContainer()}
|
||||
*/
|
||||
@Deprecated
|
||||
public IAnySilentChest newAnySilentChest() {
|
||||
IAnySilentChest iAnySilentChest = createObject(IAnySilentChest.class, "AnySilentChest");
|
||||
return iAnySilentChest != null ? iAnySilentChest : newAnySilentContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of the ISpecialPlayerInventory implementation for the given Player, or
|
||||
* null if the current version is unsupported.
|
||||
@@ -180,4 +160,21 @@ public class InternalAccessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T grabFieldOfTypeFromObject(Class<T> type, Object object) {
|
||||
// Use reflection to find the iinventory
|
||||
Class<?> clazz = object.getClass();
|
||||
T result = null;
|
||||
for (Field f : clazz.getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
if (type.isAssignableFrom(f.getDeclaringClass())) {
|
||||
try {
|
||||
result = type.cast(f.get(object));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user