package Ġme . eb on j aeger . per world inventory . listener . player Ċ Ċ import Ġme . eb on j aeger . per world inventory . Console Logger Ċ import Ġme . eb on j aeger . per world inventory . Group Manager Ċ import Ġme . eb on j aeger . per world inventory . configuration . Plugin Settings Ċ import Ġme . eb on j aeger . per world inventory . configuration . Settings Ċ import Ġme . eb on j aeger . per world inventory . data . Profile Manager Ċ import Ġme . eb on j aeger . per world inventory . event . Cause Ċ import Ġme . eb on j aeger . per world inventory . event . Inventory Load Event Ċ import Ġme . eb on j aeger . per world inventory . permission . Player Permission Ċ import Ġorg . bukkit . Bu kkit Ċ import Ġorg . bukkit . event . EventHandler Ċ import Ġorg . bukkit . event . Event Priority Ċ import Ġorg . bukkit . event . Listener Ċ import Ġorg . bukkit . event . player . Player Game Mode ChangeEvent Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠPlayer Game Mode ChangeListener Ġ@ Inject Ġconstructor ( private Ġval Ġgroup Manager : ĠGroup Manager , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġprofile Manager : ĠProfile Manager , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġsettings : ĠSettings ) Ġ: ĠListener Ċ { ĊĊĠĠĠ Ġ@ EventHandler ( priority Ġ= ĠEvent Priority . MONITOR ) ĊĠĠĠ Ġfun Ġon Player Changed Game Mode ( event : ĠPlayer Game Mode ChangeEvent ) ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( event . is Cancelled Ġ|| Ġ! settings . getProperty ( Plugin Settings . SEPAR ATE _ GM _ IN VENT ORIES )) ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġplayer Ġ= Ġevent . player ĊĠĠĠĠĠĠĠ Ġval Ġgroup Ġ= Ġgroup Manager . getGroup From World ( player . world . name ) ĊĊĠĠĠĠĠĠĠ ĠConsole Logger . fine (" on Player Changed Game Mode : Ġ'${ player . name }' Ġchanging ĠGame Modes ") ĊĠĠĠĠĠĠĠ ĠConsole Logger . debug (" on Player Changed Game Mode : Ġnew Game Mode : Ġ${ event . new Game Mode }, Ġgroup : Ġ$ group ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠSave Ġthe Ġcurrent Ġprofile ĊĠĠĠĠĠĠĠ Ġprofile Manager . add Player Profile ( player , Ġgroup , Ġplayer . game Mode ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠCheck Ġif Ġthe Ġplayer Ġcan Ġbypass Ġthe Ġinventory Ġswitch ĊĠĠĠĠĠĠĠ Ġif Ġ(! settings . getProperty ( Plugin Settings . DISABLE _ BY PASS ) Ġ&& ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġplayer . has Permission ( Player Permission . BY PASS _ GAME MODE . getNode ())) ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠConsole Logger . debug (" on Player Changed Game Mode : Ġ'${ player . name }' Ġis Ġbypass ing Ġthe Ġinventory Ġswitch ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// ĠCreate Ġand Ġcall Ġan ĠInventory Load Event . ĠIf Ġit Ġisn 't Ġcancelled , Ġload ĊĠĠĠĠĠĠĠ Ġ// Ġthe Ġplayer 's Ġnew Ġprofile ĊĠĠĠĠĠĠĠ Ġval Ġload Event Ġ= ĠInventory Load Event ( player , ĠCause . GAME MODE _ CHANGE , Ġplayer . game Mode , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġevent . new Game Mode , Ġgroup ) ĊĠĠĠĠĠĠĠ ĠBu kkit . get PluginManager (). call Event ( load Event ) ĊĠĠĠĠĠĠĠ Ġif Ġ(! event . is Cancelled ) ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠConsole Logger . fine (" on Player Changed Game Mode : ĠLoading Ġprofile Ġfor Ġ'${ player . name }' ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Manager . getPlayer Data ( player , Ġgroup , Ġevent . new Game Mode ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ