/** * Controls minecraft's thunderstorm flag in world data. * * @param world Bukkit world object * @param flag whether to set it to thundering or not */ public static void setThunderNoEvent(World world, boolean flag) { try { WorldData data = ((CraftWorld) world).getHandle().worldData; ReflectionHelper.field("isThundering").in(data).set(flag); ReflectionHelper.field("thunderTicks").in(data).set(flag ? Integer.MAX_VALUE : 0); } catch (Exception ex) { world.setStorm(true); // Can still set the storm } }
public static void setRenderDistance(World world, int distance) { try { ReflectionHelper.field("e") .in(ReflectionHelper.field("manager").in(((CraftWorld) world).getHandle()).get()) .set(distance); } catch (Exception ignored) { ignored.printStackTrace(); } }