Skip to content

Commit

Permalink
Fixed some codancy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Hutch79 committed Apr 1, 2024
1 parent 7eb6c7d commit cb199cb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This is a basic workflow to help you get started with Actions

name: Compiling Action

# Controls when the workflow will run
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/ch/hutch79/application/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import java.io.FileNotFoundException;

public class Command implements CommandExecutor {

private final ConfigManager configManager;
Expand All @@ -27,7 +29,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
}

if (args[0].equalsIgnoreCase("reload")) {
configManager.loadConfig(Config.class, "config.yml");
try {
configManager.loadConfig(Config.class, "config.yml");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
sender.sendMessage("§dF-Command §8> §7Config has been reloaded");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import org.apache.commons.lang.NullArgumentException;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;

Expand All @@ -29,20 +29,20 @@ public ConfigManager(@NotNull File pluginPath) {
}


public void writeConfig (Object configClass, String localPath) {
public void writeConfig (Object configClass, String localPath) throws FileNotFoundException {
try {
writeMapper.writeValue(new File(_pluginPath + File.separator + localPath), configClass);
} catch (IOException e) {
throw new RuntimeException(e);
throw new FileNotFoundException();
}
}

public <T> ConfigManager loadConfig(Class<?> configClass, String localPath) {
public <T> ConfigManager loadConfig(Class<?> configClass, String localPath) throws FileNotFoundException {
T config;
try {
config = (T) readMapper.readValue(new File(_pluginPath + File.separator + localPath), configClass);
} catch (IOException e) {
throw new RuntimeException(e);
throw new FileNotFoundException();
}
configCache.put(configClass, config);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class ConfigMigrator {

@Inject
public ConfigMigrator(Injector injector, ConfigManager configManager, FCommand fCommand) throws IOException {
public ConfigMigrator(Injector injector, ConfigManager configManager) throws IOException {
ConsoleMessanger messanger = new ConsoleMessanger();
try {
configManager.loadConfig(Config.class, "config.yml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PermissionCheck implements ICheck{
private final Player player;
private ConsoleMessanger debug = new ConsoleMessanger(true);

public PermissionCheck(Command command, Event event, Player player) {
public PermissionCheck(Command command, Player player) {
this.command = command;
this.player = player;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static FCommand provideFCommand() {

@Provides
@Singleton
static ConfigManager ConfigManagerProvider() {
static ConfigManager configManagerProvider() {
return configManager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class MigrationV1Test {
@Test
public void MigrationV1() {
public void migrationV1() {
MigrationV1 migrationV1 = new MigrationV1();
var configPath = Paths.get(System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator + "ch" + File.separator + "hutch79" + File.separator + "migrationTest" + File.separator + "configs");
Config migratedConfig;
Expand Down

0 comments on commit cb199cb

Please sign in to comment.