@@ -120,10 +120,10 @@ index 0000000000000000000000000000000000000000..922ca5b27bc0dd443d635646f37f8795
120
120
+ }
121
121
diff --git a/src/main/java/org/leavesmc/leaves/entity/BotManager.java b/src/main/java/org/leavesmc/leaves/entity/BotManager.java
122
122
new file mode 100644
123
- index 0000000000000000000000000000000000000000..ee6848b8990c516aa5c5490546dd16ae5c909740
123
+ index 0000000000000000000000000000000000000000..457395381d1d78eb53f307d4465ea520c1aa57fd
124
124
--- /dev/null
125
125
+++ b/src/main/java/org/leavesmc/leaves/entity/BotManager.java
126
- @@ -0,0 +1,124 @@
126
+ @@ -0,0 +1,58 @@
127
127
+ package org.leavesmc.leaves.entity;
128
128
+
129
129
+ import org.bukkit.Location;
@@ -159,72 +159,6 @@ index 0000000000000000000000000000000000000000..ee6848b8990c516aa5c5490546dd16ae
159
159
+ public Bot getBot(@NotNull String name);
160
160
+
161
161
+ /**
162
- + * Creates a fakeplayer with given param.
163
- + * <p>
164
- + * prefix and suffix will not be added.
165
- + *
166
- + * @param name fakeplayer name
167
- + * @param realName fakeplayer real name
168
- + * @param skin fakeplayer skin arr
169
- + * @param skinName fakeplayer skin name
170
- + * @param location a location will create fakeplayer
171
- + * @return a fakeplayer if success, null otherwise
172
- + */
173
- + @Deprecated(since = "1.21")
174
- + @Nullable
175
- + public Bot createBot(@NotNull String name, @NotNull String realName, @Nullable String[] skin, @Nullable String skinName, @NotNull Location location);
176
- +
177
- + /**
178
- + * Creates a fakeplayer with given param.
179
- + * <p>
180
- + * prefix and suffix will not be added.
181
- + *
182
- + * @param name fakeplayer name
183
- + * @param realName fakeplayer real name
184
- + * @param skin fakeplayer skin arr
185
- + * @param skinName fakeplayer skin name
186
- + * @param location a location will create fakeplayer
187
- + * @param consumer a consumer after create fakeplayer success
188
- + * @return a fakeplayer if you support skin arr and the creation is success, null otherwise
189
- + */
190
- + @Nullable
191
- + public Bot createBot(@NotNull String name, @NotNull String realName, @NotNull String[] skin, @Nullable String skinName, @NotNull Location location, @Nullable Consumer<Bot> consumer);
192
- +
193
- + /**
194
- + * Creates a fakeplayer with given param.
195
- + *
196
- + * @param name fakeplayer name
197
- + * @param skinName fakeplayer skin name
198
- + * @param location a location will create fakeplayer
199
- + * @param consumer a consumer after create fakeplayer success
200
- + */
201
- + public void createBot(@NotNull String name, @Nullable String skinName, @NotNull Location location, @Nullable Consumer<Bot> consumer);
202
- +
203
- + /**
204
- + * Removes a fakeplayer object by the given name.
205
- + *
206
- + * @param name the name to look up
207
- + */
208
- + public void removeBot(@NotNull String name);
209
- +
210
- + /**
211
- + * Removes a fakeplayer object by the given uuid.
212
- + *
213
- + * @param uuid the uuid to look up
214
- + */
215
- + public void removeBot(@NotNull UUID uuid);
216
- +
217
- + /**
218
- + * Removes all fakeplayers.
219
- + */
220
- + public void removeAllBots();
221
- +
222
- + /**
223
- + * Save fakeplayers data if resident-fakeplayer is true, or remove all fakeplayer.
224
- + */
225
- + public void saveOrRemoveAllBots();
226
- +
227
- + /**
228
162
+ * Gets a view of all currently logged in fakeplayers. This view is a reused object, making some operations like Collection.size() zero-allocation.
229
163
+ *
230
164
+ * @return a view of fakeplayers.
@@ -405,7 +339,7 @@ index 0000000000000000000000000000000000000000..91ea5540387b7d7e1be5b6368a2f02b3
405
339
+ }
406
340
diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotConfigModifyEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotConfigModifyEvent.java
407
341
new file mode 100644
408
- index 0000000000000000000000000000000000000000..5e55759fd3d7891e8e1d5d6a306dc8144d366469
342
+ index 0000000000000000000000000000000000000000..1ebdd3657e615a825918d455691cc1d6df78cfba
409
343
--- /dev/null
410
344
+++ b/src/main/java/org/leavesmc/leaves/event/bot/BotConfigModifyEvent.java
411
345
@@ -0,0 +1,49 @@
@@ -420,10 +354,10 @@ index 0000000000000000000000000000000000000000..5e55759fd3d7891e8e1d5d6a306dc814
420
354
+ private static final HandlerList handlers = new HandlerList();
421
355
+
422
356
+ private final String configName;
423
- + private final String configValue;
357
+ + private final String[] configValue;
424
358
+ private boolean cancel;
425
359
+
426
- + public BotConfigModifyEvent(@NotNull Bot who, String configName, String configValue) {
360
+ + public BotConfigModifyEvent(@NotNull Bot who, String configName, String[] configValue) {
427
361
+ super(who);
428
362
+ this.configName = configName;
429
363
+ this.configValue = configValue;
@@ -435,7 +369,7 @@ index 0000000000000000000000000000000000000000..5e55759fd3d7891e8e1d5d6a306dc814
435
369
+ }
436
370
+
437
371
+ @NotNull
438
- + public String getConfigValue() {
372
+ + public String[] getConfigValue() {
439
373
+ return configValue;
440
374
+ }
441
375
+
@@ -460,10 +394,10 @@ index 0000000000000000000000000000000000000000..5e55759fd3d7891e8e1d5d6a306dc814
460
394
+ }
461
395
diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotCreateEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotCreateEvent.java
462
396
new file mode 100644
463
- index 0000000000000000000000000000000000000000..be510d565c5942efea3423190b06c01873a7abd2
397
+ index 0000000000000000000000000000000000000000..ec0ed853a6d6dec263784da284ee521c81aebbc8
464
398
--- /dev/null
465
399
+++ b/src/main/java/org/leavesmc/leaves/event/bot/BotCreateEvent.java
466
- @@ -0,0 +1,118 @@
400
+ @@ -0,0 +1,119 @@
467
401
+ package org.leavesmc.leaves.event.bot;
468
402
+
469
403
+ import org.bukkit.Location;
@@ -483,14 +417,15 @@ index 0000000000000000000000000000000000000000..be510d565c5942efea3423190b06c018
483
417
+ public enum CreateReason {
484
418
+ COMMAND,
485
419
+ PLUGIN,
486
- + INTERNAL
420
+ + INTERNAL,
421
+ + UNKNOWN,
487
422
+ }
488
423
+ private static final HandlerList handlers = new HandlerList();
489
424
+
490
425
+ private final String bot;
491
426
+ private final String skin;
492
427
+ private final CreateReason reason;
493
- + private final Optional< CommandSender> creator;
428
+ + private final CommandSender creator;
494
429
+ private Location createLocation;
495
430
+ private boolean cancel = false;
496
431
+
@@ -499,7 +434,7 @@ index 0000000000000000000000000000000000000000..be510d565c5942efea3423190b06c018
499
434
+ this.skin = skin;
500
435
+ this.createLocation = createLocation;
501
436
+ this.reason = reason;
502
- + this.creator = Optional.ofNullable( creator) ;
437
+ + this.creator = creator;
503
438
+ }
504
439
+
505
440
+ /**
@@ -552,12 +487,12 @@ index 0000000000000000000000000000000000000000..be510d565c5942efea3423190b06c018
552
487
+
553
488
+ /**
554
489
+ * Gets the creator of the bot
555
- + * if the create reason is not COMMAND, the creator might be Optional.empty()
490
+ + * if the create reason is not COMMAND, the creator might be null
556
491
+ *
557
492
+ * @return An optional of creator
558
493
+ */
559
- + @NotNull
560
- + public Optional< CommandSender> getCreator() {
494
+ + @Nullable
495
+ + public CommandSender getCreator() {
561
496
+ return creator;
562
497
+ }
563
498
+
@@ -582,6 +517,81 @@ index 0000000000000000000000000000000000000000..be510d565c5942efea3423190b06c018
582
517
+ return handlers;
583
518
+ }
584
519
+ }
520
+ diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotDeathEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotDeathEvent.java
521
+ new file mode 100644
522
+ index 0000000000000000000000000000000000000000..3366b50cf1835129a027b5342e4d8cf070cecf4a
523
+ --- /dev/null
524
+ +++ b/src/main/java/org/leavesmc/leaves/event/bot/BotDeathEvent.java
525
+ @@ -0,0 +1,69 @@
526
+ + package org.leavesmc.leaves.event.bot;
527
+ +
528
+ + import net.kyori.adventure.text.Component;
529
+ + import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
530
+ + import org.bukkit.event.Cancellable;
531
+ + import org.bukkit.event.HandlerList;
532
+ + import org.jetbrains.annotations.NotNull;
533
+ + import org.jetbrains.annotations.Nullable;
534
+ + import org.leavesmc.leaves.entity.Bot;
535
+ +
536
+ + public class BotDeathEvent extends BotEvent implements Cancellable {
537
+ +
538
+ + private static final HandlerList handlers = new HandlerList();
539
+ +
540
+ + private boolean cancel = false;
541
+ + private boolean sendDeathMessage;
542
+ + private Component deathMessage;
543
+ +
544
+ + public BotDeathEvent(@NotNull Bot who, @Nullable Component deathMessage, boolean sendDeathMessage) {
545
+ + super(who);
546
+ + this.deathMessage = deathMessage;
547
+ + this.sendDeathMessage = sendDeathMessage;
548
+ + }
549
+ +
550
+ + @Override
551
+ + public @NotNull HandlerList getHandlers() {
552
+ + return handlers;
553
+ + }
554
+ +
555
+ + @NotNull
556
+ + public static HandlerList getHandlerList() {
557
+ + return handlers;
558
+ + }
559
+ +
560
+ + public Component deathMessage() {
561
+ + return deathMessage;
562
+ + }
563
+ +
564
+ + public void deathMessage(Component deathMessage) {
565
+ + this.deathMessage = deathMessage;
566
+ + }
567
+ +
568
+ + @Nullable
569
+ + public String getDeathMessage() {
570
+ + return this.deathMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.deathMessage);
571
+ + }
572
+ +
573
+ + public void setDeathMessage(@Nullable String deathMessage) {
574
+ + this.deathMessage = deathMessage != null ? LegacyComponentSerializer.legacySection().deserialize(deathMessage) : null;
575
+ + }
576
+ +
577
+ + public boolean isSendDeathMessage() {
578
+ + return sendDeathMessage;
579
+ + }
580
+ +
581
+ + public void setSendDeathMessage(boolean sendDeathMessage) {
582
+ + this.sendDeathMessage = sendDeathMessage;
583
+ + }
584
+ +
585
+ + @Override
586
+ + public boolean isCancelled() {
587
+ + return cancel;
588
+ + }
589
+ +
590
+ + @Override
591
+ + public void setCancelled(boolean cancel) {
592
+ + this.cancel = cancel;
593
+ + }
594
+ + }
585
595
diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotEvent.java
586
596
new file mode 100644
587
597
index 0000000000000000000000000000000000000000..ad358081f1e1da4075243d7ca0a01c1f7b00631b
@@ -745,10 +755,10 @@ index 0000000000000000000000000000000000000000..07f6d81c4cd897230bbd6712dac09b89
745
755
+ }
746
756
diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotRemoveEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotRemoveEvent.java
747
757
new file mode 100644
748
- index 0000000000000000000000000000000000000000..7af990a5ee020dfdbec2efc6aecf6393a4223730
758
+ index 0000000000000000000000000000000000000000..e950643e4b4da99b067d7392034a651361094853
749
759
--- /dev/null
750
760
+++ b/src/main/java/org/leavesmc/leaves/event/bot/BotRemoveEvent.java
751
- @@ -0,0 +1,105 @@
761
+ @@ -0,0 +1,107 @@
752
762
+ package org.leavesmc.leaves.event.bot;
753
763
+
754
764
+ import net.kyori.adventure.text.Component;
@@ -776,23 +786,17 @@ index 0000000000000000000000000000000000000000..7af990a5ee020dfdbec2efc6aecf6393
776
786
+ private static final HandlerList handlers = new HandlerList();
777
787
+
778
788
+ private final RemoveReason reason;
779
- + private final Optional< CommandSender> remover;
789
+ + private final CommandSender remover;
780
790
+ private Component removeMessage;
791
+ + private boolean saved;
781
792
+ private boolean cancel = false;
782
793
+
783
- + public BotRemoveEvent(@NotNull final Bot who, @NotNull RemoveReason reason) {
784
- + this(who, reason, null);
785
- + }
786
- +
787
- + public BotRemoveEvent(@NotNull final Bot who, @NotNull RemoveReason reason, @Nullable CommandSender remover) {
788
- + this(who, reason, remover, null);
789
- + }
790
- +
791
- + public BotRemoveEvent(@NotNull final Bot who, @NotNull RemoveReason reason, @Nullable CommandSender remover, @Nullable Component removeMessage) {
794
+ + public BotRemoveEvent(@NotNull final Bot who, @NotNull RemoveReason reason, @Nullable CommandSender remover, @Nullable Component removeMessage, boolean saved) {
792
795
+ super(who);
793
796
+ this.reason = reason;
794
- + this.remover = Optional.ofNullable( remover) ;
797
+ + this.remover = remover;
795
798
+ this.removeMessage = removeMessage;
799
+ + this.saved = saved;
796
800
+ }
797
801
+
798
802
+ /**
@@ -807,12 +811,12 @@ index 0000000000000000000000000000000000000000..7af990a5ee020dfdbec2efc6aecf6393
807
811
+
808
812
+ /**
809
813
+ * Gets the remover of the bot
810
- + * if the remove reason is not COMMAND, the creator might be Optional.empty()
814
+ + * if the remove reason is not COMMAND, the creator might be null
811
815
+ *
812
816
+ * @return An optional of remover
813
817
+ */
814
- + @NotNull
815
- + public Optional< CommandSender> getRemover() {
818
+ + @Nullable
819
+ + public CommandSender getRemover() {
816
820
+ return remover;
817
821
+ }
818
822
+
@@ -843,6 +847,14 @@ index 0000000000000000000000000000000000000000..7af990a5ee020dfdbec2efc6aecf6393
843
847
+ this.cancel = cancel;
844
848
+ }
845
849
+
850
+ + public boolean isSaved() {
851
+ + return saved;
852
+ + }
853
+ +
854
+ + public void setSaved(boolean saved) {
855
+ + this.saved = saved;
856
+ + }
857
+ +
846
858
+ @Override
847
859
+ @NotNull
848
860
+ public HandlerList getHandlers() {
0 commit comments