mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-28 19:12:09 +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'
|
apply plugin: 'eclipse'
|
||||||
|
|
||||||
group = 'com.sekwah.advancedportals'
|
group = 'com.sekwah.advancedportals'
|
||||||
version = '0.0.46-snapshot'
|
version = '0.0.47-snapshot'
|
||||||
|
|
||||||
description = ""
|
description = ""
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ public class CraftBukkit {
|
|||||||
private Constructor<?> blockPositionConstructor;
|
private Constructor<?> blockPositionConstructor;
|
||||||
private Method getWorldHandleMethod;
|
private Method getWorldHandleMethod;
|
||||||
private Method getTileEntityMethod;
|
private Method getTileEntityMethod;
|
||||||
|
private Field getEntityTimeoutField;
|
||||||
|
|
||||||
|
|
||||||
public CraftBukkit(AdvancedPortalsPlugin plugin, String bukkitImpl) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException {
|
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);
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -139,11 +148,9 @@ public class CraftBukkit {
|
|||||||
Object tileEntity = this.getTileEntityMethod.invoke(this.getWorldHandleMethod.invoke(block.getWorld()),
|
Object tileEntity = this.getTileEntityMethod.invoke(this.getWorldHandleMethod.invoke(block.getWorld()),
|
||||||
this.blockPositionConstructor.newInstance(block.getX(), block.getY(), block.getZ()));
|
this.blockPositionConstructor.newInstance(block.getX(), block.getY(), block.getZ()));
|
||||||
if(tileEntity.getClass().isAssignableFrom(this.tileEntityEndGatewayClass)) {
|
if(tileEntity.getClass().isAssignableFrom(this.tileEntityEndGatewayClass)) {
|
||||||
Field f = tileEntity.getClass().getDeclaredField("f");
|
getEntityTimeoutField.set(tileEntity, Integer.MAX_VALUE);
|
||||||
f.setAccessible(true);
|
|
||||||
f.set(tileEntity, Integer.MAX_VALUE);
|
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException| InvocationTargetException | InstantiationException | NoSuchFieldException e) {
|
} catch (IllegalAccessException| InvocationTargetException | InstantiationException e) {
|
||||||
this.plugin.getLogger().warning("Error setting gateway time");
|
this.plugin.getLogger().warning("Error setting gateway time");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||||
name: AdvancedPortals
|
name: AdvancedPortals
|
||||||
version: 0.0.46
|
version: 0.0.47
|
||||||
author: sekwah41
|
author: sekwah41
|
||||||
description: An advanced portals plugin for bukkit.
|
description: An advanced portals plugin for bukkit.
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
Loading…
Reference in New Issue
Block a user