mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-09-14 19:26:51 +08:00
Fix the issue where it didn't run as expected in the update suppressor.
This commit is contained in:
parent
5142ccd39f
commit
2f006a835d
@ -52,13 +52,17 @@ public abstract class BaseActionTicker implements ActionTicker {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var valid = this.action.tick();
|
try {
|
||||||
if (valid) {
|
if (this.action.tick()) {
|
||||||
if (this.setting.remains > 0) {
|
if (this.setting.remains > 0) {
|
||||||
this.setting.remains--;
|
this.setting.remains--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 声音更新抑制器会抛出异常, 但同样需要进入冷却
|
||||||
this.setting.wait = this.setting.interval;
|
this.setting.wait = this.setting.interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.hello09x.fakeplayer.core.manager.action;
|
package io.github.hello09x.fakeplayer.core.manager.action;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
|
import io.github.hello09x.fakeplayer.api.spi.ActionSetting;
|
||||||
@ -14,14 +15,18 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ActionManager {
|
public class ActionManager {
|
||||||
|
|
||||||
|
private final static Logger log = Main.getInstance().getLogger();
|
||||||
|
|
||||||
private final Map<UUID, Map<ActionType, ActionTicker>> managers = new HashMap<>();
|
private final Map<UUID, Map<ActionType, ActionTicker>> managers = new HashMap<>();
|
||||||
|
|
||||||
private final NMSBridge bridge;
|
private final NMSBridge bridge;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ActionManager(NMSBridge bridge) {
|
public ActionManager(NMSBridge bridge) {
|
||||||
this.bridge = bridge;
|
this.bridge = bridge;
|
||||||
@ -66,7 +71,14 @@ public class ActionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do tick
|
// do tick
|
||||||
entry.getValue().values().removeIf(ActionTicker::tick);
|
entry.getValue().values().removeIf(ticker -> {
|
||||||
|
try {
|
||||||
|
return ticker.tick();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.warning(Throwables.getStackTraceAsString(e));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
if (entry.getValue().isEmpty()) {
|
if (entry.getValue().isEmpty()) {
|
||||||
itr.remove();
|
itr.remove();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user