lowk did smth
This commit is contained in:
parent
702fa6deeb
commit
4879257f47
54 changed files with 486 additions and 243 deletions
60
core-bukkit-api/build.gradle.kts
Normal file
60
core-bukkit-api/build.gradle.kts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import org.gradle.internal.declarativedsl.dom.mutation.valueFromString
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("java-library")
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
group = "de.kentoj.scrow"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(platform("org.junit:junit-bom:5.10.0"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
|
||||
api("me.lucko:commodore:2.2")
|
||||
api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks.findByName("shadowJar")?.let {
|
||||
dependencies {
|
||||
"exclude"("dependency"("com.mojang.brigadier")!!)
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("CoreBukkitApi") {
|
||||
groupId = project.group.toString()
|
||||
artifactId = project.name
|
||||
version = project.version.toString()
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "scrow"
|
||||
url = uri("http://forge.kentoj.de/api/packages/scrow/maven")
|
||||
isAllowInsecureProtocol = true
|
||||
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Authorization"
|
||||
value = "token a967694822eed6e97b1b20e8737733ef1400fa1f"
|
||||
}
|
||||
|
||||
authentication {
|
||||
create<HttpHeaderAuthentication>("header")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package de.kentoj.scrow.bukkit;
|
||||
|
||||
import com.mongodb.reactivestreams.client.MongoDatabase;
|
||||
import de.kentoj.scrow.bukkit.services.EconomyService;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ScrowAPI {
|
||||
|
||||
@Getter
|
||||
private static @Nullable MongoDatabase database;
|
||||
@Getter
|
||||
private static EconomyService economyService;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void setDatabase(@Nullable MongoDatabase database) {
|
||||
ScrowAPI.database = database;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void setEconomyService(EconomyService economyService) {
|
||||
ScrowAPI.economyService = economyService;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package de.kentoj.scrow.bukkit.services;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EconomyService {
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if amount < 0
|
||||
*/
|
||||
Mono<@NotNull Integer> getCoins(UUID playerId);
|
||||
|
||||
/**
|
||||
* @param playerId uuid of player
|
||||
* @throws IllegalArgumentException if amount < 0
|
||||
*/
|
||||
Mono<@NotNull Void> depositCoins(UUID playerId, int amount);
|
||||
|
||||
/**
|
||||
* @param playerId uuid of player
|
||||
* @return true on success, false on insufficient funds
|
||||
* @throws IllegalArgumentException if amount < 0
|
||||
*/
|
||||
Mono<@NotNull Boolean> tryWithdrawCoins(UUID playerId, int amount);
|
||||
|
||||
/**
|
||||
* @param playerId uuid of player
|
||||
* @throws IllegalArgumentException if amount < 0
|
||||
*/
|
||||
Mono<@NotNull Void> setCoins(UUID playerId, int amount);
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package de.kentoj.scrow.bukkit.services.email;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Email extends EmailDraft {
|
||||
|
||||
Long getId();
|
||||
|
||||
/**
|
||||
* @return UUID of player the mail is sent to or null if console
|
||||
*/
|
||||
@Nullable UUID getFrom();
|
||||
|
||||
@Nullable Instant getSentAt();
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package de.kentoj.scrow.bukkit.services.email;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EmailDraft {
|
||||
|
||||
/**
|
||||
* @return UUID of player sending the mail or null if console
|
||||
*/
|
||||
@Nullable UUID getFrom();
|
||||
|
||||
/**
|
||||
* @return non-empty string specifying the subject
|
||||
*/
|
||||
String getSubject();
|
||||
|
||||
/**
|
||||
* @return body of the message
|
||||
*/
|
||||
String getBody();
|
||||
|
||||
/**
|
||||
* @return id of the mail this mail is replying to or null if not replying to any email
|
||||
*/
|
||||
@Nullable Long getReplyTo();
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package de.kentoj.scrow.bukkit.services.email;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* like email but for minecraft
|
||||
*/
|
||||
public interface EmailService {
|
||||
|
||||
Mono<@NotNull Email> sendMail(UUID to, EmailDraft emailDraft);
|
||||
Flux<@NotNull Email> sendMailToMany(Set<UUID> to, EmailDraft emailDraft);
|
||||
|
||||
Flux<@NotNull Email> fetchMails(UUID to);
|
||||
|
||||
/**
|
||||
* @param to uuid of player whose inbox to operate on
|
||||
* @param id id of the email
|
||||
*/
|
||||
Mono<@NotNull Void> deleteMail(UUID to, long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package de.kentoj.scrow.bukkit.services.friends;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FriendRequest {
|
||||
UUID getFrom();
|
||||
UUID getTo();
|
||||
Instant getCreatedAt();
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package de.kentoj.scrow.bukkit.services.friends;
|
||||
|
||||
import de.kentoj.scrow.bukkit.util.pair.Tuple2;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Friendship {
|
||||
Tuple2<UUID, UUID> getPlayerIds();
|
||||
Instant getCreatedAt();
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package de.kentoj.scrow.bukkit.services.old;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface CmdContext {
|
||||
|
||||
CommandSender getSender();
|
||||
|
||||
Player getSenderPlayer();
|
||||
|
||||
Entity getSenderEntity();
|
||||
|
||||
<T> T getArg(String key);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package de.kentoj.scrow.bukkit.services.old;
|
||||
|
||||
public interface CommandExecutor {
|
||||
|
||||
/**
|
||||
* @return true on success, 1 on failure
|
||||
*/
|
||||
boolean execute(CmdContext ctx);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package de.kentoj.scrow.bukkit.services.old;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public interface CommandsService {
|
||||
|
||||
void register(Plugin plugin, Command command);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package de.kentoj.scrow.bukkit.services.old;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.old.arg.CmdArg;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class RegisteredCmdArg<T> {
|
||||
int index;
|
||||
String key;
|
||||
CmdArg<T> arg;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package de.kentoj.scrow.bukkit.services.old;
|
||||
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SCommand {
|
||||
|
||||
@Nullable Permission getPermission();
|
||||
|
||||
RegisteredCmdArg<?> getArg(int index);
|
||||
|
||||
List<SCommand> getSubCommands();
|
||||
|
||||
String[] getLabels();
|
||||
|
||||
String getDescription();
|
||||
|
||||
@Nullable CommandExecutor getExecutor();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package de.kentoj.scrow.bukkit.services.old.arg;
|
||||
|
||||
public interface CmdArg<S> {
|
||||
|
||||
S parseInput(String str);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package de.kentoj.scrow.bukkit.services.old.arg;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
// FIXME module stuff
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class PlayerArgType {
|
||||
|
||||
public static final CmdArg<Player> player = str -> {
|
||||
if (str.length() == 36) {
|
||||
var uuid = UUID.fromString(str);
|
||||
return Bukkit.getPlayer(uuid);
|
||||
} else {
|
||||
return Bukkit.getPlayer(str);
|
||||
}
|
||||
};
|
||||
|
||||
public static final CmdArg<OfflinePlayer> offlinePlayer = str -> {
|
||||
var uuid = UUID.fromString(str);
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package de.kentoj.scrow.bukkit.util.pair;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class Tuple2<A, B> {
|
||||
A first;
|
||||
B second;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package de.kentoj.scrow.bukkit.util.pair;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class Tuple3<A, B, C> {
|
||||
A first;
|
||||
B second;
|
||||
C third;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package de.kentoj.scrow.bukkit.util.pair;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class Tuple4<A, B, C, D> {
|
||||
A first;
|
||||
B second;
|
||||
C third;
|
||||
D fourth;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue