Implement triggers

This commit is contained in:
samczsun 2017-04-27 12:28:07 -04:00 committed by cnr
parent ecef2fe9db
commit 1390ea1579
5 changed files with 74 additions and 13 deletions

View File

@ -58,19 +58,37 @@ public class CompromisedAccountManager extends MiniPlugin
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
CoreClient coreClient = _clientManager.Get(event.getPlayer());
PlayerInfo playerInfo = new PlayerInfo(
event.getPlayer().getName(),
coreClient.getName(),
event.getPlayer().getUniqueId(),
coreClient.getAccountId(),
UtilPlayer.getIp(event.getPlayer())
);
JsonObject response = _apiCall.post("api/server/login/" + event.getPlayer().getName(), JsonObject.class, playerInfo);
if (response != null && response.get("error") != null)
runAsync(() ->
{
getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response);
}
JsonObject response = _apiCall.post("api/server/login/" + event.getPlayer().getName(), JsonObject.class, getPlayerInfo(event.getPlayer()));
if (response != null && response.get("error") != null)
{
getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response);
}
});
}
public void triggerPriorityBan(Player player, PriorityCause cause)
{
runAsync(() ->
{
JsonObject response = _apiCall.post("api/banner/trigger/" + player.getName(), JsonObject.class, new TriggerPriorityInfo(getPlayerInfo(player), cause));
if (response != null && response.get("error") != null)
{
getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response);
}
});
}
private PlayerInfo getPlayerInfo(Player player)
{
CoreClient coreClient = _clientManager.Get(player);
return new PlayerInfo(
player.getName(),
coreClient.getName(),
player.getUniqueId(),
coreClient.getAccountId(),
UtilPlayer.getIp(player)
);
}
}

View File

@ -0,0 +1,7 @@
package mineplex.core.antihack.compedaccount;
public enum PriorityCause
{
JOIN_GAME,
CHAT
}

View File

@ -0,0 +1,23 @@
package mineplex.core.antihack.compedaccount;
public class TriggerPriorityInfo
{
private final PlayerInfo _target;
private final PriorityCause _cause;
public TriggerPriorityInfo(PlayerInfo target, PriorityCause cause)
{
_target = target;
_cause = cause;
}
public PlayerInfo getTarget()
{
return _target;
}
public PriorityCause getCause()
{
return _cause;
}
}

View File

@ -39,6 +39,8 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.compedaccount.CompromisedAccountManager;
import mineplex.core.antihack.compedaccount.PriorityCause;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blood.Blood;
import mineplex.core.bonuses.BonusManager;
@ -262,6 +264,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public final boolean IsHolidayEnabled;
private final Titles _titles;
private final CompromisedAccountManager _compromisedAccountManager = require(CompromisedAccountManager.class);
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
@ -972,6 +975,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler
public void MessageJoin(PlayerJoinEvent event)
{
_compromisedAccountManager.triggerPriorityBan(event.getPlayer(), PriorityCause.JOIN_GAME);
if (_incognitoManager.Get(event.getPlayer()).Status)
{
event.setJoinMessage(null);
@ -2063,4 +2068,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return this._titles;
}
public CompromisedAccountManager getCompromisedAccountManager()
{
return _compromisedAccountManager;
}
}

View File

@ -15,6 +15,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.jooq.tools.json.JSONObject;
import mineplex.core.antihack.compedaccount.PriorityCause;
import mineplex.core.common.Rank;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
@ -67,6 +68,8 @@ public class GameChatManager implements Listener
if (event.getMessage().trim().length() == 0)
return;
_manager.getCompromisedAccountManager().triggerPriorityBan(event.getPlayer(), PriorityCause.CHAT);
Player sender = event.getPlayer();
String senderName = sender.getName();