package Ġme . d unc an leo . mc _ auth Ċ Ċ import Ġme . d unc an leo . mc _ auth . commands . Change Password Command Ċ import Ġme . d unc an leo . mc _ auth . commands . Login Command Ċ import Ġme . d unc an leo . mc _ auth . commands . Register Command Ċ import Ġme . d unc an leo . mc _ auth . model . Users Ċ import Ġme . d unc an leo . mc _ auth . util . displayName Stri pped Ċ import Ġorg . bukkit . Chat Color Ċ import Ġorg . bukkit . Location Ċ import Ġorg . bukkit . command . Command Ċ import Ġorg . bukkit . command . Command Sender Ċ import Ġorg . bukkit . command . Tab Comp leter Ċ import Ġorg . bukkit . event . EventHandler Ċ import Ġorg . bukkit . event . Listener Ċ import Ġorg . bukkit . event . player . Player Command Pre process Event Ċ import Ġorg . bukkit . event . player . Player Join Event Ċ import Ġorg . bukkit . event . player . Player Move Event Ċ import Ġorg . bukkit . event . player . Player Quit Event Ċ import Ġorg . bukkit . plugin . java . Java Plugin Ċ import Ġorg . bukkit . scheduler . Bu kkit Runnable Ċ import Ġorg . jetbrains . ex posed . sql . Database Ċ import Ġorg . jetbrains . ex posed . sql . Schema Utils Ċ import Ġorg . jetbrains . ex posed . sql . Std Out Sql Logger Ċ import Ġorg . jetbrains . ex posed . sql . add Logger Ċ import Ġorg . jetbrains . ex posed . sql . transactions . transaction Ċ import Ġjava . io . File Ċ Ċ class ĠApp Ġ: ĠJava Plugin (), ĠListener , ĠTab Comp leter Ġ{ ĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġval Ġusers Location Map Ġ= Ġmutable Map Of < String , ĠLocation >() ĊĠĠĠ Ġval Ġusers Map Ġ= Ġmutable Map Of < String , ĠBoolean >() ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Enable () Ġ{ ĊĠĠĠ Ġlogger . info (" Hello Ġthere !") ĊĊĠĠĠ Ġserver . plugin Manager . register Events ( this , Ġthis ) ĊĠĠĠ Ġget Command (" login ") ?. set Executor ( Login Command ()) ĊĠĠĠ Ġget Command (" login ") ?. tab Comp leter Ġ= Ġthis ĊĠĠĠ Ġget Command (" register ") ?. set Executor ( Register Command ()) ĊĠĠĠ Ġget Command (" register ") ?. tab Comp leter Ġ= Ġthis ĊĠĠĠ Ġget Command (" change pw ") ?. set Executor ( Change Password Command ()) ĊĠĠĠ Ġget Command (" change pw ") ?. tab Comp leter Ġ= Ġthis ĊĊĠĠĠ Ġsave Default Config () ĊĊĠĠĠ ĠDatabase . connect (" jdbc : sqlite :${ File ( data Folder , Ġ" users . db "). absolute Path }", Ġdriver Ġ= Ġ" org . sqlite . JDBC ") ĊĊĠĠĠ Ġtransaction Ġ{ ĊĠĠĠĠĠ Ġadd Logger ( Std Out Sql Logger ) ĊĠĠĠĠĠĠĊĠĠĠĠĠ ĠSchema Utils . create ( Users ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ EventHandler ĊĠ Ġpublic Ġfun Ġon Player Join ( event : ĠPlayer Join Event ) Ġ{ ĊĠĠĠ Ġval ĠdisplayName Ġ= Ġevent . player . displayName Stri pped ĊĊĠĠĠ Ġ// ĠMaps ĊĠĠĠ Ġusers Location Map [ displayName ] Ġ= Ġevent . player . location ĊĠĠĠ Ġusers Map [ displayName ] Ġ= Ġfalse ĊĊĠĠĠ Ġ// ĠTele port Ġto Ġworld Ġspawn Ġfirst ĊĠĠĠ Ġevent . player . tele port ( event . player . world . spawn Location ) ĊĊĠĠĠ Ġobject : ĠBu kkit Runnable () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġrun () Ġ{ ĊĠĠĠĠĠĠĠ Ġevent . player . sendMessage ("${ Chat Color . DARK _ A QUA } == ĠAUTH ENT ICATION ĠREQUIRED Ġ= =") ĊĠĠĠĠĠĠĠ Ġevent . player . sendMessage ("${ Chat Color . DARK _ A QUA } Please Ġeither Ġlog Ġin Ġto Ġthe Ġserver Ġwith Ġ${ Chat Color . A QUA }/ login Ġ< password >") ĊĠĠĠĠĠĠĠ Ġevent . player . sendMessage ("${ Chat Color . DARK _ A QUA } or Ġregister Ġan Ġaccount Ġwith Ġ${ Chat Color . A QUA }/ register Ġ< password > Ġ< confirm Password >") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}. run Task Later ( this , Ġ 2 0 Ġ* Ġ 3 ) ĊĊĠĠĠ Ġobject : ĠBu kkit Runnable () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġrun () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( users Map [ displayName ] Ġ== Ġfalse ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġ// ĠStill Ġun registered ĊĠĠĠĠĠĠĠĠĠ Ġusers Location Map [ displayName ]?. let Ġ{ Ġevent . player . tele port ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġevent . player . kick Player ("${ Chat Color . DARK _ A QUA } Did Ġnot Ġlog Ġin / register Ġin Ġtime ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}. run Task Later ( this , Ġ 2 0 Ġ* Ġconfig . getLong (" login _ timeout _ sec ", Ġ 6 0 )) ĊĠ Ġ} ĊĊĠ Ġ@ EventHandler ĊĠ Ġpublic Ġfun Ġon Player Leave ( event : ĠPlayer Quit Event ) Ġ{ ĊĠĠĠ Ġval ĠdisplayName Ġ= Ġevent . player . displayName Stri pped ĊĠĠĠ Ġusers Map . remove ( displayName ) ĊĠĠĠ Ġusers Location Map . remove ( displayName ) ĊĠ Ġ} ĊĊĠ Ġ@ EventHandler ĊĠ Ġpublic Ġfun Ġon Player Move ( event : ĠPlayer Move Event ) Ġ{ ĊĠĠĠ Ġif Ġ(! is Authenticated ( event . player . displayName Stri pped )) Ġ{ ĊĠĠĠĠĠ Ġevent . is Cancelled Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ EventHandler ĊĠ Ġfun Ġon Player Command ( event : ĠPlayer Command Pre process Event ) Ġ{ ĊĠĠĠ Ġif Ġ(! is Authenticated ( event . player . displayName Stri pped ) Ġ&& Ġ! event . message . startsWith ("/ login ") Ġ&& Ġ! event . message . startsWith ("/ register ")) Ġ{ ĊĠĠĠĠĠ Ġevent . is Cancelled Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġpublic Ġoverride Ġfun Ġon Tab Complete ( sender : ĠCommand Sender , Ġcmd : ĠCommand , Ġalias : ĠString , Ġargs : ĠArray < String >): ĠList < String > Ġ{ ĊĠĠĠ Ġreturn ĠlistOf () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġis Authenticated ( player Name : ĠString ): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġusers Map [ player Name ] Ġ== Ġtrue ĊĠ Ġ} Ċ } Ċ