.
This commit is contained in:
parent
1292a519f8
commit
a379a16369
2 changed files with 14 additions and 22 deletions
|
|
@ -13,18 +13,20 @@ import java.util.UUID;
|
|||
|
||||
public class CoreImplPlugin extends JavaPlugin {
|
||||
|
||||
public static boolean ENABLE_DATABASE = true;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
ScrowAPISurface.initScrowAPI(this, true);
|
||||
|
||||
assert ScrowAPI.getDatabase() != null;
|
||||
var friendshipDAO = new MongoFriendshipDAO(ScrowAPI.getDatabase());
|
||||
var friendRequestsDAO = new MongoFriendRequestDAO(ScrowAPI.getDatabase());
|
||||
ScrowAPISurface.initScrowAPI(this, ENABLE_DATABASE);
|
||||
|
||||
{
|
||||
ScrowAPI.getCommandManager().register(new CoinsCommand().getRootNode());
|
||||
if (ENABLE_DATABASE) {
|
||||
var friendshipDAO = new MongoFriendshipDAO(ScrowAPI.getDatabase());
|
||||
var friendRequestsDAO = new MongoFriendRequestDAO(ScrowAPI.getDatabase());
|
||||
ScrowAPI.getCommandManager().register(new FriendCommand(friendshipDAO, friendRequestsDAO).getRootNode());
|
||||
}
|
||||
ScrowAPI.getCommandManager().register(new CoinsCommand().getRootNode());
|
||||
}
|
||||
|
||||
{
|
||||
var playerId = UUID.randomUUID();
|
||||
|
|
@ -41,20 +43,6 @@ public class CoreImplPlugin extends JavaPlugin {
|
|||
.doOnNext(a -> System.out.println("coins: " + a))
|
||||
.block();
|
||||
}
|
||||
|
||||
{
|
||||
friendRequestsDAO.saveFriendRequest(new FriendRequestImpl(
|
||||
UUID.fromString("7fca8ec5-c855-4547-aed9-21a20b31617c") /* logan */,
|
||||
UUID.fromString("3218c49a-b80d-49ae-a42e-4496141eb2b1") /* kento2 */,
|
||||
Instant.now()
|
||||
)).block();
|
||||
|
||||
friendRequestsDAO.saveFriendRequest(new FriendRequestImpl(
|
||||
UUID.fromString("3218c49a-b80d-49ae-a42e-4496141eb2b1") /* kento2 */,
|
||||
UUID.fromString("3218c49a-b80d-49ae-a42e-4496141eb2b1") /* kento2 */,
|
||||
Instant.now()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,9 +28,13 @@ public class FriendRemoveLiteral {
|
|||
private void removeFriend(BukkitCommandContext ctx) {
|
||||
var friend = ctx.getArg(playerArg);
|
||||
|
||||
friendshipDAO.getFriendship(friend.getUniqueId(), ctx.getPlayerSender().getUniqueId())
|
||||
friendshipDAO.deleteFriendship(friend.getUniqueId(), ctx.getPlayerSender().getUniqueId())
|
||||
.map(wasDeleted -> {
|
||||
ctx.getSender().sendMessage("[friend] You are no longer friends with " + friend.getName());
|
||||
ctx.getSender().sendMessage(
|
||||
wasDeleted
|
||||
? "[friend] You are no longer friends with " + friend.getName()
|
||||
: "[friend] Failed. You are not friends with " + friend.getName()
|
||||
);
|
||||
return Mono.empty();
|
||||
})
|
||||
.subscribe();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue