mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-09-14 11:16:46 +08:00
Optimize fake player movement
This commit is contained in:
parent
f0b6375659
commit
4d22061c6c
@ -3,8 +3,7 @@ package io.github.hello09x.fakeplayer.core.command.impl;
|
|||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import dev.jorel.commandapi.executors.CommandExecutor;
|
import dev.jorel.commandapi.executors.CommandExecutor;
|
||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
import net.kyori.adventure.util.Ticks;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -36,12 +35,20 @@ public class MoveCommand extends AbstractCommand {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只移动 1 秒
|
var fakeId = fake.getUniqueId();
|
||||||
this.stopTasks.put(fake.getUniqueId(), Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
|
var stopping = new BukkitRunnable() {
|
||||||
handle.setXxa(0);
|
@Override
|
||||||
handle.setZza(0);
|
public void run() {
|
||||||
this.stopTasks.remove(fake.getUniqueId());
|
handle.setXxa(0);
|
||||||
}, Ticks.TICKS_PER_SECOND));
|
handle.setZza(0);
|
||||||
|
var self = stopTasks.get(fakeId);
|
||||||
|
if (self != null && self.getTaskId() == this.getTaskId()) {
|
||||||
|
stopTasks.remove(fakeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.stopTasks.put(fakeId, stopping.runTaskLater(Main.getInstance(), 20));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user