mirror of
https://github.com/2006-Scape/Parabot-Randoms.git
synced 2026-07-07 16:49:11 +00:00
Merge pull request #16 from Parabot/bugfix/dreamscape-accessibly
Bugfix/dreamscape accessibly
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.parabot</groupId>
|
<groupId>org.parabot</groupId>
|
||||||
<artifactId>317-api-minified</artifactId>
|
<artifactId>317-api-minified</artifactId>
|
||||||
<version>1.15</version>
|
<version>1.201</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>*</artifactId>
|
<artifactId>*</artifactId>
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import org.parabot.core.reflect.RefClass;
|
|||||||
import org.parabot.core.reflect.RefField;
|
import org.parabot.core.reflect.RefField;
|
||||||
import org.parabot.environment.scripts.randoms.Random;
|
import org.parabot.environment.scripts.randoms.Random;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
@@ -23,17 +26,24 @@ public class SerialBanAvoider implements Random {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
RefClass client = new RefClass(Context.getInstance().getClient());
|
try {
|
||||||
RefField serial = client.getField(serialAddressField);
|
workAroundStaticValues(Context.getInstance().getClient().getClass(), serialAddressField, serialAddressValue);
|
||||||
if (serial != null) {
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
serial.set(serialAddressValue);
|
e.printStackTrace();
|
||||||
} else {
|
|
||||||
Core.verbose(String.format("Oh oh... Couldn't find field: %s", serialAddressField));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void workAroundStaticValues(Class clazz, String fieldName, Object newValue) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
Field field = clazz.getDeclaredField(fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
Field modifiers = field.getClass().getDeclaredField("modifiers");
|
||||||
|
modifiers.setAccessible(true);
|
||||||
|
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||||
|
field.set(null, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Serial ban avoider";
|
return "Serial ban avoider";
|
||||||
|
|||||||
Reference in New Issue
Block a user