Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
0fd7a9f35e | |||
4bb1cd7277 | |||
7e2c68bad8 | |||
5574342811 | |||
6bb54c5cdb | |||
cfe2575b3c | |||
11e3ca739b | |||
ab9f4b0525 | |||
a4f595594d | |||
971a4ffdce | |||
71de030ea0 | |||
b500fecadf |
@ -16,7 +16,9 @@
|
|||||||
"vscode": {
|
"vscode": {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"redhat.java",
|
"redhat.java",
|
||||||
"redhat.vscode-xml"
|
"redhat.vscode-xml",
|
||||||
|
"piotrpalarz.vscode-gitignore-generator",
|
||||||
|
"Gruntfuggly.todo-tree"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -127,4 +127,6 @@ buildtools/*
|
|||||||
!buildtools/install.sh
|
!buildtools/install.sh
|
||||||
devserver/*
|
devserver/*
|
||||||
!devserver/start.sh
|
!devserver/start.sh
|
||||||
!devserver/loadplugin.sh
|
!devserver/server.properties
|
||||||
|
!devserver/loadplugin.sh
|
||||||
|
!devserver/bukkit.yml
|
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Development Server",
|
||||||
|
"request": "attach",
|
||||||
|
"hostName": "localhost",
|
||||||
|
"port": 5005,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
.vscode/tasks.json
vendored
47
.vscode/tasks.json
vendored
@ -2,6 +2,7 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
|
"label": "Build Plugin to Development Server",
|
||||||
"type": "java (buildArtifact)",
|
"type": "java (buildArtifact)",
|
||||||
"targetPath": "${workspaceFolder}/devserver/plugins/${workspaceFolderBasename}.jar",
|
"targetPath": "${workspaceFolder}/devserver/plugins/${workspaceFolderBasename}.jar",
|
||||||
"elements": [
|
"elements": [
|
||||||
@ -9,7 +10,49 @@
|
|||||||
"${dependencies}"
|
"${dependencies}"
|
||||||
],
|
],
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"label": "Build SpigotResourceSync to plugins"
|
},
|
||||||
|
{
|
||||||
|
"label": "Install Development Server",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${workspaceFolder}/buildtools/install.sh",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}/buildtools"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Start Development Server",
|
||||||
|
"type": "shell",
|
||||||
|
"isBackground": true,
|
||||||
|
"command": "${workspaceFolder}/devserver/start.sh",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}/devserver"
|
||||||
|
},
|
||||||
|
"dependsOn": [
|
||||||
|
"Build Plugin to Development Server",
|
||||||
|
],
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"source": "Spigot Server",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}/src"
|
||||||
|
],
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^\\[\\d\\d:\\d\\d:\\d\\d\\] \\[[\\w\\s]+\/(\\w+)\\]: ([\\w \".()?]+\n[\\w \".()?:]+)$",
|
||||||
|
"severity": 1,
|
||||||
|
"message": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "^\\s+at ([\\w.$]+)\\((\\w+\\.java):(\\d+)\\) ~\\[.+:.+\\]$",
|
||||||
|
"file": 2,
|
||||||
|
"line": 3,
|
||||||
|
"loop": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
}
|
}
|
7
.woodpecker/package.yml
Normal file
7
.woodpecker/package.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
steps:
|
||||||
|
- name: package
|
||||||
|
image: maven:3.9.9-eclipse-temurin-21-alpine
|
||||||
|
commands:
|
||||||
|
- mvn package
|
||||||
|
depends_on:
|
||||||
|
- test
|
5
.woodpecker/test.yml
Normal file
5
.woodpecker/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
steps:
|
||||||
|
- name: test
|
||||||
|
image: maven:3.9.9-eclipse-temurin-21-alpine
|
||||||
|
commands:
|
||||||
|
- mvn test
|
29
Jenkinsfile
vendored
Normal file
29
Jenkinsfile
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
kubernetes {
|
||||||
|
cloud 'rsys-devel'
|
||||||
|
defaultContainer 'maven'
|
||||||
|
inheritFrom 'maven'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage("validate") {
|
||||||
|
steps {
|
||||||
|
sh "mvn validate"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("test") {
|
||||||
|
steps {
|
||||||
|
sh "mvn test"
|
||||||
|
xunit checksName: '', tools: [JUnit(excludesPattern: '', pattern: 'target/surefire-reports/TEST-*.xml', stopProcessingIfError: true)]
|
||||||
|
recordCoverage(tools: [[pattern: 'target/site/jacoco/jacoco.xml']])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("deploy") {
|
||||||
|
steps {
|
||||||
|
sh "mvn package"
|
||||||
|
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true, followSymlinks: false, onlyIfSuccessful: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
devserver/bukkit.yml
Normal file
32
devserver/bukkit.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
settings:
|
||||||
|
allow-end: true
|
||||||
|
warn-on-overload: false
|
||||||
|
permissions-file: permissions.yml
|
||||||
|
update-folder: update
|
||||||
|
plugin-profiling: false
|
||||||
|
connection-throttle: 4000
|
||||||
|
query-plugins: true
|
||||||
|
deprecated-verbose: default
|
||||||
|
shutdown-message: Server closed
|
||||||
|
minimum-api: none
|
||||||
|
use-map-color-cache: true
|
||||||
|
spawn-limits:
|
||||||
|
monsters: 70
|
||||||
|
animals: 10
|
||||||
|
water-animals: 5
|
||||||
|
water-ambient: 20
|
||||||
|
water-underground-creature: 5
|
||||||
|
axolotls: 5
|
||||||
|
ambient: 15
|
||||||
|
chunk-gc:
|
||||||
|
period-in-ticks: 600
|
||||||
|
ticks-per:
|
||||||
|
animal-spawns: 400
|
||||||
|
monster-spawns: 1
|
||||||
|
water-spawns: 1
|
||||||
|
water-ambient-spawns: 1
|
||||||
|
water-underground-creature-spawns: 1
|
||||||
|
axolotl-spawns: 1
|
||||||
|
ambient-spawns: 1
|
||||||
|
autosave: 6000
|
||||||
|
aliases: now-in-commands.yml
|
61
devserver/server.properties
Normal file
61
devserver/server.properties
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#Minecraft server properties
|
||||||
|
#Tue Nov 12 06:44:35 UTC 2024
|
||||||
|
allow-flight=false
|
||||||
|
allow-nether=true
|
||||||
|
broadcast-console-to-ops=true
|
||||||
|
broadcast-rcon-to-ops=true
|
||||||
|
debug=false
|
||||||
|
difficulty=easy
|
||||||
|
enable-command-block=false
|
||||||
|
enable-jmx-monitoring=false
|
||||||
|
enable-query=false
|
||||||
|
enable-rcon=false
|
||||||
|
enable-status=true
|
||||||
|
enforce-secure-profile=true
|
||||||
|
enforce-whitelist=false
|
||||||
|
entity-broadcast-range-percentage=100
|
||||||
|
force-gamemode=false
|
||||||
|
function-permission-level=2
|
||||||
|
gamemode=survival
|
||||||
|
generate-structures=true
|
||||||
|
generator-settings={}
|
||||||
|
hardcore=false
|
||||||
|
hide-online-players=false
|
||||||
|
initial-disabled-packs=
|
||||||
|
initial-enabled-packs=vanilla
|
||||||
|
level-name=world
|
||||||
|
level-seed=
|
||||||
|
level-type=minecraft\:normal
|
||||||
|
log-ips=true
|
||||||
|
max-chained-neighbor-updates=1000000
|
||||||
|
max-players=20
|
||||||
|
max-tick-time=600000
|
||||||
|
max-world-size=29999984
|
||||||
|
motd=A Minecraft Server
|
||||||
|
network-compression-threshold=256
|
||||||
|
online-mode=true
|
||||||
|
op-permission-level=4
|
||||||
|
player-idle-timeout=0
|
||||||
|
prevent-proxy-connections=false
|
||||||
|
pvp=true
|
||||||
|
query.port=25565
|
||||||
|
rate-limit=0
|
||||||
|
rcon.password=
|
||||||
|
rcon.port=25575
|
||||||
|
require-resource-pack=false
|
||||||
|
resource-pack=
|
||||||
|
resource-pack-id=
|
||||||
|
resource-pack-prompt=
|
||||||
|
resource-pack-sha1=
|
||||||
|
server-ip=
|
||||||
|
server-port=25565
|
||||||
|
simulation-distance=10
|
||||||
|
spawn-animals=true
|
||||||
|
spawn-monsters=true
|
||||||
|
spawn-npcs=true
|
||||||
|
spawn-protection=16
|
||||||
|
sync-chunk-writes=true
|
||||||
|
text-filtering-config=
|
||||||
|
use-native-transport=true
|
||||||
|
view-distance=10
|
||||||
|
white-list=false
|
@ -1,3 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
java -Xmx2G -XX:+UseG1GC -jar spigot.jar nogui
|
echo "Server started"
|
||||||
|
java -Xmx2G -XX:+UseG1GC -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar spigot.jar nogui
|
||||||
|
echo "Server stopped"
|
39
pom.xml
39
pom.xml
@ -47,6 +47,11 @@
|
|||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.18.0</version>
|
<version>2.18.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hive2hive</groupId>
|
||||||
|
<artifactId>org.hive2hive.core</artifactId>
|
||||||
|
<version>1.2.4</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
@ -54,5 +59,37 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>3.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.8.11</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>prepare-agent</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>report</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,57 @@
|
|||||||
|
package solutions.reslate.entertainment.spigotresourcesync;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommandController implements CommandExecutor {
|
||||||
|
private Set<String> names;
|
||||||
|
private Map<String, Command> commands;
|
||||||
|
|
||||||
|
|
||||||
|
public CommandController() {
|
||||||
|
super();
|
||||||
|
names = new HashSet<>();
|
||||||
|
names.add("resourcesync");
|
||||||
|
names.add("ressync");
|
||||||
|
commands = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCommand(Command command) {
|
||||||
|
if (command == null) throw new IllegalArgumentException("Command cannot be null!");
|
||||||
|
this.commands.put(command.getName(), command);
|
||||||
|
for (String alias : command.getAliases()) {
|
||||||
|
this.commands.put(alias, command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deregisterCommand(Command command) {
|
||||||
|
this.deregisterCommand(command.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deregisterCommand(String commandName) {
|
||||||
|
if (commandName == null || commandName.isBlank()) throw new IllegalArgumentException("Command name cannot be null or blank.");
|
||||||
|
Command removed = this.commands.remove(commandName);
|
||||||
|
for (String alias : removed.getAliases()) {
|
||||||
|
this.commands.remove(alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (args.length == 0) return false;
|
||||||
|
if (commands.containsKey(args[0])) {
|
||||||
|
Command subcommand = commands.get(args[0]);
|
||||||
|
return subcommand.execute(sender, label, Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,12 +5,14 @@ import java.io.File;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import solutions.reslate.entertainment.spigotresourcesync.commands.SyncCommand;
|
||||||
import solutions.reslate.entertainment.spigotresourcesync.serialisation.JacksonYamlSerialiser;
|
import solutions.reslate.entertainment.spigotresourcesync.serialisation.JacksonYamlSerialiser;
|
||||||
import solutions.reslate.entertainment.spigotresourcesync.synchronisation.ApacheCommonsIOSynchroniser;
|
import solutions.reslate.entertainment.spigotresourcesync.synchronisation.ApacheCommonsIOSynchroniser;
|
||||||
|
|
||||||
public class SpigotResourceSync extends JavaPlugin {
|
public class SpigotResourceSync extends JavaPlugin {
|
||||||
private ConfigManager configManager;
|
private ConfigManager configManager;
|
||||||
private SyncListManager syncListManager;
|
private SyncListManager syncListManager;
|
||||||
|
private CommandController commandController;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
@ -26,11 +28,15 @@ public class SpigotResourceSync extends JavaPlugin {
|
|||||||
if (configManager.getConfiguration().getSyncOnLoad()) {
|
if (configManager.getConfiguration().getSyncOnLoad()) {
|
||||||
syncListManager.synchroniseAllSyncList();
|
syncListManager.synchroniseAllSyncList();
|
||||||
}
|
}
|
||||||
|
commandController = new CommandController();
|
||||||
|
commandController.registerCommand(new SyncCommand(syncListManager));
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
getLogger().info(getName());
|
||||||
|
getCommand(getName()).setExecutor(commandController);
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +54,6 @@ public class SpigotResourceSync extends JavaPlugin {
|
|||||||
public void saveDefaultConfig() {
|
public void saveDefaultConfig() {
|
||||||
configManager.resetConfiguration();
|
configManager.resetConfiguration();
|
||||||
configManager.flush();
|
configManager.flush();
|
||||||
super.saveDefaultConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -36,6 +36,21 @@ public class SyncListManager implements ObjectLoadListener<Configuration> {
|
|||||||
logger.info("Done synchronising.");
|
logger.info("Done synchronising.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void synchroniseGroupSyncList(String group) {
|
||||||
|
logger.info("Synchronising group sync pairs...");
|
||||||
|
for (SyncPair syncPair : this.configuration.getSyncList().gatherGroupSyncPairs(group)) {
|
||||||
|
File source = new File(syncPair.getSource());
|
||||||
|
File dest = new File(syncPair.getDestination());
|
||||||
|
try {
|
||||||
|
synchroniser.sync(source, dest);
|
||||||
|
logger.info(String.format("Synchronised \"%s\" to \"%s\"!", source.getName(), dest.getName()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warning(String.format("Failed to synchronise \"%s\" to \"%s\". %s", source.getAbsolutePath(), dest.getAbsolutePath(), e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("Done synchronising.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void objectLoaded(Configuration obj) {
|
public void objectLoaded(Configuration obj) {
|
||||||
logger.info("Updating synchronisation list due to recently loading configuration...");
|
logger.info("Updating synchronisation list due to recently loading configuration...");
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package solutions.reslate.entertainment.spigotresourcesync.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import solutions.reslate.entertainment.spigotresourcesync.SyncListManager;
|
||||||
|
|
||||||
|
public class SyncCommand extends Command {
|
||||||
|
private SyncListManager syncListManager;
|
||||||
|
|
||||||
|
|
||||||
|
public SyncCommand(SyncListManager syncListManager) {
|
||||||
|
super(
|
||||||
|
"sync",
|
||||||
|
"Synchronise based off your configurations.",
|
||||||
|
"sync [sync group name]",
|
||||||
|
new ArrayList<>()
|
||||||
|
);
|
||||||
|
this.syncListManager = syncListManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
|
if (args.length > 1) return false;
|
||||||
|
if (args.length == 1) {
|
||||||
|
String groupName = args[0];
|
||||||
|
syncListManager.synchroniseGroupSyncList(groupName);
|
||||||
|
sender.sendMessage(String.format("Synchronisation of \"%s\" complete!", groupName));
|
||||||
|
} else {
|
||||||
|
syncListManager.synchroniseAllSyncList();
|
||||||
|
sender.sendMessage("Synchronisation of all items complete!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package solutions.reslate.entertainment.spigotresourcesync.data;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,12 +18,17 @@ public class SyncList implements Serializable {
|
|||||||
this.syncPairs = new LinkedHashMap<>();
|
this.syncPairs = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SyncPair> gatherAllSyncPairs() {
|
public SequencedCollection<SyncPair> gatherAllSyncPairs() {
|
||||||
List<SyncPair> allSyncPairs = new ArrayList<>();
|
List<SyncPair> allSyncPairs = new ArrayList<>();
|
||||||
for (SequencedCollection<SyncPair> syncPairs : this.syncPairs.values()) {
|
for (SequencedCollection<SyncPair> syncPairs : this.syncPairs.values()) {
|
||||||
allSyncPairs.addAll(syncPairs);
|
allSyncPairs.addAll(syncPairs);
|
||||||
}
|
}
|
||||||
return allSyncPairs;
|
return Collections.unmodifiableSequencedCollection(allSyncPairs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SequencedCollection<SyncPair> gatherGroupSyncPairs(String groupName) {
|
||||||
|
if (!this.syncPairs.containsKey(groupName)) throw new IllegalArgumentException(String.format("\"%s\" group does not exist!", groupName));
|
||||||
|
return Collections.unmodifiableSequencedCollection(this.syncPairs.get(groupName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSynchronisationPair(String source, String dest, String group) {
|
public void addSynchronisationPair(String source, String dest, String group) {
|
||||||
@ -52,8 +58,8 @@ public class SyncList implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> gatherSynchronisationGroups() {
|
public SequencedCollection<String> gatherSynchronisationGroups() {
|
||||||
return new ArrayList<>(this.syncPairs.keySet());
|
return Collections.unmodifiableSequencedCollection(new ArrayList<>(this.syncPairs.keySet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SequencedMap<String, SequencedCollection<SyncPair>> getSyncPairs() {
|
public SequencedMap<String, SequencedCollection<SyncPair>> getSyncPairs() {
|
||||||
|
@ -19,7 +19,7 @@ public class ApacheCommonsIOSynchroniser implements Synchroniser {
|
|||||||
if (dest.isDirectory()) {
|
if (dest.isDirectory()) {
|
||||||
FileUtils.copyDirectory(source, dest);
|
FileUtils.copyDirectory(source, dest);
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Cannot synchronise directy to non-directory!");
|
throw new IOException("Cannot synchronise directory to non-directory!");
|
||||||
// TODO add more detail to error message.
|
// TODO add more detail to error message.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
name: SpigotResourceSync
|
name: SpigotResourceSync
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
main: solutions.reslate.entertainment.spigotresourcesync.SpigotResourceSync
|
main: solutions.reslate.entertainment.spigotresourcesync.SpigotResourceSync
|
||||||
|
api-version: '1.20'
|
||||||
|
|
||||||
|
commands:
|
||||||
|
spigotresourcesync:
|
||||||
|
description: Tool suite for synchronisation resources across directories.
|
||||||
|
usage: See "/spigotresourcesync help" for help.
|
@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -27,6 +28,6 @@ public class TestConfigManager {
|
|||||||
assumeTrue(dummyConfig.exists());
|
assumeTrue(dummyConfig.exists());
|
||||||
ConfigManager finalConfigManager = new ConfigManager(dummyConfig, dummySerialiser, logger);
|
ConfigManager finalConfigManager = new ConfigManager(dummyConfig, dummySerialiser, logger);
|
||||||
finalConfigManager.load();
|
finalConfigManager.load();
|
||||||
assertEquals(dummySyncPair, finalConfigManager.getConfiguration().getSyncList().gatherAllSyncPairs().get(0));
|
assertEquals(dummySyncPair, new ArrayList<>(finalConfigManager.getConfiguration().getSyncList().gatherAllSyncPairs()).get(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package solutions.reslate.entertainment.spigotresourcesync.data;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class TestSyncList {
|
||||||
|
@Test
|
||||||
|
void testGatherSyncGroup() {
|
||||||
|
SyncList dummyList = new SyncList();
|
||||||
|
dummyList.addSynchronisationPair("abc", "def", "a");
|
||||||
|
dummyList.addSynchronisationPair("ghi", "jkl", "a");
|
||||||
|
dummyList.addSynchronisationPair("123", "456", "b");
|
||||||
|
assertEquals(new SyncPair("abc", "def"), dummyList.gatherGroupSyncPairs("a").getFirst());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user