8000 Release/9.6.0 by JorelAli · Pull Request #609 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

Release/9.6.0 #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 77 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
543c329
Set version to 9.6.0-SNAPSHOT
JorelAli Aug 11, 2024
36904c1
Remove unnecessary dependencies section from shadowJar configuration …
DerEchtePilz Aug 12, 2024
4239d48
Reword previously modified section a bit
DerEchtePilz Aug 12, 2024
c8459cf
Be more lenient when updating the minor version of the game
DerEchtePilz Aug 12, 2024
f612282
Add an option to the plugin config
DerEchtePilz Aug 12, 2024
3dcea3e
Update documentation and changelog
DerEchtePilz Aug 12, 2024
b13b696
Address code reviews
DerEchtePilz Aug 13, 2024
6bbac82
Minor JavaDocs adjustments
DerEchtePilz Aug 13, 2024
e6c80ac
Tweak Javadocs
DerEchtePilz Aug 13, 2024
ca5600a
Add a LoadContext to only display a warning when applicable
DerEchtePilz Aug 13, 2024
ef987e7
Address more code review
DerEchtePilz Aug 14, 2024
d4cc664
Fix config option name in setup_shading
DerEchtePilz Aug 14, 2024
c3ff409
Even more code review
DerEchtePilz Aug 14, 2024
8000
4edb542
Fix incorrect sentence in safe suggestions (#601)
Strokkur424 Sep 1, 2024
7479cb8
Fix CommandAPI loading on old versions (tested 1.19)
willkroboth Sep 1, 2024
41e1e77
Update Velocity API to 3.3.0-SNAPSHOT
DerEchtePilz Sep 10, 2024
68ed69e
Update instructions for shading with Gradle
DerEchtePilz Oct 3, 2024
d4bdade
Rework plugin config system
DerEchtePilz Aug 20, 2024
2c698f8
Use a loop instead of a Stream
DerEchtePilz Aug 21, 2024
9ca2efe
We want stacktraces
DerEchtePilz Aug 21, 2024
77029d2
Include generated config.yml in the documentation
DerEchtePilz Aug 23, 2024
6bdc2fd
Address code review
DerEchtePilz Sep 5, 2024
86b3f27
Use a LinkedHashMap for config options
DerEchtePilz Sep 5, 2024
3140b23
First iteration of an extendable and testable config system
DerEchtePilz Sep 7, 2024
78b1f7c
Update config system to be platform agnostic
DerEchtePilz Sep 15, 2024
a21e635
Clean up dependencies
DerEchtePilz Sep 15, 2024
a0bd0ef
Fix stuff
DerEchtePilz Sep 22, 2024
90fac61
Annotations
DerEchtePilz Sep 22, 2024
5b8886a
Fix Annotations
DerEchtePilz Sep 22, 2024
460a466
Fix more stuff
DerEchtePilz Sep 23, 2024
25b040e
Fix defaults in config.md
DerEchtePilz Sep 23, 2024
7d2ef1e
Simplify a thing
DerEchtePilz Sep 23, 2024
beeca43
Fix VelocityConfigurationAdapter#getKeys()
DerEchtePilz Sep 23, 2024
32b7eed
Don't update the Velocity config if not necessary
DerEchtePilz Sep 23, 2024
e1c35d7
Clean up Velocity plugin class
DerEchtePilz Sep 24, 2024
be6dfa3
Create static method to create a dummy instance
DerEchtePilz Sep 25, 2024
0e0d2d5
Remove Velocity config file
DerEchtePilz Sep 25, 2024
2698520
Introduce common modules to not include config classes in API modules
DerEchtePilz Sep 26, 2024
aa0d977
Remove unnecessary dependency
DerEchtePilz Sep 28, 2024
bff49cd
Move more common classes into the common module
DerEchtePilz Sep 28, 2024
677d545
Inline some stuff
DerEchtePilz Sep 28, 2024
f66e16c
Address code review
DerEchtePilz Oct 7, 2024
392d77f
More code review
DerEchtePilz Oct 7, 2024
0739a4f
Merge pull request #596 from JorelAli/dev/config-experiment
DerEchtePilz Oct 8, 2024
af9c53d
A few fixes
DerEchtePilz Oct 8, 2024
456c5a4
Add some tests
DerEchtePilz Oct 8, 2024
36c6b4b
Pass a YamlConfigurationLoader into VelocityConfigurationAdapter#crea…
DerEchtePilz Oct 8, 2024
54437c3
Generate default config correctly again
DerEchtePilz Oct 8, 2024
95a831d
Another test
DerEchtePilz Oct 8, 2024
f50a549
Extract saveDefaultConfig to ConfigurationAdapter
DerEchtePilz Oct 9, 2024
51eddbd
Update config test validation methods. Add config modules to code cov…
DerEchtePilz Oct 9, 2024
c07b4b1
Code review
DerEchtePilz Oct 16, 2024
f21647e
Pass config file to the ConfigurationAdapter impls
DerEchtePilz Oct 16, 2024
ed82a36
createDummyInstance -> createMinimalInstance
DerEchtePilz Oct 16, 2024
eddcb5c
Merge pull request #605 from JorelAli/dev/config-experiment
DerEchtePilz Oct 16, 2024
6828682
Initial work for 1.21.2
DerEchtePilz Oct 22, 2024
461ff87
Update compatible versions and add some annotations
DerEchtePilz Oct 22, 2024
4e16bd4
Fix parsing errors for advancement and recipe argument
DerEchtePilz Oct 22, 2024
52ab132
Remove TODO from runCommandFunction profiler change. Adds Differs ann…
JorelAli Oct 23, 2024
5d4111b
Tweak NMS 1.21.2 reloading to handle fuel values and recipe loading f…
JorelAli Oct 23, 2024
aa5c4ea
Fix compilation error because of wrong variable name
DerEchtePilz Oct 23, 2024
fd46152
Add 1.21.3 as a supported version
DerEchtePilz Oct 23, 2024
f91d291
Update dependencies to 1.21.3
DerEchtePilz Oct 24, 2024
9fd1d0d
Update changelog
DerEchtePilz Oct 24, 2024
0e01353
Add new Minecraft versions to the issue template
DerEchtePilz Oct 24, 2024
826bb9a
We have a Paper 1.21.3 dependency now
DerEchtePilz Oct 26, 2024
4caeb94
Update version supported table
DerEchtePilz Oct 26, 2024
9cf7fdc
Correctly place new NMS method in ArgumentNMS classes
DerEchtePilz Oct 26, 2024
c1546fc
Add changelog entry for `dev/config-experiment` changes
willkroboth Oct 26, 2024
cc64f5c
Bump Maven plugin versions (including maven-shade-plugin -> 3.6.0)
JorelAli Oct 28, 2024
1ea949c
Set version to 9.6.0
JorelAli Oct 28, 2024
aa27508
Generate 9.6.0 documentation
JorelAli Oct 28, 2024
b8acc0d
Generate 9.6.0 JavaDocs
JorelAli Oct 28, 2024
b19dee0
Update website
JorelAli Oct 28, 2024
4af8234
Downgrade maven-source-plugin back to 3.2.1
JorelAli Oct 28, 2024
ac417e4
Add some JavaDocs for non-Javadoc packages so Maven is happy
JorelAli Oct 28, 2024
0546c4f
Merge branch 'master' into release/9.6.0
JorelAli Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions commandapi-codecov/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-plugin-common</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Code coverage the tests -->
<dependency>
Expand Down
8000
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void onEnable() {
@Override
public void saveDefaultConfig() {
File configFile = new File(getDataFolder(), "config.yml");
BukkitConfigurationAdapter.createDummyInstance().saveDefaultConfig(getDataFolder(), configFile, getLogger());
BukkitConfigurationAdapter.createMinimalInstance(configFile).saveDefaultConfig(getDataFolder(), getLogger());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Logger;

public record BukkitConfigurationAdapter(YamlConfiguration config) implements ConfigurationAdapter<YamlConfiguration> {
public record BukkitConfigurationAdapter(YamlConfiguration config, File configFile) implements ConfigurationAdapter<YamlConfiguration> {

public static BukkitConfigurationAdapter createDummyInstance() {
return new BukkitConfigurationAdapter(null);
public static BukkitConfigurationAdapter createMinimalInstance(File configFile) {
return new BukkitConfigurationAdapter(null, configFile);
}

@Override
Expand Down Expand Up @@ -104,50 +103,26 @@ public ConfigurationAdapter<YamlConfiguration> complete() {
return this;
}


@Override
public ConfigurationAdapter<YamlConfiguration> createNew() {
return new BukkitConfigurationAdapter(new YamlConfiguration());
return new BukkitConfigurationAdapter(new YamlConfiguration(), configFile);
}

@Override
public void saveDefaultConfig(File directory, File configFile, Logger logger) {
ConfigGenerator configGenerator = ConfigGenerator.createNew(DefaultBukkitConfig.createDefault());
if (!directory.exists()) {
boolean createdDirectory = directory.mkdirs();
if (!createdDirectory) {
logger.severe("Failed to create directory for the CommandAPI's config.yml file!");
}
try {
ConfigurationAdapter<YamlConfiguration> bukkitConfigurationAdapter = new BukkitConfigurationAdapter(new YamlConfiguration());
configGenerator.populateDefaultConfig(bukkitConfigurationAdapter);
bukkitConfigurationAdapter.config().save(configFile);
} catch (IOException e) {
logger.severe("Could not create default config file! This is (probably) a bug.");
logger.severe("Error message: " + e.getMessage());
logger.severe("Stacktrace:");
for (StackTraceElement element : e.getStackTrace()) {
logger.severe(element.toString());
}
}
return;
}
// Update the config if necessary
try {
YamlConfiguration existingYamlConfig = YamlConfiguration.loadConfiguration(configFile);
ConfigurationAdapter<YamlConfiguration> existingConfig = new BukkitConfigurationAdapter(existingYamlConfig);
ConfigurationAdapter<YamlConfiguration> updatedConfig = configGenerator.generateWithNewValues(existingConfig);
if (updatedConfig == null) {
return;
}
updatedConfig.config().save(configFile);
} catch (IOException e) {
logger.severe("Could not update config! This is (probably) a bug.");
logger.severe("Error message: " + e.getMessage());
logger.severe("Stacktrace:");
for (StackTraceElement element : e.getStackTrace()) {
logger.severe(element.toString());
}
}
public DefaultBukkitConfig createDefaultConfig() {
return DefaultBukkitConfig.createDefault();
}

@Override
public ConfigurationAdapter<YamlConfiguration> loadFromFile() {
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
return new BukkitConfigurationAdapter(config, configFile);
}

@Override
public void saveToFile() throws IOException {
config.save(configFile);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
<artifactId>commandapi-bukkit-test-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-plugin-common</artifactId>
<version>${project.version}</version>
</dependency>

<!-- NBT API implementations (in no particular order) -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
package dev.jorel.commandapi.test;

import dev.jorel.commandapi.config.BukkitConfigurationAdapter;
import dev.jorel.commandapi.config.CommentedConfigOption;
import dev.jorel.commandapi.config.CommentedSection;
import dev.jorel.commandapi.config.ConfigGenerator;
import dev.jorel.commandapi.config.ConfigurationAdapter;
import dev.jorel.commandapi.config.DefaultBukkitConfig;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

class ConfigGenerationTests {

private CommentedConfigOption<Boolean> silentLogs;
private CommentedConfigOption<Boolean> verboseOutputs;
private CommentedConfigOption<String> missingExecutorImplementation;

private CommentedSection messages;

private ConfigGenerator generator;
private DefaultBukkitConfig bukkitConfig;
private BukkitConfigurationAdapter adapter;

@BeforeEach
public void setup() {
silentLogs = new CommentedConfigOption<>(new String[]{
"Silent logs (default: false)",
"If \"true\", turns off all logging from the CommandAPI, except for errors."
}, false);
verboseOutputs = new CommentedConfigOption<>(new String[]{
"Verbose outputs (default: false)",
"If \"true\", outputs command registration and unregistration logs in the console"
}, false);
missingExecutorImplementation = new CommentedConfigOption<>(new String[]{
"Missing executor implementation (default: \"This command has no implementations for %s\")",
"The message to display to senders when a command has no executor. Available",
"parameters are:",
" %s - the executor class (lowercase)",
" %S - the executor class (normal case)"
}, "This command has no implementations for %s");

messages = new CommentedSection(new String[]{
"Messages",
"Controls messages that the CommandAPI displays to players"
});

Map<String, CommentedConfigOption<?>> options = new LinkedHashMap<>();
options.put("silent-logs", silentLogs);
options.put("verbose-outputs", verboseOutputs);
options.put("messages.missing-executor-implementation", missingExecutorImplementation);

Map<String, CommentedSection> sections = new LinkedHashMap<>();
sections.put("messages", messages);

ConfigurationAdapter<YamlConfiguration> adapter = new BukkitConfigurationAdapter(new YamlConfiguration(), null);
bukkitConfig = DefaultBukkitConfig.create(options, sections);
generator = ConfigGenerator.createNew(bukkitConfig);
this.adapter = (BukkitConfigurationAdapter) generator.generate(adapter);
}

@AfterEach
public void reset() {
this.silentLogs = null;
this.verboseOutputs = null;
this.missingExecutorImplementation = null;
this.messages = null;
this.generator = null;
this.bukkitConfig = null;
this.adapter = null;
}

// Test methods
private void validateConfigOptions(Set<String> options, BukkitConfigurationAdapter adapter) {
for (String option : options) {
assertTrue(adapter.contains(option), "Config option '" + option + "' does not exist!");
}
}

private void validateConfigOptionComments(Map<String, String[]> comments, BukkitConfigurationAdapter adapter) {
for (String option : comments.keySet()) {
String[] expectedComment = comments.get(option);
String[] generatedComment = adapter.getComment(option);
assertArrayEquals(expectedComment, generatedComment, "Config option comment for option '" + option + "' does not exist or was incorrect!");
}
}

private void validateConfigOptionsAbsent(Set<String> options, BukkitConfigurationAdapter adapter) {
for (String option : options) {
assertFalse(adapter.contains(option), "Config option '" + option + "' does still exist!");
}
}

private void validateSections(List<String> sections, String expectedOption, YamlConfiguration config) {
ConfigurationSection root = config;

for (String section : sections) {
root = root.getConfigurationSection(section);
assertNotNull(root, "Section '" + section + "' does not exist!");
}
Object expectedValue = root.get(expectedOption);
assertNotNull(expectedValue, "Expected option '" + expectedOption + "' was not found in section '" + root.getName() + "'!");
}

@Test
void testDefaultConfigOptionGeneration() {
validateConfigOptions(Set.of(
"silent-logs", "verbose-outputs", "messages.missing-executor-implementation"
), adapter);
}

@Test
void testDefaultConfigOptionCommentGeneration() {
validateConfigOptionComments(Map.ofEntries(
Map.entry("silent-logs", silentLogs.comment()),
Map.entry("verbose-outputs", verboseOutputs.comment()),
Map.entry("messages.missing-executor-implementation", missingExecutorImplementation.comment()),
Map.entry("messages", messages.comment())
), adapter);
}

@Test
void testConfigOptionAddition() {
CommentedConfigOption<Boolean> createDispatcherJson = new CommentedConfigOption<>(new String[] {
"Create dispatcher JSON (default: false)",
"If \"true\", the CommandAPI creates a command_registration.json file showing the",
"mapping of registered commands. This is designed to be used by developers -",
"setting this to \"false\" will improve command registration performance."
}, false);

bukkitConfig.getAllOptions().put("create-dispatcher-json", createDispatcherJson);
generator = ConfigGenerator.createNew(bukkitConfig);
BukkitConfigurationAdapter updatedAdapter = (BukkitConfigurationAdapter) generator.generate(adapter);

validateConfigOpti 10000 ons(Set.of(
"silent-logs", "verbose-outputs", "messages.missing-executor-implementation", "create-dispatcher-json"
), updatedAdapter);

validateConfigOptionComments(Map.ofEntries(
Map.entry("silent-logs", silentLogs.comment()),
Map.entry("verbose-outputs", verboseOutputs.comment()),
Map.entry("messages.missing-executor-implementation", missingExecutorImplementation.comment()),
Map.entry("create-dispatcher-json", createDispatcherJson.comment()),
Map.entry("messages", messages.comment())
), updatedAdapter);
}

@Test
void testConfigOptionDeletion() {
bukkitConfig.getAllOptions().remove("silent-logs");
generator = ConfigGenerator.createNew(bukkitConfig);
BukkitConfigurationAdapter updatedAdapter = (BukkitConfigurationAdapter) generator.generate(adapter);

validateConfigOptionsAbsent(Set.of("silent-logs"), updatedAdapter);
}

@Test
void testConfigOptionCommentUpdate() {
silentLogs = new CommentedConfigOption<>(new String[] {
"Defines if silent logs should happen"
}, false);

bukkitConfig.getAllOptions().put("silent-logs", silentLogs);
generator = ConfigGenerator.createNew(bukkitConfig);
BukkitConfigurationAdapter updatedAdapter = (BukkitConfigurationAdapter) generator.generate(adapter);

validateConfigOptionComments(Map.ofEntries(
Map.entry("silent-logs", silentLogs.comment())
), updatedAdapter);
}

@Test
void testNestedSections() {
CommentedConfigOption<Boolean> subSubOption = new CommentedConfigOption<>(new String[0], false);

bukkitConfig.getAllOptions().put("root.nested.option", subSubOption);
generator = ConfigGenerator.createNew(bukkitConfig);
BukkitConfigurationAdapter updatedAdapter = (BukkitConfigurationAdapter) generator.generate(adapter);

validateSections(List.of("root", "nested"), "option", updatedAdapter.config());
}

@Test
void testConfigUpdateNotNeeded() {
assertNull(generator.generate(adapter));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ public CommandAPIMain(ProxyServer server, Logger logger, @DataDirectory Path dat
// Try to find the config file
Path configFile = dataDirectory.resolve("config.yml");

YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
.nodeStyle(NodeStyle.BLOCK)
.path(configFile)
.build();

// Create or update config
VelocityConfigurationAdapter.createDummyInstance().saveDefaultConfig(configFile.getParent().toFile(), configFile.toFile(), logger);
VelocityConfigurationAdapter.createMinimalInstance(loader).saveDefaultConfig(configFile.getParent().toFile(), logger);

// Load the file as a yaml node
ConfigurationNode configYAML;
try {
YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
.nodeStyle(NodeStyle.BLOCK)
.path(configFile)
.build();
configYAML = loader.load();
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Loading
Loading 3D50
0