Skip to content

Commit 37000c0

Browse files
[#] Improved README.md
[+] Removed redundant code in human verification module.
1 parent 4d03bca commit 37000c0

8 files changed

Lines changed: 59 additions & 21 deletions

File tree

PluginDocs.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,14 @@ Message APIs are aimed to help you to connect one or more bot between bots, that
436436
**Step 1:**
437437
Defining a message listener on a receiver bot:
438438
ExampleMessageListener.java
439+
439440
```java
440441
import org.angellock.impl.events.IListener;
441-
import org.angellock.impl.events.dolphin.MessageBroadcastEvent;
442+
import org.angellock.impl.api.events.MessageBroadcastEvent;
442443

443444
public class ExampleMessageListener implements IListener {
444445
@EventHandler
445-
public void onMessage(MessageBroadcastEvent event){
446+
public void onMessage(MessageBroadcastEvent event) {
446447
log.info("message payload: {}", event.getMessage());
447448
// Do something...
448449
}

src/main/java/org/angellock/impl/events/dolphin/CommandNotFoundEvent.java renamed to src/main/java/org/angellock/impl/api/events/CommandNotFoundEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
1010
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1111
* License for more details. You should have received a copy of the GNU General Public License along with this
12-
* program. If not, see <https://www.gnu.org/licenses/>.
12+
* program. If not, see <https://www.gnu.org/licenses/>.
1313
*
1414
* https://space.bilibili.com/386644641
1515
*/
1616

17-
package org.angellock.impl.events.dolphin;
17+
package org.angellock.impl.api.events;
1818

1919
import lombok.Getter;
2020
import org.angellock.impl.events.HandlerMapper;

src/main/java/org/angellock/impl/events/dolphin/MessageBroadcastEvent.java renamed to src/main/java/org/angellock/impl/api/events/MessageBroadcastEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* https://space.bilibili.com/386644641
1515
*/
1616

17-
package org.angellock.impl.events.dolphin;
17+
package org.angellock.impl.api.events;
1818

1919
import lombok.Getter;
20+
import org.angellock.impl.api.message.BotMessage;
2021
import org.angellock.impl.events.HandlerMapper;
2122
import org.angellock.impl.events.bukkit.AbstractEvent;
2223
@Getter
@@ -26,8 +27,8 @@ public class MessageBroadcastEvent extends AbstractEvent {
2627
public HandlerMapper getMapper() {
2728
return null;
2829
}
29-
private final String message;
30-
public MessageBroadcastEvent(String message){
30+
private final BotMessage message;
31+
public MessageBroadcastEvent(BotMessage message){
3132
this.message = message;
3233
}
3334

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* DolphinBot - https://github.com/NeonAngelThreads/DolphinBot
3+
* Copyright (C) 2025 NeonAngelThreads (https://github.com/NeonAngelThreads)
4+
*
5+
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6+
* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any
7+
* later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10+
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11+
* License for more details. You should have received a copy of the GNU General Public License along with this
12+
* program. If not, see <https://www.gnu.org/licenses/>.
13+
*
14+
* https://space.bilibili.com/386644641
15+
*/
16+
17+
package org.angellock.impl.api.events;
18+
19+
import lombok.Getter;
20+
import org.angellock.impl.api.message.BotMessage;
21+
import org.angellock.impl.api.message.Notification;
22+
import org.angellock.impl.events.HandlerMapper;
23+
import org.angellock.impl.events.bukkit.AbstractEvent;
24+
25+
@Getter
26+
public class NotificationBroadcastEvent extends AbstractEvent {
27+
private static final HandlerMapper HANDLERS = new HandlerMapper();
28+
@Override
29+
public HandlerMapper getMapper() {
30+
return null;
31+
}
32+
private final String message;
33+
public NotificationBroadcastEvent(Notification message){
34+
this.message = message.notification();
35+
}
36+
public NotificationBroadcastEvent(String message){
37+
this.message = message;
38+
}
39+
40+
public static HandlerMapper getHandlers() {
41+
return HANDLERS;
42+
}
43+
}

src/main/java/org/angellock/impl/events/dolphin/ReconnectEvent.java renamed to src/main/java/org/angellock/impl/api/events/ReconnectEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
1010
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1111
* License for more details. You should have received a copy of the GNU General Public License along with this
12-
* program. If not, see <https://www.gnu.org/licenses/>.
12+
* program. If not, see <https://www.gnu.org/licenses/>.
1313
*
1414
* https://space.bilibili.com/386644641
1515
*/
1616

17-
package org.angellock.impl.events.dolphin;
17+
package org.angellock.impl.api.events;
1818

1919
import org.angellock.impl.events.HandlerMapper;
2020
import org.angellock.impl.events.bukkit.AbstractEvent;

src/main/java/org/angellock/impl/api/message/Notification.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.angellock.impl.api.message;
1818

1919
public abstract class Notification implements INotify{
20-
public String message;
20+
private String message;
2121
public Notification(String message) {
2222
this.message = message;
2323
}

src/main/java/org/angellock/impl/extensions/PlayerVerificationPlugin.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.angellock.impl.AbstractRobot;
2121
import org.angellock.impl.EnumSystemEvents;
2222
import org.angellock.impl.events.IDisconnectListener;
23-
import org.angellock.impl.events.dolphin.MessageBroadcastEvent;
2423
import org.angellock.impl.events.handlers.ContainerPacketHandler;
2524
import org.angellock.impl.events.handlers.LoginHandler;
2625
import org.angellock.impl.events.handlers.SystemChatHandler;
@@ -29,7 +28,6 @@
2928
import org.angellock.impl.extensions.actions.LoginAction;
3029
import org.angellock.impl.extensions.actions.RegisterAction;
3130
import org.angellock.impl.extensions.actions.VerifyAction;
32-
import org.angellock.impl.managers.BotManager;
3331
import org.angellock.impl.plugin.AbstractPlugin;
3432
import org.angellock.impl.api.state.StateAction;
3533
import org.angellock.impl.api.state.LoginState;
@@ -39,20 +37,14 @@
3937
import org.angellock.impl.util.TranslatableUtil;
4038
import org.angellock.impl.util.reason.KickReason;
4139
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
42-
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
43-
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
4440
import org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerAction;
4541
import org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerActionType;
4642
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
47-
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
4843
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerButtonClickPacket;
4944
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClickPacket;
50-
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
51-
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundUseItemPacket;
5245
import org.slf4j.Logger;
5346
import org.slf4j.LoggerFactory;
5447

55-
import java.time.Instant;
5648
import java.util.HashMap;
5749

5850
public class PlayerVerificationPlugin extends AbstractPlugin {

src/main/java/org/angellock/impl/managers/BotManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import org.angellock.impl.AbstractRobot;
2424
import org.angellock.impl.EnumSystemEvents;
2525
import org.angellock.impl.RobotPlayer;
26-
import org.angellock.impl.events.dolphin.MessageBroadcastEvent;
26+
import org.angellock.impl.api.events.MessageBroadcastEvent;
27+
import org.angellock.impl.api.events.NotificationBroadcastEvent;
2728
import org.angellock.impl.extensions.Plugins;
2829
import org.angellock.impl.plugin.AbstractPlugin;
2930
import org.angellock.impl.plugin.PluginManager;
@@ -194,9 +195,9 @@ public static void dispatchMessages(List<String> msgQueue){
194195
}
195196

196197
@SuppressWarnings("unused")
197-
public void distributeMessage(String handleableMessage){
198+
public void distributeNotification(String handleableMessage){
198199
for (RobotPlayer bot : bots.values()) {
199-
bot.callHandleableEvent(new MessageBroadcastEvent(handleableMessage));
200+
bot.callHandleableEvent(new NotificationBroadcastEvent(handleableMessage));
200201
}
201202
}
202203

0 commit comments

Comments
 (0)