Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Unfinished Rewrite Part 3

  • Loading branch information...
commit 0e9d20939f94a0c637e0b999d64e0ebad5a69f32 1 parent 269ce4a
@SuperSpyTX authored
View
2  src/me/freebuild/superspytx/ab/AntiBot.java
@@ -40,7 +40,7 @@ public void onEnable()
/* Register players on server */
for(Player pl : this.getServer().getOnlinePlayers())
{
- GD.getPI(pl).ab_loggedin = true;
+ GD.getPI(pl).ab_alreadyin = true;
}
/* All finished */
View
4 src/me/freebuild/superspytx/ab/abs/EventAction.java
@@ -4,7 +4,6 @@
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerLoginEvent;
@@ -53,6 +52,9 @@ public EventAction(Event e, boolean isasync)
{
if(((Cancellable) e).isCancelled())
cancelled = true;
+
+ if(message == null)
+ cancelled = true;
}
async = isasync;
}
View
23 src/me/freebuild/superspytx/ab/abs/PI.java
@@ -9,7 +9,9 @@
public Player pl;
public String p_name;
public boolean online = true;
- public boolean ab_loggedin = false; // true if already logged in.
+ public long ab_lastdc = 0L;
+ public boolean ab_alreadyin = false; // true if already logged in.
+ public boolean ab_online = true;
/* Bot Handler Data */
public long b_connectfor = 0L;
@@ -23,6 +25,7 @@
/* Captcha Data */
public boolean cp_haspuzzle = false;
+ public Puzzle cp_puzzle;
public PI(Player pl)
@@ -41,11 +44,23 @@ public PI(String pl)
public boolean updateOnlineStatus()
{
- if(pl != null)
- return true;
-
pl = Bukkit.getPlayerExact(p_name);
+ if(pl != null)
+ this.clean();
return (pl != null);
}
+
+ public void clean()
+ {
+ this.b_connectfor = System.currentTimeMillis();
+ this.ab_lastdc = 0L;
+ this.ab_online = true;
+ this.cp_haspuzzle = false;
+ this.cs_ct = 0;
+ this.cs_lm = "";
+ this.cs_lmt = 0L;
+ this.cs_rd = 0L;
+ this.cs_trig = false;
+ }
}
View
5 src/me/freebuild/superspytx/ab/callunits/ChatUnit.java
@@ -28,7 +28,7 @@ public void cmd(PlayerCommandPreprocessEvent e)
@EventHandler(priority = EventPriority.HIGHEST)
public void highest(AsyncPlayerChatEvent e)
{
- if(WorkflowAgent.dispatchUnit(e, Handlers.CHATFLOW, true))
+ if(WorkflowAgent.dispatchUnit(e, Handlers.CHATFLOW, false))
e.setCancelled(true);
}
@@ -37,5 +37,8 @@ public void low(AsyncPlayerChatEvent e)
{
if (GD.cf_gm)
e.setCancelled(true);
+
+ if (WorkflowAgent.dispatchUnit(e, Handlers.CAPTCHA, true))
+ e.setCancelled(true);
}
}
View
3  src/me/freebuild/superspytx/ab/handlers/Handlers.java
@@ -13,7 +13,8 @@
BOT(new BotHandler(), new LoginUnit(), Permissions.JOIN),
CHATSPAM(new ChatSpamHandler(), new ChatUnit(), Permissions.CHATSPAM),
CHATFLOW(new ChatFlowHandler(), null, Permissions.VOICE),
- COUNTRYBANS(new CountryHandler(), null, Permissions.COUNTRYBAN);
+ COUNTRYBANS(new CountryHandler(), null, Permissions.COUNTRYBAN),
+ CAPTCHA(new CaptchaHandler(), null, Permissions.CAPTCHA);
private Handler handlerinstance;
private CallUnit unit;
View
17 src/me/freebuild/superspytx/ab/handlers/chat/CaptchaHandler.java
@@ -2,6 +2,8 @@
import me.freebuild.superspytx.ab.abs.EventAction;
import me.freebuild.superspytx.ab.abs.Handler;
+import me.freebuild.superspytx.ab.abs.PI;
+import me.freebuild.superspytx.ab.workflow.GD;
public class CaptchaHandler implements Handler
{
@@ -9,6 +11,21 @@
@Override
public boolean run(EventAction info)
{
+ PI pli = GD.getPI(info.player);
+ if(pli.cp_haspuzzle)
+ {
+ if(pli.cp_puzzle.overboard())
+ return true;
+ else
+ {
+ if(pli.cp_puzzle.isVersion2())
+ {
+
+ } else {
+
+ }
+ }
+ }
return false;
}
View
16 src/me/freebuild/superspytx/ab/handlers/chat/ChatFlowHandler.java
@@ -2,8 +2,6 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
import me.freebuild.superspytx.ab.AB;
import me.freebuild.superspytx.ab.AntiBot;
import me.freebuild.superspytx.ab.abs.EventAction;
@@ -19,11 +17,7 @@
@Override
public boolean run(EventAction info)
{
- if (GD.cf_gm)
- return false;
- if (info.message == null)
- return false;
- if ((GD.getPI(info.player).cs_trig))
+ if (GD.cf_gm || info.message == null || (GD.getPI(info.player).cs_trig) || (GD.getPI(info.player).cp_haspuzzle))
return false; // triggered spam? don't count towards chat flow.
AB.debug("Chat Flow debug");
int ct = 0;
@@ -39,8 +33,8 @@ public boolean run(EventAction info)
if (StringTils.strDiffCounter(info.message, GD.cf_lm) < Settings.spamdiffct && !GD.cf_lp.equalsIgnoreCase(info.player.getName()))
{
AB.debug("Str diff: " + StringTils.strDiffCounter(info.message, GD.cf_lm));
- GD.cf_cts+=2;
- ct+=2;
+ GD.cf_cts += 2;
+ ct += 2;
AB.debug("VL: " + GD.cf_cts);
}
if (GD.cf_cts >= Settings.overflows)
@@ -58,7 +52,7 @@ public boolean run(EventAction info)
return false;
}
}
-
+
AB.debug("Chat not overflowed.");
GD.cf_cts = 0;
GD.cf_lmt = System.currentTimeMillis();
@@ -87,7 +81,7 @@ public void run()
Bukkit.broadcastMessage(Settings.prefix + ChatColor.RED + Settings.overflowedmessage.replace("%sec%", Long.toString(GD.cf_ttmf)));
}
- }, 40L);
+ }, 20L);
Bukkit.getScheduler().scheduleAsyncDelayedTask(AntiBot.getInstance(), new Runnable()
{
View
2  src/me/freebuild/superspytx/ab/handlers/chat/ChatSpamHandler.java
@@ -19,7 +19,7 @@ public boolean run(EventAction info)
PI pli = GD.getPI(info.player);
pli.cs_trig = false;
- if (MathTils.getLongDiff(pli.b_connectfor) < 2000L && !pli.ab_loggedin)
+ if (MathTils.getLongDiff(pli.b_connectfor) < 2000L && !pli.ab_alreadyin)
pli.cs_ct+= 2;
AB.debug("Chat spam check for " + info.player.getName());
View
2  src/me/freebuild/superspytx/ab/handlers/login/CountryHandler.java
@@ -23,7 +23,7 @@ public boolean run(EventAction info)
@Override
public void performActions(EventAction info)
{
- // do nothing.
+ // do nothing. the player is already denied access.
}
}
View
8 src/me/freebuild/superspytx/ab/settings/Permissions.java
@@ -16,7 +16,7 @@
COUNTRYBAN("countryban", 1),
//admin level permissions
- ADMIN_PLUS("admin.basic", 2),
+ ADMIN_BASIC("admin.basic", 2),
ADMIN("admin", 3),
//individual permissions.
@@ -41,7 +41,7 @@
public boolean isLevelPermission()
{
- return baseperm == ADMIN.baseperm || baseperm == ADMIN_PLUS.baseperm;
+ return baseperm == ADMIN.baseperm || baseperm == ADMIN_BASIC.baseperm;
}
public boolean getPermission(Player pl, CommandSender sender)
@@ -82,12 +82,12 @@ public boolean getPermission(Player pl)
return false;
}
- if (ADMIN_PLUS.getPermission(pl) && level >= 3)
+ if (ADMIN.getPermission(pl) && level >= 3)
{
return true;
}
- if (ADMIN.getPermission(pl) && level < 3)
+ if (ADMIN_BASIC.getPermission(pl) && level < 3)
{
return true;
}
View
5 src/me/freebuild/superspytx/ab/settings/SettingsCore.java
@@ -54,6 +54,7 @@ public void loadDefaults()
config.put("AntiBot.Bot.ConnectionTime", Settings.connectFor);
config.put("AntiBot.AntiSpam.Enabled", Settings.enableAntiSpam);
config.put("AntiBot.AntiSpam.Amount", Settings.spamam);
+ config.put("AntiBot.AntiSpam.StringDiffMin", Settings.spamdiffct);
config.put("AntiBot.AntiSpam.Time", Settings.spamtime);
config.put("AntiBot.AntiSpam.MutePlayerIfCaptchaNotEnabled", Settings.chatMute);
config.put("AntiBot.ChatFlow.Enabled", Settings.flowEnabled);
@@ -173,6 +174,10 @@ else if (conf.equalsIgnoreCase("AntiSpam.Amount"))
{
Settings.spamam = (Integer) duh;
}
+ else if (conf.equalsIgnoreCase("AntiSpam.StringDiffMin"))
+ {
+ Settings.spamdiffct = (Integer) duh;
+ }
else if (conf.equalsIgnoreCase("AntiSpam.Time"))
{
Settings.spamtime = (Integer) duh;
View
2  src/me/freebuild/superspytx/ab/tils/MathTils.java
@@ -18,7 +18,7 @@ public static boolean consistency(PI pl, Long time) {
long round = diff - (diff % 1000); // Thanks overflowed stacks!
- // begin identifying patterns. By 5 seconds.
+ // begin identifying patterns.
if(pl.cs_rd != 0L)
{
long max = pl.cs_rd - 800L; // drop .8 seconds from the stored rounded difference.
View
11 src/me/freebuild/superspytx/ab/workflow/GD.java
@@ -41,7 +41,7 @@ public static PI getPI(Player player)
public static PI getPI(String player)
{
if(opii.containsKey(player))
- updateOfflineData(player);
+ return updateOfflineData(player);
if(pii.containsKey(player))
return pii.get(player);
else
@@ -59,21 +59,26 @@ public static void unregisterPI(Player player)
public static void unregisterPI(String player)
{
+ getPI(player).ab_lastdc = System.currentTimeMillis();
+ getPI(player).ab_online = false;
opii.put(player, getPI(player));
pii.remove(player);
}
- private static void updateOfflineData(String player)
+ private static PI updateOfflineData(String player)
{
if(opii.get(player) != null)
{
PI bug = opii.get(player);
if(bug.updateOnlineStatus())
{
- opii.remove(player);
pii.put(player, bug);
+ opii.remove(player);
}
+ return bug;
}
+
+ return null;
}
}
View
8 src/me/freebuild/superspytx/ab/workflow/WorkflowAgent.java
@@ -36,13 +36,13 @@ public static void asyncDispatchUnit(final Event event, final Handlers handle)
public void run()
{
if(!Settings.enabled) return;
- if((new EventAction(event, false).cancelled))
+ if((new EventAction(event, true).cancelled))
return;
- if(!handle.checkUser((new EventAction(event, false)).player)) return;
+ if(!handle.checkUser((new EventAction(event, true)).player)) return;
- if(handle.getHandler().run(new EventAction(event, false))) {
- handle.getHandler().performActions(new EventAction(event, false));
+ if(handle.getHandler().run(new EventAction(event, true))) {
+ handle.getHandler().performActions(new EventAction(event, true));
}
}
}, 20L);
Please sign in to comment.
Something went wrong with that request. Please try again.