2727import me .nik .combatplus .listeners .combatlog .TeleportListener ;
2828import me .nik .combatplus .listeners .fixes .Projectiles ;
2929import me .nik .combatplus .managers .CombatLog ;
30+ import me .nik .combatplus .managers .CustomRecipes ;
3031import me .nik .combatplus .managers .MsgType ;
3132import me .nik .combatplus .metrics .MetricsLite ;
32- import me .nik .combatplus .utils .CustomRecipes ;
33- import me .nik .combatplus .utils .ResetStats ;
34- import me .nik .combatplus .utils .SetAttackSpeed ;
35- import me .nik .combatplus .utils .SetCustomHealth ;
33+ import me .nik .combatplus .utils .StatUtils ;
3634import org .bukkit .Bukkit ;
3735import org .bukkit .ChatColor ;
3836import org .bukkit .attribute .Attribute ;
3937import org .bukkit .attribute .AttributeInstance ;
38+ import org .bukkit .entity .Player ;
4039import org .bukkit .plugin .PluginManager ;
4140import org .bukkit .plugin .java .JavaPlugin ;
4241
42+ import java .util .Collection ;
43+
4344public final class CombatPlus extends JavaPlugin {
4445
4546 private static CombatPlus instance ;
@@ -52,6 +53,14 @@ public static CombatPlus getInstance() {
5253 return instance ;
5354 }
5455
56+ private final String [] STARTUP_MESSAGE = {
57+ " " ,
58+ ChatColor .RED + "Combat Plus v" + this .getDescription ().getVersion (),
59+ " " ,
60+ ChatColor .WHITE + " Author: Nik" ,
61+ " "
62+ };
63+
5564 @ Override
5665 public void onDisable () {
5766 //Load Default Stats to avoid server damage
@@ -66,6 +75,10 @@ public void onDisable() {
6675 consoleMessage (MsgType .CONSOLE_DISABLED .getMessage ());
6776 }
6877
78+ /**
79+ * This needs a re-code, i might do it once im not so lazy
80+ */
81+
6982 @ Override
7083 public void onEnable () {
7184 instance = this ;
@@ -76,12 +89,7 @@ public void onEnable() {
7689 //Load Files
7790 loadFiles ();
7891
79- //Startup Message
80- consoleMessage ("" );
81- consoleMessage (" " + ChatColor .RED + "Combat Plus v" + this .getDescription ().getVersion ());
82- consoleMessage ("" );
83- consoleMessage (" " + ChatColor .WHITE + "Author: Nik" );
84- consoleMessage ("" );
92+ this .getServer ().getConsoleSender ().sendMessage (this .STARTUP_MESSAGE );
8593
8694 //Unsupported Version Checker
8795 checkSupported ();
@@ -140,7 +148,7 @@ private void checkForUpdates() {
140148 */
141149 private void setDefaultStats () {
142150 if (serverVersion ("1.8" )) return ;
143- this . getServer () .getOnlinePlayers ().forEach (player -> {
151+ Bukkit .getOnlinePlayers ().forEach (player -> {
144152 final double defaultHealth = Config .Setting .ADV_BASE_HEALTH .getDouble ();
145153 final AttributeInstance playerMaxHealth = player .getAttribute (Attribute .GENERIC_MAX_HEALTH );
146154 playerMaxHealth .setBaseValue (defaultHealth );
@@ -157,20 +165,20 @@ private void setDefaultStats() {
157165 */
158166 private void loadStats () {
159167 if (serverVersion ("1.8" )) return ;
160- SetAttackSpeed setAttackSpeed = new SetAttackSpeed ();
161- ResetStats resetStats = new ResetStats ();
162- SetCustomHealth setCustomHealth = new SetCustomHealth ();
163168
169+ Collection <? extends Player > players = Bukkit .getOnlinePlayers ();
170+
171+ //Yes i'm using forEach instead of for loop, For this case it doesn't really matter if its faster or heavier so shhh
164172 if (Config .Setting .OLD_PVP .getBoolean ()) {
165- this . getServer (). getOnlinePlayers (). forEach (setAttackSpeed :: setAttackSpd );
173+ players . forEach (StatUtils :: setAttackSpeed );
166174 } else {
167- this . getServer (). getOnlinePlayers (). forEach (resetStats ::resetAttackSpeed );
175+ players . forEach (StatUtils ::resetAttackSpeed );
168176 }
169177
170178 if (Config .Setting .CUSTOM_PLAYER_HEALTH_ENABLED .getBoolean ()) {
171- this . getServer (). getOnlinePlayers (). forEach (setCustomHealth :: setHealth );
179+ players . forEach (StatUtils :: setMaxHealth );
172180 } else {
173- this . getServer (). getOnlinePlayers (). forEach (resetStats ::resetMaxHealth );
181+ players . forEach (StatUtils ::resetMaxHealth );
174182 }
175183 }
176184
@@ -192,7 +200,7 @@ private void initialize() {
192200 pm .registerEvents (new BowBoost (), this );
193201 }
194202 if (Config .Setting .OLD_REGEN .getBoolean ()) {
195- pm .registerEvents (new PlayerRegen (this ), this );
203+ pm .registerEvents (new PlayerRegen (), this );
196204 }
197205 if (Config .Setting .DISABLED_ITEMS_ENABLED .getBoolean ()) {
198206 pm .registerEvents (new DisabledItems (), this );
0 commit comments