@@ -38,6 +38,7 @@ public class CraftBukkit {
38
38
private Constructor <?> blockPositionConstructor ;
39
39
private Method getWorldHandleMethod ;
40
40
private Method getTileEntityMethod ;
41
+ private Field getEntityTimeoutField ;
41
42
42
43
43
44
public CraftBukkit (AdvancedPortalsPlugin plugin , String bukkitImpl ) throws ClassNotFoundException , NoSuchFieldException , NoSuchMethodException {
@@ -79,7 +80,15 @@ public CraftBukkit(AdvancedPortalsPlugin plugin, String bukkitImpl) throws Class
79
80
80
81
getTileEntityMethod = Class .forName (minecraftPackage + "WorldServer" ).getMethod ("getTileEntity" , blockPos );
81
82
83
+ Field [] endGatewayFields = Class .forName (minecraftPackage + "TileEntityEndGateway" ).getDeclaredFields ();
82
84
85
+ for (Field field : endGatewayFields ) {
86
+ if (field .getType () == int .class && !field .isAccessible ()) {
87
+ field .setAccessible (true );
88
+ getEntityTimeoutField = field ;
89
+ return ;
90
+ }
91
+ }
83
92
84
93
} catch (Exception e ) {
85
94
e .printStackTrace ();
@@ -139,11 +148,9 @@ public void setGatewayAgeHigh(Block block) {
139
148
Object tileEntity = this .getTileEntityMethod .invoke (this .getWorldHandleMethod .invoke (block .getWorld ()),
140
149
this .blockPositionConstructor .newInstance (block .getX (), block .getY (), block .getZ ()));
141
150
if (tileEntity .getClass ().isAssignableFrom (this .tileEntityEndGatewayClass )) {
142
- Field f = tileEntity .getClass ().getDeclaredField ("f" );
143
- f .setAccessible (true );
144
- f .set (tileEntity , Integer .MAX_VALUE );
151
+ getEntityTimeoutField .set (tileEntity , Integer .MAX_VALUE );
145
152
}
146
- } catch (IllegalAccessException | InvocationTargetException | InstantiationException | NoSuchFieldException e ) {
153
+ } catch (IllegalAccessException | InvocationTargetException | InstantiationException e ) {
147
154
this .plugin .getLogger ().warning ("Error setting gateway time" );
148
155
e .printStackTrace ();
149
156
}
0 commit comments