diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java index 44f2086be..5e76bf104 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java @@ -87,7 +87,8 @@ public class PacketHandler extends MiniPlugin return _playerVerifierMap.get(player); } - public void addPacketHandler(IPacketHandler packetHandler, Class... packetsToListen) + @SafeVarargs + public final void addPacketHandler(IPacketHandler packetHandler, Class... packetsToListen) { if (packetsToListen.length == 0) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java b/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java index 7f8a6eba9..c6f51cc64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java @@ -1,8 +1,5 @@ package mineplex.core.vanish; -import java.sql.ResultSet; -import java.sql.SQLException; - import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -12,23 +9,31 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.vanish.commands.VanishCommand; import mineplex.core.vanish.events.PreVanishEvent; import mineplex.core.vanish.repository.VanishClient; import mineplex.core.vanish.repository.VanishRepository; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; public class Vanish extends MiniClientPlugin { private CoreClientManager _clientManager; private VanishRepository _repository; - public Vanish(JavaPlugin plugin, CoreClientManager clientManager) + public Vanish(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) { super("Vanish", plugin); _repository = new VanishRepository(this); _clientManager = clientManager; + + packetHandler.addPacketHandler(packet -> { + + }, PacketPlayOutChat.class); } public void addCommands() @@ -54,18 +59,30 @@ public class Vanish extends MiniClientPlugin return enabled; } + @EventHandler + public void join + @EventHandler(priority = EventPriority.LOWEST) public void ClientLoad(AsyncPlayerPreLoginEvent event) { _clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> { - Get(event.getName()).State = _repository.getStatus(accountId); + Get(event.getName()).State = _repository.getStatus(accountId.intValue()); }); } @EventHandler(priority = EventPriority.LOWEST) public void ClientLoad(PlayerJoinEvent event) { - Get( + if (Get(event.getPlayer()).State) + { + event.setJoinMessage(null); + informVanished(event.getPlayer()); + } + } + + private void informVanished(Player player) + { + UtilPlayer.message(player, C.cGold + ""); } public String getQuery(int accountId, String uuid, String name) @@ -73,15 +90,8 @@ public class Vanish extends MiniClientPlugin return "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, enabled TINYINT(1) NOT NULL, enabledTime BIGINT)"; } - public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException - { - int accountId = resultSet.getInt("accountId"); - boolean enabled = resultSet.getBoolean("enabled"); - } - protected VanishClient AddPlayer(String player) { return new VanishClient(); } - }