Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Added /guard reset, fixed counter.
Browse files Browse the repository at this point in the history
Former-commit-id: bde8adc
  • Loading branch information
PolskiStevek committed Feb 28, 2020
1 parent b6dbff7 commit 22f322a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import me.ishift.epicguard.bukkit.GuardBukkit;
import me.ishift.epicguard.bukkit.gui.GuiMain;
import me.ishift.epicguard.bukkit.manager.AttackManager;
import me.ishift.epicguard.bukkit.manager.User;
import me.ishift.epicguard.bukkit.manager.UserManager;
import me.ishift.epicguard.universal.Messages;
import me.ishift.epicguard.bukkit.util.server.Updater;
import me.ishift.epicguard.universal.Config;
import me.ishift.epicguard.universal.StorageManager;
import me.ishift.epicguard.universal.check.detection.SpeedCheck;
import me.ishift.epicguard.universal.util.ChatUtil;
import me.ishift.epicguard.universal.util.GeoAPI;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -41,6 +43,7 @@ public boolean onCommand(CommandSender sender, Command c, String s, String[] arg
sender.sendMessage(ChatUtil.fix(" &f/" + s + " menu &8- &7Open main plugin GUI."));
sender.sendMessage(ChatUtil.fix(" &f/" + s + " status &8- &7Toggle antibot notifications (titles)."));
sender.sendMessage(ChatUtil.fix(" &f/" + s + " reload &8- &7Reload configuration and messages."));
sender.sendMessage(ChatUtil.fix(" &f/" + s + " reset &8- &7Disabling attack mode and resetting counters."));
sender.sendMessage(ChatUtil.fix(" &f/" + s + " player <player> &8- &7See information about specific player."));
sender.sendMessage(ChatUtil.fix(" &f/" + s + " whitelist <adress> &8- &7Add specific adress to the whitelist."));
sender.sendMessage(ChatUtil.fix(" &f/" + s + " blacklist <adress> &8- &7Add specific adress to the blacklist."));
Expand Down Expand Up @@ -101,6 +104,11 @@ public boolean onCommand(CommandSender sender, Command c, String s, String[] arg
}
StorageManager.blacklist(args[1]);
send(sender, "&7Blacklisted IP: " + args[1]);
} else if (args[0].equalsIgnoreCase("reset")) {
SpeedCheck.reset();
SpeedCheck.setConnectPerSecond(0);
SpeedCheck.setPingPerSecond(0);
send(sender, "&7Attack counters has been &ccleared&7.");
} else {
send(sender, "&cCommand not found! Use &6/" + s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void handleAttack(AttackType type) {
}

Bukkit.getScheduler().runTaskLater(GuardBukkit.getInstance(), () -> {
if (SpeedCheck.getConnectPerSecond() < 0 || SpeedCheck.getPingPerSecond() < 0) return;
if (SpeedCheck.getConnectPerSecond() == 0 || SpeedCheck.getPingPerSecond() == 0) return;
if (type == AttackType.CONNECT) {
SpeedCheck.setConnectPerSecond(SpeedCheck.getConnectPerSecond() - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ public class AttackTask implements Runnable {
@Override
public void run() {
if (SpeedCheck.getPingPerSecond() < Config.pingSpeed && SpeedCheck.getConnectPerSecond() < Config.connectSpeed) {
if (SpeedCheck.isUnderAttack()) {
SpeedCheck.setAttackMode(false);
SecondTask.setTime(0);
SpeedCheck.setTotalBots(0);
}
if (SpeedCheck.isUnderAttack()) SpeedCheck.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static void handle(AttackType type) {
}

ProxyServer.getInstance().getScheduler().schedule(GuardBungee.getInstance(), () -> {
if (SpeedCheck.getConnectPerSecond() == 0 || SpeedCheck.getPingPerSecond() == 0) return;
if (type == AttackType.CONNECT) {
SpeedCheck.setConnectPerSecond(SpeedCheck.getConnectPerSecond() - 1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.ishift.epicguard.universal.check.detection;

import me.ishift.epicguard.bukkit.task.SecondTask;
import me.ishift.epicguard.universal.Config;
import me.ishift.epicguard.universal.check.Check;
import me.ishift.epicguard.universal.types.Reason;
Expand All @@ -23,6 +24,12 @@ public boolean perform(String address, String nickname) {
return isUnderAttack();
}

public static void reset() {
setAttackMode(false);
SecondTask.setTime(0);
setTotalBots(0);
}

public static int getTotalBots() {
return totalBots;
}
Expand Down

0 comments on commit 22f322a

Please sign in to comment.