Files
src
build.gradle
Code
4 105
src/main/java/com/antiflyexploit/AntiFlyExploit.java
package com.antiflyexploit;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Date;
public class AntiFlyExploit extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new FlyListener(this), this);
Bukkit.getScheduler().runTaskTimer(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isFlying()
&& !player.isOp()
&& !player.hasPermission("antiflyexploit.bypass")
&& player.getGameMode() != GameMode.CREATIVE
&& player.getGameMode() != GameMode.SPECTATOR) {
banPlayer(player);
}
}
}, 0L, 100L);
getLogger().info("AntiFlyExploit v" + getDescription().getVersion() + " enabled!");
}
@Override
public void onDisable() {
getLogger().info("AntiFlyExploit disabled!");
}
public void banPlayer(Player player) {
player.setFlying(false);
player.setAllowFlight(false);
Bukkit.getBanList(BanList.Type.NAME).addBan(
player.getName(),
"use hacks",
new Date(System.currentTimeMillis() + 172800000L),
null
);
player.kickPlayer("use hacks");
}
}