-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reload configuration command (#41)
- Loading branch information
Showing
4 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...mp-core/src/main/java/com/github/imdmk/doublejump/configuration/ConfigurationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.imdmk.doublejump.configuration; | ||
|
||
import eu.okaeri.configs.OkaeriConfig; | ||
|
||
import java.io.File; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ConfigurationService { | ||
|
||
private final Set<OkaeriConfig> configs = new HashSet<>(); | ||
|
||
public <T extends OkaeriConfig> T create(Class<T> config, File file) { | ||
T configFile = ConfigurationFactory.create(config, file); | ||
|
||
this.configs.add(configFile); | ||
return configFile; | ||
} | ||
|
||
public void reload() { | ||
for (OkaeriConfig config : this.configs) { | ||
config.load(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-core/src/main/java/com/github/imdmk/doublejump/jump/command/DoubleJumpReloadCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.imdmk.doublejump.jump.command; | ||
|
||
import com.github.imdmk.doublejump.configuration.ConfigurationService; | ||
import com.github.imdmk.doublejump.notification.NotificationSender; | ||
import com.github.imdmk.doublejump.notification.configuration.NotificationSettings; | ||
import dev.rollczi.litecommands.annotations.async.Async; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.annotations.permission.Permission; | ||
import org.bukkit.command.CommandSender; | ||
|
||
@Command(name = "doublejump reload") | ||
@Permission("command.doublejump.reload") | ||
public class DoubleJumpReloadCommand { | ||
|
||
private final NotificationSettings notificationSettings; | ||
private final NotificationSender notificationSender; | ||
private final ConfigurationService configurationService; | ||
|
||
public DoubleJumpReloadCommand(NotificationSettings notificationSettings, NotificationSender notificationSender, ConfigurationService configurationService) { | ||
this.notificationSettings = notificationSettings; | ||
this.notificationSender = notificationSender; | ||
this.configurationService = configurationService; | ||
} | ||
|
||
@Async | ||
@Execute | ||
void execute(@Context CommandSender sender) { | ||
this.configurationService.reload(); | ||
this.notificationSender.send(sender, this.notificationSettings.configurationReloaded); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters