mirror of
https://github.com/JH3Y50N/JH_AuthMeBridge.git
synced 2025-01-19 20:11:18 +01:00
Native support to AuthMe Legacy (BETA) NOT TESTED.
This commit is contained in:
parent
9ac67f158a
commit
403025afe7
18
.classpath
18
.classpath
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jheys/Downloads/AuthMe-5.6.0-beta1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jheys/Documents/bungeecord/bungeecord.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jheys/Documents/MC - Plugins/PaperSpigot-1.8.8.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jheys/Documents/Plugins - APIs/AuthMe-5.5.0-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jheys/Documents/bungeecord/bungeecord.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jheys/Documents/MC - Plugins/PaperSpigot-1.8.8.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12
bungee.yml
12
bungee.yml
@ -1,6 +1,6 @@
|
||||
name: JH_AuthMeBridge
|
||||
main: JH_AuthMeBridge.bungee
|
||||
version: 1.0
|
||||
website: www.jhdev.net
|
||||
author: Jheyson
|
||||
description: Um plugin para ligaro AuthMe com seu bungeecord
|
||||
name: JH_AuthMeBridge
|
||||
main: JH_AuthMeBridge.bungee
|
||||
version: 1.0.2
|
||||
website: www.jhdev.net
|
||||
author: Jheyson
|
||||
description: Um plugin para ligaro AuthMe com seu bungeecord
|
||||
|
14
plugin.yml
14
plugin.yml
@ -1,7 +1,7 @@
|
||||
name: JH_AuthMeBridge
|
||||
main: JH_AuthMeBridge.spigot
|
||||
version: 1.0.1
|
||||
website: www.jhdev.net
|
||||
author: Jheyson
|
||||
description: Plugin By www.jhdev.xyz Jheyson
|
||||
depend: [AuthMe]
|
||||
name: JH_AuthMeBridge
|
||||
main: JH_AuthMeBridge.spigot
|
||||
version: 1.0.2
|
||||
website: www.jhdev.net
|
||||
author: Jheyson
|
||||
description: Plugin By www.jhdev.xyz Jheyson
|
||||
depend: [AuthMe]
|
||||
|
@ -1,91 +1,93 @@
|
||||
package JH_AuthMeBridge;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
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;
|
||||
|
||||
import fr.xephi.authme.events.LoginEvent;
|
||||
|
||||
public class spigot extends JavaPlugin implements Listener, PluginMessageListener {
|
||||
|
||||
/*
|
||||
Made by Jheyson Henrique
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
try {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
String subchannel = in.readUTF();
|
||||
if(subchannel.equals("JH_AuthMeBridge")){
|
||||
String input = in.readUTF();
|
||||
if(isLogged(input))return;
|
||||
Player player = Bukkit.getPlayer(input);
|
||||
if(player != null && player.isOnline()){
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
// 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, 25L);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
package JH_AuthMeBridge;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
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;
|
||||
|
||||
import fr.xephi.authme.events.LoginEvent;
|
||||
|
||||
public class spigot extends JavaPlugin implements Listener, PluginMessageListener {
|
||||
|
||||
/*
|
||||
Made by Jheyson Henrique
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
try {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
String subchannel = in.readUTF();
|
||||
//System.out.println((p != null ? p.getName() : " not found ") + " received from channel" + channel + " and subchannel " + subchannel);
|
||||
if(subchannel.equals("JH_AuthMeBridge")){
|
||||
String input = in.readUTF();
|
||||
if(isLogged(input))return;
|
||||
Player player = Bukkit.getPlayer(input);
|
||||
if(player != null && player.isOnline()){
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
// 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, 25L);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
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