import java.util.ArrayList; import java.util.List; /** * 317HD / RLHD Hardware-Accelerated Graphics Plugin. * Exposes 317HD visual & performance settings in the Plugin Hub and synchronizes * with ClientSettings.HD_317 and HD317Pipeline. */ public class Hd317Plugin extends ClientPlugin { private boolean shadowsEnabled = true; private String shadowResolution = "1024"; private String shadowSoftness = "PCF 4-Tap"; private boolean dynamicLights = true; private boolean atmosphericFog = true; private int drawDistance = 25; private boolean groundTextures = true; private boolean normalMapping = true; private boolean waterShader = true; private int saturation = 100; private int brightness = 100; private boolean contrastCurve = true; @Override public String getName() { return "317 HD"; } @Override public String getDescription() { return "Hardware-accelerated OpenGL 317HD lighting, shadows, water, and textures."; } @Override public String getAuthor() { return "2006Scape"; } @Override public String getVersion() { return "1.0.0"; } @Override public boolean isEnabledByDefault() { return ClientSettings.HD_317; } @Override public List getConfigItems() { List list = new ArrayList<>(); list.add(new PluginConfigItem("shadowsEnabled", "Shadows", "Render directional sun shadows", shadowsEnabled)); list.add(new PluginConfigItem("shadowResolution", "Shadow Resolution", "Shadow map resolution (higher = sharper, slower)", shadowResolution, new String[]{"512", "1024", "2048"}).setVisibleWhen("shadowsEnabled")); list.add(new PluginConfigItem("shadowSoftness", "Shadow Quality", "1-Tap bilinear or 4-Tap soft PCF shadows", shadowSoftness, new String[]{"Hard (1-Tap)", "PCF 4-Tap"}).setVisibleWhen("shadowsEnabled")); list.add(new PluginConfigItem("dynamicLights", "Dynamic Lighting", "Point lights from fires, torches, braziers, and altars", dynamicLights)); list.add(new PluginConfigItem("atmosphericFog", "Atmospheric Fog", "Distance fog and regional color grading", atmosphericFog)); list.add(new PluginConfigItem("drawDistance", "Draw Distance", "Maximum render distance in tiles", drawDistance, 15, 55)); list.add(new PluginConfigItem("groundTextures", "Ground Textures", "Procedural 317HD ground textures and height splatting", groundTextures)); list.add(new PluginConfigItem("normalMapping", "Normal Mapping", "Surface bump detail and specular highlights", normalMapping)); list.add(new PluginConfigItem("waterShader", "HD Water Shader", "Animated dual-wave water with Fresnel sky reflection", waterShader)); list.add(new PluginConfigItem("saturation", "Saturation (%)", "Color saturation percentage", saturation, 50, 150)); list.add(new PluginConfigItem("brightness", "Brightness (%)", "Scene brightness percentage", brightness, 60, 140)); list.add(new PluginConfigItem("contrastCurve", "Contrast Tonemapping", "317HD S-curve contrast enhancement", contrastCurve)); return list; } @Override public void onConfigChanged(String key, Object value) { if ("shadowsEnabled".equals(key)) { shadowsEnabled = (Boolean) value; HD317Pipeline.cfgShadowsEnabled = shadowsEnabled; } else if ("shadowResolution".equals(key)) { shadowResolution = String.valueOf(value); try { HD317Pipeline.cfgShadowResolution = Integer.parseInt(shadowResolution); } catch (NumberFormatException ignored) { HD317Pipeline.cfgShadowResolution = 1024; } } else if ("shadowSoftness".equals(key)) { shadowSoftness = String.valueOf(value); HD317Pipeline.cfgShadowSoftPcf = !"Hard (1-Tap)".equals(shadowSoftness); } else if ("dynamicLights".equals(key)) { dynamicLights = (Boolean) value; HD317Pipeline.cfgDynamicLights = dynamicLights; } else if ("atmosphericFog".equals(key)) { atmosphericFog = (Boolean) value; HD317Pipeline.cfgAtmosphericFog = atmosphericFog; } else if ("drawDistance".equals(key)) { drawDistance = ((Number) value).intValue(); WorldController.drawDistance = Math.max(15, Math.min(55, drawDistance)); } else if ("groundTextures".equals(key)) { groundTextures = (Boolean) value; HD317Pipeline.cfgGroundTextures = groundTextures; } else if ("normalMapping".equals(key)) { normalMapping = (Boolean) value; HD317Pipeline.cfgNormalMapping = normalMapping; } else if ("waterShader".equals(key)) { waterShader = (Boolean) value; HD317Pipeline.cfgWaterShader = waterShader; } else if ("saturation".equals(key)) { saturation = ((Number) value).intValue(); HD317Pipeline.cfgSaturation = saturation / 100.0f; } else if ("brightness".equals(key)) { brightness = ((Number) value).intValue(); HD317Pipeline.cfgBrightness = brightness / 100.0f; } else if ("contrastCurve".equals(key)) { contrastCurve = (Boolean) value; HD317Pipeline.cfgContrastCurve = contrastCurve; } } private void syncAllConfig() { HD317Pipeline.cfgShadowsEnabled = shadowsEnabled; try { HD317Pipeline.cfgShadowResolution = Integer.parseInt(shadowResolution); } catch (NumberFormatException ignored) { HD317Pipeline.cfgShadowResolution = 1024; } HD317Pipeline.cfgShadowSoftPcf = !"Hard (1-Tap)".equals(shadowSoftness); HD317Pipeline.cfgDynamicLights = dynamicLights; HD317Pipeline.cfgAtmosphericFog = atmosphericFog; WorldController.drawDistance = Math.max(15, Math.min(55, drawDistance)); HD317Pipeline.cfgGroundTextures = groundTextures; HD317Pipeline.cfgNormalMapping = normalMapping; HD317Pipeline.cfgWaterShader = waterShader; HD317Pipeline.cfgSaturation = saturation / 100.0f; HD317Pipeline.cfgBrightness = brightness / 100.0f; HD317Pipeline.cfgContrastCurve = contrastCurve; } @Override public void onStart(PluginContext ctx) { super.onStart(ctx); syncAllConfig(); if (ctx != null && ctx.getGame() != null && !ClientSettings.HD_317) { ctx.getGame().setHD317Enabled(true); } } @Override public void onStop() { if (ctx != null && ctx.getGame() != null && ClientSettings.HD_317) { ctx.getGame().setHD317Enabled(false); } } @Override public boolean handlesCommandsWhenDisabled() { return true; } @Override public boolean onCommand(String command, String[] args) { if ("hd".equalsIgnoreCase(command) || "317hd".equalsIgnoreCase(command)) { if (PluginManager.get() != null) { PluginManager.get().togglePlugin(this); } return true; } return false; } }