Compare commits

...

18 Commits
3.1.0 ... 3.3.0

Author SHA1 Message Date
Jikoo
931cdb6fb1 Bump version to 3.3.0 for release 2017-07-05 05:52:33 -04:00
Jikoo
9db18613a1 Abuse spectator mode for SilentContainer (#64, #68)
Potentially causes issues with Cauldron and similar mods that use different mapping names.
2017-07-04 13:22:03 -04:00
Jikoo
784935a975 Synchronize cache (for real), updated dependencies
Closes #69
2017-07-03 18:06:18 -04:00
Jikoo
d9abe76531 Bump version to 3.2.2-SNAPSHOT for development 2017-06-09 20:21:30 -04:00
Jikoo
ca85a392aa Correct field name for list of inventory contents (#66) 2017-06-09 20:15:51 -04:00
Jikoo
307f47e4d3 Bump version to 3.2.1-SNAPSHOT for development 2017-06-08 18:44:10 -04:00
Jikoo
96c59f163d Slightly improve API, bump version to 3.2.0 for release
Methods are now properly annotated @Nullable when they may return null. More descriptive exceptions are thrown when issues occur instead of just returning null.
2017-06-08 18:36:01 -04:00
Jikoo
01f147b13c Fix incorrect method call for checking if a block is occluding
Switched to using the API for statistic manipulation.
2017-06-08 18:26:26 -04:00
Jikoo
1c104b775f For improved compatibility, our own Levenshtein implementation 2017-05-28 09:53:59 -04:00
Jikoo
9a53e46dd3 Replaced modern profile with recent
Going forward, the primary file uploaded to Bukkit will probably be the smaller build made with the `recent` profile, supporting only the last 2 versions. The uberjar created by the `all` will be provided as an additional download. OpenInv v3.1.3-SNAPSHOT `all` uberjar currently is 276KB. The `recent` jar is only 81KB. It's getting silly, and will only continue to get worse.
2017-05-26 05:52:35 -04:00
Jikoo
6744e71127 Support 1.12-pre2 (#65) 2017-05-14 11:47:15 -04:00
Jikoo
12c3ebb798 Bump version to 3.1.3-SNAPSHOT for development 2017-02-13 20:02:12 -05:00
Jikoo
32ec8d8147 Bump version to 3.1.2 for release 2017-02-13 20:01:18 -05:00
Jikoo
443e0c489e Synchronize cache (#63) 2017-02-13 19:56:32 -05:00
Jikoo
7ab0003b62 Bump version to 3.1.2-SNAPSHOT for development 2017-01-30 13:38:36 -05:00
Jikoo
12c0cac311 Bump version to 3.1.1 for release 2017-01-30 13:38:10 -05:00
Jikoo
f54481e872 Fix (NoSuchMethod)Exception being caught instead of NoSuchMethodError
Closes #62
2017-01-30 13:35:58 -05:00
Jikoo
f27dd8a233 Bump version to 3.1.1-SNAPSHOT for development 2017-01-20 13:02:47 -05:00
64 changed files with 2043 additions and 1098 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvapi</artifactId>

View File

@@ -1,5 +1,7 @@
package com.lishid.openinv;
import javax.annotation.Nullable;
import com.lishid.openinv.internal.IAnySilentContainer;
import com.lishid.openinv.internal.IInventoryAccess;
import com.lishid.openinv.internal.ISpecialEnderChest;
@@ -11,145 +13,172 @@ import org.bukkit.plugin.Plugin;
/**
* Interface defining behavior for the OpenInv plugin.
*
*
* @author Jikoo
*/
public interface IOpenInv {
/**
* Checks if the server version is supported by OpenInv.
*
* @return true if the server version is supported
*/
public boolean isSupportedVersion();
/**
* Gets the active IInventoryAccess implementation. May return null if the server version is
* unsupported.
*
* @return the IInventoryAccess
*/
public IInventoryAccess getInventoryAccess();
/**
* Gets the active ISilentContainer implementation. May return null if the server version is
* unsupported.
*
* @return the ISilentContainer
*/
public IAnySilentContainer getAnySilentContainer();
/**
* Gets an ISpecialPlayerInventory for the given Player.
*
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialPlayerInventory
*/
public ISpecialPlayerInventory getInventory(Player player, boolean online);
/**
* Gets an ISpecialEnderChest for the given Player.
*
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialEnderChest
*/
public ISpecialEnderChest getEnderChest(Player player, boolean online);
/**
* Forcibly unload a cached Player's data.
*
* @param player the OfflinePlayer to unload
*/
public void unload(OfflinePlayer player);
/**
* Check the configuration value for whether or not OpenInv saves player data when unloading
* players. This is exclusively for users who do not allow editing of inventories, only viewing,
* and wish to prevent any possibility of bugs such as lishid#40. If true, OpenInv will not ever
* save any edits made to players.
*
*
* @return false unless configured otherwise
*/
public boolean disableSaving();
/**
* Check the configuration value for whether or not OpenInv displays a notification to the user
* when a container is activated with SilentChest.
*
* @return true unless configured otherwise
* Gets the active ISilentContainer implementation. May return null if the server version is
* unsupported.
*
* @return the ISilentContainer
* @throws IllegalStateException if the server version is unsupported
*/
public boolean notifySilentChest();
public IAnySilentContainer getAnySilentContainer();
/**
* Check the configuration value for whether or not OpenInv displays a notification to the user
* when a container is activated with AnyChest.
*
* @return true unless configured otherwise
* Gets an ISpecialEnderChest for the given Player. Returns null if the ISpecialEnderChest could
* not be instantiated.
*
* @deprecated Use {@link IOpenInv#getSpecialEnderChest(Player, boolean)}
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialEnderChest
* @throws IllegalStateException if the server version is unsupported
*/
public boolean notifyAnyChest();
@Deprecated
@Nullable
public ISpecialEnderChest getEnderChest(Player player, boolean online);
/**
* Gets a player's SilentChest setting.
*
* @param player the OfflinePlayer
* @return true if SilentChest is enabled
* Gets an ISpecialPlayerInventory for the given Player. Returns null if the
* ISpecialPlayerInventory could not be instantiated.
*
* @deprecated Use {@link IOpenInv#getSpecialInventory(Player, boolean)}
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialPlayerInventory
* @throws IllegalStateException if the server version is unsupported
*/
public boolean getPlayerSilentChestStatus(OfflinePlayer player);
@Deprecated
@Nullable
public ISpecialPlayerInventory getInventory(Player player, boolean online);
/**
* Sets a player's SilentChest setting.
*
* @param player the OfflinePlayer
* @param status the status
* Gets the active IInventoryAccess implementation. May return null if the server version is
* unsupported.
*
* @return the IInventoryAccess
* @throws IllegalStateException if the server version is unsupported
*/
public void setPlayerSilentChestStatus(OfflinePlayer player, boolean status);
public IInventoryAccess getInventoryAccess();
/**
* Gets the provided player's AnyChest setting.
*
*
* @param player the OfflinePlayer
* @return true if AnyChest is enabled
* @throws IllegalStateException if the server version is unsupported
*/
public boolean getPlayerAnyChestStatus(OfflinePlayer player);
/**
* Sets a player's AnyChest setting.
*
* @param player the OfflinePlayer
* @param status the status
*/
public void setPlayerAnyChestStatus(OfflinePlayer player, boolean status);
/**
* Gets a unique identifier by which the OfflinePlayer can be referenced. Using the value
* returned to look up a Player will generally be much faster for later implementations.
*
*
* @param offline the OfflinePlayer
* @return the identifier
* @throws IllegalStateException if the server version is unsupported
*/
public String getPlayerID(OfflinePlayer offline);
/**
* Gets a player's SilentChest setting.
*
* @param player the OfflinePlayer
* @return true if SilentChest is enabled
* @throws IllegalStateException if the server version is unsupported
*/
public boolean getPlayerSilentChestStatus(OfflinePlayer player);
/**
* Gets an ISpecialEnderChest for the given Player.
*
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialEnderChest
* @throws IllegalStateException if the server version is unsupported
* @throws InstantiationException if the ISpecialEnderChest could not be instantiated
*/
public ISpecialEnderChest getSpecialEnderChest(Player player, boolean online) throws InstantiationException;
/**
* Gets an ISpecialPlayerInventory for the given Player.
*
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialPlayerInventory
* @throws IllegalStateException if the server version is unsupported
* @throws InstantiationException if the ISpecialPlayerInventory could not be instantiated
*/
public ISpecialPlayerInventory getSpecialInventory(Player player, boolean online) throws InstantiationException;
/**
* Checks if the server version is supported by OpenInv.
*
* @return true if the server version is supported
*/
public boolean isSupportedVersion();
/**
* Load a Player from an OfflinePlayer. May return null under some circumstances.
*
* @param offline the OfflinePlayer to load a Player for
* @return the Player, or null
* @throws IllegalStateException if the server version is unsupported
*/
@Nullable
public Player loadPlayer(final OfflinePlayer offline);
/**
* Get an OfflinePlayer by name.
* <p>
* Note: This method is potentially very heavily blocking. It should not ever be called on the
* main thread, and if it is, a stack trace will be displayed alerting server owners to the
* call.
*
*
* @param name the name of the Player
* @return the OfflinePlayer with the closest matching name or null if no players have ever logged in
*/
@Nullable
public OfflinePlayer matchPlayer(String name);
/**
* Load a Player from an OfflinePlayer. May return null under some circumstances.
*
* @param offline the OfflinePlayer to load a Player for
* @return the Player
* Check the configuration value for whether or not OpenInv displays a notification to the user
* when a container is activated with AnyChest.
*
* @return true unless configured otherwise
*/
public Player loadPlayer(final OfflinePlayer offline);
public boolean notifyAnyChest();
/**
* Check the configuration value for whether or not OpenInv displays a notification to the user
* when a container is activated with SilentChest.
*
* @return true unless configured otherwise
*/
public boolean notifySilentChest();
/**
* Mark a Player as no longer in use by a Plugin to allow OpenInv to remove it from the cache
* when eligible.
*
* @param player the Player
* @param plugin the Plugin no longer holding a reference to the Player
* @throws IllegalStateException if the server version is unsupported
*/
public void releasePlayer(Player player, Plugin plugin);
/**
* Mark a Player as in use by a Plugin to prevent it from being removed from the cache. Used to
@@ -169,19 +198,37 @@ public interface IOpenInv {
* {@link #disableSaving()} returns false. If you are making changes that OpenInv does not cause
* to persist when a Player logs in as noted above, it is suggested that you manually call
* {@link Player#saveData()} when releasing your reference to ensure your changes persist.
*
*
* @param player the Player
* @param plugin the Plugin holding the reference to the Player
* @throws IllegalStateException if the server version is unsupported
*/
public void retainPlayer(Player player, Plugin plugin);
/**
* Mark a Player as no longer in use by a Plugin to allow OpenInv to remove it from the cache
* when eligible.
*
* @param player the Player
* @param plugin the Plugin no longer holding a reference to the Player
* Sets a player's AnyChest setting.
*
* @param player the OfflinePlayer
* @param status the status
* @throws IllegalStateException if the server version is unsupported
*/
public void releasePlayer(Player player, Plugin plugin);
public void setPlayerAnyChestStatus(OfflinePlayer player, boolean status);
/**
* Sets a player's SilentChest setting.
*
* @param player the OfflinePlayer
* @param status the status
* @throws IllegalStateException if the server version is unsupported
*/
public void setPlayerSilentChestStatus(OfflinePlayer player, boolean status);
/**
* Forcibly unload a cached Player's data.
*
* @param player the OfflinePlayer to unload
* @throws IllegalStateException if the server version is unsupported
*/
public void unload(OfflinePlayer player);
}

View File

@@ -6,16 +6,27 @@ import org.bukkit.entity.Player;
public interface IAnySilentContainer {
/**
* Checks if the given block is a container which can be unblocked or silenced.
*
* @param block the BlockState
* @return true if the Block is a supported container
* Opens the container at the given coordinates for the Player. If you do not want blocked
* containers to open, be sure to check {@link #isAnyContainerNeeded(Player, Block)}
* first.
*
* @param player the Player opening the container
* @param silentchest whether the container's noise is to be silenced
* @param block the Block
* @return true if the container can be opened
*/
public boolean isAnySilentContainer(Block block);
public boolean activateContainer(Player player, boolean silentchest, Block block);
/**
* Closes the Player's currently open container silently, if necessary.
*
* @param player the Player closing a container
*/
public void deactivateContainer(Player player);
/**
* Checks if the container at the given coordinates is blocked.
*
*
* @param player the Player opening the container
* @param block the Block
* @return true if the container is blocked
@@ -23,15 +34,11 @@ public interface IAnySilentContainer {
public boolean isAnyContainerNeeded(Player player, Block block);
/**
* Opens the container at the given coordinates for the Player. If you do not want blocked
* containers to open, be sure to check {@link #isAnyContainerNeeded(Player, Block)}
* first.
*
* @param player
* @param silentchest whether the container's noise is to be silenced
* @param block the Block
* @return true if the container can be opened
* Checks if the given block is a container which can be unblocked or silenced.
*
* @param block the BlockState
* @return true if the Block is a supported container
*/
public boolean activateContainer(Player player, boolean silentchest, Block block);
public boolean isAnySilentContainer(Block block);
}

View File

@@ -1,57 +1,61 @@
/*
* 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 javax.annotation.Nullable;
import org.bukkit.inventory.Inventory;
public interface IInventoryAccess {
/**
* Check if an Inventory is an ISpecialPlayerInventory implementation.
*
* Gets an ISpecialEnderChest from an Inventory or null if the Inventory is not backed by an
* ISpecialEnderChest.
*
* @param inventory the Inventory
* @return true if the Inventory is backed by an ISpecialPlayerInventory
* @return the ISpecialEnderChest or null
*/
public boolean isSpecialPlayerInventory(Inventory inventory);
@Nullable
public ISpecialEnderChest getSpecialEnderChest(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
*/
@Nullable
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.
*
* Check if an Inventory is an ISpecialPlayerInventory implementation.
*
* @param inventory the Inventory
* @return the ISpecialEnderChest or null
* @return true if the Inventory is backed by an ISpecialPlayerInventory
*/
public ISpecialEnderChest getSpecialEnderChest(Inventory inventory);
public boolean isSpecialPlayerInventory(Inventory inventory);
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvassembly</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvcommon</artifactId>
@@ -22,7 +22,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvapi</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -9,7 +9,7 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
/**
* A minimal time-based cache implementation backed by a HashMap and TreeMultimap.
* A minimal thread-safe time-based cache implementation backed by a HashMap and TreeMultimap.
*
* @author Jikoo
*/
@@ -59,8 +59,10 @@ public class Cache<K, V> {
// Invalidate key - runs lazy check and ensures value won't be cleaned up early
invalidate(key);
internal.put(key, value);
expiry.put(System.currentTimeMillis() + retention, key);
synchronized (internal) {
internal.put(key, value);
expiry.put(System.currentTimeMillis() + retention, key);
}
}
/**
@@ -73,7 +75,9 @@ public class Cache<K, V> {
// Run lazy check to clean cache
lazyCheck();
return internal.get(key);
synchronized (internal) {
return internal.get(key);
}
}
/**
@@ -86,7 +90,9 @@ public class Cache<K, V> {
// Run lazy check to clean cache
lazyCheck();
return internal.containsKey(key);
synchronized (internal) {
return internal.containsKey(key);
}
}
/**
@@ -98,19 +104,21 @@ public class Cache<K, V> {
// Run lazy check to clean cache
lazyCheck();
if (!internal.containsKey(key)) {
// Value either not present or cleaned by lazy check. Either way, we're good
return;
}
synchronized (internal) {
if (!internal.containsKey(key)) {
// Value either not present or cleaned by lazy check. Either way, we're good
return;
}
// Remove stored object
internal.remove(key);
// Remove stored object
internal.remove(key);
// Remove expiration entry - prevents more work later, plus prevents issues with values invalidating early
for (Iterator<Map.Entry<Long, K>> iterator = expiry.entries().iterator(); iterator.hasNext();) {
if (key.equals(iterator.next().getValue())) {
iterator.remove();
break;
// Remove expiration entry - prevents more work later, plus prevents issues with values invalidating early
for (Iterator<Map.Entry<Long, K>> iterator = expiry.entries().iterator(); iterator.hasNext();) {
if (key.equals(iterator.next().getValue())) {
iterator.remove();
break;
}
}
}
}
@@ -119,11 +127,13 @@ public class Cache<K, V> {
* Forcibly invalidates all keys, even if they are considered to be in use.
*/
public void invalidateAll() {
for (V value : internal.values()) {
postRemoval.run(value);
synchronized (internal) {
for (V value : internal.values()) {
postRemoval.run(value);
}
expiry.clear();
internal.clear();
}
expiry.clear();
internal.clear();
}
/**
@@ -133,27 +143,30 @@ public class Cache<K, V> {
private void lazyCheck() {
long now = System.currentTimeMillis();
long nextExpiry = now + retention;
for (Iterator<Map.Entry<Long, K>> iterator = expiry.entries().iterator(); iterator.hasNext();) {
Map.Entry<Long, K> entry = iterator.next();
synchronized (internal) {
for (Iterator<Map.Entry<Long, K>> iterator = expiry.entries().iterator(); iterator
.hasNext();) {
Map.Entry<Long, K> entry = iterator.next();
if (entry.getKey() > now) {
break;
if (entry.getKey() > now) {
break;
}
iterator.remove();
if (inUseCheck.run(internal.get(entry.getValue()))) {
expiry.put(nextExpiry, entry.getValue());
continue;
}
V value = internal.remove(entry.getValue());
if (value == null) {
continue;
}
postRemoval.run(value);
}
iterator.remove();
if (inUseCheck.run(internal.get(entry.getValue()))) {
expiry.put(nextExpiry, entry.getValue());
continue;
}
V value = internal.remove(entry.getValue());
if (value == null) {
continue;
}
postRemoval.run(value);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
@@ -18,6 +18,7 @@ package com.lishid.openinv.util;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import com.lishid.openinv.internal.IAnySilentContainer;
import com.lishid.openinv.internal.IInventoryAccess;
@@ -30,144 +31,8 @@ import org.bukkit.plugin.Plugin;
public class InternalAccessor {
private final Plugin plugin;
private final String version;
private boolean supported = false;
public InternalAccessor(Plugin plugin) {
this.plugin = plugin;
String packageName = plugin.getServer().getClass().getPackage().getName();
version = packageName.substring(packageName.lastIndexOf('.') + 1);
try {
Class.forName("com.lishid.openinv.internal." + version + ".PlayerDataManager");
supported = true;
} catch (Exception e) {}
}
/**
* Gets the server implementation version. If not initialized, returns the string "null"
* instead.
*
* @return the version, or "null"
*/
public String getVersion() {
return this.version != null ? this.version : "null";
}
/**
* Checks if the server implementation is supported.
*
* @return true if initialized for a supported server version
*/
public boolean isSupported() {
return this.supported;
}
/**
* Creates an instance of the IPlayerDataManager implementation for the current server version,
* or null if unsupported.
*
* @return the IPlayerDataManager
*/
public IPlayerDataManager newPlayerDataManager() {
return createObject(IPlayerDataManager.class, "PlayerDataManager");
}
/**
* Creates an instance of the IInventoryAccess implementation for the current server version, or
* null if unsupported.
*
* @return the IInventoryAccess
*/
public IInventoryAccess newInventoryAccess() {
return createObject(IInventoryAccess.class, "InventoryAccess");
}
/**
* Creates an instance of the IAnySilentContainer implementation for the current server version,
* or null if unsupported.
*
* @return the IAnySilentContainer
*/
public IAnySilentContainer newAnySilentContainer() {
return createObject(IAnySilentContainer.class, "AnySilentContainer");
}
/**
* Creates an instance of the ISpecialPlayerInventory implementation for the given Player, or
* null if the current version is unsupported.
*
* @param player the Player
* @param online true if the Player is online
* @return the ISpecialPlayerInventory created
*/
public ISpecialPlayerInventory newSpecialPlayerInventory(Player player, boolean online) {
return createObject(ISpecialPlayerInventory.class, "SpecialPlayerInventory", player, online);
}
/**
* Creates an instance of the ISpecialEnderChest implementation for the given Player, or
* null if the current version is unsupported.
*
* @param player the Player
* @param online true if the Player is online
* @return the ISpecialEnderChest created
*/
public ISpecialEnderChest newSpecialEnderChest(Player player, boolean online) {
return createObject(ISpecialEnderChest.class, "SpecialEnderChest", player, online);
}
private <T> T createObject(Class<? extends T> assignableClass, String className, Object... params) {
try {
// Check if internal versioned class exists
Class<?> internalClass = Class.forName("com.lishid.openinv.internal." + version + "." + className);
if (!assignableClass.isAssignableFrom(internalClass)) {
plugin.getLogger().warning("Found class " + internalClass.getName() + " but cannot cast to " + assignableClass.getName());
return null;
}
// Quick return: no parameters, no need to fiddle about finding the correct constructor.
if (params.length == 0) {
return assignableClass.cast(internalClass.getConstructor().newInstance());
}
// Search constructors for one matching the given parameters
nextConstructor: for (Constructor<?> constructor : internalClass.getConstructors()) {
Class<?>[] requiredClasses = constructor.getParameterTypes();
if (requiredClasses.length != params.length) {
continue;
}
for (int i = 0; i < params.length; ++i) {
if (!requiredClasses[i].isAssignableFrom(params[i].getClass())) {
continue nextConstructor;
}
}
return assignableClass.cast(constructor.newInstance(params));
}
StringBuilder message = new StringBuilder("Found class ").append(internalClass.getName())
.append(" but cannot find any matching constructors for [");
for (Object object : params) {
message.append(object.getClass().getName()).append(", ");
}
if (params.length > 0) {
message.delete(message.length() - 2, message.length());
}
plugin.getLogger().warning(message.append(']').toString());
} catch (Exception e) {
plugin.getLogger().warning("OpenInv encountered an error with the CraftBukkit version \"" + version + "\". Please look for an updated version of OpenInv.");
e.printStackTrace();
}
return null;
}
public static <T> T grabFieldOfTypeFromObject(Class<T> type, Object object) {
// Use reflection to find the iinventory
public static <T> T grabFieldOfTypeFromObject(final Class<T> type, final Object object) {
// Use reflection to find the IInventory
Class<?> clazz = object.getClass();
T result = null;
for (Field f : clazz.getDeclaredFields()) {
@@ -183,4 +48,171 @@ public class InternalAccessor {
return result;
}
private final Plugin plugin;
private final String version;
private boolean supported = false;
private IPlayerDataManager playerDataManager;
private IInventoryAccess inventoryAccess;
private IAnySilentContainer anySilentContainer;
public InternalAccessor(final Plugin plugin) {
this.plugin = plugin;
String packageName = plugin.getServer().getClass().getPackage().getName();
this.version = packageName.substring(packageName.lastIndexOf('.') + 1);
try {
Class.forName("com.lishid.openinv.internal." + this.version + ".SpecialPlayerInventory");
Class.forName("com.lishid.openinv.internal." + this.version + ".SpecialEnderChest");
this.playerDataManager = this.createObject(IPlayerDataManager.class, "PlayerDataManager");
this.inventoryAccess = this.createObject(IInventoryAccess.class, "InventoryAccess");
this.anySilentContainer = this.createObject(IAnySilentContainer.class, "AnySilentContainer");
this.supported = true;
} catch (Exception e) {}
}
private <T> T createObject(final Class<? extends T> assignableClass, final String className,
final Object... params) throws ClassCastException, ClassNotFoundException,
InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException, NoSuchMethodException, SecurityException {
// Fetch internal class if it exists.
Class<?> internalClass = Class.forName("com.lishid.openinv.internal." + this.version + "." + className);
if (!assignableClass.isAssignableFrom(internalClass)) {
String message = String.format("Found class %s but cannot cast to %s!", internalClass.getName(), assignableClass.getName());
this.plugin.getLogger().warning(message);
throw new IllegalStateException(message);
}
// Quick return: no parameters, no need to fiddle about finding the correct constructor.
if (params.length == 0) {
return assignableClass.cast(internalClass.getConstructor().newInstance());
}
// Search constructors for one matching the given parameters
nextConstructor: for (Constructor<?> constructor : internalClass.getConstructors()) {
Class<?>[] requiredClasses = constructor.getParameterTypes();
if (requiredClasses.length != params.length) {
continue;
}
for (int i = 0; i < params.length; ++i) {
if (!requiredClasses[i].isAssignableFrom(params[i].getClass())) {
continue nextConstructor;
}
}
return assignableClass.cast(constructor.newInstance(params));
}
StringBuilder builder = new StringBuilder("Found class ").append(internalClass.getName())
.append(" but cannot find any matching constructors for [");
for (Object object : params) {
builder.append(object.getClass().getName()).append(", ");
}
if (params.length > 0) {
builder.delete(builder.length() - 2, builder.length());
}
String message = builder.append(']').toString();
this.plugin.getLogger().warning(message);
throw new IllegalArgumentException(message);
}
/**
* Creates an instance of the IAnySilentContainer implementation for the current server version.
*
* @return the IAnySilentContainer
* @throws IllegalStateException if server version is unsupported
*/
public IAnySilentContainer getAnySilentContainer() {
if (!this.supported) {
throw new IllegalStateException(String.format("Unsupported server version %s!", this.version));
}
return this.anySilentContainer;
}
/**
* Creates an instance of the IInventoryAccess implementation for the current server version.
*
* @return the IInventoryAccess
* @throws IllegalStateException if server version is unsupported
*/
public IInventoryAccess getInventoryAccess() {
if (!this.supported) {
throw new IllegalStateException(String.format("Unsupported server version %s!", this.version));
}
return this.inventoryAccess;
}
/**
* Creates an instance of the IPlayerDataManager implementation for the current server version.
*
* @return the IPlayerDataManager
* @throws IllegalStateException if server version is unsupported
*/
public IPlayerDataManager getPlayerDataManager() {
if (!this.supported) {
throw new IllegalStateException(String.format("Unsupported server version %s!", this.version));
}
return this.playerDataManager;
}
/**
* Gets the server implementation version. If not initialized, returns the string "null"
* instead.
*
* @return the version, or "null"
*/
public String getVersion() {
return this.version != null ? this.version : "null";
}
/**
* Checks if the server implementation is supported.
*
* @return true if initialized for a supported server version
*/
public boolean isSupported() {
return this.supported;
}
/**
* Creates an instance of the ISpecialEnderChest implementation for the given Player, or
* null if the current version is unsupported.
*
* @param player the Player
* @param online true if the Player is online
* @return the ISpecialEnderChest created
* @throws InstantiationException if the ISpecialEnderChest could not be instantiated
*/
public ISpecialEnderChest newSpecialEnderChest(final Player player, final boolean online) throws InstantiationException {
if (!this.supported) {
throw new IllegalStateException(String.format("Unsupported server version %s!", this.version));
}
try {
return this.createObject(ISpecialEnderChest.class, "SpecialEnderChest", player, online);
} catch (Exception e) {
throw new InstantiationException(String.format("Unable to create a new ISpecialEnderChest: %s", e.getMessage()));
}
}
/**
* Creates an instance of the ISpecialPlayerInventory implementation for the given Player..
*
* @param player the Player
* @param online true if the Player is online
* @return the ISpecialPlayerInventory created
* @throws InstantiationException if the ISpecialPlayerInventory could not be instantiated
*/
public ISpecialPlayerInventory newSpecialPlayerInventory(final Player player, final boolean online) throws InstantiationException {
if (!this.supported) {
throw new IllegalStateException(String.format("Unsupported server version %s!", this.version));
}
try {
return this.createObject(ISpecialPlayerInventory.class, "SpecialPlayerInventory", player, online);
} catch (Exception e) {
throw new InstantiationException(String.format("Unable to create a new ISpecialPlayerInventory: %s", e.getMessage()));
}
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_4_5</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_4_6</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,11 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvinternal</artifactId>
@@ -18,20 +18,16 @@
<profile>
<id>latest</id>
<modules>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
</modules>
</profile>
<profile>
<id>modern</id>
<id>recent</id>
<!-- The recent profile is for the most recent 2 versions. -->
<modules>
<module>v1_8_R1</module>
<module>v1_8_R2</module>
<module>v1_8_R3</module>
<module>v1_9_R1</module>
<module>v1_9_R2</module>
<module>v1_10_R1</module>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
</modules>
</profile>
@@ -60,9 +56,10 @@
<module>v1_9_R2</module>
<module>v1_10_R1</module>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
</modules>
</profile>
</profiles>
</project>
</project>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_10_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -211,4 +211,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_11_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -16,14 +16,14 @@
package com.lishid.openinv.internal.v1_11_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.inventory.InventoryView;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Block;
@@ -31,7 +31,6 @@ import net.minecraft.server.v1_11_R1.BlockChest;
import net.minecraft.server.v1_11_R1.BlockEnderChest;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.BlockShulkerBox;
import net.minecraft.server.v1_11_R1.Container;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityOcelot;
import net.minecraft.server.v1_11_R1.EntityPlayer;
@@ -40,18 +39,29 @@ import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.ITileInventory;
import net.minecraft.server.v1_11_R1.InventoryEnderChest;
import net.minecraft.server.v1_11_R1.InventoryLargeChest;
import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_11_R1.StatisticList;
import net.minecraft.server.v1_11_R1.TileEntity;
import net.minecraft.server.v1_11_R1.TileEntityChest;
import net.minecraft.server.v1_11_R1.TileEntityEnderChest;
import net.minecraft.server.v1_11_R1.TileEntityShulkerBox;
import net.minecraft.server.v1_11_R1.World;
import org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory;
import net.minecraft.server.v1_11_R1.EnumGamemode;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
public class AnySilentContainer implements IAnySilentContainer {
private Field playerInteractManagerGamemode;
public AnySilentContainer() {
try {
this.playerInteractManagerGamemode = PlayerInteractManager.class.getDeclaredField("gamemode");
this.playerInteractManagerGamemode.setAccessible(true);
} catch (Exception e) {
System.err.println("[OpenInv] Unable to directly write player gamemode! SilentChest will fail.");
e.printStackTrace();
}
}
@Override
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
@@ -123,7 +133,7 @@ public class AnySilentContainer implements IAnySilentContainer {
try {
// 1.11.2
return world.a(axisAlignedBB.a(blockPosition.shift(enumDirection)));
} catch (Exception e) {
} catch (NoSuchMethodError e) {
// 1.11
return world.b(axisAlignedBB.a(blockPosition.shift(enumDirection)));
}
@@ -186,7 +196,6 @@ public class AnySilentContainer implements IAnySilentContainer {
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
Container container = null;
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
@@ -218,68 +227,68 @@ public class AnySilentContainer implements IAnySilentContainer {
} else if (blockChest.g == BlockChest.Type.TRAP) {
player.b(StatisticList.getStatistic("stat.trappedChestTriggered"));
}
if (silentchest) {
container = new SilentContainerChest(player.inventory, tileInventory, player);
}
}
if (block instanceof BlockShulkerBox) {
player.b(StatisticList.getStatistic("stat.shulkerBoxOpened"));
if (silentchest && tileInventory instanceof TileEntityShulkerBox) {
// Set value to current + 1. Ensures consistency later when resetting.
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tileInventory,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tileInventory) + 1);
container = new SilentContainerShulkerBox(player.inventory, tileInventory, player);
}
}
// AnyChest only - SilentChest not active or container unsupported
if (!silentchest || container == null) {
// AnyChest only - SilentChest not active, container unsupported, or unnecessary.
if (!silentchest || player.playerInteractManager.getGameMode() == EnumGamemode.SPECTATOR) {
player.openContainer(tileInventory);
return true;
}
// SilentChest
// SilentChest requires access to setting players' gamemode directly.
if (this.playerInteractManagerGamemode == null) {
return false;
}
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.openContainer(tileInventory);
this.forceGameMode(player, gamemode);
return true;
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {
if (this.playerInteractManagerGamemode == null) {
return;
}
InventoryView view = bukkitPlayer.getOpenInventory();
switch (view.getType()) {
case CHEST:
case ENDER_CHEST:
case SHULKER_BOX:
break;
default:
return;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.activeContainer.b(player);
player.activeContainer = player.defaultContainer;
this.forceGameMode(player, gamemode);
}
private void forceGameMode(final EntityPlayer player, final EnumGamemode gameMode) {
if (this.playerInteractManagerGamemode == null) {
// No need to warn repeatedly, error on startup and lack of function should be enough.
return;
}
try {
// Call InventoryOpenEvent
container = CraftEventFactory.callInventoryOpenEvent(player, container, false);
if (container == null) {
return false;
if (!this.playerInteractManagerGamemode.isAccessible()) {
// Just in case, ensure accessible.
this.playerInteractManagerGamemode.setAccessible(true);
}
// Open window
int windowId = player.nextContainerCounter();
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, tileInventory.getContainerName(), tileInventory.getScoreboardDisplayName(), tileInventory.getSize()));
player.activeContainer = container;
player.activeContainer.windowId = windowId;
player.activeContainer.addSlotListener(player);
// Special handling for shulker boxes - reset value for viewers to what it was initially.
if (tile instanceof TileEntityShulkerBox) {
new BukkitRunnable() {
@Override
public void run() {
// TODO hacky
Object tile = world.getTileEntity(blockPosition);
if (!(tile instanceof TileEntityShulkerBox)) {
return;
}
TileEntityShulkerBox box = (TileEntityShulkerBox) tile;
// Reset back - we added 1, and calling TileEntityShulkerBox#startOpen adds 1 more.
SilentContainerShulkerBox.setOpenValue(box,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile) - 2);
}
}.runTaskLater(Bukkit.getPluginManager().getPlugin("OpenInv"), 2);
}
return true;
this.playerInteractManagerGamemode.set(player.playerInteractManager, gameMode);
} catch (Exception e) {
e.printStackTrace();
p.sendMessage(ChatColor.RED + "Error while sending silent container.");
return false;
}
}

View File

@@ -1,46 +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.v1_11_R1;
import net.minecraft.server.v1_11_R1.ContainerChest;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.IInventory;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
public SilentContainerChest(PlayerInventory playerInventory, IInventory iInventory,
EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
// Send close signal
iInventory.closeContainer(entityHuman);
}
@Override
public void b(EntityHuman entityHuman) {
// Don't send close signal twice, might screw up
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != ItemStack.a) {
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(ItemStack.a);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -1,56 +0,0 @@
package com.lishid.openinv.internal.v1_11_R1;
import java.lang.reflect.Field;
import net.minecraft.server.v1_11_R1.ContainerShulkerBox;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.IInventory;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.PlayerInventory;
import net.minecraft.server.v1_11_R1.TileEntityShulkerBox;
public class SilentContainerShulkerBox extends ContainerShulkerBox {
private static Field fieldShulkerActionData;
public SilentContainerShulkerBox(PlayerInventory playerInventory, IInventory iInventory,
EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
}
@Override
public void b(EntityHuman entityHuman) {
PlayerInventory playerinventory = entityHuman.inventory;
if (!playerinventory.getCarried().isEmpty()) {
entityHuman.drop(playerinventory.getCarried(), false);
playerinventory.setCarried(ItemStack.a);
}
}
private static Field exposeOpenStatus() throws NoSuchFieldException, SecurityException {
if (fieldShulkerActionData == null) {
fieldShulkerActionData = TileEntityShulkerBox.class.getDeclaredField("h");
fieldShulkerActionData.setAccessible(true);
}
return fieldShulkerActionData;
}
public static void setOpenValue(TileEntityShulkerBox tileShulkerBox, Object value) {
try {
exposeOpenStatus().set(tileShulkerBox, value);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Integer getOpenValue(TileEntityShulkerBox tileShulkerBox) {
try {
return (Integer) exposeOpenStatus().get(tileShulkerBox);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
}

41
internal/v1_12_R1/pom.xml Normal file
View File

@@ -0,0 +1,41 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_12_R1</artifactId>
<name>OpenInvAdapter1_12_R1</name>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,287 @@
/*
* 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.v1_12_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
import net.minecraft.server.v1_12_R1.Block;
import net.minecraft.server.v1_12_R1.BlockChest;
import net.minecraft.server.v1_12_R1.BlockEnderChest;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.BlockShulkerBox;
import net.minecraft.server.v1_12_R1.Entity;
import net.minecraft.server.v1_12_R1.EntityOcelot;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumDirection;
import net.minecraft.server.v1_12_R1.EnumGamemode;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.ITileInventory;
import net.minecraft.server.v1_12_R1.InventoryEnderChest;
import net.minecraft.server.v1_12_R1.InventoryLargeChest;
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import net.minecraft.server.v1_12_R1.TileEntity;
import net.minecraft.server.v1_12_R1.TileEntityChest;
import net.minecraft.server.v1_12_R1.TileEntityEnderChest;
import net.minecraft.server.v1_12_R1.TileEntityShulkerBox;
import net.minecraft.server.v1_12_R1.World;
public class AnySilentContainer implements IAnySilentContainer {
private Field playerInteractManagerGamemode;
public AnySilentContainer() {
try {
this.playerInteractManagerGamemode = PlayerInteractManager.class.getDeclaredField("gamemode");
this.playerInteractManagerGamemode.setAccessible(true);
} catch (NoSuchFieldException | SecurityException e) {
System.err.println("[OpenInv] Unable to directly write player gamemode! SilentChest will fail.");
e.printStackTrace();
}
}
@Override
public boolean activateContainer(final Player bukkitPlayer, final boolean silentchest,
final org.bukkit.block.Block bukkitBlock) {
// Silent ender chest is API-only
if (silentchest && bukkitBlock.getType() == Material.ENDER_CHEST) {
bukkitPlayer.openInventory(bukkitPlayer.getEnderChest());
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
final World world = player.world;
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
final Object tile = world.getTileEntity(blockPosition);
if (tile == null) {
return false;
}
if (tile instanceof TileEntityEnderChest) {
// Anychest ender chest. See net.minecraft.server.BlockEnderChest
InventoryEnderChest enderChest = player.getEnderChest();
enderChest.a((TileEntityEnderChest) tile);
player.openContainer(enderChest);
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
if (!(tile instanceof ITileInventory)) {
return false;
}
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
Block localBlock = world.getType(localBlockPosition).getBlock();
if (localBlock != block) {
continue;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
}
if (localEnumDirection == EnumDirection.WEST
|| localEnumDirection == EnumDirection.NORTH) {
tileInventory = new InventoryLargeChest("container.chestDouble",
(TileEntityChest) localTileEntity, tileInventory);
} else {
tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory,
(TileEntityChest) localTileEntity);
}
break;
}
BlockChest blockChest = (BlockChest) block;
if (blockChest.g == BlockChest.Type.BASIC) {
bukkitPlayer.incrementStatistic(Statistic.CHEST_OPENED);
} else if (blockChest.g == BlockChest.Type.TRAP) {
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
}
}
if (block instanceof BlockShulkerBox) {
bukkitPlayer.incrementStatistic(Statistic.SHULKER_BOX_OPENED);
}
// AnyChest only - SilentChest not active, container unsupported, or unnecessary.
if (!silentchest || player.playerInteractManager.getGameMode() == EnumGamemode.SPECTATOR) {
player.openContainer(tileInventory);
return true;
}
// SilentChest requires access to setting players' gamemode directly.
if (this.playerInteractManagerGamemode == null) {
return false;
}
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.openContainer(tileInventory);
this.forceGameMode(player, gamemode);
return true;
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {
if (this.playerInteractManagerGamemode == null) {
return;
}
InventoryView view = bukkitPlayer.getOpenInventory();
switch (view.getType()) {
case CHEST:
case ENDER_CHEST:
case SHULKER_BOX:
break;
default:
return;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.activeContainer.b(player);
player.activeContainer = player.defaultContainer;
this.forceGameMode(player, gamemode);
}
private void forceGameMode(final EntityPlayer player, final EnumGamemode gameMode) {
if (this.playerInteractManagerGamemode == null) {
// No need to warn repeatedly, error on startup and lack of function should be enough.
return;
}
try {
if (!this.playerInteractManagerGamemode.isAccessible()) {
// Just in case, ensure accessible.
this.playerInteractManagerGamemode.setAccessible(true);
}
this.playerInteractManagerGamemode.set(player.playerInteractManager, gameMode);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
private boolean hasOcelotOnTop(final World world, final BlockPosition blockPosition) {
for (Entity localEntity : world.a(EntityOcelot.class,
new AxisAlignedBB(blockPosition.getX(), blockPosition.getY() + 1,
blockPosition.getZ(), blockPosition.getX() + 1, blockPosition.getY() + 2,
blockPosition.getZ() + 1))) {
EntityOcelot localEntityOcelot = (EntityOcelot) localEntity;
if (localEntityOcelot.isSitting()) {
return true;
}
}
return false;
}
@Override
public boolean isAnyContainerNeeded(final Player p, final org.bukkit.block.Block b) {
EntityPlayer player = PlayerDataManager.getHandle(p);
World world = player.world;
BlockPosition blockPosition = new BlockPosition(b.getX(), b.getY(), b.getZ());
IBlockData blockData = world.getType(blockPosition);
Block block = blockData.getBlock();
if (block instanceof BlockShulkerBox) {
return this.isBlockedShulkerBox(world, blockPosition, blockData);
}
if (block instanceof BlockEnderChest) {
// Ender chests are not blocked by ocelots.
return world.getType(blockPosition.up()).m();
}
// Check if chest is blocked or has an ocelot on top
if (this.isBlockedChest(world, blockPosition)) {
return true;
}
// Check for matching adjacent chests that are blocked or have an ocelot on top
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
Block localBlock = world.getType(localBlockPosition).getBlock();
if (localBlock != block) {
continue;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
}
if (this.isBlockedChest(world, localBlockPosition)) {
return true;
}
}
return false;
}
@Override
public boolean isAnySilentContainer(final org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
return true;
}
BlockState state = block.getState();
return state instanceof org.bukkit.block.Chest
|| state instanceof org.bukkit.block.ShulkerBox;
}
private boolean isBlockedChest(final World world, final BlockPosition blockPosition) {
// For reference, loot at net.minecraft.server.BlockChest
return world.getType(blockPosition.up()).l() || this.hasOcelotOnTop(world, blockPosition);
}
private boolean isBlockedShulkerBox(final World world, final BlockPosition blockPosition,
final IBlockData blockData) {
// For reference, look at net.minecraft.server.BlockShulkerBox
TileEntity tile = world.getTileEntity(blockPosition);
if (!(tile instanceof TileEntityShulkerBox)) {
return false;
}
EnumDirection enumDirection = blockData.get(BlockShulkerBox.a);
if (((TileEntityShulkerBox) tile).p() == TileEntityShulkerBox.AnimationPhase.CLOSED) {
AxisAlignedBB axisAlignedBB = Block.j.b(0.5F * enumDirection.getAdjacentX(),
0.5F * enumDirection.getAdjacentY(), 0.5F * enumDirection.getAdjacentZ())
.a(enumDirection.getAdjacentX(), enumDirection.getAdjacentY(),
enumDirection.getAdjacentZ());
return world.a(axisAlignedBB.a(blockPosition.shift(enumDirection)));
}
return false;
}
}

View File

@@ -0,0 +1,74 @@
/*
* 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.v1_12_R1;
import com.lishid.openinv.internal.IInventoryAccess;
import com.lishid.openinv.internal.ISpecialEnderChest;
import com.lishid.openinv.internal.ISpecialPlayerInventory;
import com.lishid.openinv.util.InternalAccessor;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_12_R1.IInventory;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory;
public class InventoryAccess implements IInventoryAccess {
@Override
public ISpecialEnderChest getSpecialEnderChest(final Inventory inventory) {
IInventory inv;
if (inventory instanceof CraftInventory) {
inv = ((CraftInventory) inventory).getInventory();
} else {
inv = InternalAccessor.grabFieldOfTypeFromObject(IInventory.class, inventory);
}
if (inv instanceof SpecialEnderChest) {
return (SpecialEnderChest) inv;
}
return null;
}
@Override
public ISpecialPlayerInventory getSpecialPlayerInventory(final Inventory inventory) {
IInventory inv;
if (inventory instanceof CraftInventory) {
inv = ((CraftInventory) inventory).getInventory();
} else {
inv = InternalAccessor.grabFieldOfTypeFromObject(IInventory.class, inventory);
}
if (inv instanceof SpecialPlayerInventory) {
return (SpecialPlayerInventory) inv;
}
return null;
}
@Override
public boolean isSpecialEnderChest(final Inventory inventory) {
if (inventory instanceof CraftInventory) {
return ((CraftInventory) inventory).getInventory() instanceof ISpecialEnderChest;
}
return InternalAccessor.grabFieldOfTypeFromObject(IInventory.class,
inventory) instanceof ISpecialEnderChest;
}
@Override
public boolean isSpecialPlayerInventory(final Inventory inventory) {
if (inventory instanceof CraftInventory) {
return ((CraftInventory) inventory).getInventory() instanceof ISpecialPlayerInventory;
}
return InternalAccessor.grabFieldOfTypeFromObject(IInventory.class,
inventory) instanceof ISpecialPlayerInventory;
}
}

View File

@@ -0,0 +1,104 @@
/*
* 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.v1_12_R1;
import java.util.Collection;
import java.util.UUID;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
public class PlayerDataManager implements IPlayerDataManager {
public static EntityPlayer getHandle(final Player player) {
if (player instanceof CraftPlayer) {
return ((CraftPlayer) player).getHandle();
}
Server server = player.getServer();
EntityPlayer nmsPlayer = null;
if (server instanceof CraftServer) {
nmsPlayer = ((CraftServer) server).getHandle().getPlayer(player.getName());
}
if (nmsPlayer == null) {
// Could use reflection to examine fields, but it's honestly not worth the bother.
throw new RuntimeException(
"Unable to fetch EntityPlayer from provided Player implementation");
}
return nmsPlayer;
}
@Override
public Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@Override
public OfflinePlayer getPlayerByID(final String identifier) {
try {
UUID uuid = UUID.fromString(identifier);
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
// Ensure player is a real player, otherwise return null
if (player == null || !player.hasPlayedBefore() && !player.isOnline()) {
return null;
}
return player;
} catch (IllegalArgumentException e) {
// Not a UUID
return null;
}
}
@Override
public String getPlayerDataID(final OfflinePlayer player) {
return player.getUniqueId().toString();
}
@Override
public Player loadPlayer(final OfflinePlayer offline) {
// Ensure player has data
if (offline == null || !offline.hasPlayedBefore()) {
return null;
}
// Create a profile and entity to load the player data
GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile,
new PlayerInteractManager(server.getWorldServer(0)));
// Get the bukkit entity
Player target = entity == null ? null : entity.getBukkitEntity();
if (target != null) {
// Load data
target.loadData();
}
// Return the entity
return target;
}
}

View File

@@ -0,0 +1,101 @@
/*
* 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.v1_12_R1;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;
import com.lishid.openinv.internal.ISpecialEnderChest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.IInventory;
import net.minecraft.server.v1_12_R1.InventoryEnderChest;
import net.minecraft.server.v1_12_R1.InventorySubcontainer;
import net.minecraft.server.v1_12_R1.ItemStack;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory;
public class SpecialEnderChest extends InventorySubcontainer
implements IInventory, ISpecialEnderChest {
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
public SpecialEnderChest(final Player player, final Boolean online) {
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().hasCustomName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.bukkitOwner = nmsPlayer.getBukkitEntity();
this.setItemLists(this, this.enderChest.getContents());
}
@Override
public Inventory getBukkitInventory() {
return this.inventory;
}
@Override
public boolean isInUse() {
return !this.getViewers().isEmpty();
}
private void setItemLists(final InventorySubcontainer subcontainer,
final List<ItemStack> list) {
try {
// Prepare to remove final modifier
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
// Access and replace main inventory array
Field field = InventorySubcontainer.class.getField("items");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(subcontainer, list);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
@Override
public void setPlayerOffline() {
this.playerOnline = false;
}
@Override
public void setPlayerOnline(final Player player) {
if (!this.playerOnline) {
try {
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.bukkitOwner = nmsPlayer.getBukkitEntity();
this.setItemLists(nmsPlayer.getEnderChest(), this.items);
} catch (Exception e) {}
this.playerOnline = true;
}
}
@Override
public void update() {
super.update();
this.enderChest.update();
}
}

View File

@@ -0,0 +1,255 @@
/*
* 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.v1_12_R1;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import com.lishid.openinv.internal.ISpecialPlayerInventory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_12_R1.ContainerUtil;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.PlayerInventory;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory;
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
public SpecialPlayerInventory(final Player bukkitPlayer, final Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));
this.playerOnline = online;
this.setItemArrays(this, this.player.inventory.items, this.player.inventory.armor,
this.player.inventory.extraSlots);
}
@Override
public boolean a(final EntityHuman entityhuman) {
return true;
}
@Override
public Inventory getBukkitInventory() {
return this.inventory;
}
@Override
public ItemStack getItem(int i) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
return ItemStack.a;
}
return list.get(i);
}
@Override
public String getName() {
if (this.player.getName().length() > 16) {
return this.player.getName().substring(0, 16);
}
return this.player.getName();
}
private int getReversedArmorSlotNum(final int i) {
if (i == 0) {
return 3;
}
if (i == 1) {
return 2;
}
if (i == 2) {
return 1;
}
if (i == 3) {
return 0;
}
return i;
}
private int getReversedItemSlotNum(final int i) {
if (i >= 27) {
return i - 27;
}
return i + 9;
}
@Override
public int getSize() {
return super.getSize() + 4;
}
@Override
public boolean isInUse() {
return !this.getViewers().isEmpty();
}
@Override
public void setItem(int i, final ItemStack itemstack) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
this.player.drop(itemstack, true);
return;
}
if (list != null) {
list.set(i, itemstack);
}
}
private void setItemArrays(final PlayerInventory inventory, final NonNullList<ItemStack> items,
final NonNullList<ItemStack> armor, final NonNullList<ItemStack> extraSlots) {
try {
// Prepare to remove final modifier
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
// Access and replace main inventory list
Field field = PlayerInventory.class.getField("items");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, items);
// Access and replace armor inventory list
field = PlayerInventory.class.getField("armor");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, armor);
// Access and replace offhand inventory list
field = PlayerInventory.class.getField("extraSlots");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, extraSlots);
// Access and replace list containing all inventory lists
field = PlayerInventory.class.getDeclaredField("f");
field.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, Arrays.asList(new NonNullList[] { items, armor, extraSlots }));
} catch (NoSuchFieldException e) {
// Unable to set final fields to item lists, we're screwed. Noisily fail.
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
@Override
public void setPlayerOffline() {
this.playerOnline = false;
}
@Override
public void setPlayerOnline(final Player player) {
if (!this.playerOnline) {
this.player = PlayerDataManager.getHandle(player);
;
this.setItemArrays(this.player.inventory, this.items, this.armor, this.extraSlots);
this.playerOnline = true;
}
}
@Override
public ItemStack splitStack(int i, final int j) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
return ItemStack.a;
}
return list == null || list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
}
@Override
public ItemStack splitWithoutUpdate(int i) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
return ItemStack.a;
}
if (list != null && !list.get(i).isEmpty()) {
ItemStack itemstack = list.get(i);
list.set(i, ItemStack.a);
return itemstack;
}
return ItemStack.a;
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_4_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_5_R2</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_5_R3</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_6_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_6_R2</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_6_R3</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_7_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -166,4 +166,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_7_R2</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -166,4 +166,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_7_R3</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -166,4 +166,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_7_R4</artifactId>
@@ -27,7 +27,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -166,4 +166,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_8_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -210,4 +210,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_8_R2</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -211,4 +211,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_8_R3</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -211,4 +211,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_9_R1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>
</project>

View File

@@ -211,4 +211,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvadapter1_9_R2</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -211,4 +211,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvplugin</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvplugincore</artifactId>
@@ -22,12 +22,12 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvpluginv1_10_r1</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -1,38 +1,39 @@
/*
* 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.commands;
import com.lishid.openinv.OpenInv;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
public class AnyChestPluginCommand implements CommandExecutor {
private final OpenInv plugin;
public AnyChestPluginCommand(OpenInv plugin) {
public AnyChestPluginCommand(final OpenInv plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
return true;
@@ -41,12 +42,12 @@ public class AnyChestPluginCommand implements CommandExecutor {
Player player = (Player) sender;
if (args.length > 0 && args[0].equalsIgnoreCase("check")) {
sender.sendMessage("AnyChest is " + (plugin.getPlayerAnyChestStatus(player) ? "ON" : "OFF") + ".");
sender.sendMessage("AnyChest is " + (this.plugin.getPlayerAnyChestStatus(player) ? "ON" : "OFF") + ".");
return true;
}
plugin.setPlayerAnyChestStatus(player, !plugin.getPlayerAnyChestStatus(player));
sender.sendMessage("AnyChest is now " + (plugin.getPlayerAnyChestStatus(player) ? "ON" : "OFF") + ".");
this.plugin.setPlayerAnyChestStatus(player, !this.plugin.getPlayerAnyChestStatus(player));
sender.sendMessage("AnyChest is now " + (this.plugin.getPlayerAnyChestStatus(player) ? "ON" : "OFF") + ".");
return true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
@@ -35,30 +35,30 @@ public class OpenEnderPluginCommand implements CommandExecutor {
private final OpenInv plugin;
private final HashMap<Player, String> openEnderHistory = new HashMap<Player, String>();
public OpenEnderPluginCommand(OpenInv plugin) {
public OpenEnderPluginCommand(final OpenInv plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
return true;
}
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
plugin.showHelp((Player) sender);
this.plugin.showHelp((Player) sender);
return true;
}
final Player player = (Player) sender;
// History management
String history = openEnderHistory.get(player);
String history = this.openEnderHistory.get(player);
if (history == null || history == "") {
history = player.getName();
openEnderHistory.put(player, history);
this.openEnderHistory.put(player, history);
}
final String name;
@@ -73,7 +73,7 @@ public class OpenEnderPluginCommand implements CommandExecutor {
new BukkitRunnable() {
@Override
public void run() {
final OfflinePlayer offlinePlayer = plugin.matchPlayer(name);
final OfflinePlayer offlinePlayer = OpenEnderPluginCommand.this.plugin.matchPlayer(name);
if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
player.sendMessage(ChatColor.RED + "Player not found!");
@@ -86,24 +86,24 @@ public class OpenEnderPluginCommand implements CommandExecutor {
if (!player.isOnline()) {
return;
}
openInventory(player, offlinePlayer);
OpenEnderPluginCommand.this.openInventory(player, offlinePlayer);
}
}.runTask(plugin);
}.runTask(OpenEnderPluginCommand.this.plugin);
}
}.runTaskAsynchronously(plugin);
}.runTaskAsynchronously(this.plugin);
return true;
}
private void openInventory(Player player, OfflinePlayer target) {
private void openInventory(final Player player, final OfflinePlayer target) {
Player onlineTarget;
boolean online = target.isOnline();
if (!online) {
// Try loading the player's data
onlineTarget = plugin.loadPlayer(target);
onlineTarget = this.plugin.loadPlayer(target);
if (onlineTarget == null) {
player.sendMessage(ChatColor.RED + "Player not found!");
@@ -118,21 +118,30 @@ public class OpenEnderPluginCommand implements CommandExecutor {
player.sendMessage(ChatColor.RED + "You do not have permission to access other players' enderchests.");
return;
}
if (!Permissions.CROSSWORLD.hasPermission(player) && !player.getWorld().equals(onlineTarget.getWorld())) {
if (!Permissions.CROSSWORLD.hasPermission(player)
&& !player.getWorld().equals(onlineTarget.getWorld())) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
return;
}
if (!Permissions.OVERRIDE.hasPermission(player) && Permissions.EXEMPT.hasPermission(onlineTarget)) {
if (!Permissions.OVERRIDE.hasPermission(player)
&& Permissions.EXEMPT.hasPermission(onlineTarget)) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
return;
}
}
// Record the target
openEnderHistory.put(player, onlineTarget.getName());
this.openEnderHistory.put(player, onlineTarget.getName());
// Create the inventory
ISpecialEnderChest chest = plugin.getEnderChest(onlineTarget, online);
ISpecialEnderChest chest;
try {
chest = this.plugin.getSpecialEnderChest(onlineTarget, online);
} catch (Exception e) {
player.sendMessage(ChatColor.RED + "An error occurred creating " + onlineTarget.getDisplayName() + "'s inventory!");
e.printStackTrace();
return;
}
// Open the inventory
player.openInventory(chest.getBukkitInventory());

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
@@ -35,30 +35,30 @@ public class OpenInvPluginCommand implements CommandExecutor {
private final OpenInv plugin;
private final HashMap<Player, String> openInvHistory = new HashMap<Player, String>();
public OpenInvPluginCommand(OpenInv plugin) {
public OpenInvPluginCommand(final OpenInv plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
return true;
}
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
plugin.showHelp((Player) sender);
this.plugin.showHelp((Player) sender);
return true;
}
final Player player = (Player) sender;
// History management
String history = openInvHistory.get(player);
String history = this.openInvHistory.get(player);
if (history == null || history == "") {
history = player.getName();
openInvHistory.put(player, history);
this.openInvHistory.put(player, history);
}
final String name;
@@ -73,7 +73,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
new BukkitRunnable() {
@Override
public void run() {
final OfflinePlayer offlinePlayer = plugin.matchPlayer(name);
final OfflinePlayer offlinePlayer = OpenInvPluginCommand.this.plugin.matchPlayer(name);
if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
player.sendMessage(ChatColor.RED + "Player not found!");
@@ -86,17 +86,17 @@ public class OpenInvPluginCommand implements CommandExecutor {
if (!player.isOnline()) {
return;
}
openInventory(player, offlinePlayer);
OpenInvPluginCommand.this.openInventory(player, offlinePlayer);
}
}.runTask(plugin);
}.runTask(OpenInvPluginCommand.this.plugin);
}
}.runTaskAsynchronously(plugin);
}.runTaskAsynchronously(this.plugin);
return true;
}
private void openInventory(Player player, OfflinePlayer target) {
private void openInventory(final Player player, final OfflinePlayer target) {
Player onlineTarget;
@@ -104,7 +104,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
if (!online) {
// Try loading the player's data
onlineTarget = plugin.loadPlayer(target);
onlineTarget = this.plugin.loadPlayer(target);
if (onlineTarget == null) {
player.sendMessage(ChatColor.RED + "Player not found!");
@@ -123,23 +123,34 @@ public class OpenInvPluginCommand implements CommandExecutor {
}
} else {
// Protected check
if (!Permissions.OVERRIDE.hasPermission(player) && Permissions.EXEMPT.hasPermission(onlineTarget)) {
if (!Permissions.OVERRIDE.hasPermission(player)
&& Permissions.EXEMPT.hasPermission(onlineTarget)) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
return;
}
// Crossworld check
if ((!Permissions.CROSSWORLD.hasPermission(player) && !Permissions.OVERRIDE.hasPermission(player)) && onlineTarget.getWorld() != player.getWorld()) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
if (!Permissions.CROSSWORLD.hasPermission(player)
&& !Permissions.OVERRIDE.hasPermission(player)
&& !onlineTarget.getWorld().equals(player.getWorld())) {
player.sendMessage(
ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
return;
}
}
// Record the target
openInvHistory.put(player, onlineTarget.getName());
this.openInvHistory.put(player, onlineTarget.getName());
// Create the inventory
ISpecialPlayerInventory inv = plugin.getInventory(onlineTarget, online);
ISpecialPlayerInventory inv;
try {
inv = this.plugin.getSpecialInventory(onlineTarget, online);
} catch (Exception e) {
player.sendMessage(ChatColor.RED + "An error occurred creating " + onlineTarget.getDisplayName() + "'s inventory!");
e.printStackTrace();
return;
}
// Open the inventory
player.openInventory(inv.getBukkitInventory());

View File

@@ -0,0 +1,36 @@
package com.lishid.openinv.listeners;
import com.lishid.openinv.IOpenInv;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
/**
*
*
* @author Jikoo
*/
public class InventoryCloseListener implements Listener {
private final IOpenInv plugin;
public InventoryCloseListener(final IOpenInv plugin) {
this.plugin = plugin;
}
@EventHandler
public void onInventoryClose(final InventoryCloseEvent event) {
if (!(event.getPlayer() instanceof Player)) {
return;
}
Player player = (Player) event.getPlayer();
if (this.plugin.getPlayerSilentChestStatus(player)) {
this.plugin.getAnySilentContainer().deactivateContainer(player);
}
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvplugin</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvpluginv1_10_r1</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
</parent>
<artifactId>openinvplugin</artifactId>

10
pom.xml
View File

@@ -6,7 +6,7 @@
<artifactId>openinvparent</artifactId>
<name>OpenInvParent</name>
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
<version>3.1.0</version>
<version>3.3.0</version>
<packaging>pom</packaging>
@@ -51,10 +51,10 @@
</profile>
<profile>
<id>modern</id>
<id>recent</id>
<activation>
<property>
<name>modern</name>
<name>recent</name>
<value>true</value>
</property>
</activation>
@@ -74,7 +74,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<version>3.0.0</version>
<configuration>
<filters>
<filter>
@@ -98,7 +98,7 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>