gradle time
This commit is contained in:
parent
7040a6ce1e
commit
9421ef511e
47 changed files with 482 additions and 226 deletions
|
|
@ -1,22 +1,25 @@
|
|||
package de.kentoj.scrow.bukkit;
|
||||
|
||||
import de.kentoj.kencommandapi.CommandAPI;
|
||||
import de.kentoj.scrow.bukkit.friends.FriendRequestService;
|
||||
import de.kentoj.scrow.bukkit.friends.FriendshipService;
|
||||
import de.kentoj.scrow.bukkit.misc.EconomyService;
|
||||
import de.kentoj.scrow.bukkit.misc.PlayerManager;
|
||||
import de.kentoj.scrowlib.friends.FriendRequestService;
|
||||
import de.kentoj.scrowlib.friends.FriendshipService;
|
||||
import de.kentoj.scrowlib.economy.EconomyService;
|
||||
import de.kentoj.scrowlib.player.NetworkPlayer;
|
||||
import de.kentoj.scrowlib.player.NetworkPlayerFactory;
|
||||
import de.kentoj.scrow.bukkit.region.RegionManager;
|
||||
import de.kentoj.scrowlib.instancemanager.InstanceManager;
|
||||
import de.kentoj.scrowlib.messaging.MessageBroker;
|
||||
import io.nats.client.Connection;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jdbi.v3.core.Jdbi;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ScrowAPI {
|
||||
|
||||
|
|
@ -41,8 +44,15 @@ public class ScrowAPI {
|
|||
private static RegionManager regionManager;
|
||||
@Getter
|
||||
private static CommandAPI commandApi;
|
||||
@Getter
|
||||
private static PlayerManager playerManager;
|
||||
private static NetworkPlayerFactory playerFactory;
|
||||
|
||||
public static NetworkPlayer getPlayer(OfflinePlayer player) {
|
||||
return getPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static NetworkPlayer getPlayer(UUID uuid) {
|
||||
return playerFactory.create(uuid);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void setEconomyService(EconomyService economyService) {
|
||||
|
|
@ -90,8 +100,8 @@ public class ScrowAPI {
|
|||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void setPlayerManager(PlayerManager playerManager) {
|
||||
ScrowAPI.playerManager = playerManager;
|
||||
public static void setPlayerFactory(NetworkPlayerFactory playerFactory) {
|
||||
ScrowAPI.playerFactory = playerFactory;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.friends;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FriendRequest {
|
||||
UUID getFrom();
|
||||
UUID getTo();
|
||||
Instant getCreatedAt();
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.friends;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FriendRequestService {
|
||||
|
||||
List<FriendRequest> getFriendRequestsTo(UUID playerId);
|
||||
|
||||
List<FriendRequest> getFriendRequestsFrom(UUID playerId);
|
||||
|
||||
FriendRequest getFriendRequest(UUID from, UUID to);
|
||||
|
||||
/**
|
||||
* @return True if request saved, false if already existing request found.
|
||||
*/
|
||||
boolean saveFriendRequest(FriendRequest friendRequest);
|
||||
|
||||
/**
|
||||
* @return True if request deleted, false if none found.
|
||||
*/
|
||||
boolean deleteFriendRequest(UUID from, UUID to);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.friends;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Friendship {
|
||||
|
||||
OrderedUUIDPair getUuids();
|
||||
|
||||
Instant getCreatedAt();
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.friends;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FriendshipService {
|
||||
|
||||
Friendship getFriendship(UUID uuid1, UUID uuid2);
|
||||
|
||||
List<Friendship> getFriendships(UUID playerId);
|
||||
|
||||
/*
|
||||
* @return True if friendship saved, false if friendship already exists
|
||||
*/
|
||||
boolean saveFriendship(Friendship playerIds);
|
||||
|
||||
/**
|
||||
* @return True if friendship deleted, false if none found
|
||||
*/
|
||||
boolean deleteFriendship(UUID uuid1, UUID uuid2);
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.friends;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class OrderedUUIDPair {
|
||||
private final UUID first;
|
||||
private final UUID second;
|
||||
|
||||
public OrderedUUIDPair(UUID uuid1, UUID uuid2) {
|
||||
if (uuid1.compareTo(uuid2) < 0) {
|
||||
this.first = uuid1;
|
||||
this.second = uuid2;
|
||||
} else {
|
||||
this.first = uuid2;
|
||||
this.second = uuid1;
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getOther(UUID self) {
|
||||
return getFirst().equals(self) ? getSecond() : getFirst();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.minigame;
|
||||
|
||||
import de.kentoj.scrowlib.instancemanager.ServerInstance;
|
||||
|
||||
public interface MinigameInfo {
|
||||
|
||||
String getName();
|
||||
|
||||
int getPlayerCount();
|
||||
|
||||
ServerInstance getServerInstance();
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.misc;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EconomyService {
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if amount is less than 0
|
||||
*/
|
||||
int getCoins(UUID playerId);
|
||||
|
||||
/**
|
||||
* @param playerId uuid of player
|
||||
* @throws IllegalArgumentException if amount is less than 0
|
||||
*/
|
||||
void depositCoins(UUID playerId, int amount);
|
||||
|
||||
/**
|
||||
* @param playerId uuid of player
|
||||
* @return true on success, false on insufficient funds
|
||||
* @throws IllegalArgumentException if amount is less than 0
|
||||
*/
|
||||
boolean tryWithdrawCoins(UUID playerId, int amount);
|
||||
|
||||
/**
|
||||
* @param playerId uuid of player
|
||||
* @throws IllegalArgumentException if amount is less than 0
|
||||
*/
|
||||
void setCoins(UUID playerId, int amount);
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.misc;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface PlayerManager {
|
||||
|
||||
void sendPlayer(UUID uuid, String instanceHandle);
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ public class TaskImpl<T> implements Task<T> {
|
|||
private static final ExecutorService EXECUTOR = Executors.newVirtualThreadPerTaskExecutor();
|
||||
|
||||
private final Supplier<TaskState<T>> compute;
|
||||
private TaskState<T> cachedResult = null;
|
||||
private volatile TaskState<T> cachedResult = null;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<T> toFuture() {
|
||||
|
|
@ -90,8 +90,10 @@ public class TaskImpl<T> implements Task<T> {
|
|||
}
|
||||
|
||||
private TaskState<T> state() {
|
||||
if (cachedResult == null)
|
||||
cachedResult = compute.get();
|
||||
return cachedResult;
|
||||
synchronized (this) {
|
||||
if (cachedResult == null)
|
||||
cachedResult = compute.get();
|
||||
return cachedResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue