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
|
name: JH_AuthMeBridge
|
||||||
main: JH_AuthMeBridge.spigot
|
main: JH_AuthMeBridge.spigot
|
||||||
version: 1.0
|
version: 1.0.1
|
||||||
website: www.jhdev.xyz
|
website: www.jhdev.xyz
|
||||||
author: Jheyson
|
author: Jheyson
|
||||||
description: Um plugin para ligaro AuthMe com seu bungeecord
|
description: Plugin By www.jhdev.xyz Jheyson
|
||||||
depend: [AuthMe]
|
depend: [AuthMe]
|
||||||
|
@ -10,6 +10,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
@ -98,18 +99,18 @@ public class bungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> lobbyes = new ArrayList<>();
|
List<String> lobbyes = new ArrayList<>();
|
||||||
List<String> logados = new ArrayList<>();
|
HashMap<String, Boolean> logados = new HashMap<String, Boolean>();
|
||||||
List<String> comandos = new ArrayList<>();
|
List<String> comandos = new ArrayList<>();
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginMessage(PluginMessageEvent e){
|
public void onPluginMessage(PluginMessageEvent e){
|
||||||
if (e.getTag().equalsIgnoreCase("BungeeCord")) {
|
if (e.getTag().equalsIgnoreCase("BungeeCord")) {
|
||||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
|
|
||||||
try {
|
try {
|
||||||
|
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
|
||||||
String channel = in.readUTF();
|
String channel = in.readUTF();
|
||||||
if(channel.equals("JH_AuthMeBridge")){
|
if(channel.equals("JH_AuthMeBridge")){
|
||||||
String input = in.readUTF();
|
String input = in.readUTF();
|
||||||
if(isLogged(input))return;
|
if(isLogged(input))return;
|
||||||
logados.add(input);
|
logados.put(input, true);
|
||||||
}
|
}
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
@ -119,7 +120,7 @@ public class bungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLeave(PlayerDisconnectEvent event) {
|
public void onPlayerLeave(PlayerDisconnectEvent event) {
|
||||||
if(logados.contains(event.getPlayer().getName())){
|
if(isLogged(event.getPlayer())){
|
||||||
logados.remove(event.getPlayer().getName());
|
logados.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,19 +147,18 @@ public class bungee extends Plugin implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerSwitch(ServerSwitchEvent event) {
|
public void onServerSwitch(ServerSwitchEvent event) {
|
||||||
if(isLogged(event.getPlayer())){
|
if(isLogged(event.getPlayer())){
|
||||||
|
try {
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(stream);
|
DataOutputStream out = new DataOutputStream(stream);
|
||||||
try {
|
|
||||||
out.writeUTF("JH_AuthMeBridge");
|
out.writeUTF("JH_AuthMeBridge");
|
||||||
out.writeUTF(event.getPlayer().getName());
|
out.writeUTF(event.getPlayer().getName());
|
||||||
|
event.getPlayer().getServer().sendData("BungeeCord", stream.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
event.getPlayer().getServer().sendData("BungeeCord", stream.toByteArray());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String server = event.getPlayer().getServer().getInfo().getName();
|
if(!lobbyes.contains(event.getPlayer().getServer().getInfo().getName().toLowerCase())) {
|
||||||
if(!lobbyes.contains(server.toLowerCase())) {
|
|
||||||
TextComponent kickReason = new TextComponent(ChatColor.translateAlternateColorCodes('&', getConfig().getString("KickMessageNeedLogged")));
|
TextComponent kickReason = new TextComponent(ChatColor.translateAlternateColorCodes('&', getConfig().getString("KickMessageNeedLogged")));
|
||||||
kickReason.setColor(ChatColor.RED);
|
kickReason.setColor(ChatColor.RED);
|
||||||
event.getPlayer().disconnect(kickReason);
|
event.getPlayer().disconnect(kickReason);
|
||||||
@ -166,16 +166,10 @@ public class bungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isLogged(ProxiedPlayer player){
|
public Boolean isLogged(ProxiedPlayer player){
|
||||||
if(logados.contains(player.getName())){
|
return logados.containsKey(player.getName());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isLogged(String player){
|
public Boolean isLogged(String player){
|
||||||
if(logados.contains(player)){
|
return logados.containsKey(player);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,14 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -21,30 +24,38 @@ public class spigot extends JavaPlugin implements Listener, PluginMessageListene
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
|
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogin(LoginEvent event){
|
public void onLogin(LoginEvent event){
|
||||||
|
try {
|
||||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(b);
|
DataOutputStream out = new DataOutputStream(b);
|
||||||
try {
|
|
||||||
out.writeUTF("JH_AuthMeBridge");
|
out.writeUTF("JH_AuthMeBridge");
|
||||||
out.writeUTF(event.getPlayer().getName());
|
out.writeUTF(event.getPlayer().getName());
|
||||||
|
Bukkit.getServer().sendPluginMessage(this, "BungeeCord", b.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
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
|
@Override
|
||||||
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
|
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
|
||||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
|
||||||
try {
|
try {
|
||||||
|
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||||
String subchannel = in.readUTF();
|
String subchannel = in.readUTF();
|
||||||
if(subchannel.equals("JH_AuthMeBridge")){
|
if(subchannel.equals("JH_AuthMeBridge")){
|
||||||
String input = in.readUTF();
|
String input = in.readUTF();
|
||||||
|
if(isLogged(input))return;
|
||||||
Player player = Bukkit.getPlayer(input);
|
Player player = Bukkit.getPlayer(input);
|
||||||
if(player != null && player.isOnline()){
|
if(player != null && player.isOnline()){
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
@ -54,6 +65,7 @@ public class spigot extends JavaPlugin implements Listener, PluginMessageListene
|
|||||||
// For older versions of Authme
|
// For older versions of Authme
|
||||||
// fr.xephi.authme.api.API.forceLogin(player);
|
// fr.xephi.authme.api.API.forceLogin(player);
|
||||||
fr.xephi.authme.api.v3.AuthMeApi.getInstance().forceLogin(player);
|
fr.xephi.authme.api.v3.AuthMeApi.getInstance().forceLogin(player);
|
||||||
|
logados.add(player.getName());
|
||||||
}
|
}
|
||||||
}.runTaskLater(this, 20L);
|
}.runTaskLater(this, 20L);
|
||||||
}
|
}
|
||||||
@ -62,4 +74,14 @@ public class spigot extends JavaPlugin implements Listener, PluginMessageListene
|
|||||||
e.printStackTrace();
|
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