Skip to content

Commit c16c876

Browse files
committed
deprecate a bunch of duplicates
1 parent 1bce064 commit c16c876

File tree

2 files changed

+49
-62
lines changed

2 files changed

+49
-62
lines changed

paper-api/src/main/java/org/bukkit/entity/LivingEntity.java

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.bukkit.scoreboard.Team;
2323
import org.bukkit.util.RayTraceResult;
2424
import org.bukkit.util.Vector;
25+
import org.checkerframework.checker.index.qual.NonNegative;
2526
import org.jetbrains.annotations.ApiStatus;
2627
import org.jetbrains.annotations.NotNull;
2728
import org.jetbrains.annotations.Nullable;
@@ -402,106 +403,120 @@ default RayTraceResult rayTraceBlocks(double maxDistance) {
402403
*
403404
* @return ticks until arrow leaves
404405
*/
405-
public int getArrowCooldown();
406+
public @NonNegative int getArrowCooldown();
406407

407408
/**
408409
* Sets the time in ticks until the next arrow leaves the entity's body.
410+
* <p>
411+
* A value of 0 will cause the server to re-calculate the time on the next tick.
409412
*
410413
* @param ticks time until arrow leaves
411414
*/
412-
public void setArrowCooldown(int ticks);
415+
public void setArrowCooldown(@NonNegative int ticks);
413416

414417
/**
415418
* Gets the amount of arrows in an entity's body.
416419
*
417420
* @return amount of arrows in body
418421
*/
419-
public int getArrowsInBody();
422+
public @NonNegative int getArrowsInBody();
420423

421-
// Paper start
422424
/**
423425
* Set the amount of arrows in the entity's body.
424426
* <p>
425427
* Does not fire the {@link org.bukkit.event.entity.ArrowBodyCountChangeEvent}.
426428
*
427429
* @param count amount of arrows in entity's body
428430
*/
429-
default void setArrowsInBody(final int count) {
431+
default void setArrowsInBody(final @NonNegative int count) {
430432
this.setArrowsInBody(count, false);
431433
}
432-
// Paper end
433434

434435
/**
435436
* Set the amount of arrows in the entity's body.
436437
*
437438
* @param count amount of arrows in entity's body
438439
* @param fireEvent whether to fire the {@link org.bukkit.event.entity.ArrowBodyCountChangeEvent} event
439440
*/
440-
void setArrowsInBody(int count, boolean fireEvent); // Paper
441+
void setArrowsInBody(@NonNegative int count, boolean fireEvent); // Paper
441442

442-
// Paper start - Add methods for working with arrows stuck in living entities
443443
/**
444444
* Sets the amount of ticks before the next arrow gets removed from the entities body.
445445
* <p>
446446
* A value of 0 will cause the server to re-calculate the amount of ticks on the next tick.
447447
*
448448
* @param ticks Amount of ticks
449+
* @deprecated use {@link #setArrowCooldown(int)}
449450
*/
450-
void setNextArrowRemoval(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int ticks);
451+
@Deprecated(since = "1.21.10")
452+
default void setNextArrowRemoval(@NonNegative int ticks) {
453+
this.setArrowCooldown(ticks);
454+
}
451455

452456
/**
453457
* Gets the amount of ticks before the next arrow gets removed from the entities body.
454458
*
455459
* @return ticks Amount of ticks
460+
* @deprecated use {@link #getArrowCooldown()}
456461
*/
457-
int getNextArrowRemoval();
458-
// Paper end - Add methods for working with arrows stuck in living entities
462+
@Deprecated(since = "1.21.10")
463+
default @NonNegative int getNextArrowRemoval() {
464+
return this.getArrowCooldown();
465+
}
459466

460-
// Paper start - Bee Stinger API
461467
/**
462468
* Gets the time in ticks until the next bee stinger leaves the entity's body.
463469
*
464470
* @return ticks until bee stinger leaves
465471
*/
466-
public int getBeeStingerCooldown();
472+
public @NonNegative int getBeeStingerCooldown();
467473

468474
/**
469475
* Sets the time in ticks until the next stinger leaves the entity's body.
476+
* <p>
477+
* A value of 0 will cause the server to re-calculate the time on the next tick.
470478
*
471479
* @param ticks time until bee stinger leaves
472480
*/
473-
public void setBeeStingerCooldown(int ticks);
481+
public void setBeeStingerCooldown(@NonNegative int ticks);
474482

475483
/**
476484
* Gets the amount of bee stingers in an entity's body.
477485
*
478486
* @return amount of bee stingers in body
479487
*/
480-
public int getBeeStingersInBody();
488+
public @NonNegative int getBeeStingersInBody();
481489

482490
/**
483491
* Set the amount of bee stingers in the entity's body.
484492
*
485493
* @param count amount of bee stingers in entity's body
486494
*/
487-
public void setBeeStingersInBody(int count);
495+
public void setBeeStingersInBody(@NonNegative int count);
488496

489497
/**
490498
* Sets the amount of ticks before the next bee stinger gets removed from the entities body.
491499
* <p>
492500
* A value of 0 will cause the server to re-calculate the amount of ticks on the next tick.
493501
*
494502
* @param ticks Amount of ticks
503+
* @deprecated use {@link #setBeeStingerCooldown(int)}
495504
*/
496-
void setNextBeeStingerRemoval(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int ticks);
505+
@Deprecated(since = "1.21.10")
506+
default void setNextBeeStingerRemoval(@NonNegative int ticks) {
507+
this.setBeeStingerCooldown(ticks);
508+
}
497509

498510
/**
499511
* Gets the amount of ticks before the next bee stinger gets removed from the entities body.
500512
*
501513
* @return ticks Amount of ticks
514+
* @deprecated use {@link #getBeeStingerCooldown()}
502515
*/
503-
int getNextBeeStingerRemoval();
504-
// Paper end - Stinger API
516+
@Deprecated(since = "1.21.10")
517+
default @NonNegative int getNextBeeStingerRemoval() {
518+
return this.getBeeStingerCooldown();
519+
}
505520

506521
/**
507522
* Returns the living entity's current maximum no damage ticks.
@@ -1065,11 +1080,14 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) {
10651080

10661081
/**
10671082
* Get the number of arrows stuck in this entity
1083+
*
10681084
* @return Number of arrows stuck
10691085
* @deprecated use {@link #getArrowsInBody()}
10701086
*/
10711087
@Deprecated
1072-
int getArrowsStuck();
1088+
default @NonNegative int getArrowsStuck() {
1089+
return this.getArrowsInBody();
1090+
}
10731091

10741092
/**
10751093
* Set the number of arrows stuck in this entity
@@ -1079,7 +1097,9 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) {
10791097
* you want to retain exact functionality, pass {@code true} for {@code fireEvent}.</b>
10801098
*/
10811099
@Deprecated
1082-
void setArrowsStuck(int arrows);
1100+
default void setArrowsStuck(@NonNegative int arrows) {
1101+
this.setArrowsInBody(arrows, true);
1102+
}
10831103

10841104
/**
10851105
* Get the delay (in ticks) before blocking is effective for this entity

paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ public int getArrowCooldown() {
347347

348348
@Override
349349
public void setArrowCooldown(int ticks) {
350+
Preconditions.checkArgument(ticks >= 0, "Amount of ticks before next arrow removal must be non-negative");
350351
this.getHandle().removeArrowTime = ticks;
351352
}
352353

@@ -357,65 +358,41 @@ public int getArrowsInBody() {
357358

358359
@Override
359360
public void setArrowsInBody(final int count, final boolean fireEvent) { // Paper
360-
Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0");
361+
Preconditions.checkArgument(count >= 0, "New arrow amount must be non-negative");
361362
if (!fireEvent) {
362363
this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count);
363364
} else {
364365
this.getHandle().setArrowCount(count);
365366
}
366367
}
367368

368-
// Paper start - Add methods for working with arrows stuck in living entities
369-
@Override
370-
public void setNextArrowRemoval(final int ticks) {
371-
Preconditions.checkArgument(ticks >= 0, "New amount of ticks before next arrow removal must be >= 0");
372-
this.getHandle().removeArrowTime = ticks;
373-
}
374-
375-
@Override
376-
public int getNextArrowRemoval() {
377-
return this.getHandle().removeArrowTime;
378-
}
379-
// Paper end - Add methods for working with arrows stuck in living entities
380-
381369
@Override
382370
public boolean isInvulnerable() {
383371
return this.getHandle().isInvulnerableTo((ServerLevel) this.getHandle().level(), this.getHandle().damageSources().generic());
384372
}
385-
// Paper start - Bee Stinger API
373+
386374
@Override
387375
public int getBeeStingerCooldown() {
388-
return getHandle().removeStingerTime;
376+
return this.getHandle().removeStingerTime;
389377
}
390378

391379
@Override
392380
public void setBeeStingerCooldown(int ticks) {
393-
getHandle().removeStingerTime = ticks;
381+
Preconditions.checkArgument(ticks >= 0, "New amount of ticks before next bee stinger removal must be non-negative");
382+
this.getHandle().removeStingerTime = ticks;
394383
}
395384

396385
@Override
397386
public int getBeeStingersInBody() {
398-
return getHandle().getStingerCount();
387+
return this.getHandle().getStingerCount();
399388
}
400389

401390
@Override
402391
public void setBeeStingersInBody(int count) {
403392
Preconditions.checkArgument(count >= 0, "New bee stinger amount must be >= 0");
404-
getHandle().setStingerCount(count);
405-
}
406-
407-
@Override
408-
public void setNextBeeStingerRemoval(final int ticks) {
409-
Preconditions.checkArgument(ticks >= 0, "New amount of ticks before next bee stinger removal must be >= 0");
410-
this.getHandle().removeStingerTime = ticks;
393+
this.getHandle().setStingerCount(count);
411394
}
412395

413-
@Override
414-
public int getNextBeeStingerRemoval() {
415-
return this.getHandle().removeStingerTime;
416-
}
417-
// Paper end - Bee Stinger API
418-
419396
@Override
420397
public void damage(double amount) {
421398
this.damage(amount, this.getHandle().damageSources().generic());
@@ -966,16 +943,6 @@ public float getUpwardsMovement() {
966943
return this.getHandle().yya;
967944
}
968945

969-
@Override
970-
public int getArrowsStuck() {
971-
return this.getHandle().getArrowCount();
972-
}
973-
974-
@Override
975-
public void setArrowsStuck(final int arrows) {
976-
this.getHandle().setArrowCount(arrows);
977-
}
978-
979946
@Override
980947
public void startUsingItem(org.bukkit.inventory.EquipmentSlot hand) {
981948
Preconditions.checkArgument(hand != null, "hand must not be null");

0 commit comments

Comments
 (0)