Advertisement
m1enkrafft_man

AntiPass v0.0.3

Jun 17th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.01 KB | None | 0 0
  1. package m1.plugins.AntiPass;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.plugin.PluginManager;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8.  
  9. public class AntiPass extends JavaPlugin{
  10.  
  11. Logger log = this.getLogger();
  12. public final MyPlayerListener playerListener = new MyPlayerListener();
  13.  
  14. public void onEnable(){
  15. log.info("[AntiPass] v" + getDescription().getVersion() + " has enabled!");
  16. PluginManager pm = getServer().getPluginManager();
  17.  
  18. pm.registerEvents(this.playerListener, this);
  19.  
  20.  
  21. }
  22.  
  23. public void onDisable(){
  24. log.info("[AntiPass] v" + getDescription().getVersion() + " has disabled!");
  25.  
  26. }
  27.  
  28.  
  29.  
  30.  
  31. }
  32.  
  33.  
  34. package m1.plugins.AntiPass;
  35.  
  36. import java.util.ArrayList;
  37.  
  38. import org.bukkit.OfflinePlayer;
  39. import org.bukkit.command.Command;
  40. import org.bukkit.command.CommandSender;
  41. import org.bukkit.entity.Player;
  42.  
  43.  
  44. public class AntiPassCommandExecutor {
  45.  
  46. private AntiPass antipass;
  47.  
  48. public AntiPassCommandExecutor(AntiPass antipass) {
  49. this.antipass = antipass;
  50. }
  51. public static ArrayList vanish = new ArrayList();
  52. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
  53. if(cmd.getName().equalsIgnoreCase("checkjesus") && sender.isOp()){
  54. AntiPassBooleans.checkJesus = !AntiPassBooleans.checkJesus;
  55. if(AntiPassBooleans.checkJesus = true){
  56. sender.sendMessage("\247b[AntiPass] /247cJesus check has been enabled.");
  57. }else{
  58. sender.sendMessage("\247b[AntiPass] /247cJesus check has been disabled.");
  59. }
  60. return true;
  61. }else if(cmd.getName().equalsIgnoreCase("quickconsume") && sender.isOp()){
  62. AntiPassBooleans.quickConsume = !AntiPassBooleans.quickConsume;
  63. if(AntiPassBooleans.quickConsume = true){
  64. sender.sendMessage("\247b[AntiPass] /247cQuickConsume bypass check has been enabled.");
  65. }else{
  66. sender.sendMessage("\247b[AntiPass] /247cQuickConsume bypass check has been disabled.");
  67. }
  68. return true;
  69. }else if(cmd.getName().equalsIgnoreCase("checknofall") && sender.isOp()){
  70. AntiPassBooleans.checkNofall = !AntiPassBooleans.checkNofall;
  71. if(AntiPassBooleans.checkNofall = true){
  72. sender.sendMessage("\247b[AntiPass] /247cNofall bypass check(s) has been enabled.");
  73. }else{
  74. sender.sendMessage("\247b[AntiPass] /247cNofall bypass check(s) has been disabled.");
  75. }
  76. return true;
  77. }else if(cmd.getName().equalsIgnoreCase("checkfly") && sender.isOp()){
  78. AntiPassBooleans.bedCheck = !AntiPassBooleans.bedCheck;
  79. if(AntiPassBooleans.bedCheck = true){
  80. sender.sendMessage("\247b[AntiPass] /247cFlight bypass check has been enabled.");
  81. }else{
  82. sender.sendMessage("\247b[AntiPass] /247cFLight bypass check has been disabled.");
  83. }
  84. return true;
  85. }else if(cmd.getName().equalsIgnoreCase("autokick") && sender.isOp()){
  86. AntiPassBooleans.autoKick = !AntiPassBooleans.autoKick;
  87. if(AntiPassBooleans.autoKick = true){
  88. sender.sendMessage("\247b[AntiPass] /247cAutoKicker enabled. WARNING: Be wary when using this...");
  89. }else{
  90. sender.sendMessage("\247b[AntiPass] /247cAutoKicker disabled.");
  91. }
  92. return true;
  93.  
  94. }else if(cmd.getName().equalsIgnoreCase("apvanish") && sender.isOp()){
  95. if(sender instanceof Player){
  96. Player toVanish = (Player) sender;
  97. AntiPassVanish.determinePlayer(toVanish);
  98.  
  99. for(Player p : sender.getServer().getOnlinePlayers()){
  100. for(int x = 0; x < AntiPassVanish.vanish.size(); x++){
  101. Player who = (Player) AntiPassVanish.vanish.get(x);
  102. p.hidePlayer(who);
  103. }
  104. }
  105. }else{
  106. sender.sendMessage("\247b[AntiPass] /247cMust be a player to vanish!.");
  107. }
  108. return true;
  109. }else if(cmd.getName().equalsIgnoreCase("aphelp") && sender.isOp()){
  110. sender.sendMessage("\247b[AntiPass] /247c/autokick - Toggles automatic kicker.");
  111. sender.sendMessage("\247b[AntiPass] /247c/quickconsume - Toggles QuickConsume bypass check.");
  112. sender.sendMessage("\247b[AntiPass] /247c/checkfly - Toggles Fly bypass check.");
  113. sender.sendMessage("\247b[AntiPass] /247c/checkjesus - Toggles Jesus bypass check.");
  114. sender.sendMessage("\247b[AntiPass] /247c/checknofall - Toggles Nofall bypass(es) check(s).");
  115. sender.sendMessage("\247b[AntiPass] /247c/apvanish - Makes the sender invisible. (Or visible again)");
  116. return true;
  117.  
  118. }
  119. return false;
  120. }
  121.  
  122. }
  123.  
  124. package m1.plugins.AntiPass;
  125.  
  126. import javax.tools.JavaFileManager.Location;
  127.  
  128. import org.bukkit.Material;
  129. import org.bukkit.World;
  130. import org.bukkit.block.Block;
  131. import org.bukkit.entity.Player;
  132. import org.bukkit.event.EventHandler;
  133. import org.bukkit.event.Listener;
  134. import org.bukkit.event.player.PlayerInteractEvent;
  135. import org.bukkit.event.player.PlayerMoveEvent;
  136. import org.bukkit.event.player.PlayerQuitEvent;
  137.  
  138. public class MyPlayerListener implements Listener{
  139.  
  140. @EventHandler
  141. public void onPlayerMovement(PlayerMoveEvent evt) {
  142. //get some locations n stuff
  143. Location loc = (Location) evt.getPlayer().getLocation();
  144. Location locFrom = (Location) evt.getFrom();
  145. World w = ((org.bukkit.Location) loc).getWorld();
  146. Player player = evt.getPlayer();
  147.  
  148.  
  149. if(AntiPassBooleans.checkNofall){
  150. ((org.bukkit.Location) loc).setY(((org.bukkit.Location) loc).getY() - 1);
  151. int b1 = w.getBlockTypeIdAt((org.bukkit.Location) loc);
  152. boolean isWebMethod;
  153. if(b1 == 30){
  154. isWebMethod = true;
  155. }else{
  156. isWebMethod = false;
  157. }
  158. if(isWebMethod){
  159. if(player.getFallDistance() >= 10 && !player.isOp()){
  160. for (Player p : evt.getPlayer().getServer().getOnlinePlayers()) {
  161. if (p.isOp()){
  162. p.sendMessage("\247b[AntiPass] \247c" + evt.getPlayer().getName() + " might be attempting Nofall exploit. Height: " + player.getFallDistance());
  163. }
  164. }
  165. if(AntiPassBooleans.autoKick){
  166. player.kickPlayer("\247b[AntiPass] Kicked for possible hacking, but not banned. Relog to appeal... or confess.");
  167. }
  168. }
  169. }else{
  170. //add in disconnect method here
  171. }
  172.  
  173. }
  174.  
  175.  
  176.  
  177.  
  178. if(AntiPassBooleans.checkJesus){
  179. //Getting the from and to values of the player
  180. double xFrom = ((Block) locFrom).getX();
  181. double zFrom = ((Block) locFrom).getZ();
  182.  
  183. double xLoc = ((Block) loc).getX();
  184. double zLoc = ((Block) loc).getZ();
  185.  
  186. //Retrieving the differences
  187. double xDistance = xLoc - xFrom;
  188. double zDistance = zLoc - zFrom;
  189.  
  190. //Finally, we have the horizontal distance traveled
  191. final double distanceTraveledHorizontally = Math.sqrt((xDistance * xDistance + zDistance * zDistance));
  192.  
  193. ((org.bukkit.Location) loc).setY(((org.bukkit.Location) loc).getY() - 1);
  194. int b = w.getBlockTypeIdAt((org.bukkit.Location) loc);
  195. if(b == 8 || b == 9){
  196. //Values are guesstimates
  197. if(distanceTraveledHorizontally >= 1.5 && !player.isInsideVehicle() && !player.isOp()){
  198. int jesusViolationLevel = (int)(((distanceTraveledHorizontally / 1.5) * 100));
  199. for (Player p : evt.getPlayer().getServer().getOnlinePlayers()) {
  200. if (p.isOp()){
  201. p.sendMessage("\247b[AntiPass] \247c" + evt.getPlayer().getName() + " might be attempting Jesus. Level: " + jesusViolationLevel + "%");
  202. }
  203. }
  204. if(AntiPassBooleans.autoKick){
  205. player.kickPlayer("\247b[AntiPass] Kicked for possible hacking, but not banned. Relog to appeal... or confess.");
  206. }
  207.  
  208. }
  209.  
  210. }
  211. }//end jesus check
  212.  
  213. }
  214. @EventHandler
  215. public void onPlayerInteract(PlayerInteractEvent evt){
  216.  
  217. if(AntiPassBooleans.bedCheck){
  218. Location loc = (Location) evt.getPlayer().getLocation();
  219. World w = ((org.bukkit.Location) loc).getWorld();
  220. Player player = evt.getPlayer();
  221.  
  222. Location l1 = loc;
  223. Location l2 = loc;
  224. Location l3 = loc;
  225. Location l4 = loc;
  226. boolean nearBoat = false;
  227. boolean nearCart = false;
  228. boolean nearBed = false;
  229.  
  230.  
  231. if(player.getAllowFlight() != true && player.leaveVehicle() == true){
  232. for(int x = 1; x < 4; x++){
  233. ((org.bukkit.Location) l1).setX(((org.bukkit.Location) loc).getX() - x);
  234. ((org.bukkit.Location) l2).setX(((org.bukkit.Location) loc).getX() + x);
  235. ((org.bukkit.Location) l3).setZ(((org.bukkit.Location) loc).getZ() - x);
  236. ((org.bukkit.Location) l4).setZ(((org.bukkit.Location) loc).getZ() + x);
  237. int b = w.getBlockTypeIdAt((org.bukkit.Location) loc);
  238. if(b == 355){
  239. nearBed = true;
  240. }else if(b == 328){
  241. nearCart = true;
  242. }else if(b == 333){
  243. nearBoat = true;
  244. }else{
  245. doNothing();
  246. }
  247.  
  248. }
  249. Location bedLoc = (Location) player.getBedSpawnLocation();
  250. if(nearBed = false){
  251. if(bedLoc != null){
  252.  
  253. double xLoc = ((Block) loc).getX();
  254. double zLoc = ((Block) loc).getZ();
  255.  
  256. double xBed = ((Block) bedLoc).getX();
  257. double zBed = ((Block) bedLoc).getZ();
  258.  
  259. //Retrieving the differences
  260. double xDistance = xLoc - xBed;
  261. double zDistance = zLoc - zBed;
  262.  
  263. //Finally, we have the horizontal distance traveled
  264. final double distanceToPlayerBed = Math.sqrt((xDistance * xDistance + zDistance * zDistance));
  265. if(distanceToPlayerBed > 8){
  266. for (Player p : evt.getPlayer().getServer().getOnlinePlayers()) {
  267. if (p.isOp()){
  268. p.sendMessage("\247b[AntiPass] \247c" + evt.getPlayer().getName() + " might be attempting a Flight bypass.");
  269. }
  270. }
  271. if(AntiPassBooleans.autoKick){
  272. player.kickPlayer("\247b[AntiPass] Kicked for possible hacking, but not banned. Relog to appeal... or confess.");
  273. }
  274. }
  275. }
  276. }else if(bedLoc == null){
  277. for (Player p : evt.getPlayer().getServer().getOnlinePlayers()) {
  278. if (p.isOp()){
  279. p.sendMessage("\247b[AntiPass] \247c" + evt.getPlayer().getName() + " might be attempting a Flight bypass.");
  280. }
  281. }
  282. if(AntiPassBooleans.autoKick){
  283. player.kickPlayer("\247b[AntiPass] Kicked for possible hacking, but not banned. Relog to appeal... or confess.");
  284. }
  285. }
  286. }
  287. }
  288.  
  289. if(AntiPassBooleans.quickConsume){
  290. Location loc = (Location) evt.getPlayer().getLocation();
  291. World w = ((org.bukkit.Location) loc).getWorld();
  292. Player player = evt.getPlayer();
  293. boolean sprinting = player.isSprinting();
  294. if(sprinting){
  295. if(player.getItemInHand().getType() == Material.APPLE || player.getItemInHand().getType() == Material.BREAD || player.getItemInHand().getType() == Material.COOKED_BEEF || player.getItemInHand().getType() == Material.COOKED_CHICKEN || player.getItemInHand().getType() == Material.COOKED_FISH || player.getItemInHand().getType() == Material.COOKIE || player.getItemInHand().getType() == Material.GRILLED_PORK || player.getItemInHand().getType() == Material.PORK || player.getItemInHand().getType() == Material.POTION || player.getItemInHand().getType() == Material.SPIDER_EYE && !player.isOp()){
  296. for (Player p : evt.getPlayer().getServer().getOnlinePlayers()) {
  297. if (p.isOp()){
  298. p.sendMessage("\247b[AntiPass] \247c" + evt.getPlayer().getName() + " might be attempting QuickConsume bypass.");
  299. }
  300. }
  301. if(AntiPassBooleans.autoKick){
  302. player.kickPlayer("\247b[AntiPass] Kicked for possible hacking, but not banned. Relog to appeal... or confess.");
  303. }
  304. }
  305.  
  306.  
  307. }
  308. }
  309.  
  310. }//end interact
  311. @EventHandler
  312. public void onPlayerDisconnect(PlayerQuitEvent evt){
  313. Player player = evt.getPlayer();
  314. if(AntiPassBooleans.checkNofall){
  315. if(player.getFallDistance() >= 10 && !player.isOp()){
  316. for (Player p : evt.getPlayer().getServer().getOnlinePlayers()) {
  317. if (p.isOp()){
  318. p.sendMessage("\247b[AntiPass] \247c" + evt.getPlayer().getName() + " might have disconnected to avoid fall damage.");
  319. }
  320. }
  321. }
  322. }
  323. }
  324.  
  325. public void doNothing(){
  326. return;
  327. }
  328.  
  329. }
  330.  
  331.  
  332. package m1.plugins.AntiPass;
  333.  
  334. import java.util.ArrayList;
  335.  
  336. public class AntiPassBooleans {
  337.  
  338. public AntiPassBooleans(){}
  339.  
  340. public static boolean checkJesus = true;
  341.  
  342. public static boolean checkNofall = true;
  343.  
  344. public static boolean quickConsume = true;
  345.  
  346. public static boolean bedCheck = true;
  347.  
  348. public static boolean autoKick = false;
  349.  
  350.  
  351. }
  352.  
  353. package m1.plugins.AntiPass;
  354.  
  355. import java.util.ArrayList;
  356.  
  357. import org.bukkit.entity.Player;
  358.  
  359. public class AntiPassVanish {
  360.  
  361. public static ArrayList vanish = new ArrayList();
  362.  
  363. public static void determinePlayer(Player player){
  364. if(vanish.contains(player)){
  365. remPlayer(player);
  366. }else{
  367. addPlayer(player);
  368. }
  369. }
  370.  
  371. public static void addPlayer(Player player){
  372. if(!vanish.contains(player)){
  373. vanish.add(player);
  374. player.sendMessage("\247b[AntiPass] /247cLe vanished.");
  375. }
  376. }
  377.  
  378. public static void remPlayer(Player player){
  379. if(vanish.contains(player)){
  380. vanish.remove(vanish.indexOf(player));
  381. player.sendMessage("\247b[AntiPass] /247cLe visible.");
  382. }
  383.  
  384. }
  385.  
  386. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement