@@ -30,9 +30,9 @@ public class BlueMapIntegration {
3030
3131 public BlueMapIntegration (LLBlueMap plugin ) {
3232 this .plugin = plugin ;
33- this . config = plugin .getConfiguration ();
33+ config = plugin .getConfiguration ();
3434
35- this . queue = new ConcurrentHashMap <>();
35+ queue = new ConcurrentHashMap <>();
3636 }
3737
3838 private MarkerSet buildMarkerSet (MarkerAPI markerAPI ) {
@@ -42,51 +42,51 @@ private MarkerSet buildMarkerSet(MarkerAPI markerAPI) {
4242 public void hookBlueMap (BlueMapAPI blueMapAPI ) {
4343 Bukkit .getScheduler ().runTaskAsynchronously (plugin , bukkitTask -> {
4444 try {
45- final MarkerAPI markerAPI = blueMapAPI .getMarkerAPI ();
46- plugin .logToConsole ( Level . INFO , "Loading Landlord markers..." );
45+ MarkerAPI markerAPI = blueMapAPI .getMarkerAPI ();
46+ plugin .getLogger (). info ( "Loading Landlord markers..." );
4747
48- final MarkerSet markerSet = buildMarkerSet (markerAPI );
49- final int size = markerSet .getMarkers ().size ();
48+ MarkerSet markerSet = buildMarkerSet (markerAPI );
49+ int size = markerSet .getMarkers ().size ();
5050
51- plugin .logToConsole ( Level . INFO , "Updating Landlord markers..." );
51+ plugin .getLogger (). info ( "Updating Landlord markers..." );
5252 markerSet .setLabel (config .getMarkerSetLabel ());
5353 markerSet .setDefaultHidden (config .isMarkerSetDefaultHidden ());
5454 markerSet .setToggleable (config .isMarkerSetToggleable ());
5555
5656 if (size == 0 ) {
57- plugin .logToConsole ( Level . WARNING , "Landlord markers not found!" );
57+ plugin .getLogger (). warning ( "Landlord markers not found!" );
5858 importLands (blueMapAPI , markerAPI , markerSet );
5959 } else {
60- plugin .logToConsole ( Level . INFO , size + " Landlord markers found!" );
60+ plugin .getLogger (). info ( size + " Landlord markers found!" );
6161 markerAPI .save ();
6262 }
63- plugin .logToConsole ( Level . INFO , "Loading update task..." );
63+ plugin .getLogger (). info ( "Loading update task..." );
6464 initUpdateTask ();
6565 } catch (IOException e ) {
66- e . printStackTrace ( );
66+ plugin . getLogger (). log ( Level . SEVERE , "Could not retrieve marker api" , e );
6767 }
6868 });
6969 }
7070
7171 public void unhookBlueMap (BlueMapAPI blueMapAPI ) {
7272 try {
7373 updateTask .cancel ();
74- final MarkerAPI markerAPI = blueMapAPI .getMarkerAPI ();
74+ MarkerAPI markerAPI = blueMapAPI .getMarkerAPI ();
7575
76- final Set <IOwnedLand > ownedLands = plugin .getLandLordAPI ().getWGManager ().getRegions ();
77- plugin .logToConsole ( Level . WARNING , "Checking " + ownedLands .size () + " lands and processing " + queue .size () + " remaining updates, this could take a while..." );
76+ Set <IOwnedLand > ownedLands = plugin .getLandLordAPI ().getWGManager ().getRegions ();
77+ plugin .getLogger (). warning ( "Checking " + ownedLands .size () + " lands and processing " + queue .size () + " remaining updates, this could take a while..." );
7878
7979 for (IOwnedLand ownedLand : plugin .getLandLordAPI ().getWGManager ().getRegions ()) {
80- final OfflinePlayer offlinePlayer = Bukkit .getOfflinePlayer (ownedLand .getOwner ());
81- final Instant lastPlayed = Instant .ofEpochMilli (offlinePlayer .getLastPlayed ());
80+ OfflinePlayer offlinePlayer = Bukkit .getOfflinePlayer (ownedLand .getOwner ());
81+ Instant lastPlayed = Instant .ofEpochMilli (offlinePlayer .getLastPlayed ());
8282
8383 if (lastPlayed .isBefore (Instant .now ().minus (config .getMarkerSetLifetime (), ChronoUnit .DAYS ))) {
8484 enqueueLand (ownedLand , UpdateReason .UNCLAIM );
8585 }
8686 }
8787 processQueue (blueMapAPI , markerAPI , buildMarkerSet (markerAPI ), Integer .MAX_VALUE );
8888 } catch (IOException e ) {
89- e . printStackTrace ( );
89+ plugin . getLogger (). log ( Level . SEVERE , "Could not retrieve marker api" , e );
9090 }
9191 }
9292
@@ -97,17 +97,17 @@ public void initUpdateTask() {
9797 updateTask = Bukkit .getScheduler ().runTaskTimerAsynchronously (plugin , () ->
9898 BlueMapAPI .getInstance ().ifPresent (blueMapAPI -> {
9999 try {
100- final MarkerAPI markerAPI = blueMapAPI .getMarkerAPI ();
100+ MarkerAPI markerAPI = blueMapAPI .getMarkerAPI ();
101101 processQueue (blueMapAPI , markerAPI , buildMarkerSet (markerAPI ), config .getMaxProcessedPerUpdate ());
102102 } catch (IOException e ) {
103- e . printStackTrace ( );
103+ plugin . getLogger (). log ( Level . SEVERE , "Could not retrieve marker api" , e );
104104 }
105105 }), config .getUpdateTaskFrequency (), config .getUpdateTaskFrequency ());
106106 }
107107
108108 private void importLands (BlueMapAPI blueMapAPI , MarkerAPI markerAPI , MarkerSet markerSet ) {
109- final Set <IOwnedLand > ownedLands = plugin .getLandLordAPI ().getWGManager ().getRegions ();
110- plugin .logToConsole ( Level . WARNING , "Importing " + ownedLands .size () + " lands, this could take a while..." );
109+ Set <IOwnedLand > ownedLands = plugin .getLandLordAPI ().getWGManager ().getRegions ();
110+ plugin .getLogger (). warning ( "Importing " + ownedLands .size () + " lands, this could take a while..." );
111111
112112// final BlueMapIsland blueMapIsland = new BlueMapIsland(plugin, plugin.getLandLordAPI().getWGManager().getRegion("world_1429_-2113"));
113113//
@@ -145,8 +145,8 @@ private void importLands(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet m
145145// }
146146
147147 for (IOwnedLand ownedLand : plugin .getLandLordAPI ().getWGManager ().getRegions ()) {
148- final OfflinePlayer offlinePlayer = Bukkit .getOfflinePlayer (ownedLand .getOwner ());
149- final Instant lastPlayed = Instant .ofEpochMilli (offlinePlayer .getLastPlayed ());
148+ OfflinePlayer offlinePlayer = Bukkit .getOfflinePlayer (ownedLand .getOwner ());
149+ Instant lastPlayed = Instant .ofEpochMilli (offlinePlayer .getLastPlayed ());
150150
151151 if (lastPlayed .isAfter (Instant .now ().minus (config .getMarkerSetLifetime (), ChronoUnit .DAYS ))) {
152152 enqueueLand (ownedLand , UpdateReason .CLAIM );
@@ -157,20 +157,15 @@ private void importLands(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet m
157157 }
158158
159159 public void enqueueLand (IOwnedLand ownedLand , UpdateReason updateReason ) {
160- if (ownedLand == null || ownedLand .getOwner () == null )
161- return ;
160+ if (ownedLand == null || ownedLand .getOwner () == null ) return ;
162161
163162 queue .compute (ownedLand , (queuedOwnedLand , queuedUpdateReason ) -> {
164- if (queuedUpdateReason == null ) {
165- return updateReason ;
166- }
163+ if (queuedUpdateReason == null ) return updateReason ;
167164
168165 switch (queuedUpdateReason ) {
169166 case CLAIM :
170167 case UNCLAIM :
171- if (updateReason == UpdateReason .MANAGE ) {
172- return queuedUpdateReason ;
173- }
168+ if (updateReason == UpdateReason .MANAGE ) return queuedUpdateReason ;
174169 default :
175170 return updateReason ;
176171 }
@@ -181,21 +176,21 @@ private void processQueue(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet
181176 int iterations = 0 ;
182177
183178 for (Iterator <Map .Entry <IOwnedLand , UpdateReason >> iterator = queue .entrySet ().iterator (); iterator .hasNext () && iterations < limit ; ) {
184- final Map .Entry <IOwnedLand , UpdateReason > entry = iterator .next ();
179+ Map .Entry <IOwnedLand , UpdateReason > entry = iterator .next ();
185180
186181 new BlueMapLand (plugin , entry .getKey ()).process (blueMapAPI , markerSet , entry .getValue ());
187182
188183 iterator .remove ();
189184 iterations ++;
190185 }
191186
192- if (iterations == 0 )
193- return ;
187+ if (iterations == 0 ) return ;
188+
194189 try {
195190 markerAPI .save ();
196191 } catch (IOException e ) {
197- e . printStackTrace ( );
192+ plugin . getLogger (). log ( Level . SEVERE , "Could not save to marker api" , e );
198193 }
199194 }
200195
201- }
196+ }
0 commit comments