@@ -418,10 +418,22 @@ public static boolean reinforcementDamaged(Player player, Reinforcement reinforc
418
418
reinforcement .setDurability (durability );
419
419
boolean cancelled = durability > 0 ;
420
420
if (durability <= 0 ) {
421
- cancelled = reinforcementBroken (null , reinforcement );
421
+ if (CitadelConfigManager .shouldLogHostileBreaks ()) {
422
+ StringBuffer slb = new StringBuffer ();
423
+ if (player != null ) {
424
+ slb .append ("Player " ).append (player .getName ()).append (" [" ).append (player .getUniqueId ())
425
+ .append ("] " );
426
+ } else {
427
+ slb .append ("Something " );
428
+ }
429
+ slb .append ("broke a " ).append (reinforcement .getMaterial ()).append (" reinforcement at " )
430
+ .append (reinforcement .getLocation ());
431
+ Citadel .Log (slb .toString ());
432
+ }
433
+ cancelled = reinforcementBroken (null , reinforcement );
422
434
} else {
423
435
/* TODO: Move to ReinforcementEvent listener*/
424
- if (CitadelConfigManager .shouldLogBreaks ()) {
436
+ if (CitadelConfigManager .shouldLogDamage ()) {
425
437
StringBuffer slb = new StringBuffer ();
426
438
if (player != null ) {
427
439
slb .append ("Player " ).append (player .getName ()).append (" [" ).append (player .getUniqueId ())
@@ -456,6 +468,7 @@ public static boolean reinforcementDamaged(Player player, Reinforcement reinforc
456
468
slb .append ("excellent (" );
457
469
}
458
470
slb .append (durability ).append (") at " ).append (reinforcement .getLocation ());
471
+ Citadel .Log (slb .toString ());
459
472
}
460
473
if (reinforcement instanceof PlayerReinforcement ) {
461
474
// leave message
@@ -539,22 +552,19 @@ public static boolean reinforcementBroken(Player player, Reinforcement reinforce
539
552
return false ;
540
553
}
541
554
StringBuffer slb = null ;
542
- if (CitadelConfigManager .shouldLogBreaks ()) {
555
+ boolean logIt = CitadelConfigManager .shouldLogFriendlyBreaks () && player != null ;
556
+ if (logIt ) {
543
557
slb = new StringBuffer ();
544
- if (player != null ) {
545
- slb .append ("Player " ).append (player .getName ()).append (" [" ).append (player .getUniqueId ())
546
- .append ("]" );
547
- } else {
548
- slb .append ("Something " );
549
- }
550
- slb .append ("broke a " ).append (reinforcement .getMaterial ()).append (" reinforcement at " )
558
+ slb .append ("Player " ).append (player .getName ()).append (" [" ).append (player .getUniqueId ())
559
+ .append ("] bypassed a " ).append (reinforcement .getMaterial ()).append (" reinforcement at " )
551
560
.append (reinforcement .getLocation ());
552
561
}
553
562
Citadel .getReinforcementManager ().deleteReinforcement (reinforcement );
554
563
if (reinforcement instanceof PlayerReinforcement ) {
555
564
PlayerReinforcement pr = (PlayerReinforcement )reinforcement ;
556
565
ReinforcementType material = ReinforcementType .getReinforcementType (pr .getStackRepresentation ());
557
- if (rng .nextDouble () <= pr .getHealth () * material .getPercentReturn ()) {
566
+ // RNG is [0,1) so <= would give chance of return if health is 0. Replaced with < alone to fix.
567
+ if (rng .nextDouble () < pr .getHealth () * material .getPercentReturn ()) {
558
568
Location location = pr .getLocation ();
559
569
if (player != null ){
560
570
Inventory inv = player .getInventory ();
@@ -579,17 +589,17 @@ public static boolean reinforcementBroken(Player player, Reinforcement reinforce
579
589
dropItemAtLocation (location , new ItemStack (material .getMaterial ()
580
590
, material .getReturnValue ()));
581
591
}
582
- if (CitadelConfigManager . shouldLogBreaks () ) {
592
+ if (logIt ) {
583
593
slb .append (" - reinf mat refunded" );
584
594
Citadel .Log (slb .toString ());
585
595
}
586
- } else if (CitadelConfigManager . shouldLogBreaks ()) {
596
+ } else if (logIt ) {
587
597
slb .append (" - reinf mat lost" );
588
598
Citadel .Log (slb .toString ());
589
599
}
590
600
return (pr .isDoor () || pr .isContainer ());
591
601
}
592
- if (CitadelConfigManager . shouldLogBreaks () ) {
602
+ if (logIt ) {
593
603
Citadel .Log (slb .toString ());
594
604
}
595
605
return false ; // implicit isSecureable() == false
0 commit comments