Hey guys, i'm invading @H31IX's Repository!

This commit is contained in:
Super Spy committed 2012-05-21 20:05:53 -05:00
1 parent 099f2c3b0f
commit 7a95b23367
24 files changed
+3794 -3794

No files matched your search

@@ -1,89 +1,89 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.h31ix.anticheat.Anticheat;
import net.h31ix.anticheat.Configuration;
import net.h31ix.anticheat.xray.XRayTracker;
/**
* <p>
* The internal hub for all managers.
*/
public class AnticheatManager
{
private Anticheat plugin = null;
private Configuration CONFIGURATION = null;
private XRayTracker XRAY_TRACKER = null;
private PlayerManager PLAYER_MANAGER = null;
private CheckManager CHECK_MANAGER = null;
private Backend BACKEND = null;
private Logger LOGGER = null;
public AnticheatManager(Anticheat instance)
{
plugin = instance;
// now load all the others!!!!!
CONFIGURATION = new Configuration(this);
XRAY_TRACKER = new XRayTracker();
PLAYER_MANAGER = new PlayerManager(this);
CHECK_MANAGER = new CheckManager(this);
BACKEND = new Backend(this);
LOGGER = Logger.getLogger("Minecraft");
}
public void log(String message)
{
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
}
public Anticheat getPlugin()
{
return plugin;
}
public Configuration getConfiguration()
{
return CONFIGURATION;
}
public XRayTracker getXRayTracker()
{
return XRAY_TRACKER;
}
public PlayerManager getPlayerManager()
{
return PLAYER_MANAGER;
}
public CheckManager getCheckManager()
{
return CHECK_MANAGER;
}
public Backend getBackend()
{
return BACKEND;
}
}
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.h31ix.anticheat.Anticheat;
import net.h31ix.anticheat.Configuration;
import net.h31ix.anticheat.xray.XRayTracker;
/**
* <p>
* The internal hub for all managers.
*/
public class AnticheatManager
{
private Anticheat plugin = null;
private Configuration CONFIGURATION = null;
private XRayTracker XRAY_TRACKER = null;
private PlayerManager PLAYER_MANAGER = null;
private CheckManager CHECK_MANAGER = null;
private Backend BACKEND = null;
private Logger LOGGER = null;
public AnticheatManager(Anticheat instance)
{
plugin = instance;
// now load all the others!!!!!
CONFIGURATION = new Configuration(this);
XRAY_TRACKER = new XRayTracker();
PLAYER_MANAGER = new PlayerManager(this);
CHECK_MANAGER = new CheckManager(this);
BACKEND = new Backend(this);
LOGGER = Logger.getLogger("Minecraft");
}
public void log(String message)
{
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
}
public Anticheat getPlugin()
{
return plugin;
}
public Configuration getConfiguration()
{
return CONFIGURATION;
}
public XRayTracker getXRayTracker()
{
return XRAY_TRACKER;
}
public PlayerManager getPlayerManager()
{
return PLAYER_MANAGER;
}
public CheckManager getCheckManager()
{
return CHECK_MANAGER;
}
public Backend getBackend()
{
return BACKEND;
}
}
File diff suppressed because it is too large. Load diff
@@ -1,89 +1,89 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
/**
* <p>
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
*/
public class CheckManager
{
public AnticheatManager manager = null;
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
private static Multimap<Player,CheckType> exemptList = ArrayListMultimap.create();
public CheckManager(AnticheatManager instance)
{
manager = instance;
}
public void activateCheck(CheckType type)
{
manager.log("The "+type.toString()+" check was activated.");
checkIgnoreList.remove(type);
}
public void deactivateCheck(CheckType type)
{
manager.log("The "+type.toString()+" check was deactivated.");
checkIgnoreList.add(type);
}
public boolean isActive(CheckType type)
{
return !checkIgnoreList.contains(type);
}
public void exemptPlayer(Player player, CheckType type)
{
manager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
exemptList.put(player,type);
}
public void unexemptPlayer(Player player, CheckType type)
{
manager.log(player.getName()+" was re-added to the "+type.toString()+" check.");
exemptList.remove(type, type);
}
public boolean isExempt(Player player, CheckType type)
{
return exemptList.containsEntry(player, type);
}
private boolean hasPermission(Player player, String permission)
{
return player.hasPermission(permission);
}
public boolean willCheck(Player player, CheckType type)
{
return isActive(type)
&& manager.getConfiguration().checkInWorld(player.getWorld())
&& !isExempt(player, type)
&& !hasPermission(player, type.getPermission());
}
}
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
/**
* <p>
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
*/
public class CheckManager
{
public AnticheatManager manager = null;
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
private static Multimap<Player,CheckType> exemptList = ArrayListMultimap.create();
public CheckManager(AnticheatManager instance)
{
manager = instance;
}
public void activateCheck(CheckType type)
{
manager.log("The "+type.toString()+" check was activated.");
checkIgnoreList.remove(type);
}
public void deactivateCheck(CheckType type)
{
manager.log("The "+type.toString()+" check was deactivated.");
checkIgnoreList.add(type);
}
public boolean isActive(CheckType type)
{
return !checkIgnoreList.contains(type);
}
public void exemptPlayer(Player player, CheckType type)
{
manager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
exemptList.put(player,type);
}
public void unexemptPlayer(Player player, CheckType type)
{
manager.log(player.getName()+" was re-added to the "+type.toString()+" check.");
exemptList.remove(type, type);
}
public boolean isExempt(Player player, CheckType type)
{
return exemptList.containsEntry(player, type);
}
private boolean hasPermission(Player player, String permission)
{
return player.hasPermission(permission);
}
public boolean willCheck(Player player, CheckType type)
{
return isActive(type)
&& manager.getConfiguration().checkInWorld(player.getWorld())
&& !isExempt(player, type)
&& !hasPermission(player, type.getPermission());
}
}
@@ -1,63 +1,63 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
/**
* <p>
* All the types of checks and their corresponding permission nodes.
*/
public enum CheckType
{
ZOMBE_FLY("anticheat.zombe.fly"),
ZOMBE_NOCLIP("anticheat.zombe.noclip"),
ZOMBE_CHEAT("anticheat.zombe.cheat"),
FLY("anticheat.fly"),
WATER_WALK("anticheat.waterwalk"),
NO_SWING("anticheat.noswing"),
FAST_BREAK("anticheat.fastbreak"),
FAST_PLACE("anticheat.fastplace"),
SPAM("anticheat.spam"),
SPRINT("anticheat.sprint"),
SNEAK("anticheat.sneak"),
SPEED("anticheat.speed"),
SPIDER("anticheat.spider"),
NOFALL("anticheat.nofall"),
FAST_BOW("anticheat.fastbow"),
FAST_EAT("anticheat.fasteat"),
FAST_HEAL("anticheat.fastheal"),
FORCEFIELD("anticheat.forcefield"),
XRAY("anticheat.xray"),
LONG_REACH("anticheat.longreach"),
ITEM_SPAM("anticheat.itemspam");
private final String permission;
private CheckType(String permission)
{
this.permission = permission;
}
public String getPermission()
{
return this.permission;
}
}
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
/**
* <p>
* All the types of checks and their corresponding permission nodes.
*/
public enum CheckType
{
ZOMBE_FLY("anticheat.zombe.fly"),
ZOMBE_NOCLIP("anticheat.zombe.noclip"),
ZOMBE_CHEAT("anticheat.zombe.cheat"),
FLY("anticheat.fly"),
WATER_WALK("anticheat.waterwalk"),
NO_SWING("anticheat.noswing"),
FAST_BREAK("anticheat.fastbreak"),
FAST_PLACE("anticheat.fastplace"),
SPAM("anticheat.spam"),
SPRINT("anticheat.sprint"),
SNEAK("anticheat.sneak"),
SPEED("anticheat.speed"),
SPIDER("anticheat.spider"),
NOFALL("anticheat.nofall"),
FAST_BOW("anticheat.fastbow"),
FAST_EAT("anticheat.fasteat"),
FAST_HEAL("anticheat.fastheal"),
FORCEFIELD("anticheat.forcefield"),
XRAY("anticheat.xray"),
LONG_REACH("anticheat.longreach"),
ITEM_SPAM("anticheat.itemspam");
private final String permission;
private CheckType(String permission)
{
this.permission = permission;
}
public String getPermission()
{
return this.permission;
}
}
@@ -1,47 +1,47 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import org.bukkit.Location;
public class Distance
{
private final Location l1,l2;
public Distance(Location from, Location to)
{
l1 = to;
l2 = from;
}
public double getXDifference()
{
return Math.abs(l1.getX()-l2.getX());
}
public double getZDifference()
{
return Math.abs(l1.getZ()-l2.getZ());
}
public double getYDifference()
{
return Math.abs(l1.getY()-l2.getY());
}
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import org.bukkit.Location;
public class Distance
{
private final Location l1,l2;
public Distance(Location from, Location to)
{
l1 = to;
l2 = from;
}
public double getXDifference()
{
return Math.abs(l1.getX()-l2.getX());
}
public double getZDifference()
{
return Math.abs(l1.getZ()-l2.getZ());
}
public double getYDifference()
{
return Math.abs(l1.getY()-l2.getY());
}
}
@@ -1,161 +1,161 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import java.util.HashMap;
import java.util.Map;
import net.h31ix.anticheat.Configuration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* <p>
* The manager that AntiCheat will use to monitor player's hack levels and to execute events that the admin has set
*/
public class PlayerManager
{
private static Map<String,Integer> level = new HashMap<String,Integer>();
private static Configuration config = null;
private static final int MED_THRESHOLD = 20;
private static final int HIGH_THRESHOLD = 50;
public PlayerManager(AnticheatManager instance) {
config = instance.getConfiguration();
}
private static void reactMedium(Player player)
{
execute("Medium",player);
String [] alert = new String[2];
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
Utilities.alert(alert);
}
private static void reactHigh(Player player)
{
execute("High",player);
String [] alert = new String[2];
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
Utilities.alert(alert);
}
public void increaseLevel(Player player)
{
final String name = player.getName();
if(level.get(name) == null || level.get(name) == 0)
{
level.put(name,1);
}
else
{
final int playerLevel = level.get(name);
level.put(name, playerLevel+1);
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
{
reactMedium(player);
}
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
{
reactHigh(player);
level.put(player.getName(), MED_THRESHOLD+5);
}
else if (playerLevel > 60)
{
level.put(player.getName(), MED_THRESHOLD+5);
}
}
}
public void decreaseLevel(Player player)
{
final String name = player.getName();
if(level.get(name) != null && level.get(name) != 0)
{
int playerLevel = level.get(name)-1;
level.put(name, playerLevel);
}
}
public int getLevel(Player player)
{
final String name = player.getName();
if(level.get(name) != null)
{
return level.get(name);
}
else
{
return 0;
}
}
public void setLevel(Player player, int x)
{
if(!(x > 60 && x < 0))
{
level.put(player.getName(), x);
}
}
public boolean hasLevel(Player player)
{
return level.containsKey(player.getName());
}
public void reset(Player player)
{
level.put(player.getName(),0);
}
public Map<String,Integer> getLevels()
{
return level;
}
private static void execute(String level, Player player)
{
String result = config.getResult(level);
if(result.startsWith("COMMAND["))
{
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}
else if(result.equalsIgnoreCase("KICK"))
{
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
}
else if(result.equalsIgnoreCase("WARN"))
{
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
}
else if(result.equalsIgnoreCase("BAN"))
{
player.setBanned(true);
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
}
}
}
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import java.util.HashMap;
import java.util.Map;
import net.h31ix.anticheat.Configuration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* <p>
* The manager that AntiCheat will use to monitor player's hack levels and to execute events that the admin has set
*/
public class PlayerManager
{
private static Map<String,Integer> level = new HashMap<String,Integer>();
private static Configuration config = null;
private static final int MED_THRESHOLD = 20;
private static final int HIGH_THRESHOLD = 50;
public PlayerManager(AnticheatManager instance) {
config = instance.getConfiguration();
}
private static void reactMedium(Player player)
{
execute("Medium",player);
String [] alert = new String[2];
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
Utilities.alert(alert);
}
private static void reactHigh(Player player)
{
execute("High",player);
String [] alert = new String[2];
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
Utilities.alert(alert);
}
public void increaseLevel(Player player)
{
final String name = player.getName();
if(level.get(name) == null || level.get(name) == 0)
{
level.put(name,1);
}
else
{
final int playerLevel = level.get(name);
level.put(name, playerLevel+1);
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
{
reactMedium(player);
}
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
{
reactHigh(player);
level.put(player.getName(), MED_THRESHOLD+5);
}
else if (playerLevel > 60)
{
level.put(player.getName(), MED_THRESHOLD+5);
}
}
}
public void decreaseLevel(Player player)
{
final String name = player.getName();
if(level.get(name) != null && level.get(name) != 0)
{
int playerLevel = level.get(name)-1;
level.put(name, playerLevel);
}
}
public int getLevel(Player player)
{
final String name = player.getName();
if(level.get(name) != null)
{
return level.get(name);
}
else
{
return 0;
}
}
public void setLevel(Player player, int x)
{
if(!(x > 60 && x < 0))
{
level.put(player.getName(), x);
}
}
public boolean hasLevel(Player player)
{
return level.containsKey(player.getName());
}
public void reset(Player player)
{
level.put(player.getName(),0);
}
public Map<String,Integer> getLevels()
{
return level;
}
private static void execute(String level, Player player)
{
String result = config.getResult(level);
if(result.startsWith("COMMAND["))
{
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}
else if(result.equalsIgnoreCase("KICK"))
{
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
}
else if(result.equalsIgnoreCase("WARN"))
{
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
}
else if(result.equalsIgnoreCase("BAN"))
{
player.setBanned(true);
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
}
}
}
@@ -1,138 +1,138 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.h31ix.anticheat.Anticheat;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public final class Utilities
{
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
private static final List<Material> FOOD = new ArrayList<Material>();
private Utilities()
{
}
public static void alert(String [] message)
{
for(Player p : Bukkit.getServer().getOnlinePlayers())
{
if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.isOp())
{
for(String msg : message)
{
p.sendMessage(msg);
}
}
}
if(Anticheat.getManager().getConfiguration().logConsole())
{
Logger logger = Logger.getLogger("Minecraft");
for(String msg : message)
{
logger.log(Level.INFO,ChatColor.stripColor(msg));
}
}
}
public static boolean cantStandAt(Block block)
{
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
}
private static boolean cantStandClose(Block block)
{
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
}
private static boolean cantStandFar(Block block)
{
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
}
public static boolean canStand(Block block)
{
return !(block.isLiquid() || block.getType() == Material.AIR);
}
public static boolean isInstantBreak(Material m)
{
return INSTANT_BREAK.contains(m);
}
public static boolean isFood(Material m)
{
return FOOD.contains(m);
}
public static boolean sprintFly(Player player)
{
return player.isSprinting() || player.isFlying();
}
public static boolean isOnLilyPad(Player player)
{
Block block = player.getLocation().getBlock();
Material lily = Material.WATER_LILY;
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
}
static
{
INSTANT_BREAK.add(Material.RED_MUSHROOM);
INSTANT_BREAK.add(Material.RED_ROSE);
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
INSTANT_BREAK.add(Material.REDSTONE);
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
INSTANT_BREAK.add(Material.LONG_GRASS);
INSTANT_BREAK.add(Material.PAINTING);
INSTANT_BREAK.add(Material.WHEAT);
INSTANT_BREAK.add(Material.SUGAR_CANE);
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
INSTANT_BREAK.add(Material.DIODE);
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
INSTANT_BREAK.add(Material.SAPLING);
INSTANT_BREAK.add(Material.TORCH);
INSTANT_BREAK.add(Material.CROPS);
INSTANT_BREAK.add(Material.SNOW);
FOOD.add(Material.COOKED_BEEF);
FOOD.add(Material.COOKED_CHICKEN);
FOOD.add(Material.COOKED_FISH);
FOOD.add(Material.GRILLED_PORK);
FOOD.add(Material.PORK);
FOOD.add(Material.MUSHROOM_SOUP);
FOOD.add(Material.RAW_BEEF);
FOOD.add(Material.RAW_CHICKEN);
FOOD.add(Material.RAW_FISH);
FOOD.add(Material.APPLE);
FOOD.add(Material.GOLDEN_APPLE);
FOOD.add(Material.MELON);
FOOD.add(Material.COOKIE);
FOOD.add(Material.BREAD);
FOOD.add(Material.SPIDER_EYE);
FOOD.add(Material.ROTTEN_FLESH);
}
}
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 H31IX http://h31ix.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.manage;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.h31ix.anticheat.Anticheat;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public final class Utilities
{
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
private static final List<Material> FOOD = new ArrayList<Material>();
private Utilities()
{
}
public static void alert(String [] message)
{
for(Player p : Bukkit.getServer().getOnlinePlayers())
{
if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.isOp())
{
for(String msg : message)
{
p.sendMessage(msg);
}
}
}
if(Anticheat.getManager().getConfiguration().logConsole())
{
Logger logger = Logger.getLogger("Minecraft");
for(String msg : message)
{
logger.log(Level.INFO,ChatColor.stripColor(msg));
}
}
}
public static boolean cantStandAt(Block block)
{
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
}
private static boolean cantStandClose(Block block)
{
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
}
private static boolean cantStandFar(Block block)
{
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
}
public static boolean canStand(Block block)
{
return !(block.isLiquid() || block.getType() == Material.AIR);
}
public static boolean isInstantBreak(Material m)
{
return INSTANT_BREAK.contains(m);
}
public static boolean isFood(Material m)
{
return FOOD.contains(m);
}
public static boolean sprintFly(Player player)
{
return player.isSprinting() || player.isFlying();
}
public static boolean isOnLilyPad(Player player)
{
Block block = player.getLocation().getBlock();
Material lily = Material.WATER_LILY;
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
}
static
{
INSTANT_BREAK.add(Material.RED_MUSHROOM);
INSTANT_BREAK.add(Material.RED_ROSE);
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
INSTANT_BREAK.add(Material.REDSTONE);
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
INSTANT_BREAK.add(Material.LONG_GRASS);
INSTANT_BREAK.add(Material.PAINTING);
INSTANT_BREAK.add(Material.WHEAT);
INSTANT_BREAK.add(Material.SUGAR_CANE);
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
INSTANT_BREAK.add(Material.DIODE);
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
INSTANT_BREAK.add(Material.SAPLING);
INSTANT_BREAK.add(Material.TORCH);
INSTANT_BREAK.add(Material.CROPS);
INSTANT_BREAK.add(Material.SNOW);
FOOD.add(Material.COOKED_BEEF);
FOOD.add(Material.COOKED_CHICKEN);
FOOD.add(Material.COOKED_FISH);
FOOD.add(Material.GRILLED_PORK);
FOOD.add(Material.PORK);
FOOD.add(Material.MUSHROOM_SOUP);
FOOD.add(Material.RAW_BEEF);
FOOD.add(Material.RAW_CHICKEN);
FOOD.add(Material.RAW_FISH);
FOOD.add(Material.APPLE);
FOOD.add(Material.GOLDEN_APPLE);
FOOD.add(Material.MELON);
FOOD.add(Material.COOKIE);
FOOD.add(Material.BREAD);
FOOD.add(Material.SPIDER_EYE);
FOOD.add(Material.ROTTEN_FLESH);
}
}