mirror of
https://github.com/JH3Y50N/JH_AuthMeBridge.git
synced 2024-11-30 12:43:33 +01:00
Post login Kick FIX
This commit is contained in:
parent
a54911ba6c
commit
6beb53c2ec
@ -1,7 +1,7 @@
|
||||
name: JH_AuthMeBridge
|
||||
main: JH_AuthMeBridge.spigot
|
||||
version: 1.0
|
||||
version: 1.0.1
|
||||
website: www.jhdev.xyz
|
||||
author: Jheyson
|
||||
description: Um plugin para ligaro AuthMe com seu bungeecord
|
||||
description: Plugin By www.jhdev.xyz Jheyson
|
||||
depend: [AuthMe]
|
||||
|
@ -10,6 +10,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
@ -98,18 +99,18 @@ public class bungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
List<String> lobbyes = new ArrayList<>();
|
||||
List<String> logados = new ArrayList<>();
|
||||
HashMap<String, Boolean> logados = new HashMap<String, Boolean>();
|
||||
List<String> comandos = new ArrayList<>();
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent e){
|
||||
if (e.getTag().equalsIgnoreCase("BungeeCord")) {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
|
||||
if (e.getTag().equalsIgnoreCase("BungeeCord")) {
|
||||
try {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
|
||||
String channel = in.readUTF();
|
||||
if(channel.equals("JH_AuthMeBridge")){
|
||||
String input = in.readUTF();
|
||||
if(isLogged(input))return;
|
||||
logados.add(input);
|
||||
logados.put(input, true);
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
@ -119,18 +120,18 @@ public class bungee extends Plugin implements Listener {
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerDisconnectEvent event) {
|
||||
if(logados.contains(event.getPlayer().getName())){
|
||||
if(isLogged(event.getPlayer())){
|
||||
logados.remove(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onChat(ChatEvent event) {
|
||||
public void onChat(ChatEvent event){
|
||||
if (event.isCancelled())return;
|
||||
if (!(event.getSender() instanceof ProxiedPlayer))return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
ProxiedPlayer player = (ProxiedPlayer)event.getSender();
|
||||
if(isLogged(player))return;
|
||||
if(event.isCommand()) {
|
||||
if(event.isCommand()){
|
||||
String command = event.getMessage().split(" ")[0].toLowerCase();
|
||||
if(comandos.contains(command)){
|
||||
return;
|
||||
@ -145,20 +146,19 @@ public class bungee extends Plugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onServerSwitch(ServerSwitchEvent event) {
|
||||
if(isLogged(event.getPlayer())){
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(stream);
|
||||
if(isLogged(event.getPlayer())){
|
||||
try {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(stream);
|
||||
out.writeUTF("JH_AuthMeBridge");
|
||||
out.writeUTF(event.getPlayer().getName());
|
||||
event.getPlayer().getServer().sendData("BungeeCord", stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
event.getPlayer().getServer().sendData("BungeeCord", stream.toByteArray());
|
||||
}
|
||||
return;
|
||||
}
|
||||
String server = event.getPlayer().getServer().getInfo().getName();
|
||||
if(!lobbyes.contains(server.toLowerCase())) {
|
||||
}
|
||||
if(!lobbyes.contains(event.getPlayer().getServer().getInfo().getName().toLowerCase())) {
|
||||
TextComponent kickReason = new TextComponent(ChatColor.translateAlternateColorCodes('&', getConfig().getString("KickMessageNeedLogged")));
|
||||
kickReason.setColor(ChatColor.RED);
|
||||
event.getPlayer().disconnect(kickReason);
|
||||
@ -166,16 +166,10 @@ public class bungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
public Boolean isLogged(ProxiedPlayer player){
|
||||
if(logados.contains(player.getName())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return logados.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public Boolean isLogged(String player){
|
||||
if(logados.contains(player)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return logados.containsKey(player);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,14 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -21,32 +24,40 @@ public class spigot extends JavaPlugin implements Listener, PluginMessageListene
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(LoginEvent event){
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
public void onLogin(LoginEvent event){
|
||||
try {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("JH_AuthMeBridge");
|
||||
out.writeUTF(event.getPlayer().getName());
|
||||
Bukkit.getServer().sendPluginMessage(this, "BungeeCord", b.toByteArray());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Bukkit.getServer().sendPluginMessage(this, "BungeeCord", b.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event){
|
||||
if(isLogged(event.getPlayer())){
|
||||
logados.remove(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
|
||||
try {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
String subchannel = in.readUTF();
|
||||
if(subchannel.equals("JH_AuthMeBridge")){
|
||||
String input = in.readUTF();
|
||||
String input = in.readUTF();
|
||||
if(isLogged(input))return;
|
||||
Player player = Bukkit.getPlayer(input);
|
||||
if(player != null && player.isOnline()){
|
||||
if(player != null && player.isOnline()){
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
@ -54,6 +65,7 @@ public class spigot extends JavaPlugin implements Listener, PluginMessageListene
|
||||
// For older versions of Authme
|
||||
// fr.xephi.authme.api.API.forceLogin(player);
|
||||
fr.xephi.authme.api.v3.AuthMeApi.getInstance().forceLogin(player);
|
||||
logados.add(player.getName());
|
||||
}
|
||||
}.runTaskLater(this, 20L);
|
||||
}
|
||||
@ -62,4 +74,14 @@ public class spigot extends JavaPlugin implements Listener, PluginMessageListene
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
List<String> logados = new ArrayList<>();
|
||||
|
||||
public Boolean isLogged(Player player){
|
||||
return logados.contains(player.getName());
|
||||
}
|
||||
|
||||
public Boolean isLogged(String player){
|
||||
return logados.contains(player);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user