mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 22:15:28 +00:00
Fixed killaura, added auto-updater
This commit is contained in:
1 parent
cf60474a6d
commit
671329369e
5 files changed
+45
-10
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.gravitydevelopment.anticheat</groupId>
|
<groupId>net.gravitydevelopment.anticheat</groupId>
|
||||||
<artifactId>AntiCheat</artifactId>
|
<artifactId>AntiCheat</artifactId>
|
||||||
<version>1.1.0-ALPHA</version>
|
<version>1.2.0-ALPHA</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://rammelkast.com</url>
|
<url>https://rammelkast.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
@@ -93,6 +93,12 @@
|
|||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.gravitydevelopment.updater</groupId>
|
||||||
|
<artifactId>updater</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib-API</artifactId>
|
<artifactId>ProtocolLib-API</artifactId>
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
|
|
||||||
package net.gravitydevelopment.anticheat;
|
package net.gravitydevelopment.anticheat;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
@@ -38,9 +40,9 @@ import net.gravitydevelopment.anticheat.event.InventoryListener;
|
|||||||
import net.gravitydevelopment.anticheat.event.PlayerListener;
|
import net.gravitydevelopment.anticheat.event.PlayerListener;
|
||||||
import net.gravitydevelopment.anticheat.event.VehicleListener;
|
import net.gravitydevelopment.anticheat.event.VehicleListener;
|
||||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
||||||
import net.gravitydevelopment.anticheat.manage.PacketManager;
|
|
||||||
import net.gravitydevelopment.anticheat.util.User;
|
import net.gravitydevelopment.anticheat.util.User;
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
||||||
|
import net.gravitydevelopment.updater.Updater;
|
||||||
|
|
||||||
public class AntiCheat extends JavaPlugin {
|
public class AntiCheat extends JavaPlugin {
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean developer;
|
private static boolean developer;
|
||||||
private static final int PROJECT_ID = 38723;
|
private static final int PROJECT_ID = 100229;
|
||||||
private static ProtocolManager protocolManager;
|
private static ProtocolManager protocolManager;
|
||||||
private static boolean protocolLib = false;
|
private static boolean protocolLib = false;
|
||||||
private static Long loadTime;
|
private static Long loadTime;
|
||||||
@@ -71,6 +73,7 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
setupConfig();
|
setupConfig();
|
||||||
setupEvents();
|
setupEvents();
|
||||||
setupCommands();
|
setupCommands();
|
||||||
|
setupUpdater();
|
||||||
setupProtocol();
|
setupProtocol();
|
||||||
// Enterprise must come before levels
|
// Enterprise must come before levels
|
||||||
setupEnterprise();
|
setupEnterprise();
|
||||||
@@ -98,7 +101,26 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
KillAuraCheck.listenPackets();
|
KillAuraCheck.listenPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setupUpdater() {
|
||||||
|
if (config.getConfig().autoUpdate.getValue()) {
|
||||||
|
final File file = this.getFile();
|
||||||
|
final Plugin plugin = this;
|
||||||
|
getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
verboseLog("Checking for a new update...");
|
||||||
|
Updater updater = new Updater(plugin, PROJECT_ID, file, Updater.UpdateType.DEFAULT, false);
|
||||||
|
update = updater.getResult() == Updater.UpdateResult.SUCCESS;
|
||||||
|
verboseLog("Update available: " + update);
|
||||||
|
if (update) {
|
||||||
|
updateDetails = updater.getLatestName() + " for " + updater.getLatestGameVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
verboseLog("Saving user levels...");
|
verboseLog("Saving user levels...");
|
||||||
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
@@ -40,7 +41,7 @@ public class KillAuraCheck {
|
|||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if (!CHECKER_NPCS.containsKey(p.getUniqueId()))
|
if (!CHECKER_NPCS.containsKey(p.getUniqueId()) || AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.KILLAURA))
|
||||||
return;
|
return;
|
||||||
int entityId = ((Integer)e.getPacket().getIntegers().read(0));
|
int entityId = ((Integer)e.getPacket().getIntegers().read(0));
|
||||||
boolean isBot = CHECKER_NPCS.get(p.getUniqueId()).onHit(entityId);
|
boolean isBot = CHECKER_NPCS.get(p.getUniqueId()).onHit(entityId);
|
||||||
@@ -60,6 +61,8 @@ public class KillAuraCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
||||||
|
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.KILLAURA))
|
||||||
|
return;
|
||||||
if (VersionUtil.getVersion().equals("v1_8_R3")) { // TODO 1.9 support
|
if (VersionUtil.getVersion().equals("v1_8_R3")) { // TODO 1.9 support
|
||||||
if (!CHECKER_NPCS.containsKey(p.getUniqueId())) { // Enable killaura check after player damaged other player, this is more efficient
|
if (!CHECKER_NPCS.containsKey(p.getUniqueId())) { // Enable killaura check after player damaged other player, this is more efficient
|
||||||
CHECKER_NPCS.put(p.getUniqueId(), new CheckerNPCS(p));
|
CHECKER_NPCS.put(p.getUniqueId(), new CheckerNPCS(p));
|
||||||
@@ -69,6 +72,10 @@ public class KillAuraCheck {
|
|||||||
|
|
||||||
public static void doMove(PlayerMoveEvent e) {
|
public static void doMove(PlayerMoveEvent e) {
|
||||||
if (CHECKER_NPCS.containsKey(e.getPlayer().getUniqueId())) {
|
if (CHECKER_NPCS.containsKey(e.getPlayer().getUniqueId())) {
|
||||||
|
if (AntiCheat.getManager().getCheckManager().isOpExempt(e.getPlayer()) || AntiCheat.getManager().getCheckManager().isExempt(e.getPlayer(), CheckType.KILLAURA)) {
|
||||||
|
cleanPlayer(e.getPlayer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
CHECKER_NPCS.get(e.getPlayer().getUniqueId()).doMove(e);
|
CHECKER_NPCS.get(e.getPlayer().getUniqueId()).doMove(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class CommandBase {
|
|||||||
public static final ChatColor GOLD = ChatColor.GOLD;
|
public static final ChatColor GOLD = ChatColor.GOLD;
|
||||||
public static final ChatColor AQUA = ChatColor.AQUA;
|
public static final ChatColor AQUA = ChatColor.AQUA;
|
||||||
public static final Server SERVER = Bukkit.getServer();
|
public static final Server SERVER = Bukkit.getServer();
|
||||||
public static final String PERMISSIONS_ERROR = RED + "Insufficient Permissions.";
|
public static final String PERMISSIONS_ERROR = RED + "You don't have the permissions to use this command.";
|
||||||
public static final String MENU_END = "-----------------------------------------------------";
|
public static final String MENU_END = "-----------------------------------------------------";
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
@@ -73,9 +73,9 @@ public class CommandBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendHelp(CommandSender cs) {
|
public void sendHelp(CommandSender cs) {
|
||||||
cs.sendMessage(GREEN + "== " + GRAY + getName() + GREEN + " ==");
|
cs.sendMessage(RED + "== " + GRAY + getName() + RED + " ==");
|
||||||
cs.sendMessage(GREEN + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
|
cs.sendMessage(RED + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
|
||||||
cs.sendMessage(GREEN + "Permission: " + GRAY + getPermission().toString());
|
cs.sendMessage(RED + "Permission: " + GRAY + getPermission().toString());
|
||||||
for (String string : getHelp()) {
|
for (String string : getHelp()) {
|
||||||
cs.sendMessage(string);
|
cs.sendMessage(string);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class CommandUpdate extends CommandBase {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(GRAY + "Your config settings have disabled update checking.");
|
cs.sendMessage(GRAY + "Your config settings have disabled update checking.");
|
||||||
cs.sendMessage(GRAY + "Please enable this setting or visit http://dev.bukkit.org/bukkit-plugins/anticheat/");
|
cs.sendMessage(GRAY + "Please enable this setting or visit http://dev.bukkit.org/bukkit-plugins/anticheatreloaded/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user