Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb4c288fb0 | ||
|
|
06821e3ad2 | ||
|
|
3428d489eb | ||
|
|
c84303e236 | ||
|
|
08e3c7a09c | ||
|
|
bb2bc39bad | ||
|
|
5fee18b551 | ||
|
|
e8ae11d574 | ||
|
|
d24ef111a3 | ||
|
|
1e75141ca8 | ||
|
|
f33d17b85e | ||
|
|
25dc1464cd | ||
|
|
f4be87e267 | ||
|
|
25ef74f7da | ||
|
|
2d50c0afdf | ||
|
|
62389c904c | ||
|
|
2f17d95923 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
[submodule "GrimAPI"]
|
||||
path = GrimAPI
|
||||
url = https://github.com/GrimAnticheat/GrimAPI
|
||||
[submodule "api"]
|
||||
path = api
|
||||
url = https://github.com/GrimAnticheat/GrimAPI
|
||||
Submodule
+1
Submodule api added at 6061ddc684.
@@ -9,11 +9,11 @@ plugins {
|
||||
val shadowCommon: Configuration by project.configurations.creating {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
// Extend from the "implementation" configuration of the current project
|
||||
extendsFrom(project.configurations.getByName("implementation"))
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
minimize()
|
||||
archiveFileName.set("${rootProject.name}-${project.name}-${rootProject.version}.jar")
|
||||
from(shadowCommon) // Use from() instead of direct assignment
|
||||
|
||||
@@ -40,6 +40,7 @@ tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("io.leangen.geantyref", "ac.grim.grimac.shaded.geantyref") // Required by cloud
|
||||
}
|
||||
mergeServiceFiles()
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.named("assemble") {
|
||||
|
||||
@@ -51,7 +51,7 @@ object BuildConfig {
|
||||
_shadePE = resolveBool(project, "shadePE", altKey = "SHADE_PE", default = true)
|
||||
_relocate = resolveBool(project, "relocate", altKey = "RELOCATE_JAR", default = true)
|
||||
_release = resolveBool(project, "release", default = false)
|
||||
_mavenLocalOverride = resolveBool(project, "mavenLocalOverride", default = false)
|
||||
_mavenLocalOverride = resolveBool(project, "mavenLocalOverride", altKey = "MAVEN_LOCAL_OVERRIDE", default = false)
|
||||
}
|
||||
|
||||
// Unified resolution logic (System > Gradle > Env)
|
||||
|
||||
@@ -44,8 +44,9 @@ dependencies {
|
||||
implementation(libs.cloud.paper)
|
||||
implementation(libs.adventure.platform.bukkit)
|
||||
|
||||
implementation(project(":common"))
|
||||
shadow(project(":common"))
|
||||
shadowCommon(project(":common", "default"))
|
||||
implementation(project(":api"))
|
||||
implementation(project(":api:packetevents"))
|
||||
}
|
||||
|
||||
bukkit {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ac.grim.grimac.platform.bukkit;
|
||||
|
||||
import ac.grim.grimac.platform.api.PlatformPlugin;
|
||||
import ac.grim.grimac.api.platform.PlatformPlugin;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitPlatformPlugin implements PlatformPlugin {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit;
|
||||
|
||||
import ac.grim.grimac.platform.api.PlatformServer;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.api.platform.PlatformServer;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import io.github.retrooper.packetevents.util.SpigotReflectionUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
package ac.grim.grimac.platform.bukkit;
|
||||
|
||||
import ac.grim.grimac.api.lazy.LazyHolder;
|
||||
import ac.grim.grimac.api.packet.MCPacketAPI;
|
||||
import ac.grim.grimac.api.packet.pe.PEPacketAPI;
|
||||
import ac.grim.grimac.api.platform.CoreLoader;
|
||||
import ac.grim.grimac.api.platform.init.Initable;
|
||||
import ac.grim.grimac.api.plugin.BasicGrimPlugin;
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.api.GrimAPIProvider;
|
||||
import ac.grim.grimac.api.GrimAbstractAPI;
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.manager.init.Initable;
|
||||
import ac.grim.grimac.manager.init.start.ExemptOnlinePlayersOnReload;
|
||||
import ac.grim.grimac.manager.init.start.StartableInitable;
|
||||
import ac.grim.grimac.platform.api.Platform;
|
||||
import ac.grim.grimac.platform.api.PlatformLoader;
|
||||
import ac.grim.grimac.platform.api.PlatformServer;
|
||||
import ac.grim.grimac.platform.api.manager.ItemResetHandler;
|
||||
import ac.grim.grimac.platform.api.manager.MessagePlaceHolderManager;
|
||||
import ac.grim.grimac.platform.api.manager.ParserDescriptorFactory;
|
||||
import ac.grim.grimac.platform.api.manager.PermissionRegistrationManager;
|
||||
import ac.grim.grimac.platform.api.manager.PlatformPluginManager;
|
||||
import ac.grim.grimac.platform.api.player.PlatformPlayerFactory;
|
||||
import ac.grim.grimac.platform.api.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.platform.api.sender.SenderFactory;
|
||||
import ac.grim.grimac.api.platform.init.StartableInitable;
|
||||
import ac.grim.grimac.api.platform.Platform;
|
||||
import ac.grim.grimac.api.platform.PlatformLoader;
|
||||
import ac.grim.grimac.api.platform.PlatformServer;
|
||||
import ac.grim.grimac.api.platform.manager.ItemResetHandler;
|
||||
import ac.grim.grimac.api.platform.manager.MessagePlaceHolderManager;
|
||||
import ac.grim.grimac.api.platform.manager.ParserDescriptorFactory;
|
||||
import ac.grim.grimac.api.platform.manager.PermissionRegistrationManager;
|
||||
import ac.grim.grimac.api.platform.manager.PlatformPluginManager;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayerFactory;
|
||||
import ac.grim.grimac.api.platform.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import ac.grim.grimac.api.platform.sender.SenderFactory;
|
||||
import ac.grim.grimac.platform.bukkit.initables.BukkitBStats;
|
||||
import ac.grim.grimac.platform.bukkit.initables.BukkitEventManager;
|
||||
import ac.grim.grimac.platform.bukkit.initables.BukkitTickEndEvent;
|
||||
@@ -33,7 +35,6 @@ import ac.grim.grimac.platform.bukkit.scheduler.bukkit.BukkitPlatformScheduler;
|
||||
import ac.grim.grimac.platform.bukkit.scheduler.folia.FoliaPlatformScheduler;
|
||||
import ac.grim.grimac.platform.bukkit.sender.BukkitSenderFactory;
|
||||
import ac.grim.grimac.platform.bukkit.utils.placeholder.PlaceholderAPIExpansion;
|
||||
import ac.grim.grimac.utils.lazy.LazyHolder;
|
||||
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -66,6 +67,7 @@ public final class GrimACBukkitLoaderPlugin extends JavaPlugin implements Platfo
|
||||
private final PlatformServer platformServer = new BukkitPlatformServer();
|
||||
private final MessagePlaceHolderManager messagePlaceHolderManager = new BukkitMessagePlaceHolderManager();
|
||||
private final BukkitPermissionRegistrationManager bukkitPermissionRegistrationManager = new BukkitPermissionRegistrationManager();
|
||||
private final MCPacketAPI mcPacketAPI = new PEPacketAPI();
|
||||
|
||||
public GrimACBukkitLoaderPlugin() {
|
||||
this.plugin = new BasicGrimPlugin(
|
||||
@@ -80,12 +82,11 @@ public final class GrimACBukkitLoaderPlugin extends JavaPlugin implements Platfo
|
||||
@Override
|
||||
public void onLoad() {
|
||||
LOADER = this;
|
||||
GrimAPI.INSTANCE.load(this, this.getBukkitInitTasks());
|
||||
CoreLoader.Manager.loadAll(this, this.getBukkitInitTasks());
|
||||
}
|
||||
|
||||
private Initable[] getBukkitInitTasks() {
|
||||
return new Initable[] {
|
||||
new ExemptOnlinePlayersOnReload(),
|
||||
new BukkitEventManager(),
|
||||
new BukkitTickEndEvent(),
|
||||
new BukkitBStats(),
|
||||
@@ -99,12 +100,12 @@ public final class GrimACBukkitLoaderPlugin extends JavaPlugin implements Platfo
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
GrimAPI.INSTANCE.start();
|
||||
CoreLoader.Manager.startAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
GrimAPI.INSTANCE.stop();
|
||||
CoreLoader.Manager.stopAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +124,7 @@ public final class GrimACBukkitLoaderPlugin extends JavaPlugin implements Platfo
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketEventsAPI<?> getPacketEvents() {
|
||||
public PacketEventsAPI<?> getPacketAPI() {
|
||||
return packetEvents.get();
|
||||
}
|
||||
|
||||
@@ -158,9 +159,9 @@ public final class GrimACBukkitLoaderPlugin extends JavaPlugin implements Platfo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAPIService() {
|
||||
GrimAPIProvider.init(GrimAPI.INSTANCE.getExternalAPI());
|
||||
Bukkit.getServicesManager().register(GrimAbstractAPI.class, GrimAPI.INSTANCE.getExternalAPI(), GrimACBukkitLoaderPlugin.LOADER, ServicePriority.Normal);
|
||||
public void registerAPIService(GrimAbstractAPI api) {
|
||||
GrimAPIProvider.init(api);
|
||||
Bukkit.getServicesManager().register(GrimAbstractAPI.class, api, GrimACBukkitLoaderPlugin.LOADER, ServicePriority.Normal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,8 +174,13 @@ public final class GrimACBukkitLoaderPlugin extends JavaPlugin implements Platfo
|
||||
return bukkitPermissionRegistrationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCPacketAPI getMCPacketAPI() {
|
||||
return mcPacketAPI;
|
||||
}
|
||||
|
||||
private PlatformScheduler createScheduler() {
|
||||
return GrimAPI.INSTANCE.getPlatform() == Platform.FOLIA ? new FoliaPlatformScheduler() : new BukkitPlatformScheduler();
|
||||
return GrimAPIProvider.getDirect().getPlatform() == Platform.FOLIA ? new FoliaPlatformScheduler() : new BukkitPlatformScheduler();
|
||||
}
|
||||
|
||||
private CommandManager<Sender> createCommandManager() {
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.command;
|
||||
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.platform.api.command.PlayerSelector;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.api.GrimAPIProvider;
|
||||
import ac.grim.grimac.api.platform.command.PlayerSelector;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import ac.grim.grimac.platform.bukkit.sender.BukkitSenderFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -22,12 +22,12 @@ public class BukkitPlayerSelectorAdapter implements PlayerSelector {
|
||||
|
||||
@Override
|
||||
public Sender getSinglePlayer() {
|
||||
return ((BukkitSenderFactory) GrimAPI.INSTANCE.getSenderFactory()).map(bukkitSelector.single());
|
||||
return ((BukkitSenderFactory) GrimAPIProvider.getDirect().getPlatformLoader().getSenderFactory()).map(bukkitSelector.single());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Sender> getPlayers() {
|
||||
return Collections.singletonList(((BukkitSenderFactory) GrimAPI.INSTANCE.getSenderFactory()).map(bukkitSelector.single()));
|
||||
return Collections.singletonList(((BukkitSenderFactory) GrimAPIProvider.getDirect().getPlatformLoader().getSenderFactory()).map(bukkitSelector.single()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit.command;
|
||||
|
||||
import ac.grim.grimac.platform.api.command.AbstractPlayerSelectorParser;
|
||||
import ac.grim.grimac.platform.api.command.PlayerSelector;
|
||||
import ac.grim.grimac.api.platform.command.AbstractPlayerSelectorParser;
|
||||
import ac.grim.grimac.api.platform.command.PlayerSelector;
|
||||
import org.incendo.cloud.bukkit.parser.selector.SinglePlayerSelectorParser;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.parser.ParserDescriptor;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package ac.grim.grimac.platform.bukkit.entity;
|
||||
|
||||
import ac.grim.grimac.platform.api.entity.GrimEntity;
|
||||
import ac.grim.grimac.platform.api.world.PlatformWorld;
|
||||
import ac.grim.grimac.api.platform.entity.GrimEntity;
|
||||
import ac.grim.grimac.api.platform.world.PlatformWorld;
|
||||
import ac.grim.grimac.platform.bukkit.utils.convert.BukkitConversionUtils;
|
||||
import ac.grim.grimac.platform.bukkit.utils.reflection.PaperUtils;
|
||||
import ac.grim.grimac.platform.bukkit.world.BukkitPlatformWorld;
|
||||
import ac.grim.grimac.utils.math.Location;
|
||||
import ac.grim.grimac.api.math.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package ac.grim.grimac.platform.bukkit.events;
|
||||
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.api.GrimAPIProvider;
|
||||
import ac.grim.grimac.api.GrimUser;
|
||||
import ac.grim.grimac.api.data.PistonData;
|
||||
import ac.grim.grimac.api.data.boxes.BaseSCB;
|
||||
import ac.grim.grimac.platform.bukkit.utils.convert.BukkitConversionUtils;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
|
||||
import ac.grim.grimac.utils.data.PistonData;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import ac.grim.grimac.api.packet.world.enums.BlockFace;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -26,13 +26,13 @@ public class PistonEvent implements Listener {
|
||||
boolean hasSlimeBlock = false;
|
||||
boolean hasHoneyBlock = false;
|
||||
|
||||
List<SimpleCollisionBox> boxes = new ArrayList<>();
|
||||
List<BaseSCB> boxes = new ArrayList<>();
|
||||
for (Block block : event.getBlocks()) {
|
||||
boxes.add(new SimpleCollisionBox(0, 0, 0, 1, 1, 1, true)
|
||||
boxes.add(new BaseSCB(0, 0, 0, 1, 1, 1, true)
|
||||
.offset(block.getX(),
|
||||
block.getY(),
|
||||
block.getZ()));
|
||||
boxes.add(new SimpleCollisionBox(0, 0, 0, 1, 1, 1, true)
|
||||
boxes.add(new BaseSCB(0, 0, 0, 1, 1, 1, true)
|
||||
.offset(block.getX() + event.getDirection().getModX(),
|
||||
block.getY() + event.getDirection().getModY(),
|
||||
block.getZ() + event.getDirection().getModZ()));
|
||||
@@ -50,19 +50,19 @@ public class PistonEvent implements Listener {
|
||||
Block piston = event.getBlock();
|
||||
|
||||
// Add bounding box of the actual piston head pushing
|
||||
boxes.add(new SimpleCollisionBox(0, 0, 0, 1, 1, 1, true)
|
||||
boxes.add(new BaseSCB(0, 0, 0, 1, 1, 1, true)
|
||||
.offset(piston.getX() + event.getDirection().getModX(),
|
||||
piston.getY() + event.getDirection().getModY(),
|
||||
piston.getZ() + event.getDirection().getModZ()));
|
||||
|
||||
boolean finalHasSlimeBlock = hasSlimeBlock;
|
||||
boolean finalHasHoneyBlock = hasHoneyBlock;
|
||||
for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
|
||||
int lastTrans = player.lastTransactionSent.get();
|
||||
for (GrimUser player : GrimAPIProvider.getDirect().getGrimUsers()) {
|
||||
int lastTrans = player.getLastTransactionSent();
|
||||
player.runSafely(() -> {
|
||||
if (player.compensatedWorld.isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
|
||||
if (player.getCompensatedWorld().isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
|
||||
PistonData data = new PistonData(BukkitConversionUtils.fromBukkitFace(event.getDirection()), boxes, lastTrans, true, finalHasSlimeBlock, finalHasHoneyBlock);
|
||||
player.latencyUtils.addRealTimeTaskAsync(lastTrans, () -> player.compensatedWorld.activePistons.add(data));
|
||||
player.addRealTimeTask(lastTrans, () -> player.getCompensatedWorld().addActivePistons(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class PistonEvent implements Listener {
|
||||
boolean hasSlimeBlock = false;
|
||||
boolean hasHoneyBlock = false;
|
||||
|
||||
List<SimpleCollisionBox> boxes = new ArrayList<>();
|
||||
List<BaseSCB> boxes = new ArrayList<>();
|
||||
BlockFace face = BukkitConversionUtils.fromBukkitFace(event.getDirection());
|
||||
|
||||
// The event was called without blocks and is therefore in the right direction
|
||||
@@ -91,16 +91,16 @@ public class PistonEvent implements Listener {
|
||||
Block piston = event.getBlock();
|
||||
|
||||
// Add bounding box of the actual piston head pushing
|
||||
boxes.add(new SimpleCollisionBox(0, 0, 0, 1, 1, 1, true)
|
||||
boxes.add(new BaseSCB(0, 0, 0, 1, 1, 1, true)
|
||||
.offset(piston.getX() + face.getModX(),
|
||||
piston.getY() + face.getModY(),
|
||||
piston.getZ() + face.getModZ()));
|
||||
}
|
||||
|
||||
for (Block block : event.getBlocks()) {
|
||||
boxes.add(new SimpleCollisionBox(0, 0, 0, 1, 1, 1, true)
|
||||
boxes.add(new BaseSCB(0, 0, 0, 1, 1, 1, true)
|
||||
.offset(block.getX(), block.getY(), block.getZ()));
|
||||
boxes.add(new SimpleCollisionBox(0, 0, 0, 1, 1, 1, true)
|
||||
boxes.add(new BaseSCB(0, 0, 0, 1, 1, 1, true)
|
||||
.offset(block.getX() + face.getModX(), block.getY() + face.getModY(), block.getZ() + face.getModZ()));
|
||||
|
||||
// Support honey block like this because ViaVersion replacement
|
||||
@@ -115,12 +115,12 @@ public class PistonEvent implements Listener {
|
||||
|
||||
boolean finalHasSlimeBlock = hasSlimeBlock;
|
||||
boolean finalHasHoneyBlock = hasHoneyBlock;
|
||||
for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
|
||||
int lastTrans = player.lastTransactionSent.get();
|
||||
for (GrimUser player : GrimAPIProvider.getDirect().getGrimUsers()) {
|
||||
int lastTrans = player.getLastTransactionSent();
|
||||
player.runSafely(() -> {
|
||||
if (player.compensatedWorld.isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
|
||||
if (player.getCompensatedWorld().isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
|
||||
PistonData data = new PistonData(BukkitConversionUtils.fromBukkitFace(event.getDirection()), boxes, lastTrans, false, finalHasSlimeBlock, finalHasHoneyBlock);
|
||||
player.latencyUtils.addRealTimeTaskAsync(lastTrans, () -> player.compensatedWorld.activePistons.add(data));
|
||||
player.addRealTimeTask(lastTrans, () -> player.getCompensatedWorld().addActivePistons(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ac.grim.grimac.platform.bukkit.initables;
|
||||
|
||||
import ac.grim.grimac.manager.init.start.StartableInitable;
|
||||
import ac.grim.grimac.api.platform.init.StartableInitable;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import io.github.retrooper.packetevents.bstats.bukkit.Metrics;
|
||||
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package ac.grim.grimac.platform.bukkit.initables;
|
||||
|
||||
import ac.grim.grimac.manager.init.start.StartableInitable;
|
||||
import ac.grim.grimac.api.platform.init.StartableInitable;
|
||||
import ac.grim.grimac.api.util.LogUtil;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import ac.grim.grimac.platform.bukkit.events.PistonEvent;
|
||||
import ac.grim.grimac.utils.anticheat.LogUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitEventManager implements StartableInitable {
|
||||
|
||||
+17
-18
@@ -1,15 +1,14 @@
|
||||
package ac.grim.grimac.platform.bukkit.initables;
|
||||
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.manager.init.start.AbstractTickEndEvent;
|
||||
import ac.grim.grimac.platform.api.Platform;
|
||||
import ac.grim.grimac.api.GrimAPIProvider;
|
||||
import ac.grim.grimac.api.GrimUser;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.platform.Platform;
|
||||
import ac.grim.grimac.api.platform.init.AbstractTickEndEvent;
|
||||
import ac.grim.grimac.api.util.LogUtil;
|
||||
import ac.grim.grimac.platform.bukkit.player.BukkitPlatformPlayer;
|
||||
import ac.grim.grimac.platform.bukkit.utils.list.HookedListWrapper;
|
||||
import ac.grim.grimac.platform.bukkit.utils.reflection.PaperUtils;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.LogUtil;
|
||||
import ac.grim.grimac.utils.lists.HookedListWrapper;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.util.reflection.Reflection;
|
||||
import io.github.retrooper.packetevents.util.SpigotReflectionUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -30,11 +29,11 @@ public class BukkitTickEndEvent extends AbstractTickEndEvent implements Listener
|
||||
if (!super.shouldInjectEndTick()) {
|
||||
return;
|
||||
}
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThan(ServerVersion.V_1_11_2) && !Boolean.getBoolean("paper.explicit-flush")) {
|
||||
if (ServerVersions.getServerVersion().isNewerThan(ServerVersions.V_1_11_2) && !Boolean.getBoolean("paper.explicit-flush")) {
|
||||
LogUtil.warn("Reach.enable-post-packet=true but paper.explicit-flush=false, add \"-Dpaper.explicit-flush=true\" to your server's startup flags for fully functional extra reach accuracy.");
|
||||
}
|
||||
// this is necessary for folia
|
||||
if (GrimAPI.INSTANCE.getPlatform() == Platform.FOLIA) {
|
||||
if (GrimAPIProvider.getDirect().getPlatform() == Platform.FOLIA) {
|
||||
PaperUtils.registerTickEndEvent(this, this::tickAllFoliaPlayers);
|
||||
return;
|
||||
}
|
||||
@@ -45,19 +44,19 @@ public class BukkitTickEndEvent extends AbstractTickEndEvent implements Listener
|
||||
}
|
||||
|
||||
private void tickAllPlayers() {
|
||||
for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
|
||||
if (player.disableGrim) continue;
|
||||
super.onEndOfTick(player);
|
||||
for (GrimUser player : GrimAPIProvider.getDirect().getGrimUsers()) {
|
||||
if (player.isGrimDisabled()) continue;
|
||||
player.onEndOfTick();
|
||||
}
|
||||
}
|
||||
|
||||
private void tickAllFoliaPlayers() {
|
||||
for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
|
||||
if (player.disableGrim) continue;
|
||||
if (player.platformPlayer == null) continue;
|
||||
Player p = ((BukkitPlatformPlayer) player.platformPlayer).getNative();
|
||||
for (GrimUser player : GrimAPIProvider.getDirect().getGrimUsers()) {
|
||||
if (player.isGrimDisabled()) continue;
|
||||
if (player.getPlatformPlayer() == null) continue;
|
||||
Player p = ((BukkitPlatformPlayer) player.getPlatformPlayer()).getNative();
|
||||
if (!Bukkit.isOwnedByCurrentRegion(p)) continue;
|
||||
super.onEndOfTick(player);
|
||||
player.onEndOfTick();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -1,11 +1,11 @@
|
||||
package ac.grim.grimac.platform.bukkit.manager;
|
||||
|
||||
import ac.grim.grimac.platform.api.manager.ItemResetHandler;
|
||||
import ac.grim.grimac.platform.api.player.PlatformPlayer;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.PacketServerVersion;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.platform.manager.ItemResetHandler;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayer;
|
||||
import ac.grim.grimac.platform.bukkit.player.BukkitPlatformPlayer;
|
||||
import ac.grim.grimac.platform.bukkit.utils.reflection.PaperUtils;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -28,14 +28,14 @@ public class BukkitItemResetHandler implements ItemResetHandler {
|
||||
|
||||
@SneakyThrows
|
||||
private @NotNull ItemUsageReset createItemUsageResetFunction() {
|
||||
ServerVersion version = PacketEvents.getAPI().getServerManager().getVersion();
|
||||
if (version.isNewerThan(ServerVersion.V_1_17) && PaperUtils.PAPER) {
|
||||
if (version.isOlderThan(ServerVersion.V_1_19)) {
|
||||
PacketServerVersion version = ServerVersions.getServerVersion();
|
||||
if (version.isNewerThan(ServerVersions.V_1_17) && PaperUtils.PAPER) {
|
||||
if (version.isOlderThan(ServerVersions.V_1_19)) {
|
||||
return LivingEntity::clearActiveItem;
|
||||
}
|
||||
Method setLivingEntityFlag = Class.forName(version.isOlderThan(ServerVersion.V_1_20_5) ? "net.minecraft.world.entity.EntityLiving" : "net.minecraft.world.entity.LivingEntity")
|
||||
.getDeclaredMethod(version.isOlderThan(ServerVersion.V_1_20_5) ? "c" : "setLivingEntityFlag", int.class, boolean.class);
|
||||
Method getHandle = (version.isOlderThan(ServerVersion.V_1_20_5)
|
||||
Method setLivingEntityFlag = Class.forName(version.isOlderThan(ServerVersions.V_1_20_5) ? "net.minecraft.world.entity.EntityLiving" : "net.minecraft.world.entity.LivingEntity")
|
||||
.getDeclaredMethod(version.isOlderThan(ServerVersions.V_1_20_5) ? "c" : "setLivingEntityFlag", int.class, boolean.class);
|
||||
Method getHandle = (version.isOlderThan(ServerVersions.V_1_20_5)
|
||||
? Class.forName("org.bukkit.craftbukkit." + Bukkit.getServer().getClass().getPackageName().split("\\.")[3] + ".entity.CraftPlayer")
|
||||
: Class.forName("org.bukkit.craftbukkit.entity.CraftPlayer")
|
||||
).getMethod("getHandle");
|
||||
@@ -49,7 +49,7 @@ public class BukkitItemResetHandler implements ItemResetHandler {
|
||||
};
|
||||
}
|
||||
|
||||
if (version == ServerVersion.V_1_8_8) {
|
||||
if (version == ServerVersions.V_1_8_8) {
|
||||
Class<?> EntityHuman = Class.forName("net.minecraft.server.v1_8_R3.EntityHuman");
|
||||
Method getHandle = Class.forName("org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer").getMethod("getHandle");
|
||||
Method clearActiveItem = EntityHuman.getMethod("bV");
|
||||
@@ -68,7 +68,7 @@ public class BukkitItemResetHandler implements ItemResetHandler {
|
||||
}
|
||||
|
||||
String nmsPackage = Bukkit.getServer().getClass().getPackageName().split("\\.")[3];
|
||||
String livingEntityPackage = version.isNewerThan(ServerVersion.V_1_16_5) ? "net.minecraft.world.entity.EntityLiving" : "net.minecraft.server." + nmsPackage + ".EntityLiving";
|
||||
String livingEntityPackage = version.isNewerThan(ServerVersions.V_1_16_5) ? "net.minecraft.world.entity.EntityLiving" : "net.minecraft.server." + nmsPackage + ".EntityLiving";
|
||||
Method getHandle = Class.forName("org.bukkit.craftbukkit." + nmsPackage + ".entity.CraftPlayer").getMethod("getHandle");
|
||||
Method clearActiveItem = Class.forName(livingEntityPackage).getMethod(
|
||||
switch (nmsPackage) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit.manager;
|
||||
|
||||
import ac.grim.grimac.platform.api.manager.MessagePlaceHolderManager;
|
||||
import ac.grim.grimac.platform.api.player.PlatformPlayer;
|
||||
import ac.grim.grimac.api.platform.manager.MessagePlaceHolderManager;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayer;
|
||||
import ac.grim.grimac.platform.bukkit.player.BukkitPlatformPlayer;
|
||||
import com.github.retrooper.packetevents.util.reflection.Reflection;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.manager;
|
||||
|
||||
import ac.grim.grimac.platform.api.command.PlayerSelector;
|
||||
import ac.grim.grimac.platform.api.manager.ParserDescriptorFactory;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.api.platform.command.PlayerSelector;
|
||||
import ac.grim.grimac.api.platform.manager.ParserDescriptorFactory;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import ac.grim.grimac.platform.bukkit.command.BukkitPlayerSelectorParser;
|
||||
import org.incendo.cloud.parser.ParserDescriptor;
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit.manager;
|
||||
|
||||
import ac.grim.grimac.platform.api.manager.PermissionRegistrationManager;
|
||||
import ac.grim.grimac.platform.api.permissions.PermissionDefaultValue;
|
||||
import ac.grim.grimac.api.platform.manager.PermissionRegistrationManager;
|
||||
import ac.grim.grimac.api.platform.permissions.PermissionDefaultValue;
|
||||
import ac.grim.grimac.platform.bukkit.utils.convert.BukkitConversionUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit.manager;
|
||||
|
||||
import ac.grim.grimac.platform.api.PlatformPlugin;
|
||||
import ac.grim.grimac.platform.api.manager.PlatformPluginManager;
|
||||
import ac.grim.grimac.api.platform.PlatformPlugin;
|
||||
import ac.grim.grimac.api.platform.manager.PlatformPluginManager;
|
||||
import ac.grim.grimac.platform.bukkit.BukkitPlatformPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
+12
-12
@@ -1,11 +1,11 @@
|
||||
package ac.grim.grimac.platform.bukkit.player;
|
||||
|
||||
import ac.grim.grimac.platform.api.player.PlatformInventory;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import ac.grim.grimac.api.packet.item.PacketItemStack;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayerInventory;
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BukkitPlatformInventory implements PlatformInventory {
|
||||
public class BukkitPlatformInventory implements PlatformPlayerInventory {
|
||||
|
||||
private final Player bukkitPlayer;
|
||||
|
||||
@@ -14,44 +14,44 @@ public class BukkitPlatformInventory implements PlatformInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand() {
|
||||
public PacketItemStack getItemInHand() {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getItemInHand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInOffHand() {
|
||||
public PacketItemStack getItemInOffHand() {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(int bukkitSlot, int vanillaSlot) {
|
||||
public PacketItemStack getStack(int bukkitSlot, int vanillaSlot) {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getItem(bukkitSlot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getHelmet() {
|
||||
public PacketItemStack getHelmet() {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getHelmet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChestplate() {
|
||||
public PacketItemStack getChestplate() {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getChestplate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeggings() {
|
||||
public PacketItemStack getLeggings() {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getLeggings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getBoots() {
|
||||
public PacketItemStack getBoots() {
|
||||
return SpigotConversionUtil.fromBukkitItemStack(bukkitPlayer.getInventory().getBoots());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getContents() {
|
||||
public PacketItemStack[] getContents() {
|
||||
org.bukkit.inventory.ItemStack[] bukkitItems = bukkitPlayer.getInventory().getContents();
|
||||
ItemStack[] items = new ItemStack[bukkitItems.length];
|
||||
PacketItemStack[] items = new PacketItemStack[bukkitItems.length];
|
||||
for (int i = 0; i < bukkitItems.length; i++) {
|
||||
if (bukkitItems[i] == null) continue;
|
||||
items[i] = SpigotConversionUtil.fromBukkitItemStack(bukkitItems[i]);
|
||||
|
||||
+15
-16
@@ -1,21 +1,20 @@
|
||||
package ac.grim.grimac.platform.bukkit.player;
|
||||
|
||||
import ac.grim.grimac.platform.api.entity.GrimEntity;
|
||||
import ac.grim.grimac.platform.api.player.PlatformInventory;
|
||||
import ac.grim.grimac.platform.api.player.PlatformPlayer;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.api.math.Vector3dm;
|
||||
import ac.grim.grimac.api.platform.entity.GrimEntity;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayer;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayerInventory;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import ac.grim.grimac.platform.bukkit.entity.BukkitGrimEntity;
|
||||
import ac.grim.grimac.platform.bukkit.utils.anticheat.MultiLibUtil;
|
||||
import ac.grim.grimac.platform.bukkit.utils.convert.BukkitConversionUtils;
|
||||
import ac.grim.grimac.platform.bukkit.utils.reflection.PaperUtils;
|
||||
import ac.grim.grimac.utils.math.Location;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||
import ac.grim.grimac.api.math.Location;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@@ -31,7 +30,7 @@ public class BukkitPlatformPlayer extends BukkitGrimEntity implements PlatformPl
|
||||
|
||||
@Getter
|
||||
private final Player bukkitPlayer;
|
||||
private final PlatformInventory inventory;
|
||||
private final PlatformPlayerInventory inventory;
|
||||
|
||||
public BukkitPlatformPlayer(Player bukkitPlayer) {
|
||||
super(bukkitPlayer);
|
||||
@@ -90,13 +89,13 @@ public class BukkitPlatformPlayer extends BukkitGrimEntity implements PlatformPl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getPosition() {
|
||||
public Vector3dm getPosition() {
|
||||
org.bukkit.Location location = this.bukkitPlayer.getLocation();
|
||||
return new Vector3d(location.getX(), location.getY(), location.getZ());
|
||||
return new Vector3dm(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformInventory getInventory() {
|
||||
public PlatformPlayerInventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -106,13 +105,13 @@ public class BukkitPlatformPlayer extends BukkitGrimEntity implements PlatformPl
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode() {
|
||||
return SpigotConversionUtil.fromBukkitGameMode(bukkitPlayer.getGameMode());
|
||||
public int getGameModeID() {
|
||||
return bukkitPlayer.getGameMode().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gameMode) {
|
||||
bukkitPlayer.setGameMode(SpigotConversionUtil.toBukkitGameMode(gameMode));
|
||||
public void setGameMode(int gameModeID) {
|
||||
bukkitPlayer.setGameMode(GameMode.getByValue(gameModeID));
|
||||
}
|
||||
|
||||
public World getBukkitWorld() {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit.player;
|
||||
|
||||
import ac.grim.grimac.platform.api.player.AbstractPlatformPlayerFactory;
|
||||
import ac.grim.grimac.platform.api.player.PlatformPlayer;
|
||||
import ac.grim.grimac.api.platform.player.AbstractPlatformPlayerFactory;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.bukkit;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.bukkit;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.entity.GrimEntity;
|
||||
import ac.grim.grimac.platform.api.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.entity.GrimEntity;
|
||||
import ac.grim.grimac.api.platform.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.bukkit;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.bukkit;
|
||||
|
||||
import ac.grim.grimac.platform.api.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.RegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.RegionScheduler;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class BukkitPlatformScheduler implements PlatformScheduler {
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.bukkit;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.scheduler.RegionScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.api.world.PlatformWorld;
|
||||
import ac.grim.grimac.api.platform.scheduler.RegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.world.PlatformWorld;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import ac.grim.grimac.utils.math.Location;
|
||||
import ac.grim.grimac.api.math.Location;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.bukkit;
|
||||
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class BukkitTaskHandle implements TaskHandle {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.folia;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.folia;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.entity.GrimEntity;
|
||||
import ac.grim.grimac.platform.api.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.entity.GrimEntity;
|
||||
import ac.grim.grimac.api.platform.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import ac.grim.grimac.platform.bukkit.entity.BukkitGrimEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.folia;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.folia;
|
||||
|
||||
import ac.grim.grimac.platform.api.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.RegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.AsyncScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.EntityScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.GlobalRegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.RegionScheduler;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class FoliaPlatformScheduler implements PlatformScheduler {
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.folia;
|
||||
|
||||
import ac.grim.grimac.api.plugin.GrimPlugin;
|
||||
import ac.grim.grimac.platform.api.scheduler.RegionScheduler;
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.platform.api.world.PlatformWorld;
|
||||
import ac.grim.grimac.api.platform.scheduler.RegionScheduler;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.world.PlatformWorld;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import ac.grim.grimac.platform.bukkit.world.BukkitPlatformWorld;
|
||||
import ac.grim.grimac.utils.math.Location;
|
||||
import ac.grim.grimac.api.math.Location;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package ac.grim.grimac.platform.bukkit.scheduler.folia;
|
||||
|
||||
import ac.grim.grimac.platform.api.scheduler.TaskHandle;
|
||||
import ac.grim.grimac.api.platform.scheduler.TaskHandle;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
||||
public class FoliaTaskHandle implements TaskHandle {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.sender;
|
||||
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.platform.api.sender.SenderFactory;
|
||||
import ac.grim.grimac.api.GrimAPIProvider;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import ac.grim.grimac.api.platform.sender.SenderFactory;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -45,8 +45,8 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> implements
|
||||
if (sender instanceof Player || sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender) {
|
||||
this.audiences.sender(sender).sendMessage(message);
|
||||
} else {
|
||||
GrimAPI.INSTANCE.getScheduler().getGlobalRegionScheduler().run(
|
||||
GrimAPI.INSTANCE.getGrimPlugin(),
|
||||
GrimAPIProvider.getDirect().getPlatformLoader().getScheduler().getGlobalRegionScheduler().run(
|
||||
GrimAPIProvider.getDirect().getPlatformLoader().getPlugin(),
|
||||
() -> this.audiences.sender(sender).sendMessage(message)
|
||||
);
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
package ac.grim.grimac.platform.bukkit.utils.anticheat;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -9,7 +8,7 @@ import java.lang.reflect.Method;
|
||||
public class MultiLibUtil {
|
||||
|
||||
public final static Method externalPlayerMethod = getMethod(Player.class, "isExternalPlayer");
|
||||
private static final boolean IS_PRE_1_18 = PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_18);
|
||||
private static final boolean IS_PRE_1_18 = ServerVersions.getServerVersion().isOlderThan(ServerVersions.V_1_18);
|
||||
|
||||
public static Method getMethod(Class<?> clazz, String methodName) {
|
||||
try {
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package ac.grim.grimac.platform.bukkit.utils.convert;
|
||||
|
||||
import ac.grim.grimac.platform.api.permissions.PermissionDefaultValue;
|
||||
import ac.grim.grimac.api.platform.permissions.PermissionDefaultValue;
|
||||
import ac.grim.grimac.platform.bukkit.world.BukkitPlatformWorld;
|
||||
import ac.grim.grimac.utils.math.Location;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import ac.grim.grimac.api.math.Location;
|
||||
import ac.grim.grimac.api.packet.world.enums.BlockFace;
|
||||
|
||||
public class BukkitConversionUtils {
|
||||
public static org.bukkit.Location toBukkitLocation(Location location) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ac.grim.grimac.utils.lists;
|
||||
package ac.grim.grimac.platform.bukkit.utils.list;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ac.grim.grimac.utils.lists;
|
||||
package ac.grim.grimac.platform.bukkit.utils.list;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
+8
-9
@@ -1,8 +1,7 @@
|
||||
package ac.grim.grimac.platform.bukkit.utils.placeholder;
|
||||
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.api.GrimAPIProvider;
|
||||
import ac.grim.grimac.api.GrimUser;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -22,12 +21,12 @@ public class PlaceholderAPIExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
public @NotNull String getAuthor() {
|
||||
return String.join(", ", GrimAPI.INSTANCE.getGrimPlugin().getDescription().getAuthors());
|
||||
return String.join(", ", GrimAPIProvider.getDirect().getPlatformLoader().getPlugin().getDescription().getAuthors());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return GrimAPI.INSTANCE.getExternalAPI().getGrimVersion();
|
||||
return GrimAPIProvider.getDirect().getGrimVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,8 +36,8 @@ public class PlaceholderAPIExpansion extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> getPlaceholders() {
|
||||
Set<String> staticReplacements = GrimAPI.INSTANCE.getExternalAPI().getStaticReplacements().keySet();
|
||||
Set<String> variableReplacements = GrimAPI.INSTANCE.getExternalAPI().getVariableReplacements().keySet();
|
||||
Set<String> staticReplacements = GrimAPIProvider.getDirect().getStaticReplacements().keySet();
|
||||
Set<String> variableReplacements = GrimAPIProvider.getDirect().getVariableReplacements().keySet();
|
||||
ArrayList<String> placeholders = new ArrayList<>(staticReplacements.size() + variableReplacements.size());
|
||||
for (String s : staticReplacements) {
|
||||
placeholders.add(s.equals("%grim_version%") ? s : "%grim_" + s.replaceAll("%", "") + "%");
|
||||
@@ -51,7 +50,7 @@ public class PlaceholderAPIExpansion extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
|
||||
for (Map.Entry<String, String> entry : GrimAPI.INSTANCE.getExternalAPI().getStaticReplacements().entrySet()) {
|
||||
for (Map.Entry<String, String> entry : GrimAPIProvider.getDirect().getStaticReplacements().entrySet()) {
|
||||
String key = entry.getKey().equals("%grim_version%")
|
||||
? "version"
|
||||
: entry.getKey().replaceAll("%", "");
|
||||
@@ -61,10 +60,10 @@ public class PlaceholderAPIExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
if (offlinePlayer instanceof Player player) {
|
||||
GrimPlayer grimPlayer = GrimAPI.INSTANCE.getPlayerDataManager().getPlayer(player.getUniqueId());
|
||||
GrimUser grimPlayer = GrimAPIProvider.getDirect().getGrimUser(player.getUniqueId());
|
||||
if (grimPlayer == null) return null;
|
||||
|
||||
for (Map.Entry<String, Function<GrimUser, String>> entry : GrimAPI.INSTANCE.getExternalAPI().getVariableReplacements().entrySet()) {
|
||||
for (Map.Entry<String, Function<GrimUser, String>> entry : GrimAPIProvider.getDirect().getVariableReplacements().entrySet()) {
|
||||
String key = entry.getKey().equals("%player%")
|
||||
? "player"
|
||||
: "player_" + entry.getKey().replaceAll("%", "");
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.utils.reflection;
|
||||
|
||||
import ac.grim.grimac.api.reflection.ReflectionUtils;
|
||||
import ac.grim.grimac.api.util.LogUtil;
|
||||
import ac.grim.grimac.platform.bukkit.GrimACBukkitLoaderPlugin;
|
||||
import ac.grim.grimac.utils.anticheat.LogUtil;
|
||||
import ac.grim.grimac.utils.reflection.ReflectionUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package ac.grim.grimac.platform.bukkit.world;
|
||||
|
||||
import ac.grim.grimac.platform.api.world.PlatformChunk;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import ac.grim.grimac.api.packet.block.PacketBlockState;
|
||||
import ac.grim.grimac.api.platform.world.PlatformChunk;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BukkitPlatformChunk implements PlatformChunk {
|
||||
private static final HashMap<BlockData, Integer> blockDataToId = new HashMap<>();
|
||||
private static final boolean isFlat = PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_13);
|
||||
private static final Map<BlockData, Integer> blockDataToId = new HashMap<>();
|
||||
private static final boolean isFlat = ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_13);
|
||||
private final Chunk chunk;
|
||||
|
||||
public BukkitPlatformChunk(@NotNull Chunk chunkAt) {
|
||||
@@ -25,7 +25,7 @@ public class BukkitPlatformChunk implements PlatformChunk {
|
||||
Block block = chunk.getBlock(x, y, z);
|
||||
|
||||
return isFlat // Cache blockDataToID because Strings are expensive
|
||||
? blockDataToId.computeIfAbsent(block.getBlockData(), data -> WrappedBlockState.getByString(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion(), data.getAsString(false)).getGlobalId())
|
||||
? blockDataToId.computeIfAbsent(block.getBlockData(), data -> PacketBlockState.getByString(ServerVersions.getServerVersion().toClientVersion(), data.getAsString(false)).getGlobalId())
|
||||
: (block.getType().getId() << 4) | block.getData();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package ac.grim.grimac.platform.bukkit.world;
|
||||
|
||||
import ac.grim.grimac.platform.api.world.PlatformChunk;
|
||||
import ac.grim.grimac.platform.api.world.PlatformWorld;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import ac.grim.grimac.api.platform.world.PlatformChunk;
|
||||
import ac.grim.grimac.api.platform.world.PlatformWorld;
|
||||
import ac.grim.grimac.api.packet.block.PacketBlockState;
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -26,9 +26,15 @@ public class BukkitPlatformWorld implements PlatformWorld {
|
||||
return bukkitWorld.isChunkLoaded(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public getBlockAt(int x, int y, int z) {
|
||||
// return fromBukkitBlockData(bukkitWorld.getBlockAt(x, y, z).getBlockData());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public WrappedBlockState getBlockAt(int x, int y, int z) {
|
||||
return SpigotConversionUtil.fromBukkitBlockData(bukkitWorld.getBlockAt(x, y, z).getBlockData());
|
||||
public boolean isAirAt(int x, int y, int z) {
|
||||
PacketBlockState wrappedBlockState = SpigotConversionUtil.fromBukkitBlockData(bukkitWorld.getBlockData(x, y , z));
|
||||
return wrappedBlockState.getType().isAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,12 +40,13 @@ dependencies {
|
||||
exclude(group = "org.yaml", module = "snakeyaml")
|
||||
}
|
||||
// Bump snakeyaml (transitive dep of configuralize) 1.29 -> 2.2 for geyser-fabric
|
||||
api("org.yaml:snakeyaml:2.2")
|
||||
api(libs.snakeyaml)
|
||||
api(libs.fastutil)
|
||||
api(libs.adventure.text.minimessage)
|
||||
api(libs.jetbrains.annotations)
|
||||
|
||||
api("ac.grim.grimac:GrimAPI:1.1.0.0")
|
||||
implementation(project(":api"))
|
||||
implementation(project(":api:packetevents"))
|
||||
|
||||
compileOnly(libs.floodgate.api)
|
||||
compileOnly(libs.via.version.api)
|
||||
|
||||
@@ -9,32 +9,31 @@ import ac.grim.grimac.manager.InitManager;
|
||||
import ac.grim.grimac.manager.SpectateManager;
|
||||
import ac.grim.grimac.manager.TickManager;
|
||||
import ac.grim.grimac.manager.config.BaseConfigManager;
|
||||
import ac.grim.grimac.manager.init.Initable;
|
||||
import ac.grim.grimac.platform.api.Platform;
|
||||
import ac.grim.grimac.platform.api.PlatformLoader;
|
||||
import ac.grim.grimac.platform.api.PlatformServer;
|
||||
import ac.grim.grimac.platform.api.manager.ItemResetHandler;
|
||||
import ac.grim.grimac.platform.api.manager.MessagePlaceHolderManager;
|
||||
import ac.grim.grimac.platform.api.manager.ParserDescriptorFactory;
|
||||
import ac.grim.grimac.platform.api.manager.PermissionRegistrationManager;
|
||||
import ac.grim.grimac.platform.api.manager.PlatformPluginManager;
|
||||
import ac.grim.grimac.platform.api.player.PlatformPlayerFactory;
|
||||
import ac.grim.grimac.platform.api.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.platform.api.sender.SenderFactory;
|
||||
import ac.grim.grimac.api.platform.init.Initable;
|
||||
import ac.grim.grimac.api.platform.Platform;
|
||||
import ac.grim.grimac.api.platform.PlatformLoader;
|
||||
import ac.grim.grimac.api.platform.PlatformServer;
|
||||
import ac.grim.grimac.api.platform.manager.ItemResetHandler;
|
||||
import ac.grim.grimac.api.platform.manager.MessagePlaceHolderManager;
|
||||
import ac.grim.grimac.api.platform.manager.ParserDescriptorFactory;
|
||||
import ac.grim.grimac.api.platform.manager.PermissionRegistrationManager;
|
||||
import ac.grim.grimac.api.platform.manager.PlatformPluginManager;
|
||||
import ac.grim.grimac.api.platform.player.PlatformPlayerFactory;
|
||||
import ac.grim.grimac.api.platform.scheduler.PlatformScheduler;
|
||||
import ac.grim.grimac.api.platform.sender.Sender;
|
||||
import ac.grim.grimac.api.platform.sender.SenderFactory;
|
||||
import ac.grim.grimac.utils.anticheat.PlayerDataManager;
|
||||
import ac.grim.grimac.utils.reflection.ReflectionUtils;
|
||||
import ac.grim.grimac.api.reflection.ReflectionUtils;
|
||||
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||
import lombok.Getter;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
public final class GrimAPI {
|
||||
public static final GrimAPI INSTANCE = new GrimAPI();
|
||||
public final static GrimAPI INSTANCE = new GrimAPI();
|
||||
|
||||
@Getter
|
||||
private final Platform platform = detectPlatform();
|
||||
@@ -51,15 +50,17 @@ public final class GrimAPI {
|
||||
private InitManager initManager;
|
||||
private boolean initialized = false;
|
||||
|
||||
private GrimAPI() {
|
||||
public GrimAPI() {
|
||||
this.configManager = new BaseConfigManager();
|
||||
this.alertManager = new AlertManagerImpl();
|
||||
this.spectateManager = new SpectateManager();
|
||||
this.discordManager = new DiscordManager();
|
||||
this.playerDataManager = new PlayerDataManager();
|
||||
this.alertManager = new AlertManagerImpl(this);
|
||||
this.spectateManager = new SpectateManager(this);
|
||||
this.discordManager = new DiscordManager(this);
|
||||
this.playerDataManager = new PlayerDataManager(this);
|
||||
this.tickManager = new TickManager();
|
||||
this.eventBus = new OptimizedEventBus();
|
||||
this.externalAPI = new GrimExternalAPI(this);
|
||||
System.out.println("GrimAPI classloader: " + GrimAPI.class.getClassLoader());
|
||||
System.out.println("GrimAPI instance: " + this);
|
||||
}
|
||||
|
||||
private static Platform detectPlatform() {
|
||||
@@ -76,9 +77,9 @@ public final class GrimAPI {
|
||||
.orElseThrow(() -> new IllegalStateException("Unknown platform!"));
|
||||
}
|
||||
|
||||
public void load(PlatformLoader platformLoader, Initable... platformSpecificInitables) {
|
||||
public void bootstrap(@NotNull PlatformLoader platformLoader, Initable... platformSpecificInitables) {
|
||||
this.loader = platformLoader;
|
||||
this.initManager = new InitManager(loader.getPacketEvents(), loader::getCommandManager, platformSpecificInitables);
|
||||
this.initManager = new InitManager((PacketEventsAPI<?>) loader.getPacketAPI(), loader::getCommandManager, platformSpecificInitables);
|
||||
this.initManager.load();
|
||||
this.initialized = true;
|
||||
}
|
||||
@@ -142,4 +143,5 @@ public final class GrimAPI {
|
||||
public PermissionRegistrationManager getPermissionManager() {
|
||||
return loader.getPermissionManager();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package ac.grim.grimac;
|
||||
|
||||
import ac.grim.grimac.api.platform.CoreLoader;
|
||||
import ac.grim.grimac.api.platform.PlatformLoader;
|
||||
import ac.grim.grimac.api.platform.init.Initable;
|
||||
|
||||
/**
|
||||
* Service-loader entry that just forwards every call to the
|
||||
* canonical singleton GrimAPI.INSTANCE.
|
||||
* Ensures that ServiceLoader call to clazz.getDeclaredConstructor().newInstance(); will not create two instances
|
||||
*/
|
||||
public final class GrimAPICoreLoader implements CoreLoader {
|
||||
|
||||
@Override
|
||||
public void bootstrap(PlatformLoader platform, Initable... initables) {
|
||||
GrimAPI.INSTANCE.bootstrap(platform, initables);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
GrimAPI.INSTANCE.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
GrimAPI.INSTANCE.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package ac.grim.grimac;
|
||||
|
||||
import ac.grim.grimac.api.GrimAbstractAPI;
|
||||
import ac.grim.grimac.api.platform.Platform;
|
||||
import ac.grim.grimac.api.platform.PlatformLoader;
|
||||
import ac.grim.grimac.api.platform.init.LoadableInitable;
|
||||
import ac.grim.grimac.api.plugin.GrimPluginDescription;
|
||||
import ac.grim.grimac.api.GrimUser;
|
||||
import ac.grim.grimac.api.alerts.AlertManager;
|
||||
@@ -8,16 +11,17 @@ import ac.grim.grimac.api.config.ConfigManager;
|
||||
import ac.grim.grimac.api.event.EventBus;
|
||||
import ac.grim.grimac.api.event.events.GrimReloadEvent;
|
||||
import ac.grim.grimac.manager.config.ConfigManagerFileImpl;
|
||||
import ac.grim.grimac.manager.init.start.StartableInitable;
|
||||
import ac.grim.grimac.api.platform.init.StartableInitable;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.LogUtil;
|
||||
import ac.grim.grimac.utils.chat.ChatUtil;
|
||||
import ac.grim.grimac.api.util.LogUtil;
|
||||
import ac.grim.grimac.api.util.ChatUtil;
|
||||
import ac.grim.grimac.utils.common.ConfigReloadObserver;
|
||||
import com.github.retrooper.packetevents.netty.channel.ChannelHelper;
|
||||
import lombok.Getter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -26,7 +30,7 @@ import java.util.function.Function;
|
||||
|
||||
//This is used for grim's external API. It has its own class just for organization.
|
||||
|
||||
public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, StartableInitable {
|
||||
public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, StartableInitable, LoadableInitable {
|
||||
|
||||
private final GrimAPI api;
|
||||
@Getter
|
||||
@@ -34,12 +38,13 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
@Getter
|
||||
private final Map<String, String> staticReplacements = new ConcurrentHashMap<>();
|
||||
private final Map<String, Function<Object, Object>> functions = new ConcurrentHashMap<>();
|
||||
private final ConfigManagerFileImpl configManagerFile = new ConfigManagerFileImpl();
|
||||
private final ConfigManagerFileImpl configManagerFile;
|
||||
private ConfigManager configManager = null;
|
||||
private boolean started = false;
|
||||
|
||||
public GrimExternalAPI(GrimAPI api) {
|
||||
this.api = api;
|
||||
this.configManagerFile = new ConfigManagerFileImpl(api);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +57,11 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
return api.getPlayerDataManager().getPlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GrimUser> getGrimUsers() {
|
||||
return (Collection) api.getPlayerDataManager().getEntries();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerVariable(String string, Function<GrimUser, String> replacement) {
|
||||
if (replacement == null) {
|
||||
@@ -72,7 +82,7 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
|
||||
@Override
|
||||
public String getGrimVersion() {
|
||||
GrimPluginDescription description = GrimAPI.INSTANCE.getGrimPlugin().getDescription();
|
||||
GrimPluginDescription description = api.getGrimPlugin().getDescription();
|
||||
return description.getVersion();
|
||||
}
|
||||
|
||||
@@ -92,7 +102,7 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
|
||||
@Override
|
||||
public AlertManager getAlertManager() {
|
||||
return GrimAPI.INSTANCE.getAlertManager();
|
||||
return api.getAlertManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,13 +117,23 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
|
||||
@Override
|
||||
public int getCurrentTick() {
|
||||
return GrimAPI.INSTANCE.getTickManager().currentTick;
|
||||
return api.getTickManager().currentTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformLoader getPlatformLoader() {
|
||||
return api.getLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform getPlatform() {
|
||||
return api.getPlatform();
|
||||
}
|
||||
|
||||
// on load, load the config & register the service
|
||||
public void load() {
|
||||
reload(configManagerFile);
|
||||
api.getLoader().registerAPIService();
|
||||
api.getLoader().registerAPIService(this);
|
||||
}
|
||||
|
||||
// handles any config loading that's needed to be done after load
|
||||
@@ -121,7 +141,7 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
public void start() {
|
||||
started = true;
|
||||
try {
|
||||
GrimAPI.INSTANCE.getConfigManager().start();
|
||||
api.getConfigManager().start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -130,7 +150,7 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
@Override
|
||||
public void reload(ConfigManager config) {
|
||||
if (config.isLoadedAsync() && started) {
|
||||
GrimAPI.INSTANCE.getScheduler().getAsyncScheduler().runNow(GrimAPI.INSTANCE.getGrimPlugin(),
|
||||
api.getScheduler().getAsyncScheduler().runNow(api.getGrimPlugin(),
|
||||
() -> successfulReload(config));
|
||||
} else {
|
||||
successfulReload(config);
|
||||
@@ -141,7 +161,7 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
public CompletableFuture<Boolean> reloadAsync(ConfigManager config) {
|
||||
if (config.isLoadedAsync() && started) {
|
||||
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
GrimAPI.INSTANCE.getScheduler().getAsyncScheduler().runNow(GrimAPI.INSTANCE.getGrimPlugin(),
|
||||
api.getScheduler().getAsyncScheduler().runNow(api.getGrimPlugin(),
|
||||
() -> future.complete(successfulReload(config)));
|
||||
return future;
|
||||
}
|
||||
@@ -151,19 +171,19 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
private boolean successfulReload(ConfigManager config) {
|
||||
try {
|
||||
config.reload();
|
||||
GrimAPI.INSTANCE.getConfigManager().load(config);
|
||||
if (started) GrimAPI.INSTANCE.getConfigManager().start();
|
||||
api.getConfigManager().load(config);
|
||||
if (started) api.getConfigManager().start();
|
||||
onReload(config);
|
||||
if (started)
|
||||
GrimAPI.INSTANCE.getScheduler().getAsyncScheduler().runNow(GrimAPI.INSTANCE.getGrimPlugin(),
|
||||
() -> GrimAPI.INSTANCE.getEventBus().post(new GrimReloadEvent(true)));
|
||||
api.getScheduler().getAsyncScheduler().runNow(api.getGrimPlugin(),
|
||||
() -> api.getEventBus().post(new GrimReloadEvent(true)));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (started)
|
||||
GrimAPI.INSTANCE.getScheduler().getAsyncScheduler().runNow(GrimAPI.INSTANCE.getGrimPlugin(),
|
||||
() -> GrimAPI.INSTANCE.getEventBus().post(new GrimReloadEvent(false)));
|
||||
api.getScheduler().getAsyncScheduler().runNow(api.getGrimPlugin(),
|
||||
() -> api.getEventBus().post(new GrimReloadEvent(false)));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -178,13 +198,13 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
// Update variables
|
||||
updateVariables();
|
||||
// Restart
|
||||
GrimAPI.INSTANCE.getAlertManager().reload(configManager);
|
||||
GrimAPI.INSTANCE.getDiscordManager().reload();
|
||||
GrimAPI.INSTANCE.getSpectateManager().reload();
|
||||
api.getAlertManager().reload(configManager);
|
||||
api.getDiscordManager().reload();
|
||||
api.getSpectateManager().reload();
|
||||
// Don't reload players if the plugin hasn't started yet
|
||||
if (!started) return;
|
||||
// Reload checks for all players
|
||||
for (GrimPlayer grimPlayer : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
|
||||
for (GrimPlayer grimPlayer : api.getPlayerDataManager().getEntries()) {
|
||||
ChannelHelper.runInEventLoop(grimPlayer.user.getChannel(), () -> {
|
||||
grimPlayer.updatePermissions();
|
||||
grimPlayer.reload(configManager);
|
||||
@@ -200,10 +220,10 @@ public class GrimExternalAPI implements GrimAbstractAPI, ConfigReloadObserver, S
|
||||
variableReplacements.putIfAbsent("%h_sensitivity%", user -> ((int) Math.round(user.getHorizontalSensitivity() * 200)) + "");
|
||||
variableReplacements.putIfAbsent("%v_sensitivity%", user -> ((int) Math.round(user.getVerticalSensitivity() * 200)) + "");
|
||||
variableReplacements.putIfAbsent("%fast_math%", user -> !user.isVanillaMath() + "");
|
||||
variableReplacements.putIfAbsent("%tps%", user -> String.format("%.2f", GrimAPI.INSTANCE.getPlatformServer().getTPS()));
|
||||
variableReplacements.putIfAbsent("%tps%", user -> String.format("%.2f", api.getPlatformServer().getTPS()));
|
||||
variableReplacements.putIfAbsent("%version%", GrimUser::getVersionName);
|
||||
// static variables
|
||||
staticReplacements.put("%prefix%", ChatUtil.translateAlternateColorCodes('&', GrimAPI.INSTANCE.getConfigManager().getPrefix()));
|
||||
staticReplacements.put("%prefix%", ChatUtil.translateAlternateColorCodes('&', api.getConfigManager().getPrefix()));
|
||||
staticReplacements.putIfAbsent("%grim_version%", getGrimVersion());
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.api.AbstractCheck;
|
||||
import ac.grim.grimac.api.config.ConfigManager;
|
||||
import ac.grim.grimac.api.event.events.FlagEvent;
|
||||
import ac.grim.grimac.api.packet.MCPacket;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketType;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.PacketWrapperFactory;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerFlyingMetaPacket;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,6 +40,8 @@ public class Check extends GrimProcessor implements AbstractCheck {
|
||||
private boolean noModifyPacketPermission;
|
||||
private long lastViolationTime;
|
||||
|
||||
protected PacketWrapperFactory packetFactory = MCPacket.getAPI().packetFactory();
|
||||
|
||||
public Check(final @NotNull GrimPlayer player) {
|
||||
this.player = Objects.requireNonNull(player);
|
||||
|
||||
@@ -171,22 +175,22 @@ public class Check extends GrimProcessor implements AbstractCheck {
|
||||
return offset > 0.001 ? String.format("%.5f", offset) : String.format("%.2E", offset);
|
||||
}
|
||||
|
||||
public boolean isTransaction(PacketTypeCommon packetType) {
|
||||
return packetType == PacketType.Play.Client.PONG ||
|
||||
packetType == PacketType.Play.Client.WINDOW_CONFIRMATION;
|
||||
public boolean isTransaction(PacketType packetType) {
|
||||
return packetType == PacketTypes.Play.Client.PONG ||
|
||||
packetType == PacketTypes.Play.Client.WINDOW_CONFIRMATION;
|
||||
}
|
||||
|
||||
public boolean isFlying(PacketTypeCommon packetType) {
|
||||
return WrapperPlayClientPlayerFlying.isFlying(packetType);
|
||||
public boolean isFlying(PacketType type) {
|
||||
return ClientPlayerFlyingMetaPacket.isFlying(type);
|
||||
}
|
||||
|
||||
public boolean isUpdate(PacketTypeCommon packetType) {
|
||||
public boolean isUpdate(PacketType packetType) {
|
||||
return isFlying(packetType)
|
||||
|| packetType == PacketType.Play.Client.CLIENT_TICK_END
|
||||
|| packetType == PacketTypes.Play.Client.CLIENT_TICK_END
|
||||
|| isTransaction(packetType);
|
||||
}
|
||||
|
||||
public boolean isTickPacket(PacketTypeCommon packetType) {
|
||||
public boolean isTickPacket(PacketType packetType) {
|
||||
if (isTickPacketIncludingNonMovement(packetType)) {
|
||||
if (isFlying(packetType)) {
|
||||
return !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate;
|
||||
@@ -196,12 +200,12 @@ public class Check extends GrimProcessor implements AbstractCheck {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTickPacketIncludingNonMovement(PacketTypeCommon packetType) {
|
||||
public boolean isTickPacketIncludingNonMovement(PacketType packetType) {
|
||||
// On 1.21.2+ fall back to the TICK_END packet IF the player did not send a movement packet for their tick
|
||||
// TickTimer checks to see if player did not send a tick end packet before new flying packet is sent
|
||||
if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21_2)
|
||||
if (player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_21_2)
|
||||
&& !player.packetStateData.didSendMovementBeforeTickEnd) {
|
||||
if (packetType == PacketType.Play.Client.CLIENT_TICK_END) {
|
||||
if (packetType == PacketTypes.Play.Client.CLIENT_TICK_END) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -209,4 +213,6 @@ public class Check extends GrimProcessor implements AbstractCheck {
|
||||
return isFlying(packetType);
|
||||
}
|
||||
|
||||
|
||||
public static final PacketType[] POSSIBLE_TICK_PACKET_TYPES = new PacketType[]{PacketTypes.Play.Client.CLIENT_TICK_END, PacketTypes.Play.Client.PLAYER_FLYING, PacketTypes.Play.Client.PLAYER_POSITION, PacketTypes.Play.Client.PLAYER_ROTATION, PacketTypes.Play.Client.PLAYER_POSITION_AND_ROTATION};
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;
|
||||
|
||||
@CheckData(name = "BadPacketsA", description = "Sent duplicate slot id")
|
||||
public class BadPacketsA extends Check implements PacketCheck {
|
||||
@@ -18,8 +17,8 @@ public class BadPacketsA extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) {
|
||||
final int slot = new WrapperPlayClientHeldItemChange(event).getSlot();
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.HELD_ITEM_CHANGE) {
|
||||
final int slot = packetFactory.clientHeldItemChange(event).getSlot();
|
||||
|
||||
if (slot == lastSlot && flagAndAlert("slot=" + slot) && shouldModifyPackets()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "BadPacketsB", description = "Ignored set rotation packet")
|
||||
public class BadPacketsB extends Check implements PacketCheck {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
@CheckData(name = "BadPacketsC", description = "Interacted with self")
|
||||
public class BadPacketsC extends Check implements PacketCheck {
|
||||
@@ -17,9 +16,9 @@ public class BadPacketsC extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.INTERACT_ENTITY) {
|
||||
if (player.gamemode == GameMode.SPECTATOR) return;
|
||||
if (new WrapperPlayClientInteractEntity(event).getEntityId() == player.entityID) {
|
||||
if (packetFactory.clientInteractEntity(event).getEntityId() == player.entityID) {
|
||||
// Instant ban
|
||||
if (flagAndAlert() && shouldModifyPackets()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerFlyingMetaPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "BadPacketsD", description = "Impossible pitch")
|
||||
public class BadPacketsD extends Check implements PacketCheck {
|
||||
@@ -18,8 +18,8 @@ public class BadPacketsD extends Check implements PacketCheck {
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.packetStateData.lastPacketWasTeleport) return;
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_ROTATION || event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION) {
|
||||
final float pitch = new WrapperPlayClientPlayerFlying(event).getLocation().getPitch();
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.PLAYER_ROTATION || event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION_AND_ROTATION) {
|
||||
final float pitch = ClientPlayerFlyingMetaPacket.from(event).getLocation().getPitch();
|
||||
if (pitch > 90 || pitch < -90) {
|
||||
// Ban.
|
||||
if (flagAndAlert("pitch=" + pitch)) {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
|
||||
@CheckData(name = "BadPacketsE")
|
||||
public class BadPacketsE extends Check implements PacketCheck {
|
||||
@@ -21,13 +19,13 @@ public class BadPacketsE extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
final boolean isViaPleaseStopUsingProtocolHacksOnYourServer = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21_2) || PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2);
|
||||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION ||
|
||||
event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION) {
|
||||
final boolean isViaPleaseStopUsingProtocolHacksOnYourServer = player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_21_2) || ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_21_2);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION_AND_ROTATION ||
|
||||
event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION) {
|
||||
noReminderTicks = 0;
|
||||
} else if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport) {
|
||||
} else if (isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport) {
|
||||
noReminderTicks++;
|
||||
} else if (event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE
|
||||
} else if (event.getPacketType() == PacketTypes.Play.Client.STEER_VEHICLE
|
||||
|| (isViaPleaseStopUsingProtocolHacksOnYourServer && player.inVehicle())) {
|
||||
noReminderTicks = 0; // Exempt vehicles
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "BadPacketsF", description = "Sent duplicate sprinting status")
|
||||
public class BadPacketsF extends Check implements PacketCheck {
|
||||
@@ -19,10 +19,10 @@ public class BadPacketsF extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
|
||||
WrapperPlayClientEntityAction packet = new WrapperPlayClientEntityAction(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION) {
|
||||
ClientEntityActionPacket packet = packetFactory.clientEntityAction(event);
|
||||
|
||||
if (packet.getAction() == WrapperPlayClientEntityAction.Action.START_SPRINTING) {
|
||||
if (packet.getAction() == ClientEntityActionPacket.Action.START_SPRINTING) {
|
||||
if (lastSprinting) {
|
||||
if (exemptNext) {
|
||||
exemptNext = false;
|
||||
@@ -35,7 +35,7 @@ public class BadPacketsF extends Check implements PacketCheck {
|
||||
}
|
||||
|
||||
lastSprinting = true;
|
||||
} else if (packet.getAction() == WrapperPlayClientEntityAction.Action.STOP_SPRINTING) {
|
||||
} else if (packet.getAction() == ClientEntityActionPacket.Action.STOP_SPRINTING) {
|
||||
if (!lastSprinting) {
|
||||
if (exemptNext) {
|
||||
exemptNext = false;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
|
||||
@CheckData(name = "BadPacketsG", description = "Sent duplicate sneaking status")
|
||||
public class BadPacketsG extends Check implements PacketCheck {
|
||||
@@ -18,10 +18,10 @@ public class BadPacketsG extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
|
||||
WrapperPlayClientEntityAction packet = new WrapperPlayClientEntityAction(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION) {
|
||||
ClientEntityActionPacket packet = packetFactory.clientEntityAction(event);
|
||||
|
||||
if (packet.getAction() == WrapperPlayClientEntityAction.Action.START_SNEAKING) {
|
||||
if (packet.getAction() == ClientEntityActionPacket.Action.START_SNEAKING) {
|
||||
// The player may send two START_SNEAKING packets if they respawned
|
||||
if (lastSneaking && !respawn) {
|
||||
if (flagAndAlert("state=true") && shouldModifyPackets()) {
|
||||
@@ -32,7 +32,7 @@ public class BadPacketsG extends Check implements PacketCheck {
|
||||
lastSneaking = true;
|
||||
}
|
||||
respawn = false;
|
||||
} else if (packet.getAction() == WrapperPlayClientEntityAction.Action.STOP_SNEAKING) {
|
||||
} else if (packet.getAction() == ClientEntityActionPacket.Action.STOP_SNEAKING) {
|
||||
if (!lastSneaking && !respawn) {
|
||||
if (flagAndAlert("state=false") && shouldModifyPackets()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockPlaceCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockPlace;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUseItem;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "BadPacketsH", description = "Sent unexpected sequence id", experimental = true)
|
||||
public class BadPacketsH extends BlockPlaceCheck {
|
||||
private int lastSequence;
|
||||
private final boolean isSupportedVersion = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_19) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19);
|
||||
private final boolean isSupportedVersion = player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_19) && ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_19);
|
||||
|
||||
public BadPacketsH(final GrimPlayer player) {
|
||||
super(player);
|
||||
@@ -23,8 +21,8 @@ public class BadPacketsH extends BlockPlaceCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.USE_ITEM
|
||||
&& shouldCancel(new WrapperPlayClientUseItem(event).getSequence())) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.USE_ITEM
|
||||
&& shouldCancel(packetFactory.clientPlayerUseItem(event).getSequence())) {
|
||||
event.setCancelled(true);
|
||||
player.onPacketCancel();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerAbilitiesPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerAbilities;
|
||||
|
||||
@CheckData(name = "BadPacketsI", description = "Claimed to be flying while unable to fly")
|
||||
public class BadPacketsI extends Check implements PacketCheck {
|
||||
@@ -16,8 +16,8 @@ public class BadPacketsI extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_ABILITIES) {
|
||||
if (new WrapperPlayClientPlayerAbilities(event).isFlying() && !player.canFly) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.PLAYER_ABILITIES) {
|
||||
if (ClientPlayerAbilitiesPacket.from(event).isFlying() && !player.canFly) {
|
||||
if (flagAndAlert() && shouldModifyPackets()) {
|
||||
event.setCancelled(true);
|
||||
player.onPacketCancel();
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.data.HeadRotation;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUseItem;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerUseItemPacket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -31,15 +30,15 @@ public class BadPacketsJ extends Check implements PostPredictionCheck {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.USE_ITEM && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21)
|
||||
&& PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21)) {
|
||||
WrapperPlayClientUseItem packet = new WrapperPlayClientUseItem(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.USE_ITEM && player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_21)
|
||||
&& ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_21)) {
|
||||
ClientPlayerUseItemPacket packet = packetFactory.clientPlayerUseItem(event);
|
||||
rotations.add(new HeadRotation(packet.getYaw(), packet.getPitch()));
|
||||
}
|
||||
|
||||
if (isTickPacket(event.getPacketType())) {
|
||||
// due to tick skipping, the rotations sent could be last tick's
|
||||
boolean allowLast = player.canSkipTicks() && (event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION || event.getPacketType() == PacketType.Play.Client.PLAYER_ROTATION);
|
||||
boolean allowLast = player.canSkipTicks() && (event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION_AND_ROTATION || event.getPacketType() == PacketTypes.Play.Client.PLAYER_ROTATION);
|
||||
for (HeadRotation rotation : rotations) {
|
||||
if (rotation.getYaw() == player.xRot && rotation.getPitch() == player.yRot) {
|
||||
allowLast = false;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "BadPacketsK", description = "Sent spectate packets while not in spectator mode")
|
||||
public class BadPacketsK extends Check implements PacketCheck {
|
||||
@@ -16,7 +16,7 @@ public class BadPacketsK extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.SPECTATE) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.SPECTATE) {
|
||||
if (player.gamemode != GameMode.SPECTATOR) {
|
||||
if (flagAndAlert() && shouldModifyPackets()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerDiggingPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -21,15 +21,15 @@ public class BadPacketsL extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) {
|
||||
final WrapperPlayClientPlayerDigging packet = new WrapperPlayClientPlayerDigging(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.PLAYER_DIGGING) {
|
||||
final ClientPlayerDiggingPacket packet = packetFactory.clientPlayerDigging(event);
|
||||
|
||||
if (packet.getAction() == DiggingAction.START_DIGGING || packet.getAction() == DiggingAction.FINISHED_DIGGING || packet.getAction() == DiggingAction.CANCELLED_DIGGING)
|
||||
if (packet.getDiggingAction() == DiggingAction.START_DIGGING || packet.getDiggingAction() == DiggingAction.FINISHED_DIGGING || packet.getDiggingAction() == DiggingAction.CANCELLED_DIGGING)
|
||||
return;
|
||||
|
||||
// 1.8 and above clients always send digging packets that aren't used for digging at 0, 0, 0, facing DOWN
|
||||
// 1.7 and below clients do the same, except use SOUTH for RELEASE_USE_ITEM
|
||||
final int expectedFace = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10) && packet.getAction() == DiggingAction.RELEASE_USE_ITEM
|
||||
final int expectedFace = player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_7_10) && packet.getDiggingAction() == DiggingAction.RELEASE_USE_ITEM
|
||||
? 255 : 0;
|
||||
|
||||
if (packet.getBlockFaceId() != expectedFace
|
||||
@@ -42,8 +42,8 @@ public class BadPacketsL extends Check implements PacketCheck {
|
||||
+ packet.getBlockPosition().getX() + ", " + packet.getBlockPosition().getY() + ", " + packet.getBlockPosition().getZ()
|
||||
+ ", face=" + packet.getBlockFace()
|
||||
+ ", sequence=" + packet.getSequence()
|
||||
+ ", action=" + packet.getAction().toString().toLowerCase(Locale.ROOT)
|
||||
) && shouldModifyPackets() && packet.getAction() != DiggingAction.RELEASE_USE_ITEM) {
|
||||
+ ", action=" + packet.getDiggingAction().toString().toLowerCase(Locale.ROOT)
|
||||
) && shouldModifyPackets() && packet.getDiggingAction() != DiggingAction.RELEASE_USE_ITEM) {
|
||||
event.setCancelled(true);
|
||||
player.onPacketCancel();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientKeepAlivePacket;
|
||||
import ac.grim.grimac.api.packet.types.server.play.ServerKeepAlivePacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.data.Pair;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientKeepAlive;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerKeepAlive;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketSendEvent;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
@@ -24,16 +24,16 @@ public class BadPacketsO extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Server.KEEP_ALIVE) {
|
||||
WrapperPlayServerKeepAlive packet = new WrapperPlayServerKeepAlive(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Server.KEEP_ALIVE) {
|
||||
ServerKeepAlivePacket packet = ServerKeepAlivePacket.from(event);
|
||||
keepaliveMap.add(new Pair<>(packet.getId(), System.nanoTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.KEEP_ALIVE) {
|
||||
WrapperPlayClientKeepAlive packet = new WrapperPlayClientKeepAlive(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.KEEP_ALIVE) {
|
||||
ClientKeepAlivePacket packet = ClientKeepAlivePacket.from(event);
|
||||
|
||||
long id = packet.getId();
|
||||
boolean hasID = false;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientClickWindowPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketSendEvent;
|
||||
import ac.grim.grimac.api.packet.types.server.play.ServerOpenWindowPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.WindowClickType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientClickWindowPacket.WindowClickType;
|
||||
|
||||
@CheckData(name = "BadPacketsP", experimental = true)
|
||||
public class BadPacketsP extends Check implements PacketCheck {
|
||||
@@ -23,8 +23,8 @@ public class BadPacketsP extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketSend(final PacketSendEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Server.OPEN_WINDOW) {
|
||||
WrapperPlayServerOpenWindow window = new WrapperPlayServerOpenWindow(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Server.OPEN_WINDOW) {
|
||||
ServerOpenWindowPacket window = packetFactory.serverOpenWindow(event);
|
||||
this.containerType = window.getType();
|
||||
this.containerId = window.getContainerId();
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public class BadPacketsP extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) {
|
||||
WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.CLICK_WINDOW) {
|
||||
ClientClickWindowPacket wrapper = packetFactory.clientClickWindow(event);
|
||||
WindowClickType clickType = wrapper.getWindowClickType();
|
||||
int button = wrapper.getButton();
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType.Play.Client;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction.Action;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes.Play.Client;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket.Action;
|
||||
|
||||
@CheckData(name = "BadPacketsQ")
|
||||
public class BadPacketsQ extends Check implements PacketCheck {
|
||||
@@ -18,7 +18,7 @@ public class BadPacketsQ extends Check implements PacketCheck {
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == Client.ENTITY_ACTION) {
|
||||
WrapperPlayClientEntityAction wrapper = new WrapperPlayClientEntityAction(event);
|
||||
ClientEntityActionPacket wrapper = packetFactory.clientEntityAction(event);
|
||||
// you are able to send negative jump boost, how and why!?
|
||||
if (Math.abs(wrapper.getJumpBoost()) > 100
|
||||
|| wrapper.getEntityId() != player.entityID
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
@CheckData(name = "BadPacketsR", decay = 0.25, experimental = true)
|
||||
public class BadPacketsR extends Check implements PacketCheck {
|
||||
@@ -38,10 +38,10 @@ public class BadPacketsR extends Check implements PacketCheck {
|
||||
}
|
||||
}
|
||||
//
|
||||
if ((event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION ||
|
||||
event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION) && !player.inVehicle()) {
|
||||
if ((event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION_AND_ROTATION ||
|
||||
event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION) && !player.inVehicle()) {
|
||||
positions++;
|
||||
} else if ((event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE || event.getPacketType() == PacketType.Play.Client.VEHICLE_MOVE)
|
||||
} else if ((event.getPacketType() == PacketTypes.Play.Client.STEER_VEHICLE || event.getPacketType() == PacketTypes.Play.Client.VEHICLE_MOVE)
|
||||
&& player.inVehicle()) {
|
||||
positions++;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.protocol.attribute.Attributes;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientInteractEntityPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.data.packetentity.PacketEntity;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||
import ac.grim.grimac.api.packet.entity.PacketEntityTypes;
|
||||
|
||||
@CheckData(name = "BadPacketsT")
|
||||
public class BadPacketsT extends Check implements PacketCheck {
|
||||
// 1.7 and 1.8 seem to have different hitbox "expansion" values than 1.9+
|
||||
// https://github.com/GrimAnticheat/Grim/pull/1274#issuecomment-1872458702
|
||||
// https://github.com/GrimAnticheat/Grim/pull/1274#issuecomment-1872533497
|
||||
private final boolean hasLegacyExpansion = player.getClientVersion().isOlderThan(ClientVersion.V_1_9);
|
||||
private final boolean hasLegacyExpansion = player.getClientVersion().isOlderThan(PacketClientVersions.V_1_9);
|
||||
private final double maxHorizontalDisplacement = 0.3001 + (hasLegacyExpansion ? 0.1 : 0);
|
||||
private final double minVerticalDisplacement = -0.0001 - (hasLegacyExpansion ? 0.1 : 0);
|
||||
private final double maxVerticalDisplacement = 1.8001 + (hasLegacyExpansion ? 0.1 : 0);
|
||||
@@ -28,8 +28,8 @@ public class BadPacketsT extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (event.getPacketType().equals(PacketType.Play.Client.INTERACT_ENTITY)) {
|
||||
final WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event);
|
||||
if (event.getPacketType().equals(PacketTypes.Play.Client.INTERACT_ENTITY)) {
|
||||
final ClientInteractEntityPacket wrapper = packetFactory.clientInteractEntity(event);
|
||||
// Only INTERACT_AT actually has an interaction vector
|
||||
wrapper.getTarget().ifPresent(targetVector -> {
|
||||
final PacketEntity packetEntity = player.compensatedEntities.getEntity(wrapper.getEntityId());
|
||||
@@ -39,7 +39,7 @@ public class BadPacketsT extends Check implements PacketCheck {
|
||||
}
|
||||
|
||||
// Make sure our target entity is actually a player (Player NPCs work too)
|
||||
if (!EntityTypes.PLAYER.equals(packetEntity.getType())) {
|
||||
if (!PacketEntityTypes.PLAYER.equals(packetEntity.getType())) {
|
||||
// We can't check for any entity that is not a player
|
||||
return;
|
||||
}
|
||||
@@ -50,15 +50,15 @@ public class BadPacketsT extends Check implements PacketCheck {
|
||||
// 28/12/2023 - Player-only is fine
|
||||
// 30/12/2023 - Expansions differ in 1.9+
|
||||
final float scale = (float) packetEntity.getAttributeValue(Attributes.SCALE);
|
||||
if (targetVector.y > (minVerticalDisplacement * scale) && targetVector.y < (maxVerticalDisplacement * scale)
|
||||
&& Math.abs(targetVector.x) < (maxHorizontalDisplacement * scale)
|
||||
&& Math.abs(targetVector.z) < (maxHorizontalDisplacement * scale)) {
|
||||
if (targetVector.getY() > (minVerticalDisplacement * scale) && targetVector.getY() < (maxVerticalDisplacement * scale)
|
||||
&& Math.abs(targetVector.getX()) < (maxHorizontalDisplacement * scale)
|
||||
&& Math.abs(targetVector.getZ()) < (maxHorizontalDisplacement * scale)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Log the vector
|
||||
final String verbose = String.format("%.5f/%.5f/%.5f",
|
||||
targetVector.x, targetVector.y, targetVector.z);
|
||||
targetVector.getX(), targetVector.getY(), targetVector.getZ());
|
||||
// We could pretty much ban the player at this point
|
||||
flagAndAlert(verbose);
|
||||
});
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.item.PacketItemStack;
|
||||
import ac.grim.grimac.api.packet.item.PacketItemTypes;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerBlockPlacementPacket;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3f;
|
||||
import ac.grim.grimac.api.packet.world.enums.BlockFace;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3i;
|
||||
|
||||
@CheckData(name = "BadPacketsU", description = "Sent impossible use item packet")
|
||||
public class BadPacketsU extends Check implements PacketCheck {
|
||||
@@ -22,34 +22,34 @@ public class BadPacketsU extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) {
|
||||
final WrapperPlayClientPlayerBlockPlacement packet = new WrapperPlayClientPlayerBlockPlacement(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.PLAYER_BLOCK_PLACEMENT) {
|
||||
final ClientPlayerBlockPlacementPacket packet = packetFactory.clientPlayerBlockPlacement(event);
|
||||
// BlockFace.OTHER is USE_ITEM for pre 1.9
|
||||
if (packet.getFace() == BlockFace.OTHER) {
|
||||
|
||||
// This packet is always sent at (-1, -1, -1) at (0, 0, 0) on the block
|
||||
// except y gets wrapped?
|
||||
final int expectedY = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8) ? 4095 : 255;
|
||||
final int expectedY = player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_8) ? 4095 : 255;
|
||||
|
||||
final boolean failedItemCheck = packet.getItemStack().isPresent() && isEmpty(packet.getItemStack().get())
|
||||
// ViaVersion can sometimes cause this part of the check to false
|
||||
&& player.getClientVersion().isOlderThan(ClientVersion.V_1_9);
|
||||
&& player.getClientVersion().isOlderThan(PacketClientVersions.V_1_9);
|
||||
|
||||
final Vector3i pos = packet.getBlockPosition();
|
||||
final Vector3f cursor = packet.getCursorPosition();
|
||||
final ImmutableVector3i pos = packet.getBlockPosition();
|
||||
final ImmutableVector3f cursor = packet.getCursorPosition();
|
||||
|
||||
if (failedItemCheck
|
||||
|| pos.x != -1
|
||||
|| pos.y != expectedY
|
||||
|| pos.z != -1
|
||||
|| cursor.x != 0
|
||||
|| cursor.y != 0
|
||||
|| cursor.z != 0
|
||||
|| pos.getX() != -1
|
||||
|| pos.getY() != expectedY
|
||||
|| pos.getZ() != -1
|
||||
|| cursor.getX() != 0
|
||||
|| cursor.getY() != 0
|
||||
|| cursor.getZ() != 0
|
||||
|| packet.getSequence() != 0
|
||||
) {
|
||||
final String verbose = String.format(
|
||||
"xyz=%s, %s, %s, cursor=%s, %s, %s, item=%s, sequence=%s",
|
||||
pos.x, pos.y, pos.z, cursor.x, cursor.y, cursor.z, !failedItemCheck, packet.getSequence()
|
||||
pos.getX(), pos.getY(), pos.getZ(), cursor.getX(), cursor.getY(), cursor.getZ(), !failedItemCheck, packet.getSequence()
|
||||
);
|
||||
if (flagAndAlert(verbose) && shouldModifyPackets()) {
|
||||
player.onPacketCancel();
|
||||
@@ -60,7 +60,7 @@ public class BadPacketsU extends Check implements PacketCheck {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmpty(ItemStack itemStack) {
|
||||
return itemStack.getType() == null || itemStack.getType() == ItemTypes.AIR;
|
||||
private boolean isEmpty(PacketItemStack itemStack) {
|
||||
return itemStack.getType() == null || itemStack.getType() == PacketItemTypes.AIR;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.MCPacket;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerFlyingMetaPacket;
|
||||
|
||||
@CheckData(name = "BadPacketsV", description = "Did not move far enough", experimental = true)
|
||||
public class BadPacketsV extends Check implements PacketCheck {
|
||||
@@ -21,12 +21,12 @@ public class BadPacketsV extends Check implements PacketCheck {
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (!player.canSkipTicks() && isTickPacket(event.getPacketType())) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION || event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION) {
|
||||
int positionAtLeastEveryNTicks = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) ? 20 : 19;
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION || event.getPacketType() == PacketTypes.Play.Client.PLAYER_POSITION_AND_ROTATION) {
|
||||
int positionAtLeastEveryNTicks = player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8) ? 20 : 19;
|
||||
|
||||
if (noReminderTicks < positionAtLeastEveryNTicks && !player.uncertaintyHandler.lastTeleportTicks.hasOccurredSince(1)) {
|
||||
final double deltaSq = new WrapperPlayClientPlayerFlying(event).getLocation().getPosition()
|
||||
.distanceSquared(new Vector3d(player.lastX, player.lastY, player.lastZ));
|
||||
final double deltaSq = ClientPlayerFlyingMetaPacket.from(event).getLocation().getPosition()
|
||||
.distanceSquared(MCPacket.getAPI().getVectorFactory().getImmutableVec3d(player.lastX, player.lastY, player.lastZ));
|
||||
if (deltaSq <= player.getMovementThreshold() * player.getMovementThreshold()) {
|
||||
flagAndAlert("delta=" + Math.sqrt(deltaSq));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
@CheckData(name = "BadPacketsX", experimental = true)
|
||||
public class BadPacketsX extends Check implements PostPredictionCheck {
|
||||
@@ -47,8 +46,8 @@ public class BadPacketsX extends Check implements PostPredictionCheck {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
|
||||
switch (new WrapperPlayClientEntityAction(event).getAction()) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION) {
|
||||
switch (packetFactory.clientEntityAction(event).getAction()) {
|
||||
case START_SNEAKING, STOP_SNEAKING -> {
|
||||
if (sneak) {
|
||||
if (player.canSkipTicks() || flagAndAlert()) {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package ac.grim.grimac.checks.impl.badpackets;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "BadPacketsY", description = "Sent out of bounds slot id")
|
||||
public class BadPacketsY extends Check implements PacketCheck {
|
||||
@@ -16,8 +15,8 @@ public class BadPacketsY extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) {
|
||||
final int slot = new WrapperPlayClientHeldItemChange(event).getSlot();
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.HELD_ITEM_CHANGE) {
|
||||
final int slot = packetFactory.clientHeldItemChange(event).getSlot();
|
||||
if (slot > 8 || slot < 0) { // ban
|
||||
if (flagAndAlert("slot=" + slot) && shouldModifyPackets()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.GrimAPI;
|
||||
import ac.grim.grimac.api.packet.MCPacket;
|
||||
import ac.grim.grimac.api.packet.item.PacketItemTypes;
|
||||
import ac.grim.grimac.api.packet.item.PacketStateType;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3i;
|
||||
import ac.grim.grimac.api.packet.world.PacketStateTypes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@CheckData(name = "AirLiquidBreak", description = "Breaking a block that cannot be broken")
|
||||
public class AirLiquidBreak extends Check implements BlockBreakCheck {
|
||||
public final boolean noFireHitbox = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_15_2);
|
||||
public final boolean noFireHitbox = player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_15_2);
|
||||
private int lastTick;
|
||||
private boolean didLastFlag;
|
||||
// Initialize to non-null values to prevent NPE when checking for blockType properties and if position equals old position
|
||||
private @NonNull Vector3i lastBreakLoc = new Vector3i();
|
||||
private @NonNull StateType lastBlockType = StateTypes.AIR;
|
||||
private @NonNull ImmutableVector3i lastBreakLoc = MCPacket.getAPI().getVectorFactory().getImmutableVec3i();
|
||||
private @NonNull PacketStateType lastBlockType = PacketStateTypes.AIR;
|
||||
|
||||
public AirLiquidBreak(GrimPlayer player) {
|
||||
super(player);
|
||||
@@ -32,7 +33,7 @@ public class AirLiquidBreak extends Check implements BlockBreakCheck {
|
||||
if (blockBreak.action != DiggingAction.START_DIGGING && blockBreak.action != DiggingAction.FINISHED_DIGGING)
|
||||
return;
|
||||
|
||||
final StateType block = blockBreak.block.getType();
|
||||
final PacketStateType block = blockBreak.block.getType();
|
||||
|
||||
// Fixes false from breaking kelp underwater
|
||||
// The client sends two start digging packets to the server both in the same tick. AirLiquidBreak gets called twice, doesn't false the first time, but falses the second
|
||||
@@ -44,20 +45,20 @@ public class AirLiquidBreak extends Check implements BlockBreakCheck {
|
||||
&& !didLastFlag
|
||||
&& lastBlockType.getHardness() == 0.0F
|
||||
&& lastBlockType.getBlastResistance() == 0.0F
|
||||
&& block == StateTypes.WATER
|
||||
&& block == PacketStateTypes.WATER
|
||||
) return;
|
||||
lastTick = newTick;
|
||||
lastBreakLoc = blockBreak.position;
|
||||
lastBlockType = block;
|
||||
|
||||
// the block does not have a hitbox
|
||||
boolean invalid = (block == StateTypes.LIGHT && !(player.getInventory().getHeldItem().is(ItemTypes.LIGHT) || player.getInventory().getOffHand().is(ItemTypes.LIGHT)))
|
||||
boolean invalid = (block == PacketStateTypes.LIGHT && !(player.getInventory().getHeldItem() == PacketItemTypes.LIGHT || player.getInventory().getOffHand() == PacketItemTypes.LIGHT))
|
||||
|| block.isAir()
|
||||
|| block == StateTypes.WATER
|
||||
|| block == StateTypes.LAVA
|
||||
|| block == StateTypes.BUBBLE_COLUMN
|
||||
|| block == StateTypes.MOVING_PISTON
|
||||
|| block == StateTypes.FIRE && noFireHitbox
|
||||
|| block == PacketStateTypes.WATER
|
||||
|| block == PacketStateTypes.LAVA
|
||||
|| block == PacketStateTypes.BUBBLE_COLUMN
|
||||
|| block == PacketStateTypes.MOVING_PISTON
|
||||
|| block == PacketStateTypes.FIRE && noFireHitbox
|
||||
// or the client claims to have broken an unbreakable block
|
||||
|| block.getHardness() == -1.0f && blockBreak.action == DiggingAction.FINISHED_DIGGING;
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
import ac.grim.grimac.api.packet.protocol.attribute.Attributes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
|
||||
import ac.grim.grimac.utils.math.Vector3dm;
|
||||
import ac.grim.grimac.api.math.Vector3dm;
|
||||
import ac.grim.grimac.utils.math.VectorUtils;
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
|
||||
@CheckData(name = "FarBreak", description = "Breaking blocks too far away", experimental = true)
|
||||
public class FarBreak extends Check implements BlockBreakCheck {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.block.PacketBlockState;
|
||||
import ac.grim.grimac.api.packet.item.PacketStateType;
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3i;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
@@ -8,16 +15,8 @@ import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.math.GrimMath;
|
||||
import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed;
|
||||
import ac.grim.grimac.utils.reflection.ViaVersionUtil;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.world.PacketStateTypes;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -29,15 +28,15 @@ public class FastBreak extends Check implements BlockBreakCheck {
|
||||
|
||||
// For some reason these states flag and I don't know why.
|
||||
// Better to just exempt to not annoy legit players.
|
||||
private static final Set<StateType> EXEMPT_STATES = Set.of();
|
||||
private final boolean clientOlderThanServer = PacketEvents.getAPI().getServerManager().getVersion().getProtocolVersion() > player.getClientVersion().getProtocolVersion();
|
||||
private static final Set<PacketStateType> EXEMPT_STATES = Set.of();
|
||||
private final boolean clientOlderThanServer = ServerVersions.getServerVersion().getProtocolVersion() > player.getClientVersion().getProtocolVersion();
|
||||
|
||||
public FastBreak(GrimPlayer playerData) {
|
||||
super(playerData);
|
||||
}
|
||||
|
||||
// The block the player is currently breaking
|
||||
Vector3i targetBlockPosition = null;
|
||||
ImmutableVector3i targetBlockPosition = null;
|
||||
// The maximum amount of damage the player deals to the block
|
||||
//
|
||||
double maximumBlockDamage = 0;
|
||||
@@ -55,8 +54,8 @@ public class FastBreak extends Check implements BlockBreakCheck {
|
||||
if (blockBreak.action == DiggingAction.START_DIGGING) {
|
||||
if (!ViaVersionUtil.isAvailable()) {
|
||||
// Exempt all blocks that do not exist in the player version
|
||||
final WrappedBlockState defaultState = WrappedBlockState.getDefaultState(player.getClientVersion(), blockBreak.block.getType());
|
||||
if (defaultState.getType() == StateTypes.AIR || EXEMPT_STATES.contains(defaultState.getType())) {
|
||||
final PacketBlockState defaultState = PacketBlockState.getDefaultState(player.getClientVersion(), blockBreak.block.getType());
|
||||
if (defaultState.getType() == PacketStateTypes.AIR || EXEMPT_STATES.contains(defaultState.getType())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +64,7 @@ public class FastBreak extends Check implements BlockBreakCheck {
|
||||
// TODO this lazy loads PacketEvents mappings for older versions for clients on versions older than the servers, increasing memory usage
|
||||
// * its the only thing we use non-native mappings for behind ViaVersion
|
||||
// * can we translate back "up" to server version and run check against server version to avoid loading older registries?
|
||||
WrappedBlockState block = clientOlderThanServer ? WrappedBlockState.getByGlobalId(player.getClientVersion(), player.getViaTranslatedClientBlockID(blockBreak.block.getGlobalId())) : blockBreak.block;
|
||||
PacketBlockState block = clientOlderThanServer ? PacketBlockState.getByGlobalId(player.getClientVersion(), player.getViaTranslatedClientBlockID(blockBreak.block.getGlobalId())) : blockBreak.block;
|
||||
|
||||
startBreak = System.currentTimeMillis() - (targetBlockPosition == null ? 50 : 0); // ???
|
||||
targetBlockPosition = blockBreak.position;
|
||||
@@ -117,7 +116,7 @@ public class FastBreak extends Check implements BlockBreakCheck {
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
// Find the most optimal block damage using the animation packet, which is sent at least once a tick when breaking blocks
|
||||
// On 1.8 clients, via screws with this packet meaning we must fall back to the 1.8 idle flying packet
|
||||
if ((player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? event.getPacketType() == PacketType.Play.Client.ANIMATION : WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) && targetBlockPosition != null) {
|
||||
if ((player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_9) ? event.getPacketType() == PacketTypes.Play.Client.ANIMATION : isFlying(event.getPacketType())) && targetBlockPosition != null) {
|
||||
maximumBlockDamage = Math.max(maximumBlockDamage, BlockBreakSpeed.getBlockDamage(player, player.compensatedWorld.getBlock(targetBlockPosition)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
|
||||
@CheckData(name = "InvalidBreak", description = "Sent impossible block face id")
|
||||
public class InvalidBreak extends Check implements BlockBreakCheck {
|
||||
@@ -16,7 +16,7 @@ public class InvalidBreak extends Check implements BlockBreakCheck {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreak blockBreak) {
|
||||
if (blockBreak.faceId == 255 && blockBreak.action == DiggingAction.CANCELLED_DIGGING && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) {
|
||||
if (blockBreak.faceId == 255 && blockBreak.action == DiggingAction.CANCELLED_DIGGING && player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_7_10)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
import ac.grim.grimac.api.packet.world.enums.BlockFace;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
@@ -7,11 +10,8 @@ import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.MessageUtil;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3i;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,7 +21,7 @@ public class MultiBreak extends Check implements BlockBreakCheck {
|
||||
private final List<String> flags = new ArrayList<>();
|
||||
private boolean hasBroken;
|
||||
private BlockFace lastFace;
|
||||
private Vector3i lastPos;
|
||||
private ImmutableVector3i lastPos;
|
||||
|
||||
public MultiBreak(GrimPlayer player) {
|
||||
super(player);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
|
||||
@CheckData(name = "NoSwingBreak", description = "Did not swing while breaking block", experimental = true)
|
||||
public class NoSwingBreak extends Check implements BlockBreakCheck {
|
||||
@@ -27,7 +27,7 @@ public class NoSwingBreak extends Check implements BlockBreakCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.ANIMATION) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ANIMATION) {
|
||||
sentAnimation = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.world.PacketStateTypes;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
|
||||
|
||||
@CheckData(name = "PositionBreakA")
|
||||
public class PositionBreakA extends Check implements BlockBreakCheck {
|
||||
@@ -19,7 +19,7 @@ public class PositionBreakA extends Check implements BlockBreakCheck {
|
||||
public void onBlockBreak(BlockBreak blockBreak) {
|
||||
if (player.inVehicle()
|
||||
|| blockBreak.action == DiggingAction.CANCELLED_DIGGING
|
||||
|| blockBreak.block.getType() == StateTypes.REDSTONE_WIRE
|
||||
|| blockBreak.block.getType() == PacketStateTypes.REDSTONE_WIRE
|
||||
) return;
|
||||
|
||||
SimpleCollisionBox combined = blockBreak.getCombinedBox();
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import ac.grim.grimac.api.packet.world.enums.BlockFace;
|
||||
|
||||
@CheckData(name = "PositionBreakB", experimental = true)
|
||||
public class PositionBreakB extends Check implements BlockBreakCheck {
|
||||
private final int releaseFace = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8) ? 0 : 255;
|
||||
private final int releaseFace = player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_8) ? 0 : 255;
|
||||
private BlockFace lastFace;
|
||||
|
||||
public PositionBreakB(GrimPlayer player) {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.MCPacket;
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3d;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3f;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
@@ -7,16 +12,12 @@ import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
|
||||
import ac.grim.grimac.utils.data.Pair;
|
||||
import ac.grim.grimac.utils.math.Vector3dm;
|
||||
import ac.grim.grimac.api.math.Vector3dm;
|
||||
import ac.grim.grimac.utils.nmsutil.Ray;
|
||||
import ac.grim.grimac.utils.nmsutil.ReachUtils;
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
import ac.grim.grimac.api.packet.protocol.attribute.Attributes;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
import ac.grim.grimac.api.packet.world.enums.BlockFace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -91,25 +92,25 @@ public class RotationBreak extends Check implements BlockBreakCheck {
|
||||
}
|
||||
// End checking if the player is in the block
|
||||
|
||||
List<Vector3f> possibleLookDirs = new ArrayList<>(Arrays.asList(
|
||||
new Vector3f(player.lastXRot, player.yRot, 0),
|
||||
new Vector3f(player.xRot, player.yRot, 0)
|
||||
List<ImmutableVector3f> possibleLookDirs = new ArrayList<>(Arrays.asList(
|
||||
MCPacket.getAPI().getVectorFactory().getImmutableVector3f(player.lastXRot, player.yRot, 0),
|
||||
MCPacket.getAPI().getVectorFactory().getImmutableVector3f(player.xRot, player.yRot, 0)
|
||||
));
|
||||
|
||||
// 1.9+ players could be a tick behind because we don't get skipped ticks
|
||||
if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) {
|
||||
possibleLookDirs.add(new Vector3f(player.lastXRot, player.lastYRot, 0));
|
||||
if (player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_9)) {
|
||||
possibleLookDirs.add(MCPacket.getAPI().getVectorFactory().getImmutableVector3f(player.lastXRot, player.lastYRot, 0));
|
||||
}
|
||||
|
||||
// 1.7 players do not have any of these issues! They are always on the latest look vector
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_8)) {
|
||||
possibleLookDirs = Collections.singletonList(new Vector3f(player.xRot, player.yRot, 0));
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_8)) {
|
||||
possibleLookDirs = Collections.singletonList(MCPacket.getAPI().getVectorFactory().getImmutableVector3f(player.xRot, player.yRot, 0));
|
||||
}
|
||||
|
||||
final double distance = player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
|
||||
for (double d : possibleEyeHeights) {
|
||||
for (Vector3f lookDir : possibleLookDirs) {
|
||||
Vector3d starting = new Vector3d(player.x, player.y + d, player.z);
|
||||
for (ImmutableVector3f lookDir : possibleLookDirs) {
|
||||
ImmutableVector3d starting = MCPacket.getAPI().getVectorFactory().getImmutableVec3d(player.x, player.y + d, player.z);
|
||||
Ray trace = new Ray(player, starting.getX(), starting.getY(), starting.getZ(), lookDir.getX(), lookDir.getY());
|
||||
Pair<Vector3dm, BlockFace> intercept = ReachUtils.calculateIntercept(box, trace.getOrigin(), trace.getPointAtDistance(distance));
|
||||
|
||||
|
||||
@@ -1,48 +1,47 @@
|
||||
package ac.grim.grimac.checks.impl.breaking;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3i;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockBreakCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.MessageUtil;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.packet.player.enums.DiggingAction;
|
||||
import ac.grim.grimac.api.packet.block.PacketBlockState;
|
||||
|
||||
import static ac.grim.grimac.utils.nmsutil.BlockBreakSpeed.getBlockDamage;
|
||||
|
||||
@CheckData(name = "WrongBreak")
|
||||
public class WrongBreak extends Check implements BlockBreakCheck {
|
||||
private final int exemptedY = player.getClientVersion().isOlderThan(ClientVersion.V_1_8) ? 255 : (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_14) ? -1 : 4095);
|
||||
private final int exemptedY = player.getClientVersion().isOlderThan(PacketClientVersions.V_1_8) ? 255 : (ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_14) ? -1 : 4095);
|
||||
private boolean lastBlockWasInstantBreak = false;
|
||||
private Vector3i lastBlock, lastCancelledBlock, lastLastBlock = null;
|
||||
private ImmutableVector3i lastBlock, lastCancelledBlock, lastLastBlock = null;
|
||||
|
||||
public WrongBreak(final GrimPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
// The client sometimes sends a wierd cancel packet
|
||||
private boolean shouldExempt(final WrappedBlockState block, int yPos) {
|
||||
private boolean shouldExempt(final PacketBlockState block, int yPos) {
|
||||
// lastLastBlock is always null when this happens, and lastBlock isn't
|
||||
if (lastLastBlock != null || lastBlock == null)
|
||||
return false;
|
||||
|
||||
// on pre 1.14.4 clients, the YPos of this packet is always the same
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14_4) && yPos != exemptedY)
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_14_4) && yPos != exemptedY)
|
||||
return false;
|
||||
|
||||
// and if this block is not an instant break
|
||||
return player.getClientVersion().isOlderThan(ClientVersion.V_1_14_4) || getBlockDamage(player, block) < 1;
|
||||
return player.getClientVersion().isOlderThan(PacketClientVersions.V_1_14_4) || getBlockDamage(player, block) < 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreak blockBreak) {
|
||||
if (blockBreak.action == DiggingAction.START_DIGGING) {
|
||||
final Vector3i pos = blockBreak.position;
|
||||
final ImmutableVector3i pos = blockBreak.position;
|
||||
|
||||
lastBlockWasInstantBreak = getBlockDamage(player, blockBreak.block) >= 1;
|
||||
lastCancelledBlock = null;
|
||||
@@ -51,11 +50,11 @@ public class WrongBreak extends Check implements BlockBreakCheck {
|
||||
}
|
||||
|
||||
if (blockBreak.action == DiggingAction.CANCELLED_DIGGING) {
|
||||
final Vector3i pos = blockBreak.position;
|
||||
final ImmutableVector3i pos = blockBreak.position;
|
||||
|
||||
if (!shouldExempt(blockBreak.block, pos.y) && !pos.equals(lastBlock)) {
|
||||
if (!shouldExempt(blockBreak.block, pos.getY()) && !pos.equals(lastBlock)) {
|
||||
// https://github.com/GrimAnticheat/Grim/issues/1512
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14_4) || (!lastBlockWasInstantBreak && pos.equals(lastCancelledBlock))) {
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_14_4) || (!lastBlockWasInstantBreak && pos.equals(lastCancelledBlock))) {
|
||||
if (flagAndAlert("action=CANCELLED_DIGGING" + ", last=" + MessageUtil.toUnlabledString(lastBlock) + ", pos=" + MessageUtil.toUnlabledString(pos))) {
|
||||
if (shouldModifyPackets()) {
|
||||
blockBreak.cancel();
|
||||
@@ -71,10 +70,10 @@ public class WrongBreak extends Check implements BlockBreakCheck {
|
||||
}
|
||||
|
||||
if (blockBreak.action == DiggingAction.FINISHED_DIGGING) {
|
||||
final Vector3i pos = blockBreak.position;
|
||||
final ImmutableVector3i pos = blockBreak.position;
|
||||
|
||||
// when a player looks away from the mined block, they send a cancel, and if they look at it again, they don't send another start. (thanks mojang!)
|
||||
if (!pos.equals(lastCancelledBlock) && (!lastBlockWasInstantBreak || player.getClientVersion().isOlderThan(ClientVersion.V_1_14_4)) && !pos.equals(lastBlock)) {
|
||||
if (!pos.equals(lastCancelledBlock) && (!lastBlockWasInstantBreak || player.getClientVersion().isOlderThan(PacketClientVersions.V_1_14_4)) && !pos.equals(lastBlock)) {
|
||||
if (flagAndAlert("action=FINISHED_DIGGING" + ", last=" + MessageUtil.toUnlabledString(lastBlock) + ", pos=" + MessageUtil.toUnlabledString(pos))) {
|
||||
if (shouldModifyPackets()) {
|
||||
blockBreak.cancel();
|
||||
@@ -83,7 +82,7 @@ public class WrongBreak extends Check implements BlockBreakCheck {
|
||||
}
|
||||
|
||||
// 1.14.4+ clients don't send another start break in protected regions
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14_4)) {
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_14_4)) {
|
||||
lastCancelledBlock = null;
|
||||
lastLastBlock = null;
|
||||
lastBlock = null;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.combat;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientInteractEntityPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -25,8 +25,8 @@ public class MultiInteractA extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
|
||||
WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.INTERACT_ENTITY) {
|
||||
ClientInteractEntityPacket packet = packetFactory.clientInteractEntity(event);
|
||||
int entity = packet.getEntityId();
|
||||
boolean sneaking = packet.isSneaking().orElse(false);
|
||||
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package ac.grim.grimac.checks.impl.combat;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3f;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.MessageUtil;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@CheckData(name = "MultiInteractB", experimental = true)
|
||||
public class MultiInteractB extends Check implements PostPredictionCheck {
|
||||
private final ArrayList<String> flags = new ArrayList<>();
|
||||
private Vector3f lastPos;
|
||||
private ImmutableVector3f lastPos;
|
||||
private boolean hasInteracted = false;
|
||||
|
||||
public MultiInteractB(final GrimPlayer player) {
|
||||
@@ -26,8 +25,8 @@ public class MultiInteractB extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
|
||||
Vector3f pos = new WrapperPlayClientInteractEntity(event).getTarget().orElse(null);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.INTERACT_ENTITY) {
|
||||
ImmutableVector3f pos = packetFactory.clientInteractEntity(event).getTarget().orElse(null);
|
||||
|
||||
if (pos == null) {
|
||||
return;
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
package ac.grim.grimac.checks.impl.combat;
|
||||
|
||||
import ac.grim.grimac.api.config.ConfigManager;
|
||||
import ac.grim.grimac.api.packet.MCPacket;
|
||||
import ac.grim.grimac.api.packet.entity.PacketEntityTypes;
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientInteractEntityPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.util.vec.ImmutableVector3d;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
@@ -23,17 +29,12 @@ import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
|
||||
import ac.grim.grimac.utils.data.packetentity.PacketEntity;
|
||||
import ac.grim.grimac.utils.data.packetentity.dragon.PacketEntityEnderDragonPart;
|
||||
import ac.grim.grimac.utils.math.Vector3dm;
|
||||
import ac.grim.grimac.api.math.Vector3dm;
|
||||
import ac.grim.grimac.utils.nmsutil.ReachUtils;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||
import ac.grim.grimac.api.packet.protocol.attribute.Attributes;
|
||||
import ac.grim.grimac.api.packet.entity.PacketEntityType;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,14 +48,14 @@ import java.util.List;
|
||||
@CheckData(name = "Reach", setback = 10)
|
||||
public class Reach extends Check implements PacketCheck {
|
||||
|
||||
private static final List<EntityType> blacklisted = Arrays.asList(
|
||||
EntityTypes.BOAT,
|
||||
EntityTypes.CHEST_BOAT,
|
||||
EntityTypes.SHULKER);
|
||||
private static final List<PacketEntityType> blacklisted = Arrays.asList(
|
||||
PacketEntityTypes.BOAT,
|
||||
PacketEntityTypes.CHEST_BOAT,
|
||||
PacketEntityTypes.SHULKER);
|
||||
private static final CheckResult NONE = new CheckResult(ResultType.NONE, "");
|
||||
// Only one flag per reach attack, per entity, per tick.
|
||||
// We store position because lastX isn't reliable on teleports.
|
||||
private final Int2ObjectMap<Vector3d> playerAttackQueue = new Int2ObjectOpenHashMap<>();
|
||||
private final Int2ObjectMap<ImmutableVector3d> playerAttackQueue = new Int2ObjectOpenHashMap<>();
|
||||
private boolean cancelImpossibleHits;
|
||||
private double threshold;
|
||||
private double cancelBuffer; // For the next 4 hits after using reach, we aggressively cancel reach
|
||||
@@ -65,8 +66,8 @@ public class Reach extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (!player.disableGrim && event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
|
||||
WrapperPlayClientInteractEntity action = new WrapperPlayClientInteractEntity(event);
|
||||
if (!player.disableGrim && event.getPacketType() == PacketTypes.Play.Client.INTERACT_ENTITY) {
|
||||
ClientInteractEntityPacket action = packetFactory.clientInteractEntity(event);
|
||||
|
||||
// Don't let the player teleport to bypass reach
|
||||
if (player.getSetbackTeleportUtil().shouldBlockMovement()) {
|
||||
@@ -92,7 +93,7 @@ public class Reach extends Check implements PacketCheck {
|
||||
if (entity.isDead) return;
|
||||
|
||||
// TODO: Remove when in front of via
|
||||
if (entity.getType() == EntityTypes.ARMOR_STAND && player.getClientVersion().isOlderThan(ClientVersion.V_1_8))
|
||||
if (entity.getType() == PacketEntityTypes.ARMOR_STAND && player.getClientVersion().isOlderThan(PacketClientVersions.V_1_8))
|
||||
return;
|
||||
|
||||
if (player.gamemode == GameMode.CREATIVE || player.gamemode == GameMode.SPECTATOR)
|
||||
@@ -102,7 +103,7 @@ public class Reach extends Check implements PacketCheck {
|
||||
|
||||
boolean tooManyAttacks = playerAttackQueue.size() > 10;
|
||||
if (!tooManyAttacks) {
|
||||
playerAttackQueue.put(action.getEntityId(), new Vector3d(player.x, player.y, player.z)); // Queue for next tick for very precise check
|
||||
playerAttackQueue.put(action.getEntityId(), MCPacket.getAPI().getVectorFactory().getImmutableVec3d(player.x, player.y, player.z)); // Queue for next tick for very precise check
|
||||
}
|
||||
|
||||
boolean knownInvalid = isKnownInvalid(entity);
|
||||
@@ -129,7 +130,7 @@ public class Reach extends Check implements PacketCheck {
|
||||
// Meaning that the other check should be the only one that flags.
|
||||
private boolean isKnownInvalid(PacketEntity reachEntity) {
|
||||
// If the entity doesn't exist, or if it is exempt, or if it is dead
|
||||
if ((blacklisted.contains(reachEntity.getType()) || !reachEntity.isLivingEntity()) && reachEntity.getType() != EntityTypes.END_CRYSTAL)
|
||||
if ((blacklisted.contains(reachEntity.getType()) || !reachEntity.isLivingEntity()) && reachEntity.getType() != PacketEntityTypes.END_CRYSTAL)
|
||||
return false; // exempt
|
||||
|
||||
if (player.gamemode == GameMode.CREATIVE || player.gamemode == GameMode.SPECTATOR)
|
||||
@@ -138,11 +139,11 @@ public class Reach extends Check implements PacketCheck {
|
||||
|
||||
// Filter out what we assume to be cheats
|
||||
if (cancelBuffer != 0) {
|
||||
CheckResult result = checkReach(reachEntity, new Vector3d(player.x, player.y, player.z), true);
|
||||
CheckResult result = checkReach(reachEntity, MCPacket.getAPI().getVectorFactory().getImmutableVec3d(player.x, player.y, player.z), true);
|
||||
return result.isFlag(); // If they flagged
|
||||
} else {
|
||||
SimpleCollisionBox targetBox = reachEntity.getPossibleCollisionBoxes();
|
||||
if (reachEntity.getType() == EntityTypes.END_CRYSTAL) {
|
||||
if (reachEntity.getType() == PacketEntityTypes.END_CRYSTAL) {
|
||||
targetBox = new SimpleCollisionBox(reachEntity.trackedServerPosition.getPos().subtract(1, 0, 1), reachEntity.trackedServerPosition.getPos().add(1, 2, 1));
|
||||
}
|
||||
return ReachUtils.getMinReachToBox(player, targetBox) > player.compensatedEntities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
|
||||
@@ -150,7 +151,7 @@ public class Reach extends Check implements PacketCheck {
|
||||
}
|
||||
|
||||
private void tickBetterReachCheckWithAngle() {
|
||||
for (Int2ObjectMap.Entry<Vector3d> attack : playerAttackQueue.int2ObjectEntrySet()) {
|
||||
for (Int2ObjectMap.Entry<ImmutableVector3d> attack : playerAttackQueue.int2ObjectEntrySet()) {
|
||||
PacketEntity reachEntity = player.compensatedEntities.entityMap.get(attack.getIntKey());
|
||||
if (reachEntity == null) continue;
|
||||
|
||||
@@ -171,16 +172,16 @@ public class Reach extends Check implements PacketCheck {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CheckResult checkReach(PacketEntity reachEntity, Vector3d from, boolean isPrediction) {
|
||||
private CheckResult checkReach(PacketEntity reachEntity, ImmutableVector3d from, boolean isPrediction) {
|
||||
SimpleCollisionBox targetBox = reachEntity.getPossibleCollisionBoxes();
|
||||
|
||||
if (reachEntity.getType() == EntityTypes.END_CRYSTAL) { // Hardcode end crystal box
|
||||
if (reachEntity.getType() == PacketEntityTypes.END_CRYSTAL) { // Hardcode end crystal box
|
||||
targetBox = new SimpleCollisionBox(reachEntity.trackedServerPosition.getPos().subtract(1, 0, 1), reachEntity.trackedServerPosition.getPos().add(1, 2, 1));
|
||||
}
|
||||
|
||||
// 1.7 and 1.8 players get a bit of extra hitbox (this is why you should use 1.8 on cross version servers)
|
||||
// Yes, this is vanilla and not uncertainty. All reach checks have this or they are wrong.
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) {
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_9)) {
|
||||
targetBox.expand(0.1f);
|
||||
}
|
||||
|
||||
@@ -204,12 +205,12 @@ public class Reach extends Check implements PacketCheck {
|
||||
possibleLookDirs.add(ReachUtils.getLook(player, player.lastXRot, player.yRot));
|
||||
|
||||
// 1.9+ players could be a tick behind because we don't get skipped ticks
|
||||
if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) {
|
||||
if (player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_9)) {
|
||||
possibleLookDirs.add(ReachUtils.getLook(player, player.lastXRot, player.lastYRot));
|
||||
}
|
||||
|
||||
// 1.7 players do not have any of these issues! They are always on the latest look vector
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_8)) {
|
||||
possibleLookDirs = Collections.singletonList(ReachUtils.getLook(player, player.xRot, player.yRot));
|
||||
}
|
||||
}
|
||||
@@ -238,7 +239,7 @@ public class Reach extends Check implements PacketCheck {
|
||||
}
|
||||
|
||||
// if the entity is not exempt and the entity is alive
|
||||
if ((!blacklisted.contains(reachEntity.getType()) && reachEntity.isLivingEntity()) || reachEntity.getType() == EntityTypes.END_CRYSTAL) {
|
||||
if ((!blacklisted.contains(reachEntity.getType()) && reachEntity.isLivingEntity()) || reachEntity.getType() == PacketEntityTypes.END_CRYSTAL) {
|
||||
if (minDistance == Double.MAX_VALUE) {
|
||||
cancelBuffer = 1;
|
||||
return new CheckResult(ResultType.HITBOX, "");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerFlyingMetaPacket;
|
||||
|
||||
@CheckData(name = "CrashA")
|
||||
public class CrashA extends Check implements PacketCheck {
|
||||
@@ -18,8 +18,8 @@ public class CrashA extends Check implements PacketCheck {
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.packetStateData.lastPacketWasTeleport) return;
|
||||
if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) {
|
||||
WrapperPlayClientPlayerFlying packet = new WrapperPlayClientPlayerFlying(event);
|
||||
if (isFlying(event.getPacketType())) {
|
||||
ClientPlayerFlyingMetaPacket packet = ClientPlayerFlyingMetaPacket.from(event);
|
||||
|
||||
if (!packet.hasPositionChanged()) return;
|
||||
// Y technically is uncapped, but no player will reach these values legit
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
@CheckData(name = "CrashB", description = "Sent creative mode inventory click packets while not in creative mode")
|
||||
public class CrashB extends Check implements PacketCheck {
|
||||
@@ -16,7 +16,7 @@ public class CrashB extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.CREATIVE_INVENTORY_ACTION) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.CREATIVE_INVENTORY_ACTION) {
|
||||
if (player.gamemode != GameMode.CREATIVE) {
|
||||
event.setCancelled(true);
|
||||
player.onPacketCancel();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.world.IViewPoint;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerFlyingMetaPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
|
||||
@CheckData(name = "CrashC", description = "Sent non-finite position or rotation")
|
||||
public class CrashC extends Check implements PacketCheck {
|
||||
@@ -16,10 +16,10 @@ public class CrashC extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) {
|
||||
WrapperPlayClientPlayerFlying flying = new WrapperPlayClientPlayerFlying(event);
|
||||
if (isFlying(event.getPacketType())) {
|
||||
ClientPlayerFlyingMetaPacket flying = ClientPlayerFlyingMetaPacket.from(event);
|
||||
if (flying.hasPositionChanged()) {
|
||||
Location pos = flying.getLocation();
|
||||
IViewPoint pos = flying.getLocation();
|
||||
if (Double.isNaN(pos.getX()) || Double.isNaN(pos.getY()) || Double.isNaN(pos.getZ())
|
||||
|| Double.isInfinite(pos.getX()) || Double.isInfinite(pos.getY()) || Double.isInfinite(pos.getZ()) ||
|
||||
Float.isNaN(pos.getYaw()) || Float.isNaN(pos.getPitch()) ||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientClickWindowPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketSendEvent;
|
||||
import ac.grim.grimac.api.packet.types.server.play.ServerOpenWindowPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.inventory.inventory.MenuType;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
|
||||
@CheckData(name = "CrashD", description = "Clicking slots in lectern window")
|
||||
public class CrashD extends Check implements PacketCheck {
|
||||
@@ -25,8 +24,8 @@ public class CrashD extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketSend(final PacketSendEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Server.OPEN_WINDOW && isSupportedVersion()) {
|
||||
WrapperPlayServerOpenWindow window = new WrapperPlayServerOpenWindow(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Server.OPEN_WINDOW && isSupportedVersion()) {
|
||||
ServerOpenWindowPacket window = packetFactory.serverOpenWindow(event);
|
||||
this.type = MenuType.getMenuType(window.getType());
|
||||
if (type == MenuType.LECTERN) lecternId = window.getContainerId();
|
||||
}
|
||||
@@ -34,8 +33,8 @@ public class CrashD extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW && isSupportedVersion()) {
|
||||
WrapperPlayClientClickWindow click = new WrapperPlayClientClickWindow(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.CLICK_WINDOW && isSupportedVersion()) {
|
||||
ClientClickWindowPacket click = packetFactory.clientClickWindow(event);
|
||||
int clickType = click.getWindowClickType().ordinal();
|
||||
int button = click.getButton();
|
||||
int windowId = click.getWindowId();
|
||||
@@ -50,7 +49,7 @@ public class CrashD extends Check implements PacketCheck {
|
||||
}
|
||||
|
||||
private boolean isSupportedVersion() {
|
||||
return PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_14);
|
||||
return ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_14);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientSettingsPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientSettings;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "CrashE")
|
||||
public class CrashE extends Check implements PacketCheck {
|
||||
@@ -17,8 +17,8 @@ public class CrashE extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.CLIENT_SETTINGS) {
|
||||
WrapperPlayClientSettings wrapper = new WrapperPlayClientSettings(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.CLIENT_SETTINGS) {
|
||||
ClientSettingsPacket wrapper = ClientSettingsPacket.from(event);
|
||||
int viewDistance = wrapper.getViewDistance();
|
||||
if (viewDistance < 2) {
|
||||
flagAndAlert("distance=" + viewDistance);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientClickWindowPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow;
|
||||
|
||||
@CheckData(name = "CrashF")
|
||||
public class CrashF extends Check implements PacketCheck {
|
||||
@@ -17,8 +17,8 @@ public class CrashF extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) {
|
||||
WrapperPlayClientClickWindow click = new WrapperPlayClientClickWindow(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.CLICK_WINDOW) {
|
||||
ClientClickWindowPacket click = packetFactory.clientClickWindow(event);
|
||||
int clickType = click.getWindowClickType().ordinal();
|
||||
int button = click.getButton();
|
||||
int windowId = click.getWindowId();
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.protocol.version.server.ServerVersions;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientPlayerUseItemPacket;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.BlockPlaceCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
|
||||
import ac.grim.grimac.utils.anticheat.update.BlockPlace;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUseItem;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "CrashG", description = "Sent negative sequence id")
|
||||
public class CrashG extends BlockPlaceCheck {
|
||||
@@ -21,8 +20,8 @@ public class CrashG extends BlockPlaceCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(final PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.USE_ITEM && isSupportedVersion()) {
|
||||
WrapperPlayClientUseItem use = new WrapperPlayClientUseItem(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.USE_ITEM && isSupportedVersion()) {
|
||||
ClientPlayerUseItemPacket use = packetFactory.clientPlayerUseItem(event);
|
||||
if (use.getSequence() < 0) {
|
||||
flagAndAlert();
|
||||
event.setCancelled(true);
|
||||
@@ -48,7 +47,7 @@ public class CrashG extends BlockPlaceCheck {
|
||||
}
|
||||
|
||||
private boolean isSupportedVersion() {
|
||||
return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_19) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19);
|
||||
return player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_19) && ServerVersions.getServerVersion().isNewerThanOrEquals(ServerVersions.V_1_19);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientTabCompletePacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientTabComplete;
|
||||
|
||||
@CheckData(name = "CrashH")
|
||||
public class CrashH extends Check implements PacketCheck {
|
||||
@@ -17,8 +17,8 @@ public class CrashH extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
|
||||
WrapperPlayClientTabComplete wrapper = new WrapperPlayClientTabComplete(event);
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.TAB_COMPLETE) {
|
||||
ClientTabCompletePacket wrapper = ClientTabCompletePacket.from(event);
|
||||
String text = wrapper.getText();
|
||||
final int length = text.length();
|
||||
// general length limit
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ac.grim.grimac.checks.impl.crash;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientSelectBundleItemPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PacketCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientSelectBundleItem;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "CrashI")
|
||||
public class CrashI extends Check implements PacketCheck {
|
||||
@@ -16,10 +16,10 @@ public class CrashI extends Check implements PacketCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.SELECT_BUNDLE_ITEM) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.SELECT_BUNDLE_ITEM) {
|
||||
int selectedItemIndex;
|
||||
try {
|
||||
selectedItemIndex = new WrapperPlayClientSelectBundleItem(event).getSelectedItemIndex();
|
||||
selectedItemIndex = ClientSelectBundleItemPacket.from(event).getSelectedItemIndex();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// thanks packetevents!
|
||||
if (e.getMessage().startsWith("Invalid selectedItemIndex: ")) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "ElytraA", description = "Started gliding while already gliding", experimental = true)
|
||||
public class ElytraA extends Check implements PostPredictionCheck {
|
||||
@@ -19,7 +19,7 @@ public class ElytraA extends Check implements PostPredictionCheck {
|
||||
}
|
||||
|
||||
public void onStartGliding(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ public class ElytraA extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_15) && event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
if (player.getClientVersion().isOlderThan(PacketClientVersions.V_1_15) && event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
) onStartGliding(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "ElytraB", description = "Started gliding without jumping", experimental = true)
|
||||
public class ElytraB extends Check implements PostPredictionCheck {
|
||||
@@ -20,8 +20,8 @@ public class ElytraB extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
&& player.supportsEndTick()
|
||||
) {
|
||||
if (player.packetStateData.knownInput.jump()) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.player.enums.GameMode;
|
||||
|
||||
@CheckData(name = "ElytraC", description = "Started gliding too frequently", experimental = true)
|
||||
public class ElytraC extends Check implements PostPredictionCheck {
|
||||
@@ -22,7 +22,7 @@ public class ElytraC extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ElytraC extends Check implements PostPredictionCheck {
|
||||
glideThisTick = glideLastTick = false;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION && new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA) {
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION && packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA) {
|
||||
if (glideThisTick || glideLastTick) {
|
||||
if (player.canSkipTicks()) {
|
||||
flags++;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
|
||||
@CheckData(name = "ElytraD", description = "Started gliding without an elytra", experimental = true)
|
||||
public class ElytraD extends Check implements PostPredictionCheck {
|
||||
@@ -20,12 +20,12 @@ public class ElytraD extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
&& !player.canGlide()
|
||||
&& flagAndAlert()
|
||||
) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "ElytraE", description = "Started gliding while flying", experimental = true)
|
||||
public class ElytraE extends Check implements PostPredictionCheck {
|
||||
@@ -20,12 +20,12 @@ public class ElytraE extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
&& player.isFlying
|
||||
&& flagAndAlert()
|
||||
) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "ElytraF", description = "Started gliding while on ground", experimental = true)
|
||||
public class ElytraF extends Check implements PostPredictionCheck {
|
||||
@@ -20,12 +20,12 @@ public class ElytraF extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
&& player.clientClaimsLastOnGround
|
||||
&& flagAndAlert()
|
||||
) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.protocol.potion.PotionTypes;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.potion.PotionTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
|
||||
@CheckData(name = "ElytraG", description = "Started gliding with levitation", experimental = true)
|
||||
public class ElytraG extends Check implements PostPredictionCheck {
|
||||
@@ -21,9 +21,9 @@ public class ElytraG extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
&& player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_16)
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
&& player.getClientVersion().isNewerThanOrEquals(PacketClientVersions.V_1_16)
|
||||
&& player.compensatedEntities.self.hasPotionEffect(PotionTypes.LEVITATION)
|
||||
&& flagAndAlert()
|
||||
) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ac.grim.grimac.checks.impl.elytra;
|
||||
|
||||
import ac.grim.grimac.api.packet.protocol.PacketClientVersions;
|
||||
import ac.grim.grimac.api.packet.types.client.play.ClientEntityActionPacket;
|
||||
import ac.grim.grimac.checks.Check;
|
||||
import ac.grim.grimac.checks.CheckData;
|
||||
import ac.grim.grimac.checks.type.PostPredictionCheck;
|
||||
import ac.grim.grimac.player.GrimPlayer;
|
||||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
|
||||
import ac.grim.grimac.api.packet.types.event.PacketReceiveEvent;
|
||||
import ac.grim.grimac.api.packet.types.PacketTypes;
|
||||
|
||||
@CheckData(name = "ElytraH", description = "Started gliding in vehicle", experimental = true)
|
||||
public class ElytraH extends Check implements PostPredictionCheck {
|
||||
@@ -20,12 +20,12 @@ public class ElytraH extends Check implements PostPredictionCheck {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
|
||||
if (player.getClientVersion().isOlderThanOrEquals(PacketClientVersions.V_1_8)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
|
||||
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
|
||||
if (event.getPacketType() == PacketTypes.Play.Client.ENTITY_ACTION
|
||||
&& packetFactory.clientEntityAction(event).getAction() == ClientEntityActionPacket.Action.START_FLYING_WITH_ELYTRA
|
||||
&& player.inVehicle()
|
||||
&& flagAndAlert()
|
||||
) {
|
||||
|
||||
Loaded 100 of 459 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user