.
This commit is contained in:
parent
1292a519f8
commit
a379a16369
2 changed files with 14 additions and 22 deletions
|
|
@ -13,17 +13,19 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class CoreImplPlugin extends JavaPlugin {
|
public class CoreImplPlugin extends JavaPlugin {
|
||||||
|
|
||||||
|
public static boolean ENABLE_DATABASE = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
ScrowAPISurface.initScrowAPI(this, true);
|
ScrowAPISurface.initScrowAPI(this, ENABLE_DATABASE);
|
||||||
|
|
||||||
assert ScrowAPI.getDatabase() != null;
|
|
||||||
var friendshipDAO = new MongoFriendshipDAO(ScrowAPI.getDatabase());
|
|
||||||
var friendRequestsDAO = new MongoFriendRequestDAO(ScrowAPI.getDatabase());
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
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());
|
ScrowAPI.getCommandManager().register(new CoinsCommand().getRootNode());
|
||||||
ScrowAPI.getCommandManager().register(new FriendCommand(friendshipDAO, friendRequestsDAO).getRootNode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -41,20 +43,6 @@ public class CoreImplPlugin extends JavaPlugin {
|
||||||
.doOnNext(a -> System.out.println("coins: " + a))
|
.doOnNext(a -> System.out.println("coins: " + a))
|
||||||
.block();
|
.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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,13 @@ public class FriendRemoveLiteral {
|
||||||
private void removeFriend(BukkitCommandContext ctx) {
|
private void removeFriend(BukkitCommandContext ctx) {
|
||||||
var friend = ctx.getArg(playerArg);
|
var friend = ctx.getArg(playerArg);
|
||||||
|
|
||||||
friendshipDAO.getFriendship(friend.getUniqueId(), ctx.getPlayerSender().getUniqueId())
|
friendshipDAO.deleteFriendship(friend.getUniqueId(), ctx.getPlayerSender().getUniqueId())
|
||||||
.map(wasDeleted -> {
|
.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();
|
return Mono.empty();
|
||||||
})
|
})
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue