Skip to content

Commit

Permalink
Release 2.0.1 (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs authored Jul 26, 2023
2 parents 2b05f69 + 24e642d commit 29aa31a
Show file tree
Hide file tree
Showing 220 changed files with 3,006 additions and 3,726 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_to_nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3.5.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Verify state
on:
push:
pull_request:
types: [opened, ready_for_review, review_requested, edited]
types: [ opened, ready_for_review, review_requested, edited ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3.5.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
168 changes: 92 additions & 76 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,108 +1,124 @@
import com.diffplug.gradle.spotless.SpotlessPlugin
import de.chojo.PublishData

plugins {
id("com.github.johnrengelman.shadow") version "8.1.0"
java
`maven-publish`
`java-library`
id("de.chojo.publishdata") version "1.2.3"
id("com.diffplug.spotless") version "6.16.0"
id("de.chojo.publishdata") version "1.2.4"
id("com.diffplug.spotless") version "6.18.0"
}
group = "de.eldoria"
group = "de.eldoria.util"
var mainPackage = "eldoutilities"
val shadebase = group as String? + "." + mainPackage + "."
version = "1.14.4"
version = "2.0.1"
description = "Utility Library for spigot plugins used by the eldoria team."

javaToolchains {
java {
sourceCompatibility = JavaVersion.VERSION_17
allprojects {
apply {
plugin<JavaLibraryPlugin>()
plugin<SpotlessPlugin>()
plugin<JavaPlugin>()
plugin<MavenPublishPlugin>()
plugin<PublishData>()
}
testing{

repositories {
mavenCentral()
maven("https://eldonexus.de/repository/maven-public")
maven("https://eldonexus.de/repository/maven-proxies")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots")
maven("https://repo.papermc.io/repository/maven-public/")
}
}

repositories {
mavenCentral()
maven("https://eldonexus.de/repository/maven-proxies")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots")
maven("https://repo.papermc.io/repository/maven-public/")

}

dependencies {
implementation("org.bstats", "bstats-bukkit", "3.0.1")
compileOnly("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
compileOnly("org.jetbrains", "annotations", "24.0.1")

testImplementation("org.jetbrains", "annotations", "24.0.1")
testImplementation("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.9.2")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.9.2")
testImplementation("org.mockito", "mockito-core", "5.2.0")
testImplementation("com.github.seeseemelk", "MockBukkit-v1.19", "2.145.0")
}

java {
withSourcesJar()
withJavadocJar()
}
dependencies {
compileOnly("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
compileOnly("org.jetbrains", "annotations", "24.0.1")

publishData {
useEldoNexusRepos()
publishTask("shadowJar")
publishTask("sourcesJar")
publishTask("javadocJar")
}
testImplementation("org.jetbrains", "annotations", "24.0.1")
testImplementation("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.9.2")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.9.2")
testImplementation("org.mockito", "mockito-core", "5.2.0")
testImplementation("com.github.seeseemelk", "MockBukkit-v1.19", "2.145.0")
}

spotless {
java {
licenseHeaderFile(rootProject.file("HEADER.txt"))
target("**/*.java")
java {
withSourcesJar()
withJavadocJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

publishing {
publications.create<MavenPublication>("maven") {
publishData.configurePublication(this);
publishData{
useEldoNexusRepos()
publishComponent("java")
}

repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("NEXUS_USERNAME")
password = System.getenv("NEXUS_PASSWORD")
publishing {
publications.create<MavenPublication>("maven") {
publishData.configurePublication(this);
}

repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("NEXUS_USERNAME")
password = System.getenv("NEXUS_PASSWORD")
}
}
}

name = "EldoNexus"
setUrl(publishData.getRepository())
name = "EldoNexus"
setUrl(publishData.getRepository())
}
}
}
}

tasks {
compileJava {
options.encoding = "UTF-8"
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER.txt"))
target("**/*.java")
}
}

javadoc {
options.encoding = "UTF-8"
}
tasks {
compileJava {
options.encoding = "UTF-8"
}

compileTestJava {
options.encoding = "UTF-8"
}
javadoc {
options.encoding = "UTF-8"
}

test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
compileTestJava {
options.encoding = "UTF-8"
}

test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
}
shadowJar {
relocate("org.bstats", shadebase + "bstats")
mergeServiceFiles()
archiveClassifier.set("")
}
}

dependencies{
api(project(":commands"))
api(project(":configuration"))
api(project(":core"))
api(project(":crossversion"))
api(project(":debugging"))
api(project(":entities"))
api(project(":inventory"))
api(project(":items"))
api(project(":legacy-serialization"))
api(project(":localization"))
api(project(":messaging"))
api(project(":metrics"))
api(project(":plugin"))
api(project(":threading"))
api(project(":updater"))
}
6 changes: 6 additions & 0 deletions commands/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
api(project(":core"))
api(project(":messaging"))
api(project(":debugging"))
api(project(":localization"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Copyright (C) EldoriaRPG Team and Contributor
*/

package de.eldoria.eldoutilities.simplecommands;
package de.eldoria.eldoutilities.commands;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import de.eldoria.eldoutilities.C;
import de.eldoria.eldoutilities.commands.command.util.CommandAssertions;
import de.eldoria.eldoutilities.commands.exceptions.CommandException;
import de.eldoria.eldoutilities.utils.ArrayUtil;
Expand Down Expand Up @@ -43,20 +42,16 @@
* @since 1.0.0
*/
@SuppressWarnings("unused")
public final class TabCompleteUtil {
public final class Completion {
public static final long OFFLINE_PLAYER_CACHE_SIZE = 1000L;
private static final Set<String> PLAYER_NAMES = new HashSet<>();
private static final Set<String> ONLINE_NAMES = new HashSet<>();
public static final long OFFLINE_PLAYER_CACHE_SIZE = 1000L;
private static Instant lastPlayerRefresh = Instant.now();
private static final Set<String> SMART_MATS;
private static final Map<String, List<String>> SMART_SHORT_MATS;
private static final Map<String, List<String>> SMART_PART_MATS;
private static final Pattern SHORT_NAME = Pattern.compile("(?:(?:^|_)(.))");
private static final Cache<String, List<String>> SMART_MAT_RESULTS = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build();

private TabCompleteUtil() {
throw new UnsupportedOperationException("This is a utility class.");
}
private static Instant lastPlayerRefresh = Instant.now();

static {
SMART_MATS = new LinkedHashSet<>();
Expand All @@ -74,6 +69,10 @@ private TabCompleteUtil() {
}
}

private Completion() {
throw new UnsupportedOperationException("This is a utility class.");
}

private static String getShortName(Material mat) {
var matcher = SHORT_NAME.matcher(mat.name());
var builder = new StringBuilder();
Expand Down Expand Up @@ -204,7 +203,7 @@ public static List<String> completeBoolean(String value) {
* @return list of strings
*/
public static List<String> completeWorlds(String value) {
return completeWorlds(value, C.SPACE_REPLACE);
return completeWorlds(value, ":");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@

package de.eldoria.eldoutilities.commands.command;

import de.eldoria.eldoutilities.commands.Completion;
import de.eldoria.eldoutilities.commands.command.util.Arguments;
import de.eldoria.eldoutilities.commands.command.util.CommandAssertions;
import de.eldoria.eldoutilities.commands.exceptions.CommandException;
import de.eldoria.eldoutilities.commands.executor.IConsoleTabExecutor;
import de.eldoria.eldoutilities.commands.executor.IPlayerTabExecutor;
import de.eldoria.eldoutilities.commands.executor.ITabExecutor;
import de.eldoria.eldoutilities.localization.DummyLocalizer;
import de.eldoria.eldoutilities.localization.ILocalizer;
import de.eldoria.eldoutilities.localization.Replacement;
import de.eldoria.eldoutilities.messages.MessageSender;
import de.eldoria.eldoutilities.simplecommands.TabCompleteUtil;
import de.eldoria.eldoutilities.messages.Replacement;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -107,7 +106,7 @@ public void commandRoute(CommandSender sender, String label, Arguments args) thr
}
if (!access) {
var permissions = String.join(", ", meta().permissions());
return Collections.singletonList(localizer().localize("error.permission",
return Collections.singletonList(messageSender.translatePlain("error.permission",
Replacement.create("PERMISSION", permissions)));
}
}
Expand All @@ -127,12 +126,12 @@ public void commandRoute(CommandSender sender, String label, Arguments args) thr

// Provide routes
if (args.size() == 1) {
return TabCompleteUtil.complete(args.asString(0), meta.registeredCommands());
return Completion.complete(args.asString(0), meta.registeredCommands());
}

var command = getCommand(args.asString(0));
if (command.isEmpty()) {
return Collections.singletonList(localizer().getMessage("error.invalidCommand"));
return Collections.singletonList(localizer().localize("error.invalidCommand"));
}
// forward
return command.get().tabCompleteRoute(sender, args.asString(0), args.subArguments());
Expand All @@ -153,7 +152,7 @@ private Optional<AdvancedCommand> getCommand(String command) {
* @return localizer instance
*/
protected final ILocalizer localizer() {
if (localizer == null || localizer instanceof DummyLocalizer) {
if (localizer == null || localizer instanceof ILocalizer.DummyLocalizer) {
localizer = ILocalizer.getPluginLocalizer(plugin);
}
return localizer;
Expand All @@ -165,7 +164,7 @@ protected final ILocalizer localizer() {
* @return message sender instance
*/
protected final MessageSender messageSender() {
if (messageSender == null || messageSender.isDefault()) {
if (messageSender == null || messageSender.isAnonymous()) {
messageSender = MessageSender.getPluginMessageSender(plugin);
}
return messageSender;
Expand Down Expand Up @@ -197,8 +196,8 @@ protected final void meta(CommandMeta meta) {
}

public void handleCommandError(CommandSender sender, Throwable e) {
if (e instanceof CommandException) {
messageSender().sendLocalizedError(sender, e.getMessage(), ((CommandException) e).replacements());
if (e instanceof CommandException cmd) {
messageSender().sendError(sender, e.getMessage(), cmd.replacements());
plugin().getLogger().log(Level.CONFIG, "Command exception occured.", e);
return;
}
Expand Down
Loading

0 comments on commit 29aa31a

Please sign in to comment.