mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-02 15:43:54 +01:00
Really rough delay when thottling hits
This commit is contained in:
parent
39cc0c7d0b
commit
7cb22cc1c5
@ -156,6 +156,7 @@ public class HumanController extends AbstractEntityController {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e.getMessage() != null && e.getMessage().contains("too many requests")) {
|
if (e.getMessage() != null && e.getMessage().contains("too many requests")) {
|
||||||
SKIN_THREAD.addRunnable(this);
|
SKIN_THREAD.addRunnable(this);
|
||||||
|
SKIN_THREAD.delay();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -179,14 +180,23 @@ public class HumanController extends AbstractEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SkinThread implements Runnable {
|
public static class SkinThread implements Runnable {
|
||||||
|
private volatile int delay = 0;
|
||||||
private final BlockingDeque<Runnable> tasks = new LinkedBlockingDeque<Runnable>();
|
private final BlockingDeque<Runnable> tasks = new LinkedBlockingDeque<Runnable>();
|
||||||
|
|
||||||
public void addRunnable(Runnable r) {
|
public void addRunnable(Runnable r) {
|
||||||
tasks.offer(r);
|
tasks.offer(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void delay() {
|
||||||
|
delay = 12;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (delay != 0) {
|
||||||
|
delay--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
Runnable r = tasks.pollFirst();
|
Runnable r = tasks.pollFirst();
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user