Hey, so I am a decently new plygin maker. I know the basics have made a couple super simple plugins for my server but I want to start on a “Anti-Reach” Project where it notifies me when someone is hitting someone from more than a certain amount if blocks away. I dont know how to start at all. You dont have to baby me and give me the codes if you dont want maybe just explain what I need to use and what functions. Thanks guys hopefully you guys can help me
Dont be so basic. I dont even know what you mean by that. I mean thanks but can you explain it a bit more? Like what I have to make the event do
PHP: public function HIT(EntityDamageEvent $hit) {if($hit instanceof EntityDamageByEntityEvent) {if(($hit->getEntity() instanceof Player) and ($hit->getDamager() instanceof Player)) {//code}}}
PHP: public $hited = [];onDamage(){$this->hited[$p] = true;}if(isset($this->hited[$p])){ //ban him} something like that
PHP: public function onDamage(EntityDamageEvent $event) { if($event instanceof EntityDamageByEntityEvent) { $damager = $event->getDamager(); $damaged = $event->getEntity(); if($damaged instanceof Player and $damager instanceof Player) { $blocks = 6; // max distance allowed (can be float or int) if(ceil($damager->distance($damaged)) > $blocks) { $damager->kick("hacks", false); } } } }
PHP: /*** @param EntityDamageEvent $event*/public function onDamage(EntityDamageEvent $event){ $entity = $event->getEntity(); if($event instanceof EntityDamageByEntityEvent and $entity instanceof Player){ $damager = $event->getDamager(); if($damager instanceof Player){ if($damager->getGamemode() == Player::CREATIVE or $damager->getGamemode() == Player::SPECTATOR) return; $distance = $damager->distance($entity); $max = 3.9; //The Maximum amount of reach that i got when i was legit. if($distance > $max){ $event->setCancelled(true); $this->getLogger()->debug(TextFormat::RED . $damager->getName() . " got " . $distance . " of reach!"); } } }}
For what you do anticheats with the events you will have falses logs, The best anticheats it is to do them with the packets (DataPacket) and all ...
What are you saying ?? did u really test both of them at the same time before spreading probably fake informations ?