mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-27 10:31:34 +01:00
Changed reflection to grab the version by type rather than name
This commit is contained in:
parent
81e339172d
commit
accfda8d90
@ -4,7 +4,7 @@ apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
group = 'com.sekwah.advancedportals'
|
||||
version = '0.0.46-snapshot'
|
||||
version = '0.0.47-snapshot'
|
||||
|
||||
description = ""
|
||||
|
||||
|
@ -38,6 +38,7 @@ public class CraftBukkit {
|
||||
private Constructor<?> blockPositionConstructor;
|
||||
private Method getWorldHandleMethod;
|
||||
private Method getTileEntityMethod;
|
||||
private Field getEntityTimeoutField;
|
||||
|
||||
|
||||
public CraftBukkit(AdvancedPortalsPlugin plugin, String bukkitImpl) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException {
|
||||
@ -79,7 +80,15 @@ public class CraftBukkit {
|
||||
|
||||
getTileEntityMethod = Class.forName(minecraftPackage + "WorldServer").getMethod("getTileEntity", blockPos);
|
||||
|
||||
Field[] endGatewayFields = Class.forName(minecraftPackage + "TileEntityEndGateway").getDeclaredFields();
|
||||
|
||||
for(Field field : endGatewayFields) {
|
||||
if(field.getType() == int.class && !field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
getEntityTimeoutField = field;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -139,11 +148,9 @@ public class CraftBukkit {
|
||||
Object tileEntity = this.getTileEntityMethod.invoke(this.getWorldHandleMethod.invoke(block.getWorld()),
|
||||
this.blockPositionConstructor.newInstance(block.getX(), block.getY(), block.getZ()));
|
||||
if(tileEntity.getClass().isAssignableFrom(this.tileEntityEndGatewayClass)) {
|
||||
Field f = tileEntity.getClass().getDeclaredField("f");
|
||||
f.setAccessible(true);
|
||||
f.set(tileEntity, Integer.MAX_VALUE);
|
||||
getEntityTimeoutField.set(tileEntity, Integer.MAX_VALUE);
|
||||
}
|
||||
} catch (IllegalAccessException| InvocationTargetException | InstantiationException | NoSuchFieldException e) {
|
||||
} catch (IllegalAccessException| InvocationTargetException | InstantiationException e) {
|
||||
this.plugin.getLogger().warning("Error setting gateway time");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.0.46
|
||||
version: 0.0.47
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
api-version: 1.13
|
||||
|
Loading…
Reference in New Issue
Block a user