@@ -121,16 +121,6 @@ private void fixItemLore(ItemStack original, Player player) {
121121 PersistentDataContainer container = finalMeta .getPersistentDataContainer ();
122122 List <String > lore = new ArrayList <>();
123123
124- String caughtByLore = toolStats .configTools .getLoreFromConfig ("fished.caught-by" , false );
125- String lootedByLore = toolStats .configTools .getLoreFromConfig ("looted.found-by" , false );
126- String tradedByLore = toolStats .configTools .getLoreFromConfig ("traded.traded-by" , false );
127- String spawnedByLore = toolStats .configTools .getLoreFromConfig ("spawned-in.spawned-by" , false );
128-
129- // make sure the config messages are not null
130- if (caughtByLore == null || lootedByLore == null || tradedByLore == null || spawnedByLore == null ) {
131- return ;
132- }
133-
134124 // set how the item was obtained
135125 Integer origin = -1 ;
136126 if (container .has (toolStats .originType , PersistentDataType .INTEGER )) {
@@ -155,13 +145,16 @@ private void fixItemLore(ItemStack original, Player player) {
155145
156146 if (flightTime != null ) {
157147 if (toolStats .config .getBoolean ("enabled.flight-time" )) {
158- lore .add (toolStats .configTools .getLoreFromConfig ("flight-time" , true ).replace ("{time}" , toolStats .numberFormat .formatDouble ((double ) flightTime / 1000 )));
148+ String line = toolStats .configTools .formatLore ("flight-time" , "{time}" , toolStats .numberFormat .formatDouble ((double ) flightTime / 1000 ));
149+ lore .add (line );
159150 }
160151 }
161152
162153 if (timeCreated != null ) {
163- lore .add (toolStats .configTools .getLoreFromConfig ("looted.found-by" , true ).replace ("{player}" , player .getName ()));
164- lore .add (toolStats .configTools .getLoreFromConfig ("looted.found-on" , true ).replace ("{date}" , toolStats .numberFormat .formatDate (new Date (timeCreated ))));
154+ String timeCreatedLine = toolStats .configTools .formatLore ("looted.found-by" , "{player}" , player .getName ());
155+ String playerOwnerLine = toolStats .configTools .formatLore ("looted.found-on" , "{date}" , toolStats .numberFormat .formatDate (new Date (timeCreated )));
156+ lore .add (timeCreatedLine );
157+ lore .add (playerOwnerLine );
165158 }
166159
167160 finalMeta .setLore (lore );
@@ -191,27 +184,27 @@ private void fixItemLore(ItemStack original, Player player) {
191184 // show how the item was created based on the previous lore
192185 switch (origin ) {
193186 case 0 : {
194- lore .add (toolStats .configTools .getLoreFromConfig ("created.created-by" , true ). replace ( "{player}" , ownerName ));
187+ lore .add (toolStats .configTools .formatLore ("created.created-by" , "{player}" , ownerName ));
195188 break ;
196189 }
197190 case 2 : {
198- lore .add (toolStats .configTools .getLoreFromConfig ("looted.looted-by" , true ). replace ( "{player}" , ownerName ));
191+ lore .add (toolStats .configTools .formatLore ("looted.looted-by" , "{player}" , ownerName ));
199192 break ;
200193 }
201194 case 3 : {
202- lore .add (toolStats .configTools .getLoreFromConfig ("traded.traded-by" , true ). replace ( "{player}" , ownerName ));
195+ lore .add (toolStats .configTools .formatLore ("traded.traded-by" , "{player}" , ownerName ));
203196 break ;
204197 }
205198 case 4 : {
206- lore .add (toolStats .configTools .getLoreFromConfig ("looted.found-by" , true ). replace ( "{player}" , ownerName ));
199+ lore .add (toolStats .configTools .formatLore ("looted.found-by" , "{player}" , ownerName ));
207200 break ;
208201 }
209202 case 5 : {
210- lore .add (toolStats .configTools .getLoreFromConfig ("fished.caught-by" , true ). replace ( "{player}" , ownerName ));
203+ lore .add (toolStats .configTools .formatLore ("fished.caught-by" , "{player}" , ownerName ));
211204 break ;
212205 }
213206 case 6 : {
214- lore .add (toolStats .configTools .getLoreFromConfig ("spawned-in.spawned-by" , true ). replace ( "{player}" , ownerName ));
207+ lore .add (toolStats .configTools .formatLore ("spawned-in.spawned-by" , "{player}" , ownerName ));
215208 break ;
216209 }
217210 }
@@ -221,30 +214,31 @@ private void fixItemLore(ItemStack original, Player player) {
221214 if (container .has (toolStats .timeCreated , PersistentDataType .LONG )) {
222215 Long time = container .get (toolStats .timeCreated , PersistentDataType .LONG );
223216 if (time != null ) {
217+ String date = toolStats .numberFormat .formatDate (new Date (time ));
224218 // show how when the item was created based on the previous lore
225219 switch (origin ) {
226220 case 0 : {
227- lore .add (toolStats .configTools .getLoreFromConfig ("created.created-on" , true ). replace ( "{date}" , toolStats . numberFormat . formatDate ( new Date ( time )) ));
221+ lore .add (toolStats .configTools .formatLore ("created.created-on" , "{date}" , date ));
228222 break ;
229223 }
230224 case 2 : {
231- lore .add (toolStats .configTools .getLoreFromConfig ("looted.looted-on" , true ). replace ( "{date}" , toolStats . numberFormat . formatDate ( new Date ( time )) ));
225+ lore .add (toolStats .configTools .formatLore ("looted.looted-on" , "{date}" , date ));
232226 break ;
233227 }
234228 case 3 : {
235- lore .add (toolStats .configTools .getLoreFromConfig ("traded.traded-on" , true ). replace ( "{date}" , toolStats . numberFormat . formatDate ( new Date ( time )) ));
229+ lore .add (toolStats .configTools .formatLore ("traded.traded-on" , "{date}" , date ));
236230 break ;
237231 }
238232 case 4 : {
239- lore .add (toolStats .configTools .getLoreFromConfig ("looted.found-on" , true ). replace ( "{date}" , toolStats . numberFormat . formatDate ( new Date ( time )) ));
233+ lore .add (toolStats .configTools .formatLore ("looted.found-on" , "{date}" , date ));
240234 break ;
241235 }
242236 case 5 : {
243- lore .add (toolStats .configTools .getLoreFromConfig ("fished.caught-on" , true ). replace ( "{date}" , toolStats . numberFormat . formatDate ( new Date ( time )) ));
237+ lore .add (toolStats .configTools .formatLore ("fished.caught-on" , "{date}" , date ));
244238 break ;
245239 }
246240 case 6 : {
247- lore .add (toolStats .configTools .getLoreFromConfig ("spawned-in.spawned-on" , true ). replace ( "{date}" , toolStats . numberFormat . formatDate ( new Date ( time )) ));
241+ lore .add (toolStats .configTools .formatLore ("spawned-in.spawned-on" , "{date}" , date ));
248242 break ;
249243 }
250244 }
@@ -255,15 +249,15 @@ private void fixItemLore(ItemStack original, Player player) {
255249 if (container .has (toolStats .swordPlayerKills , PersistentDataType .INTEGER )) {
256250 Integer kills = container .get (toolStats .swordPlayerKills , PersistentDataType .INTEGER );
257251 if (kills != null ) {
258- lore .add (toolStats .configTools .getLoreFromConfig ("kills.player" , true ). replace ( "{kills}" , toolStats .numberFormat .formatInt (kills )));
252+ lore .add (toolStats .configTools .formatLore ("kills.player" , "{kills}" , toolStats .numberFormat .formatInt (kills )));
259253 }
260254 }
261255 }
262256 if (toolStats .configTools .checkConfig (original .getType (), "mob-kills" )) {
263257 if (container .has (toolStats .swordMobKills , PersistentDataType .INTEGER )) {
264258 Integer kills = container .get (toolStats .swordMobKills , PersistentDataType .INTEGER );
265259 if (kills != null ) {
266- lore .add (toolStats .configTools .getLoreFromConfig ("kills.mob" , true ). replace ( "{kills}" , toolStats .numberFormat .formatInt (kills )));
260+ lore .add (toolStats .configTools .formatLore ("kills.mob" , "{kills}" , toolStats .numberFormat .formatInt (kills )));
267261 }
268262 }
269263 }
@@ -272,46 +266,46 @@ private void fixItemLore(ItemStack original, Player player) {
272266 if (container .has (toolStats .cropsHarvested , PersistentDataType .INTEGER )) {
273267 Integer crops = container .get (toolStats .cropsHarvested , PersistentDataType .INTEGER );
274268 if (crops != null ) {
275- lore .add (toolStats .configTools .getLoreFromConfig ("crops-harvested" , true ). replace ( "{crops}" , toolStats .numberFormat .formatInt (crops )));
269+ lore .add (toolStats .configTools .formatLore ("crops-harvested" , "{crops}" , toolStats .numberFormat .formatInt (crops )));
276270 }
277271 }
278272 }
279273 if (container .has (toolStats .genericMined , PersistentDataType .INTEGER )) {
280274 Integer blocksMined = container .get (toolStats .genericMined , PersistentDataType .INTEGER );
281275 if (blocksMined != null ) {
282- lore .add (toolStats .configTools .getLoreFromConfig ("blocks-mined" , true ). replace ( "{blocks}" , toolStats .numberFormat .formatInt (blocksMined )));
276+ lore .add (toolStats .configTools .formatLore ("blocks-mined" , "{blocks}" , toolStats .numberFormat .formatInt (blocksMined )));
283277 }
284278 }
285279 }
286280 if (toolStats .config .getBoolean ("enabled.fish-caught" )) {
287281 if (container .has (toolStats .fishingRodCaught , PersistentDataType .INTEGER )) {
288282 Integer fish = container .get (toolStats .fishingRodCaught , PersistentDataType .INTEGER );
289283 if (fish != null ) {
290- lore .add (toolStats .configTools .getLoreFromConfig ("fished.fish-caught" , true ). replace ( "{fish}" , toolStats .numberFormat .formatInt (fish )));
284+ lore .add (toolStats .configTools .formatLore ("fished.fish-caught" , "{fish}" , toolStats .numberFormat .formatInt (fish )));
291285 }
292286 }
293287 }
294288 if (toolStats .config .getBoolean ("enabled.sheep-sheared" )) {
295289 if (container .has (toolStats .shearsSheared , PersistentDataType .INTEGER )) {
296290 Integer sheep = container .get (toolStats .shearsSheared , PersistentDataType .INTEGER );
297291 if (sheep != null ) {
298- lore .add (toolStats .configTools .getLoreFromConfig ("sheep-sheared" , true ). replace ( "{sheep}" , toolStats .numberFormat .formatInt (sheep )));
292+ lore .add (toolStats .configTools .formatLore ("sheep-sheared" , "{sheep}" , toolStats .numberFormat .formatInt (sheep )));
299293 }
300294 }
301295 }
302296 if (toolStats .config .getBoolean ("enabled.armor-damage" )) {
303297 if (container .has (toolStats .armorDamage , PersistentDataType .DOUBLE )) {
304298 Double damage = container .get (toolStats .armorDamage , PersistentDataType .DOUBLE );
305299 if (damage != null ) {
306- lore . add ( toolStats .configTools .getLoreFromConfig ("damage-taken" , true ). replace ( "{damage}" , toolStats .numberFormat .formatDouble (damage ) ));
300+ toolStats .configTools .formatLore ("damage-taken" , "{damage}" , toolStats .numberFormat .formatDouble (damage ));
307301 }
308302 }
309303 }
310304 if (toolStats .config .getBoolean ("enabled.arrows-shot" )) {
311305 if (container .has (toolStats .arrowsShot , PersistentDataType .INTEGER )) {
312306 Integer arrows = container .get (toolStats .arrowsShot , PersistentDataType .INTEGER );
313307 if (arrows != null ) {
314- lore . add ( toolStats .configTools .getLoreFromConfig ("arrows-shot" , true ). replace ( "{arrows}" , toolStats .numberFormat .formatInt (arrows ) ));
308+ toolStats .configTools .formatLore ("arrows-shot" , "{arrows}" , toolStats .numberFormat .formatInt (arrows ));
315309 }
316310 }
317311 }
0 commit comments