Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Updated PiggyAntiCheats. Now simple!
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jun 19, 2017
1 parent 9b35c8e commit 7776b5d
Show file tree
Hide file tree
Showing 16 changed files with 562 additions and 164 deletions.
18 changes: 18 additions & 0 deletions .idea/PiggyAntiCheats.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/dictionaries/Kevin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

443 changes: 443 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2017 MCPEPIG
Copyright 2017 DaPigGuy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PiggyAntiCheats [![Poggit-CI](https://poggit.pmmp.io/ci.badge/MCPEPIG/PiggyAntiCheats/PiggyAntiCheats/master)](https://poggit.pmmp.io/ci.badge/MCPEPIG/PiggyAntiCheats/PiggyAntiCheats/master)
Get rid of those pesky modders!
Get rid of those pesky hackers!

# Changelog

###v1.0.0
* Speed detection
###v1.0.0 REBOOT
* First release

# Mods Prevented
* Fly
* No clip
* Speed

4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: PiggyAntiCheats
main: PiggyAntiCheats\Main
version: 1.0.0
api: [2.0.0, 3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3, 3.0.0-ALPHA4]
author: MCPEPIG
api: [3.0.0-ALPHA5]
author: DaPigGuy
permissions:
piggyanticheats:
default: op
Expand Down
7 changes: 0 additions & 7 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
#`---'.| `--'' \ \ .'
# `---` `---`

detection:
#Speed needed to be detected (blocks per second)
speed: 2
#Blocks up needed to be detected (blocks per second)
jump: 2
#Distance above ground to detect fly
fly: 3
punishment:
#How many points needed before a punishment
points-til-punishment: 10
Expand Down
7 changes: 1 addition & 6 deletions resources/lang_eng.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
too-fast: "&c[PAC] {player} is going {speed} per second."
fly: "&c[PAC] {player} is trying to fly."
no-clip: "&c[PAC] {player} is trying to use no-clip."
high-jump: "&c[PAC] {player} is jumping {blocks} per second."
notifications:
enabled: "&c[PAC] &aNotifications enabled."
disabled: "&c[PAC] Notifications disabled."
no-clip: "&c[PAC] {player} is trying to use no-clip."
33 changes: 0 additions & 33 deletions src/PiggyAntiCheats/Commands/PACCommand.php

This file was deleted.

69 changes: 27 additions & 42 deletions src/PiggyAntiCheats/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,56 @@

namespace PiggyAntiCheats;

use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerMoveEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\event\Listener;
use pocketmine\network\protocol\AdventureSettingsPacket;
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;

class EventListener implements Listener {
public function __construct($plugin) {
$this->plugin = $plugin;
}

public function onJoin(PlayerJoinEvent $event) {
$player = $event->getPlayer();
if ($player->hasPermission("piggyanticheat.notify")) {
$this->plugin->notified[$player->getName()] = true;
}
}
/**
* Class EventListener
* @package PiggyAntiCheats
*/
class EventListener implements Listener
{
private $plugin;

public function onMove(PlayerMoveEvent $event) {
$player = $event->getPlayer();
$from = $event->getFrom();
$to = $event->getTo();
$this->plugin->blocks[$player->getName()] = + pow($to->x - $from->x, 2) + pow($to->z - $from->z, 2); //Don't get distance for y
$this->plugin->blocksup[$player->getName()] = + ($to->y - $from->y); //Returns negative if going down :)
//Fly
$distance = round($this->plugin->blocksup[$player->getName()], 3) * 1000;
$maxblock = $this->plugin->getConfig()->getNested("detection.jump");
if ($player->getEffect(8) !== null) {
$maxblock = $maxblock + ($player->getEffect(8)->getAmplifier() / 8 + 0.46);
}
if ($this->plugin->secondinair[$player->getName()] > 1 && $distance >= 0 && $player->getAllowFlight() !== true && $distance < $maxblocks) {
$ground = $player->getLevel()->getHighestBlockAt(floor($to->x), floor($to->z));
if ($to->y - $this->getConfig()->getNested("detection.fly") > $ground) {
foreach ($this->plugin->getServer()->getOnlinePlayers() as $p) {
if ($p->hasPermission("piggyanticheat.notify") && isset($this->plugin->notified[$player->getName()])) {
$player->sendMessage(str_replace("{player}", $player->getName(), $this->plugin->getMessage("fly")));
}
}
$event->setCancelled();
}
}
/**
* EventListener constructor.
* @param Main $plugin
*/
public function __construct(Main $plugin)
{
$this->plugin = $plugin;
}

public function onQuit(PlayerQuitEvent $event) {
/**
* @param PlayerQuitEvent $event
*/
public function onQuit(PlayerQuitEvent $event)
{
$player = $event->getPlayer();
unset($this->plugin->blocks[$player->getName()]);
unset($this->plugin->points[$player->getName()]);
}

public function onRecieve(DataPacketReceiveEvent $event) {
/**
* @param DataPacketReceiveEvent $event
*/
public function onRecieve(DataPacketReceiveEvent $event)
{
$player = $event->getPlayer();
$packet = $event->getPacket();
if ($packet instanceof AdventureSettingsPacket) {
if (($packet->allowFlight || $packet->isFlying) && $player->getAllowFlight() !== true) {
foreach ($this->plugin->getServer()->getOnlinePlayers() as $p) {
if ($p->hasPermission("piggyanticheat.notify") && isset($this->plugin->notified[$player->getName()])) {
if ($p->hasPermission("piggyanticheat.notify")) {
$player->sendMessage(str_replace("{player}", $player->getName(), $this->plugin->getMessage("fly")));
}
}
$this->plugin->points[$player->getName()]++;
}
if ($packet->noClip && $player->isSpectator() !== true) {
foreach ($this->plugin->getServer()->getOnlinePlayers() as $p) {
if ($p->hasPermission("piggyanticheat.notify") && isset($this->plugin->notified[$player->getName()])) {
if ($p->hasPermission("piggyanticheat.notify")) {
$player->sendMessage(str_replace("{player}", $player->getName(), $this->plugin->getMessage("no-clip")));
}
}
Expand Down
23 changes: 14 additions & 9 deletions src/PiggyAntiCheats/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

namespace PiggyAntiCheats;

use PiggyAntiCheats\Commands\PACCommand;
use PiggyAntiCheats\Tasks\AntiCheatsTick;

use pocketmine\plugin\PluginBase;
use pocketmine\utils\Config;

class Main extends PluginBase {
public $blocks;
public $blocksup;
public $secondinair;
/**
* Class Main
* @package PiggyAntiCheats
*/
class Main extends PluginBase
{
public $points;
public $notified;
public $lang;

public function onEnable() {
public function onEnable()
{
$this->saveDefaultConfig();
if (!file_exists($this->getDataFolder() . "lang_" . $this->getConfig()->getNested("message.lang") . ".yml")) {
if ($this->getResource("lang_" . $this->getConfig()->getNested("message.lang") . ".yml") !== null) {
Expand All @@ -32,13 +33,17 @@ public function onEnable() {
} else {
$this->lang = new Config($this->getDataFolder() . "lang_" . $this->getConfig()->getNested("message.lang") . ".yml");
}
$this->getServer()->getCommandMap()->register('pac', new PACCommand('pac', $this));
$this->getServer()->getScheduler()->scheduleRepeatingTask(new AntiCheatsTick($this), 20);
$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
$this->getLogger()->info("§aEnabled.");
}

public function getMessage($message) {
/**
* @param $message
* @return mixed
*/
public function getMessage($message)
{
return str_replace("&", "§", $this->lang->getNested($message));
}

Expand Down
Loading

0 comments on commit 7776b5d

Please sign in to comment.