From a54911ba6cfa1236999318f5827fe0d278f42cbc Mon Sep 17 00:00:00 2001 From: JH3Y50N Date: Sun, 26 Aug 2018 07:56:17 -0300 Subject: [PATCH] JH_AuthMeBridge 1.0.0 --- .classpath | 9 ++ .project | 17 +++ .settings/org.eclipse.jdt.core.prefs | 11 ++ bin/JH_AuthMeBridge/bungee$1.class | Bin 0 -> 1489 bytes bin/JH_AuthMeBridge/bungee.class | Bin 0 -> 8379 bytes bin/JH_AuthMeBridge/spigot$1.class | Bin 0 -> 810 bytes bin/JH_AuthMeBridge/spigot.class | Bin 0 -> 3285 bytes bungee.yml | 6 + config.yml | 18 +++ plugin.yml | 7 ++ src/JH_AuthMeBridge/bungee.java | 181 +++++++++++++++++++++++++++ src/JH_AuthMeBridge/spigot.java | 65 ++++++++++ 12 files changed, 314 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 bin/JH_AuthMeBridge/bungee$1.class create mode 100644 bin/JH_AuthMeBridge/bungee.class create mode 100644 bin/JH_AuthMeBridge/spigot$1.class create mode 100644 bin/JH_AuthMeBridge/spigot.class create mode 100644 bungee.yml create mode 100644 config.yml create mode 100644 plugin.yml create mode 100644 src/JH_AuthMeBridge/bungee.java create mode 100644 src/JH_AuthMeBridge/spigot.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..43ccfec --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..72d74da --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + JH_AuthMeBridge + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bin/JH_AuthMeBridge/bungee$1.class b/bin/JH_AuthMeBridge/bungee$1.class new file mode 100644 index 0000000000000000000000000000000000000000..fbd724cfed1cf069e7e89ea72966c065bb2f5b2b GIT binary patch literal 1489 zcma)6U2hXd6g}g(Sz~XSVDnYdmQ66hu}L;21WHXQ#JD1r14xb{Xdj} z2!Ex2AkUH7Qd+4Gyj0>xq2AdIkr0krue`hW&fR;@J#+57d;jO(0Is29A;)m;$NM{X zlX$Qx)^*_bg}a-`z7W->g*?N&6tO$>ch(NwE*}N%C`|f+blYk;R8GpgukjuW?i*+FTt;KDId|UbA1Q<#-KEq@Y6PU7L;d6%5 zweg=!cLOONB*R^yxA<--7|LDc@o<~#z}Sb*yn)Sd{un&fCc!RMxm5DiP$d!dSN^mf zgC+Kam&8=%X01Dpu0x)BLi$3te*QGa;&uV&7|uK!>~PwNq1a7#Vp)q&aleG~_|n2G z!`y#nxA7IeW|$iA=#kLFAc_Jdk0I(O3l77=xSZaA$L^NciwXKjNg?9`<{7TO-S?iT z#PO9QRqPD-3*n58$~dudbRr$Ys^ewam@DD}rc4KyY%Jh15gHKrwh649I%5U^Id#u(BH2!H4hOeBAa^X`0 z@@dddG>?hF0-6jhitT8vv}1OK4E09r7p=5geM|2|9Gx%#0agddtz@LV^4z=&en*SufQazoA&a@*4I*8Z=G! zVj9fo!v{ws=qpq9CpKe+dC_Ce-a`QTdm9aj%1@hqBjY_1Yg18X5gzD(s^()S9ju410n zn^>dkI_}{H?&I4OayEqq70Z UaF?EWnt^r7Y)GNaq$mCU1=m%4!vFvP literal 0 HcmV?d00001 diff --git a/bin/JH_AuthMeBridge/bungee.class b/bin/JH_AuthMeBridge/bungee.class new file mode 100644 index 0000000000000000000000000000000000000000..9e1c518825d99fcece5032068440f0a9a984daa2 GIT binary patch literal 8379 zcmbtZ3wRXQb^edE(yW#NWbqI(*kD^2Nk}ZVc^P4hBp?VRK_medVB?W?SQb_@@;(5W z#EEU}*ohxaQpbfj&ZBW@^QxhEg`y;OlGbk1x7(&KH*MYbJ8hG;c3ms~nb}>fq?MBI zD?&T7_ue_@+;jf(pEFnAdH1W|0I*J;Hc%p1ynENtmUQZPr`?)}MWS}NKkY9=yr=u|^ywAHBC>Pu`%d(DGGG#k7I>%yB!Ob00*ZVW! zHg7>XVWncO(=0IJZh!xD{#^=K6QbOw2<_Fux<_*j?$teml`?^~Y&xRfjuZ#Sd7C zn10U=22#gkG-^pl@leq6pzG{#^obDl++?B_D>)doQ~MI`nPCpq)lYM(#>$)Su@k54 zL~{tMP;a14uzafjrz|zmfYo%m%J-t&X*pI@W7s%@o=KR=_el zaSJsk?5N@kp_CZ!@tDm4Z;*wIV+7LfC*!1~%pb9&^L( zdv}}}u!j_nCT`dD^M?qhR8PtpIN6)92AC%d&ywPStGy+NJNU?n<3}xK*r46-WmpKC zai^kdo1m#~rl3!Uuo~WkRugU5PN_K`wYh_eWx?+MuZyyh=%EVi#4ZExVJJN8`!+;VDkJdqsO{MKWb2Qg&oTGCeS0CzHq0 z@%ZqX5W29>z}^DK7lMlufx%KCVec z!(Ar&aEQwY`R!K9+Udq4iuX$5-E#nUxHA^FiRmM_$H3hJvvAzRQQS+4v(FH=Ol5M( zAzj*UVn8R#22Vy}i6CfU$S1os!-H{M5mg`@*9@MlsMr>D{RtB%RpQ(Mx;kZd*{9Vm z-2)@zz@-nlhi*IRrV|5pOOo`*kO=CFIW4cU-5E*~)L!%q+($$g?rv{7m7fk_2uZb> z(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5$K`@Ft|{jvxLY7bE!V5&T^zckqv0O;!Jr!M~kHgMQl_ zXi%vCM+X0O9)U}ATTM;C2j|3A)x0|ikPX;IxaifVg$66x3Qcg@@>4sjn$G|{*SIHrHmT9%ew$21Tan+ zzH4ex`YyH^c*6i4b9tQp_TBV4$2>Q^&GkYU@V#`ZqiA0Ve}H=3=<1A=j7m^2DsxM4 z9*d_8Rx(2`ak0Ny>f!xaEFwbd@PM}=pY!VT8>*KDvXC26&SU+kqY;Zl7iqxecmWfs zZj~kZs43pg(vTYUKCjn*Qz|ZGZ(os$P6kQH;9hVzz4AP6;H7SX@UyA(Rx(K!ttP?v zTVMpU4_v^_s{sf$n96ECLo9Up4-HgCmaq>9HG&nKATPZEw#F|tqNev*yCdz}Zqvw1h1r5oD0+ogO5+bw&z z|E-uO9bR0MFqFBo(KJyO485bRX+>=ly|q{NWxZ7h?|2s8&o^+_@69=6=a}^NjmUw{ zF*(@RI3j%>vgJsVF7o12^l_7yr zw9mKd(hFE!=)vTK2b(TSIwQj>fxdjd`cjd6E3ur*kF6}(z%zvCCs@dzS(ES}F3-Jd4qewO9^b4c@a_z8TT$K5aBQ>0||?JiOUxGtA7&(pUbq^8CE8{dQS z5WS^3+vQ<;bR+$wMOT}J+vObnT|#-+$Rl}w--y6C4fHrvx((?yff9Mb`+QQK;#C{H&Ajs8j{s&DpF{uv literal 0 HcmV?d00001 diff --git a/bin/JH_AuthMeBridge/spigot$1.class b/bin/JH_AuthMeBridge/spigot$1.class new file mode 100644 index 0000000000000000000000000000000000000000..f3b2f94a926b1633297fa88416999ee3d227cf90 GIT binary patch literal 810 zcmaJ<+iuf96r7DiF0N@pfKm$ORs$g*mWZ2B0ja5|C~{ELqQ3BeHp$jr>aL@;9nsH1 zq5|>22k=pdvuPeGlwir;bD1-qGxqO4KYsyug1coD7?$6?{j`y1QCD`18itamBNZl@ z-!7xbu$GvR_w$1TmGN{C$zdK#!#k70POi1+$C9CxMJn|l5m_*sZJog#i`XB<;z$~X zmEaVw)S1eTcyH1pWa*{SDtpcFv^kG%{`kE;hT>*2lvOaC^>79y8`V6NQE}nmoQEnJ z3{KNRYk|`8eSX-N=EKP@jUX9_cuyE*^J%eY7qqfxujjW(wqtVb;xew3vBGd^-|#PT z6e%vq+(XI5Nb!x{wuh@&B{%jHGmt?ND$TIk{Qo}gZjuvvOIfcMPQK5>&tfb{{~JAs zlT_)jE3+sWmT`+=X|_raK5mn;MEByHUfh*wDnhv<2U3mYkfGfSEGv(N4*70oh;@Cw zvX32Wptr5HG@G$VQ<>rhS?$ozRjAjk^FX~}eYX|5t8l5mK+!A8Ew0wOe+;kn;24Xo z@2G#B0MFCYoeYpqc#I2_do)OJT*MNcv;-Pcs%LcCUZwR7i$AdZFUNBd@ZuClWy;~; X8ch{&okRmg+{7C0P-G=qKDzz_RwKT- literal 0 HcmV?d00001 diff --git a/bin/JH_AuthMeBridge/spigot.class b/bin/JH_AuthMeBridge/spigot.class new file mode 100644 index 0000000000000000000000000000000000000000..d537a3777f74e4e456c1bd66aa8eb870909316cb GIT binary patch literal 3285 zcmb7G**Zx0kzdKpT0MT&7rr-OPrELN=hfT|Lj|x;rqC*0K9y=*RsK!zq zOAr!R7B?+ci@H$qbNnm+Ox4os$Yo`hPG|X~Yk4XXTR5erI$j1c8k@Hlame3BA84oeAakO26BM-*j{fwrSYv zhoG>iV>==OI+dtoNy`gA>eo{=KbPIIXlE^21w!3^0yXZRH>jBh=ZOWIuIxAv-g@Ilx zVP_T^c<@vP7Rk+AYz5a9MC4M5`kjmM=?Qx-cyw_L*R(BCTC=UV&EgW+7KvYXVz*^> z%#0bV@r;alClNJmI}KqoI$@?TOInh@-zyIOo#Fq$-?s ze!{anO?Q$_Os%qh25?@(IfhxmX`hUa3%JM>v5d|d8MduPDqO(J5H8`e1}0`j39sIP zleZHxt5U4vd9MX#$zcL)B*q6FBjGi$jSA@z9ar&!K%Hxsv%wY`iH>xu3cse~B^a!6 z7ID(YLAL6rV)sb5;!e=x1Y6<%;F^FKRg5Y{Rrb%9XLfx%?+UCb%gtvC87Bzd%CbNO zJX~Aqq0(<;i(_E5ZTSMdAQRG@kV!A#1?cprJ?D6_k2Df!gdgNhAB}wrR?%-7ouW&HUk3q+4 zc%4&J-pm_mTJqJxz~~K`a66+{)W~~Nk^C)z_Qk5@@kl7DzoX+_yvLd|a|2eI^Vpl# zS2VoOK<3qG@l>&8cL;a!p^Ek+f&G!k&E>}%jt&KRcu`lQQuV2h&+s|tl9RUvjof(L z;Mf#6`X4;*^L5x|?RQs8>o<4^5ONO2fkPB>9-;HIH|a`wK0bkW`Iy^QO9S zxXjjhtf9S7EbsqyWEoVB)=wUok!fpTX8?=nwf)g=cuL@qVtrGQR5t0W3#7zj&-FZ@%U! z1EPJ=$;`De8?D4y(v+b<~7w9^s7+Ev)^4 zXjq%U+XDB|Jd3--tzm5%AG9{&<0*V{S)sw*M57S?c?_1rZ}-66;W^*LfLln9D0X8P z_TU)yqL-uOJpCPFz#};BL2;F2qMv0buHp-P$tcvnukbaYP;cMh9-*km8GK8(0!;cL zd`Gz;^+)hM-)d-O6Mo lobbyes = new ArrayList<>(); + List logados = new ArrayList<>(); + List comandos = new ArrayList<>(); + @EventHandler + public void onPluginMessage(PluginMessageEvent e){ + if (e.getTag().equalsIgnoreCase("BungeeCord")) { + DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData())); + try { + String channel = in.readUTF(); + if(channel.equals("JH_AuthMeBridge")){ + String input = in.readUTF(); + if(isLogged(input))return; + logados.add(input); + } + } catch (IOException e1) { + e1.printStackTrace(); + } + + } + } + @EventHandler + public void onPlayerLeave(PlayerDisconnectEvent event) { + if(logados.contains(event.getPlayer().getName())){ + logados.remove(event.getPlayer().getName()); + } + } + + @EventHandler(priority=EventPriority.LOWEST) + public void onChat(ChatEvent event) { + if (event.isCancelled())return; + if (!(event.getSender() instanceof ProxiedPlayer))return; + ProxiedPlayer player = (ProxiedPlayer) event.getSender(); + if(isLogged(player))return; + if(event.isCommand()) { + String command = event.getMessage().split(" ")[0].toLowerCase(); + if(comandos.contains(command)){ + return; + } + } + if(!isLogged(player)){ + event.setCancelled(true); + TextComponent message = new TextComponent(ChatColor.translateAlternateColorCodes('&', getConfig().getString("NeedLoginToEnter"))); + player.sendMessage(message); + } + } + + @EventHandler + public void onServerSwitch(ServerSwitchEvent event) { + if(isLogged(event.getPlayer())){ + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(stream); + try { + out.writeUTF("JH_AuthMeBridge"); + out.writeUTF(event.getPlayer().getName()); + } 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())) { + TextComponent kickReason = new TextComponent(ChatColor.translateAlternateColorCodes('&', getConfig().getString("KickMessageNeedLogged"))); + kickReason.setColor(ChatColor.RED); + event.getPlayer().disconnect(kickReason); + } + } + + public Boolean isLogged(ProxiedPlayer player){ + if(logados.contains(player.getName())){ + return true; + } + return false; + } + + public Boolean isLogged(String player){ + if(logados.contains(player)){ + return true; + } + return false; + } +} diff --git a/src/JH_AuthMeBridge/spigot.java b/src/JH_AuthMeBridge/spigot.java new file mode 100644 index 0000000..318abe7 --- /dev/null +++ b/src/JH_AuthMeBridge/spigot.java @@ -0,0 +1,65 @@ +package JH_AuthMeBridge; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +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 { + + @Override + public void onEnable() { + Bukkit.getPluginManager().registerEvents(this, this); + this.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); + try { + out.writeUTF("JH_AuthMeBridge"); + out.writeUTF(event.getPlayer().getName()); + } catch (IOException e) { + e.printStackTrace(); + } + Bukkit.getServer().sendPluginMessage(this, "BungeeCord", b.toByteArray()); + } + + @Override + public void onPluginMessageReceived(String channel, Player p, byte[] message) { + DataInputStream in = new DataInputStream(new ByteArrayInputStream(message)); + try { + String subchannel = in.readUTF(); + if(subchannel.equals("JH_AuthMeBridge")){ + String input = in.readUTF(); + 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); + } + }.runTaskLater(this, 20L); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } +}