. + improve build system
This commit is contained in:
parent
00eb51595d
commit
e09ae6cc18
10 changed files with 117 additions and 107 deletions
|
|
@ -4,56 +4,12 @@ val scrowToken = providers.gradleProperty("scrowMavenToken")
|
|||
plugins {
|
||||
id("java")
|
||||
id("java-library")
|
||||
id("maven-publish")
|
||||
id("io.freefair.lombok") version "9.2.0"
|
||||
}
|
||||
|
||||
group = "de.kentoj"
|
||||
version = "2.0.2"
|
||||
|
||||
fun scrowRepo(handler: RepositoryHandler) = handler.maven {
|
||||
name = "scrow"
|
||||
url = uri("http://forge.kentoj.de/api/packages/scrow/maven")
|
||||
isAllowInsecureProtocol = true
|
||||
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Authorization"
|
||||
value = "token $scrowToken"
|
||||
}
|
||||
|
||||
authentication {
|
||||
create<HttpHeaderAuthentication>("header")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
|
||||
name = "spigotmc-repo"
|
||||
}
|
||||
scrowRepo(this)
|
||||
}
|
||||
version = "2.2.0"
|
||||
|
||||
dependencies {
|
||||
// https://mvnrepository.com/artifact/org.jetbrains/annotations
|
||||
implementation("org.jetbrains:annotations:26.0.2-1")
|
||||
|
||||
api("de.kentoj:kencommandapi-core:2.0.2")
|
||||
|
||||
api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
|
||||
implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("KenCommandAPIBukkit") {
|
||||
groupId = project.group.toString()
|
||||
artifactId = "kencommandapi-bukkit"
|
||||
version = project.version.toString()
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
scrowRepo(this)
|
||||
}
|
||||
api(project(":kencommandapi-core"))
|
||||
compileOnly("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package de.kentoj.kencommandapi;
|
||||
|
||||
import de.kentoj.kencommandapi.api.processing.CommandException;
|
||||
import de.kentoj.kencommandapi.api.processing.ParsedArgument;
|
||||
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
|
||||
import de.kentoj.kencommandapi.impl.AbstractKenCommandApi;
|
||||
|
|
@ -20,6 +21,12 @@ public class BukkitKenCommandApi extends AbstractKenCommandApi<CommandSender, Bu
|
|||
return new BukkitCommandContext(sender, parsedArguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendErrorMessage(CommandSender sender, CommandException ex) {
|
||||
var cause = (ex.getCause() != null) ? ": " + ex.getCause().getMessage() : "";
|
||||
sender.sendMessage("§c" + ex.getMessage() + cause);
|
||||
}
|
||||
|
||||
public void register(CommandNode<CommandSender, BukkitCommandContext> rootNode) {
|
||||
try {
|
||||
Field field = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package de.kentoj.kencommandapi.type;
|
||||
|
||||
import de.kentoj.kencommandapi.BukkitCommandContext;
|
||||
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
||||
import de.kentoj.kencommandapi.api.processing.CommandException;
|
||||
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
||||
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
||||
import lombok.AccessLevel;
|
||||
|
|
@ -22,15 +22,15 @@ public class OfflinePlayerArgumentType implements ArgumentType<CommandSender, Bu
|
|||
|
||||
@Override
|
||||
public OfflinePlayer parseInput(String string) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(string);
|
||||
OfflinePlayer player = Bukkit.getPlayerExact(string);
|
||||
if (player == null) {
|
||||
try {
|
||||
player = Bukkit.getOfflinePlayer(UUID.fromString(string));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new RuntimeException("Not a UUID or online player -- " + string);
|
||||
throw new CommandException("Not a UUID or online player -- " + string);
|
||||
}
|
||||
}
|
||||
if (!player.hasPlayedBefore()) throw new RuntimeException("Unknown player -- " + string);
|
||||
if (!player.hasPlayedBefore() && !player.isOnline()) throw new CommandException("Unknown player -- " + string);
|
||||
return player;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package de.kentoj.kencommandapi.type;
|
|||
|
||||
import de.kentoj.kencommandapi.BukkitCommandContext;
|
||||
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
||||
import de.kentoj.kencommandapi.api.processing.CommandException;
|
||||
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
||||
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
||||
import lombok.AccessLevel;
|
||||
|
|
@ -22,7 +23,7 @@ public class PlayerArgumentType implements ArgumentType<CommandSender, BukkitCom
|
|||
@Override
|
||||
public Player parseInput(String string) {
|
||||
var player = Bukkit.getPlayer(string);
|
||||
if (player == null) throw new RuntimeException("Player not online -- " + string);
|
||||
if (player == null) throw new CommandException("Player not online -- " + string);
|
||||
return player;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue