Skip to content

Commit

Permalink
Update Dependencies and remove core and jetbrains annotations (#50)
Browse files Browse the repository at this point in the history
* Update dependencies in build.gradle.kts files

Upgraded 'version-checker' in velocity to 1.2.1 and 'paper' in paper to 1.5.2. This ensures compatibility with the latest features and bug fixes.

* [ci skip] Set Dependabot update interval to daily

Changed the schedule for Dependabot checks from weekly to daily. This ensures that dependencies are checked and updated more frequently, improving security and keeping the project up-to-date.

* Update dependencies and Java configuration

Upgraded various dependencies for improved stability and compatibility, including updates to Lombok, bstats, and core files. Modified the Java toolchain setup to use a more precise language version configuration. Incremented the version numbers for API and necessary plugins.

* Apply `@NullMarked` annotation and remove package-info.java

Added the `@NullMarked` annotation to several interfaces for improved nullability handling. The redundant `package-info.java` file was deleted to streamline package-level annotations.

* Remove package-info.java files and add @NullMarked annotations

Deleted package-info.java files to eliminate redundant nullability annotations. Integrated @NullMarked annotations directly into classes for improved null-safety handling.

* Refactor code for Nullmarked annotations support.

Integrated @NullMarked annotations across several classes to improve nullness checking consistency. Adjusted method calls to use the plugin's server instance instead of direct Bukkit calls for better encapsulation. Also removed redundant package-info.java files.

* [ci skip] Update version properties for game and velocity

Extended the game version range to include 1.21.3. Added support for velocity version 3.4 alongside 3.3 in the properties file.

* Replace JetBrains @nullable with JSpecify @nullable

Standardize @nullable annotations across the codebase by replacing JetBrains @nullable with JSpecify @nullable. This change enhances consistency and improves annotation processing.
  • Loading branch information
NonSwag authored Nov 20, 2024
1 parent f2187ae commit 21c1f8d
Show file tree
Hide file tree
Showing 58 changed files with 172 additions and 212 deletions.
11 changes: 6 additions & 5 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "net.thenextlvl.commander"
version = "4.1.0"
version = "4.1.1"

repositories {
mavenCentral()
Expand All @@ -13,16 +13,17 @@ repositories {
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.compileJava {
options.release.set(21)
}

dependencies {
compileOnly("org.projectlombok:lombok:1.18.36")
compileOnly("org.jetbrains:annotations:26.0.1")
compileOnly("net.thenextlvl.core:annotations:2.0.1")

compileOnly("com.google.code.gson:gson:2.11.0")
compileOnly("net.kyori:adventure-api:4.17.0")
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/net/thenextlvl/commander/CommandFinder.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package net.thenextlvl.commander;

import org.jspecify.annotations.NullMarked;

import java.util.Set;
import java.util.stream.Stream;

/**
* The CommandFinder interface defines methods for finding commands based on a given input.
*/
@NullMarked
public interface CommandFinder {
/**
* Finds commands based on the given input.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.thenextlvl.commander;

import net.kyori.adventure.audience.Audience;
import org.jspecify.annotations.NullMarked;

import java.util.Set;

@NullMarked
public interface CommandRegistry {
Set<String> hiddenCommands();

Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/net/thenextlvl/commander/Commander.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.thenextlvl.commander;

import core.annotation.MethodsReturnNotNullByDefault;
import core.i18n.file.ComponentBundle;
import org.jspecify.annotations.NullMarked;

@MethodsReturnNotNullByDefault
@NullMarked
public interface Commander {
/**
* Retrieves the CommandFinder instance associated with the Commander.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package net.thenextlvl.commander;

import net.kyori.adventure.audience.Audience;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.util.Map;

@NullMarked
public interface PermissionOverride {
Map<String, @Nullable String> originalPermissions();

Expand Down
10 changes: 0 additions & 10 deletions api/src/main/java/net/thenextlvl/commander/package-info.java

This file was deleted.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gameVersions=1.21
velocityVersions=3.3
gameVersions=1.21-1.21.3
velocityVersions=3.3,3.4
12 changes: 7 additions & 5 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription

plugins {
id("java")
id("io.github.goooler.shadow") version "8.1.8"
id("com.gradleup.shadow") version "8.3.5"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("net.minecrell.plugin-yml.paper") version "0.6.0"
id("com.modrinth.minotaur") version "2.+"
Expand All @@ -13,8 +13,11 @@ group = project(":api").group
version = project(":api").version

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain.languageVersion = JavaLanguageVersion.of(21)
}

tasks.compileJava {
options.release.set(21)
}

repositories {
Expand All @@ -26,14 +29,13 @@ repositories {

dependencies {
compileOnly("org.projectlombok:lombok:1.18.36")
compileOnly("net.thenextlvl.core:annotations:2.0.1")
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT")

implementation(project(":api"))
implementation("org.bstats:bstats-bukkit:3.1.0")
implementation("net.thenextlvl.core:files:2.0.0")
implementation("net.thenextlvl.core:i18n:1.0.20")
implementation("net.thenextlvl.core:paper:1.4.1")
implementation("net.thenextlvl.core:paper:1.5.3")

annotationProcessor("org.projectlombok:lombok:1.18.36")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
import net.thenextlvl.commander.paper.listener.CommandListener;
import net.thenextlvl.commander.paper.version.CommanderVersionChecker;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.jspecify.annotations.NullMarked;

import java.io.File;
import java.util.Locale;
import java.util.Objects;

@Getter
@NullMarked
@Accessors(fluent = true)
public class CommanderPlugin extends JavaPlugin implements Commander {
private final Metrics metrics = new Metrics(this, 22782);
Expand All @@ -45,23 +45,13 @@ public class CommanderPlugin extends JavaPlugin implements Commander {

@Override
public void onLoad() {
Bukkit.getServicesManager().register(Commander.class, this, this, ServicePriority.Highest);
versionChecker.retrieveLatestSupportedVersion(latest -> latest.ifPresentOrElse(version -> {
if (version.equals(versionChecker.getVersionRunning())) {
getComponentLogger().info("You are running the latest version of Commander");
} else if (version.compareTo(Objects.requireNonNull(versionChecker.getVersionRunning())) > 0) {
getComponentLogger().warn("An update for Commander is available");
getComponentLogger().warn("You are running version {}, the latest supported version is {}", versionChecker.getVersionRunning(), version);
getComponentLogger().warn("Update at https://modrinth.com/plugin/commander-1 or https://hangar.papermc.io/TheNextLvl/CommandControl");
} else {
getComponentLogger().warn("You are running a snapshot version of Commander");
}
}, () -> getComponentLogger().error("Version check failed")));
getServer().getServicesManager().register(Commander.class, this, this, ServicePriority.Highest);
versionChecker().checkVersion();
}

@Override
public void onEnable() {
Bukkit.getGlobalRegionScheduler().execute(this, () -> {
getServer().getGlobalRegionScheduler().execute(this, () -> {
permissionOverride().overridePermissions();
commandRegistry().unregisterCommands();
});
Expand All @@ -74,14 +64,14 @@ public void onDisable() {
commandRegistry().getHiddenFile().save();
commandRegistry().getUnregisteredFile().save();
permissionOverride().getOverridesFile().save();
metrics.shutdown();
metrics().shutdown();
}

private void registerCommands() {
new CommanderCommand().register(this);
}

private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new CommandListener(this), this);
getServer().getPluginManager().registerEvents(new CommandListener(this), this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
import io.papermc.paper.command.brigadier.CommandSourceStack;
import lombok.RequiredArgsConstructor;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.jspecify.annotations.NullMarked;

import java.util.concurrent.CompletableFuture;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class CommandSuggestionProvider implements SuggestionProvider<CommandSourceStack> {
private final CommanderPlugin plugin;

@Override
public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) {
Bukkit.getCommandMap().getKnownCommands().values().stream()
plugin.getServer().getCommandMap().getKnownCommands().values().stream()
.map(Command::getLabel)
.filter(s -> !plugin.commandRegistry().isUnregistered(s))
.map(StringArgumentType::escapeIfRequired)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import io.papermc.paper.command.brigadier.Commands;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.jspecify.annotations.NullMarked;

@NullMarked
@SuppressWarnings("UnstableApiUsage")
public class CommanderCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jspecify.annotations.NullMarked;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class HideCommand {
Expand All @@ -21,7 +22,7 @@ class HideCommand {
return Commands.literal("hide")
.then(Commands.argument("command", StringArgumentType.string())
.suggests((context, suggestions) -> {
Bukkit.getCommandMap().getKnownCommands().values().stream()
plugin.getServer().getCommandMap().getKnownCommands().values().stream()
.map(org.bukkit.command.Command::getLabel)
.filter(s -> !plugin.commandRegistry().isUnregistered(s))
.filter(s -> !plugin.commandRegistry().isHidden(s))
Expand All @@ -39,7 +40,7 @@ private int hide(CommandContext<CommandSourceStack> context) {
var success = plugin.commandRegistry().hide(command);
var message = success ? "command.hidden" : "nothing.changed";
plugin.bundle().sendMessage(sender, message, Placeholder.parsed("command", command));
if (success) Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
if (success) plugin.getServer().getOnlinePlayers().forEach(Player::updateCommands);
return Command.SINGLE_SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import io.papermc.paper.command.brigadier.Commands;
import lombok.RequiredArgsConstructor;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.jspecify.annotations.NullMarked;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class PermissionCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.jspecify.annotations.NullMarked;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class PermissionQueryCommand {
Expand All @@ -25,7 +26,7 @@ class PermissionQueryCommand {
private int query(CommandContext<CommandSourceStack> context) {
var sender = context.getSource().getSender();
var command = context.getArgument("command", String.class);
var registered = Bukkit.getCommandMap().getKnownCommands().get(command);
var registered = plugin.getServer().getCommandMap().getKnownCommands().get(command);
var permission = registered != null ? registered.getPermission() : null;
var message = registered == null ? "command.unknown" : permission != null ?
"permission.query.defined" : "permission.query.undefined";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jspecify.annotations.NullMarked;

import java.util.Optional;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class PermissionResetCommand {
Expand All @@ -38,12 +39,12 @@ private int reset(CommandContext<CommandSourceStack> context) {
var command = context.getArgument("command", String.class);
var success = plugin.permissionOverride().reset(command);
var message = success ? "permission.reset" : "nothing.changed";
var permission = Optional.ofNullable(Bukkit.getCommandMap().getCommand(command))
var permission = Optional.ofNullable(plugin.getServer().getCommandMap().getCommand(command))
.map(org.bukkit.command.Command::getPermission)
.orElse("null");
plugin.bundle().sendMessage(sender, message, Placeholder.parsed("command", command),
Placeholder.parsed("permission", permission));
if (success) Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
if (success) plugin.getServer().getOnlinePlayers().forEach(Player::updateCommands);
return Command.SINGLE_SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.jspecify.annotations.NullMarked;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class PermissionSetCommand {
Expand All @@ -23,7 +24,7 @@ class PermissionSetCommand {
.suggests(new CommandSuggestionProvider(plugin))
.then(Commands.argument("permission", StringArgumentType.string())
.suggests((context, suggestions) -> {
Bukkit.getPluginManager().getPermissions().stream()
plugin.getServer().getPluginManager().getPermissions().stream()
.map(Permission::getName)
.map(StringArgumentType::escapeIfRequired)
.filter(s -> s.contains(suggestions.getRemaining()))
Expand All @@ -42,7 +43,7 @@ private int set(CommandContext<CommandSourceStack> context) {
plugin.bundle().sendMessage(sender, message,
Placeholder.parsed("permission", permission),
Placeholder.parsed("command", command));
if (success) Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
if (success) plugin.getServer().getOnlinePlayers().forEach(Player::updateCommands);
return com.mojang.brigadier.Command.SINGLE_SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jspecify.annotations.NullMarked;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class PermissionUnsetCommand {
Expand All @@ -31,7 +32,7 @@ private int unset(CommandContext<CommandSourceStack> context) {
plugin.bundle().sendMessage(sender, message,
Placeholder.parsed("permission", "null"),
Placeholder.parsed("command", command));
if (success) Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
if (success) plugin.getServer().getOnlinePlayers().forEach(Player::updateCommands);
return com.mojang.brigadier.Command.SINGLE_SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.commander.paper.CommanderPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jspecify.annotations.NullMarked;

@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
class RegisterCommand {
Expand All @@ -36,7 +37,7 @@ private int register(CommandContext<CommandSourceStack> context) {
var success = plugin.commandRegistry().register(command);
var message = success ? "command.registered" : "nothing.changed";
plugin.bundle().sendMessage(sender, message, Placeholder.parsed("command", command));
if (success) Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
if (success) plugin.getServer().getOnlinePlayers().forEach(Player::updateCommands);
return Command.SINGLE_SUCCESS;
}
}
Loading

0 comments on commit 21c1f8d

Please sign in to comment.