mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-10 06:48:06 +02:00
Add some settings to control NPC skin retries
This commit is contained in:
parent
fc8d7e104d
commit
954a3bd27b
@ -91,12 +91,14 @@ public class Settings {
|
||||
KEEP_CHUNKS_LOADED("npc.chunks.always-keep-loaded", false),
|
||||
LOCALE("general.translation.locale", ""),
|
||||
MAX_NPC_LIMIT_CHECKS("npc.limits.max-permission-checks", 100),
|
||||
MAX_NPC_SKIN_RETRIES("npc.skins.max-retries", -1),
|
||||
MAX_SPEED("npc.limits.max-speed", 100),
|
||||
MAX_TEXT_RANGE("npc.chat.options.max-text-range", 500),
|
||||
MESSAGE_COLOUR("general.color-scheme.message", "<a>"),
|
||||
NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder-open-doors", false),
|
||||
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75),
|
||||
NPC_COST("economy.npc.cost", 100D),
|
||||
NPC_SKIN_RETRY_DELAY("npc.skins.retry-delay", 120),
|
||||
PACKET_UPDATE_DELAY("npc.packets.update-delay", 30),
|
||||
QUICK_SELECT("npc.selection.quick-select", false),
|
||||
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
|
||||
|
@ -219,6 +219,7 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
public static class SkinThread implements Runnable {
|
||||
private volatile int delay = 0;
|
||||
private volatile int retryTimes = 0;
|
||||
private final BlockingDeque<Runnable> tasks = new LinkedBlockingDeque<Runnable>();
|
||||
|
||||
public void addRunnable(Runnable r) {
|
||||
@ -232,13 +233,18 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
public void delay() {
|
||||
delay = 120; // need to wait a minute before Mojang accepts API
|
||||
// calls again
|
||||
delay = Setting.NPC_SKIN_RETRY_DELAY.asInt();
|
||||
// need to wait before Mojang accepts API calls again
|
||||
retryTimes++;
|
||||
if (Setting.MAX_NPC_SKIN_RETRIES.asInt() >= 0 && retryTimes > Setting.MAX_NPC_SKIN_RETRIES.asInt()) {
|
||||
tasks.clear();
|
||||
retryTimes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (delay != 0) {
|
||||
if (delay > 0) {
|
||||
delay--;
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user