Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
All Files
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Feb 5, 2019
0 parents commit 4c88c8a
Show file tree
Hide file tree
Showing 33 changed files with 6,132 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .classpath
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/imodm/Documents/API/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/bin/
/target/
23 changes: 23 additions & 0 deletions .project
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AntiCheat</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Empty file added config.yml
Empty file.
Empty file added guis.yml
Empty file.
1 change: 1 addition & 0 deletions lang.yml
@@ -0,0 +1 @@
NoPermission: '%prefix% You do not have permission to do this.'
8 changes: 8 additions & 0 deletions plugin.yml
@@ -0,0 +1,8 @@
name: AntiCheat
main: org.mswsplex.anticheat.msws.AntiCheat
version: 1.0
description: Default Plugin Outline
commands:
command1:
usage: /<command>
description: foo
19 changes: 19 additions & 0 deletions pom.xml
@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>AntiCheat</groupId>
<artifactId>AntiCheat</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
13 changes: 13 additions & 0 deletions src/org/mswsplex/anticheat/checks/Check.java
@@ -0,0 +1,13 @@
package org.mswsplex.anticheat.checks;

import org.mswsplex.anticheat.msws.AntiCheat;

public interface Check {
public CheckType getType();

public void register(AntiCheat plugin);

public String getCategory();

public String getDebugName();
}
5 changes: 5 additions & 0 deletions src/org/mswsplex/anticheat/checks/CheckType.java
@@ -0,0 +1,5 @@
package org.mswsplex.anticheat.checks;

public enum CheckType {
MOVEMENT, CLIENT, COMBAT, RENDER, TICK, MISC
}
44 changes: 44 additions & 0 deletions src/org/mswsplex/anticheat/checks/Checks.java
@@ -0,0 +1,44 @@
package org.mswsplex.anticheat.checks;

import java.util.ArrayList;
import java.util.List;

import org.mswsplex.anticheat.checks.client.NoGround;
import org.mswsplex.anticheat.checks.movement.GeneralMovement1;
import org.mswsplex.anticheat.checks.movement.Teleport1;
import org.mswsplex.anticheat.checks.movement.Timer1;
import org.mswsplex.anticheat.checks.movement.Flight1;
import org.mswsplex.anticheat.checks.movement.Speed1;
import org.mswsplex.anticheat.checks.movement.GeneralMovement2;
import org.mswsplex.anticheat.msws.AntiCheat;

public class Checks {
private AntiCheat plugin;
private List<Check> activeChecks;

public Checks(AntiCheat plugin) {
this.plugin = plugin;
activeChecks = new ArrayList<Check>();
}

public void registerChecks() {
Check[] checks = { new GeneralMovement1(), new Flight1(), new NoGround(), new Speed1(), new GeneralMovement2(),
new Teleport1(), new Timer1() };

for (Check check : checks) {
activeChecks.add(check);
check.register(plugin);
}
}

public List<Check> getActiveChecks() {
return activeChecks;
}

public void registerCheck(Check check) {
if (activeChecks.contains(check))
throw new IllegalArgumentException("Check already registered");
check.register(plugin);
activeChecks.add(check);
}
}
84 changes: 84 additions & 0 deletions src/org/mswsplex/anticheat/checks/Global.java
@@ -0,0 +1,84 @@
package org.mswsplex.anticheat.checks;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.mswsplex.anticheat.data.CPlayer;
import org.mswsplex.anticheat.msws.AntiCheat;

public class Global implements Listener {
private AntiCheat plugin;

public Global(AntiCheat plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}

@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
CPlayer cp = plugin.getCPlayer(player);

boolean onGround = cp.isOnGround(), weirdBlock = cp.isInWeirdBlock();

Location from = event.getFrom(), to = event.getTo();

if (to.getBlock().isLiquid() || from.getBlock().isLiquid())
cp.setTempData("lastLiquid", (double) System.currentTimeMillis());

if (from.getY() != to.getY())
cp.setTempData("lastYChange", (double) System.currentTimeMillis());

if (onGround) {
cp.setTempData("lastOnGround", (double) System.currentTimeMillis());
if (!weirdBlock)
cp.setLastSafeLocation(player.getLocation());
} else {
cp.setTempData("lastInAir", (double) System.currentTimeMillis());
}
if (weirdBlock)
cp.setTempData("lastWeirdBlock", (double) System.currentTimeMillis());

Location vertLine = player.getLocation();
while (!vertLine.getBlock().getType().isSolid() && vertLine.getY() > 0) {
vertLine.subtract(0, 1, 0);
}

Block lowestBlock = vertLine.getBlock();

if (lowestBlock.getType() == Material.SLIME_BLOCK)
cp.setTempData("lastSlimeBlock", (double) System.currentTimeMillis());
}

@EventHandler
public void onToggleFlight(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
CPlayer cp = plugin.getCPlayer(player);

cp.setTempData("toggleFlight", (double) System.currentTimeMillis());

if (player.isFlying()) {
cp.setTempData("disableFlight", (double) System.currentTimeMillis());
} else {
cp.setTempData("enableFlight", (double) System.currentTimeMillis());
}
}

@EventHandler
public void onDamage(EntityDamageEvent event) {
Entity ent = event.getEntity();
if (!(ent instanceof Player))
return;
Player player = (Player) ent;
CPlayer cp = plugin.getCPlayer(player);
cp.setTempData("lastDamageTaken", (double) System.currentTimeMillis());
}
}
33 changes: 33 additions & 0 deletions src/org/mswsplex/anticheat/checks/TPSChecker.java
@@ -0,0 +1,33 @@
package org.mswsplex.anticheat.checks;

import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.mswsplex.anticheat.msws.AntiCheat;

public class TPSChecker {

private float tps;
private float amo;
private long lastCheck;

public TPSChecker(AntiCheat plugin) {

tps = 20.0f;
amo = 0.0f;

int checkEvery = 1000;
lastCheck = System.currentTimeMillis();
Bukkit.getScheduler().scheduleSyncRepeatingTask((Plugin) plugin, () -> {
if (System.currentTimeMillis() - lastCheck > checkEvery) {
tps = (float) (amo / (checkEvery / 1000.0));
amo = 0.0f;
lastCheck = System.currentTimeMillis();
}
amo++;
}, 0L, 1L);
}

public float getTPS() {
return this.tps;
}
}
53 changes: 53 additions & 0 deletions src/org/mswsplex/anticheat/checks/client/NoGround.java
@@ -0,0 +1,53 @@
package org.mswsplex.anticheat.checks.client;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.mswsplex.anticheat.checks.Check;
import org.mswsplex.anticheat.checks.CheckType;
import org.mswsplex.anticheat.data.CPlayer;
import org.mswsplex.anticheat.msws.AntiCheat;

public class NoGround implements Check, Listener {

private AntiCheat plugin;

@Override
public CheckType getType() {
return CheckType.CLIENT;
}

@Override
public void register(AntiCheat plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}

@SuppressWarnings("deprecation")
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
CPlayer cp = plugin.getCPlayer(player);

if (!player.isOnGround()) // If the client SAYS they're not on the ground, return
return;

if (cp.isOnGround())
return;

cp.flagHack(this, 1);

}

@Override
public String getCategory() {
return "NoGround";
}

@Override
public String getDebugName() {
return "CPlayerNoGround";
}
}

0 comments on commit 4c88c8a

Please sign in to comment.