Check twofactor status instead of interact events
This commit is contained in:
parent
babc72a87c
commit
5ba3fac58c
@ -7,7 +7,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
@ -17,6 +16,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
@ -36,9 +36,11 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
|
||||
public class CosmeticManager extends MiniPlugin
|
||||
{
|
||||
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
||||
private InventoryManager _inventoryManager;
|
||||
private GadgetManager _gadgetManager;
|
||||
private MountManager _mountManager;
|
||||
@ -136,7 +138,7 @@ public class CosmeticManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void openShop(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.useItemInHand() == Event.Result.DENY || !_showInterface)
|
||||
if (_twofactor.isAuthenticating(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.hasItem() && event.getItem().getType() == Material.CHEST)
|
||||
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
@ -19,6 +18,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -34,6 +34,7 @@ import mineplex.core.party.rediscommands.PartyTransferResponse;
|
||||
import mineplex.core.portal.Intent;
|
||||
import mineplex.core.portal.events.GenericServerTransferEvent;
|
||||
import mineplex.core.portal.events.ServerTransferEvent;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.utils.UtilGameProfile;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
@ -43,6 +44,7 @@ import mineplex.serverdata.data.MinecraftServer;
|
||||
*/
|
||||
public class PartyJoinManager implements Listener
|
||||
{
|
||||
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
||||
private final PartyManager _plugin;
|
||||
private final int _maxPlayers;
|
||||
|
||||
@ -344,7 +346,7 @@ public class PartyJoinManager implements Listener
|
||||
@EventHandler
|
||||
public void onClick(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.useItemInHand() == Event.Result.DENY)
|
||||
if (_twofactor.isAuthenticating(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ import mineplex.core.titles.tracks.Track;
|
||||
import mineplex.core.titles.tracks.TrackFormat;
|
||||
import mineplex.core.titles.tracks.TrackManager;
|
||||
import mineplex.core.titles.tracks.TrackTier;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
|
||||
/**
|
||||
* This manager handles displaying titles above a player's head, as well as their tracks
|
||||
@ -97,6 +98,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
private final TitlesRepository _titlesRepository = new TitlesRepository();
|
||||
|
||||
private final GadgetManager _gadgetManager = require(GadgetManager.class);
|
||||
private final TwoFactorAuth _twofactor = require(TwoFactorAuth.class);
|
||||
|
||||
private final BaseComponent[] CLICK_ENABLE_TRACK = new ComponentBuilder("")
|
||||
.append("Click to enable this track")
|
||||
@ -175,10 +177,10 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getItem() != null && UtilEvent.isAction(event, UtilEvent.ActionType.R))
|
||||
if (!_twofactor.isAuthenticating(event.getPlayer()) && event.getItem() != null && UtilEvent.isAction(event, UtilEvent.ActionType.R))
|
||||
{
|
||||
boolean cancel = false;
|
||||
|
||||
|
@ -81,6 +81,11 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isAuthenticating(Player player)
|
||||
{
|
||||
return authenticating.contains(player.getUniqueId()) || setupData.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
private void setup2FA(Player player)
|
||||
{
|
||||
String secret = authenticator.createCredentials().getKey();
|
||||
@ -243,7 +248,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onClick(InventoryClickEvent event)
|
||||
{
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -253,7 +258,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onDrag(InventoryDragEvent event)
|
||||
{
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -263,7 +268,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -273,7 +278,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -283,7 +288,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onInteractWithEntity(PlayerInteractEntityEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -293,7 +298,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
event.setMessage("/");
|
||||
event.setCancelled(true);
|
||||
@ -304,7 +309,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (setupData.containsKey(player.getUniqueId()) || authenticating.contains(player.getUniqueId()))
|
||||
if (isAuthenticating(player))
|
||||
{
|
||||
if (Recharge.Instance.use(player, "two-factor message cooldown", 3000L, false, false))
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -119,6 +118,7 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.treasure.TreasureLocation;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.valentines.ValentinesGiftManager;
|
||||
@ -156,6 +156,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
private Punish _punishManager;
|
||||
private IncognitoManager _incognito;
|
||||
private BonusManager _bonusManager;
|
||||
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
||||
|
||||
private Location _spawn;
|
||||
private int _scoreboardTick = 0;
|
||||
@ -969,7 +970,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
@EventHandler
|
||||
public void openProfile(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.useItemInHand() == Event.Result.DENY || event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM)
|
||||
if(_twofactor.isAuthenticating(event.getPlayer()) || event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM)
|
||||
return;
|
||||
|
||||
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager).openInventory();;
|
||||
|
@ -21,7 +21,6 @@ import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -112,6 +111,7 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.valentines.ValentinesGiftManager;
|
||||
@ -175,6 +175,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
// private HalloweenSpookinessManager _halloweenManager;
|
||||
// private TrickOrTreatManager _trickOrTreatManager;
|
||||
private MavericksManager _mavericksManager;
|
||||
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
||||
|
||||
private Location _spawn;
|
||||
|
||||
@ -976,7 +977,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
@EventHandler
|
||||
public void openProfile(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.useItemInHand() == Event.Result.DENY || event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM)
|
||||
if (_twofactor.isAuthenticating(event.getPlayer()) || event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM)
|
||||
return;
|
||||
|
||||
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager, _personalServerManager).openInventory();
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
@ -26,6 +25,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
@ -48,6 +48,7 @@ import mineplex.core.portal.Intent;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
@ -78,6 +79,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
|
||||
private ServerStatusManager _statusManager;
|
||||
private HubManager _hubManager;
|
||||
private BoosterManager _boosterManager;
|
||||
private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class);
|
||||
|
||||
private NautHashMap<String, Long> _queueCooldowns = new NautHashMap<String, Long>();
|
||||
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
||||
@ -203,7 +205,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
|
||||
@EventHandler
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.useItemInHand() == Event.Result.DENY)
|
||||
if (_twofactor.isAuthenticating(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.Iterator;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -86,11 +85,6 @@ public class TutorialManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void InteractCancel(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.useItemInHand() == Event.Result.DENY)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (InTutorial(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user