Update to Java 8 and Minecraft 1.8.8
This commit is contained in:
@@ -28,13 +28,6 @@
|
||||
<name>OpenInvCommon</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.5-R1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/bukkit-1.4.5-R1.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lishid</groupId>
|
||||
<artifactId>openinvapi</artifactId>
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.lishid.openinv.internal;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
@@ -35,29 +34,6 @@ public interface IPlayerDataManager {
|
||||
*/
|
||||
@Nullable Player loadPlayer(@NotNull OfflinePlayer offline);
|
||||
|
||||
/**
|
||||
* Gets a unique identifying string for an OfflinePlayer.
|
||||
*
|
||||
* @param offline the OfflinePlayer
|
||||
* @return the unique identifier
|
||||
*/
|
||||
@NotNull String getPlayerDataID(@NotNull OfflinePlayer offline);
|
||||
|
||||
/**
|
||||
* Gets an OfflinePlayer by the given unique identifier.
|
||||
*
|
||||
* @param identifier the unique identifier
|
||||
* @return the OfflinePlayer, or null if no exact match was found
|
||||
*/
|
||||
@Nullable OfflinePlayer getPlayerByID(@NotNull String identifier);
|
||||
|
||||
/**
|
||||
* Gets a Collection of all Players currently online.
|
||||
*
|
||||
* @return the Collection of Players
|
||||
*/
|
||||
@NotNull Collection<? extends Player> getOnlinePlayers();
|
||||
|
||||
/**
|
||||
* Opens an ISpecialInventory for a Player.
|
||||
*
|
||||
|
@@ -17,41 +17,20 @@
|
||||
package com.lishid.openinv.util;
|
||||
|
||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||
import com.lishid.openinv.internal.IInventoryAccess;
|
||||
import com.lishid.openinv.internal.IPlayerDataManager;
|
||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class InternalAccessor {
|
||||
|
||||
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()) {
|
||||
f.setAccessible(true);
|
||||
if (type.isAssignableFrom(f.getDeclaringClass())) {
|
||||
try {
|
||||
result = type.cast(f.get(object));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
@@ -65,9 +44,8 @@ public class InternalAccessor {
|
||||
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;
|
||||
this.supported = InventoryAccess.isUseable();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@@ -128,19 +106,6 @@ public class InternalAccessor {
|
||||
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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user