Win10版でブロックを右クリックしたまま少しでも視点をずらすと、大量にPlayerInteractEventが発生します。一定時間発生しないようにする以外に、根本的な解決策はないものでしょうか。
								どうしても解決したいならPCのみクリック制限つければいいかとWin10版でブロックを右クリックしたまま少しでも視点をずらすと、大量にPlayerInteractEventが発生します。一定時間発生しないようにする以外に、根本的な解決策はないものでしょうか。
それはどういう意味ですか?ユーザー側にクリックをしないようにお願いするということでしょうか?どうしても解決したいならPCのみクリック制限つければいいかと
それはどういう意味ですか?ユーザー側にクリックをしないようにお願いするということでしょうか?
<?
//namespace省略
//use文省略
class Main extends PluginBase implements Listener{
    public function onEnable(){
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
   
        $this->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, 'update'], []), 20);
    }
    public function onTouch(PlayerInteractEvent $event){
        $player = $event->getPlayer();
        $name = $player->getName();
        if(!isset($this->cooldown[$name])){
            $this->cooldown[$name] = true;
            //処理
        }elseif(!$this->cooldown[$name]){
            $this->cooldown[$name] = true;
            //処理
        }else{
            $this->cooldown[$name] = true;
        }
    }
    public function update(){
        $players = $this->getServer()->getOnlinePlayers();
        foreach($players as $player){
            $name = $player->getName();
            $this->cooldown[$name] = false;
        }
    }
}
class CallbackTask extends Task{
    protected $callable;
    protected $args;
    public function __construct(callable $callable, array $args = []){
        $this->callable = $callable;
        $this->args = $args;
    }
    public function getCallable(): callable{
        return $this->callable;
    }
    public function onRun(int $currentTicks){
        $c = $this->callable;
        $args = $this->args;
        $c(...$args);
    }
}元スレッドにあるように、一定時間発生しないようにする以外の方法がないかなので...こんな感じですかね、ユーザー全体連打を防止する機能見たいなやつですPHP:<? //namespace省略 //use文省略 class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, 'update'], []), 20); } public function onTouch(PlayerInteractEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); if(!isset($this->cooldown[$name])){ $this->cooldown[$name] = true; //処理 }elseif(!$this->cooldown[$name]){ $this->cooldown[$name] = true; //処理 }else{ $this->cooldown[$name] = true; } } public function update(){ $players = $this->getServer()->getOnlinePlayers(); foreach($players as $player){ $name = $player->getName(); $this->cooldown[$name] = false; } } } class CallbackTask extends Task{ protected $callable; protected $args; public function __construct(callable $callable, array $args = []){ $this->callable = $callable; $this->args = $args; } public function getCallable(): callable{ return $this->callable; } public function onRun(int $currentTicks){ $c = $this->callable; $args = $this->args; $c(...$args); } }
//処理の部分は同じ処理でいいかと思います
すみません、ちゃんと読んでいませんでした…それなら冬月さんが仰った通りWindows10の仕様なので根本的に解決するのは不可能かと思われます…お力になれずすみません┏○ペコッ元スレッドにあるように、一定時間発生しないようにする以外の方法がないかなので...
わざわざ教えていただいているのに申し訳ないのですが、これ以外のやり方を探してるんです...
 
				
		