77import io .github .simplex .luck .util .RegenerateConfigCMD ;
88import io .github .simplex .luck .util .SpecialFootItem ;
99import io .github .simplex .metrics .Metrics ;
10- import org .bukkit .command .CommandMap ;
11- import org .bukkit .plugin .java .JavaPlugin ;
12- import org .jetbrains .annotations .NotNull ;
13-
1410import java .io .File ;
1511import java .util .Arrays ;
1612import java .util .HashMap ;
1713import java .util .Map ;
1814import java .util .UUID ;
15+ import net .kyori .adventure .chat .ChatType ;
16+ import net .kyori .adventure .text .Component ;
17+ import org .bukkit .command .CommandMap ;
18+ import org .bukkit .plugin .java .JavaPlugin ;
19+ import org .jetbrains .annotations .NotNull ;
1920
20- public final class FeelingLucky extends JavaPlugin {
21+ public final class FeelingLucky extends JavaPlugin
22+ {
2123 private final Map <UUID , PlayerConfig > configMap = new HashMap <>();
2224 private final File playerDirectory = new File (getDataFolder (), "players" );
2325 private final SpecialFootItem specialFootItem = new SpecialFootItem ();
24-
26+ private final ChatType . Bound bind = ChatType . CHAT . bind ( Component . text ( getName ()));
2527 private PlayerHandler handler ;
2628 private Config config ;
2729
28- public Map <UUID , PlayerConfig > getConfigMap () {
30+ public Map <UUID , PlayerConfig > getConfigMap ()
31+ {
2932 return configMap ;
3033 }
3134
3235 @ Override
33- public void onEnable () {
36+ public void onEnable ()
37+ {
3438 getLogger ().info ("Initializing metrics..." );
3539 new Metrics (this , 15054 );
3640 getLogger ().info ("Metrics loaded. Initializing the PlayerHandler..." );
@@ -50,36 +54,44 @@ public void onEnable() {
5054 }
5155
5256 @ Override
53- public void onDisable () {
57+ public void onDisable ()
58+ {
5459 getLogger ().info ("Saving all player configurations..." );
5560 configMap .values ().forEach (PlayerConfig ::save );
5661 getLogger ().info ("Complete! Saving the main config..." );
5762 config .save ();
5863 getLogger ().info ("Complete! Goodbye! :)" );
5964 }
6065
61- private void loadPlayerConfigurations () {
62- if (!playerDirectory .exists ()) {
66+ private void loadPlayerConfigurations ()
67+ {
68+ if (!playerDirectory .exists ())
69+ {
6370 getLogger ().info ("No directory exists. Creating..." );
6471 playerDirectory .mkdirs ();
6572 getLogger ().info ("Created new directory \" FeelingLucky/players\" ." );
6673 return ;
6774 }
6875
6976 File [] files = playerDirectory .listFiles ();
70- if (files != null ) {
71- Arrays .stream (files ).forEach (file -> {
72- UUID uuid = UUID .fromString (file .getName ().split ("\\ ." )[0 ]);
73- configMap .put (uuid , PlayerConfig .initFrom (this , file ));
74- });
77+ if (files != null )
78+ {
79+ Arrays .stream (files ).forEach (file ->
80+ {
81+ UUID uuid = UUID .fromString (file .getName ().split ("\\ ." )[0 ]);
82+ configMap .put (uuid , PlayerConfig .initFrom (this , file ));
83+ });
7584 configMap .forEach ((u , pc ) -> pc .load ());
7685 getLogger ().info ("Successfully loaded all configurations!" );
77- } else {
86+ }
87+ else
88+ {
7889 getLogger ().info ("There are no player configurations to load." );
7990 }
8091 }
8192
82- private void registerListeners () {
93+ private void registerListeners ()
94+ {
8395 new BlockDrops (this );
8496 new BonemealFullCrop (this );
8597 new CheatDeath (this );
@@ -90,7 +102,7 @@ private void registerListeners() {
90102 new IllOmen (this );
91103 new ItemDrops (this );
92104 new JumpBoost (this );
93- new OreVein (this );
105+ // new OreVein(this); (Currently unstable & unsafe).
94106 new PlayerListener (this );
95107 new RandomEffect (this );
96108 new RestoreHunger (this );
@@ -99,21 +111,30 @@ private void registerListeners() {
99111 new VillagerInventory (this );
100112 }
101113
102- public PlayerHandler getHandler () {
114+ public PlayerHandler getHandler ()
115+ {
103116 return handler ;
104117 }
105118
106119 @ Override
107120 @ NotNull
108- public Config getConfig () {
121+ public Config getConfig ()
122+ {
109123 return config ;
110124 }
111125
112- public SpecialFootItem getFoot () {
126+ public SpecialFootItem getFoot ()
127+ {
113128 return specialFootItem ;
114129 }
115130
116- public CommandMap getCommandMap () {
131+ public CommandMap getCommandMap ()
132+ {
117133 return getServer ().getCommandMap ();
118134 }
135+
136+ public ChatType .Bound bind ()
137+ {
138+ return bind ;
139+ }
119140}
0 commit comments