Skip to content

Commit

Permalink
Merge pull request #199 from rheimus/master
Browse files Browse the repository at this point in the history
Initial manifest style sync support
  • Loading branch information
rheimus authored Sep 19, 2020
2 parents a4a208c + 1f8a506 commit b08da75
Show file tree
Hide file tree
Showing 50 changed files with 1,777 additions and 1,380 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clean-old-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Clean old artifacts

on:
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * 0'

jobs:
delete-artifacts:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ $RECYCLE.BIN/
# =========================
# Working Dir
# =========================
serversync-server.json
serversync-client.json
*.pydevproject
.project
.metadata
Expand Down
64 changes: 61 additions & 3 deletions config-server-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{
"file_ignore_list": [
{
"pattern": "**/*.jar"
"pattern": "\\*\\*/*.jar"
}
],
"directory_include_list": [
Expand Down Expand Up @@ -198,7 +198,7 @@
"examples": [
[
{
"pattern": "**/*.jar",
"pattern": "\\*\\*/*.jar",
"description": "No JARs"
}
]
Expand All @@ -215,7 +215,7 @@
"default": {},
"examples": [
{
"pattern": "**/*.jar",
"pattern": "\\*\\*/*.jar",
"description": "No JARs"
}
],
Expand Down Expand Up @@ -260,6 +260,64 @@
}
]
}
},
"redirect_files": {
"$id": "#/properties/rules/properties/redirect_files",
"type": "array",
"description": "A list of patterns for redirecting files to a different location on the client",
"default": [],
"examples": [
{
"pattern": "\\*\\*/\\*.jar",
"redirectTo": "ignored-mods"
}
],
"additionalItems": true,
"items": {
"$id": "#/properties/rules/properties/redirect_files/items",
"anyOf": [
{
"$id": "#/properties/rules/properties/redirect_files/items/anyOf/0",
"type": "object",
"title": "Detailed configuration",
"description": "Used to specify extra information about a pattern",
"default": {},
"examples": [
{
"pattern": "\\*\\*/\\*.jar",
"redirectTo": "ignored-mods"
}
],
"required": [
"pattern",
"redirectTo"
],
"additionalProperties": true,
"properties": {
"redirectTo": {
"$id": "#/properties/rules/properties/file_ignore_list/items/anyOf/0/properties/redirectTo",
"type": "string",
"title": "Where to redirect the file on the client",
"description": "This is where the file should end up on the client relative to the 'rootDir'",
"default": "",
"examples": [
"some-place"
]
},
"pattern": {
"$id": "#/properties/rules/properties/file_ignore_list/items/anyOf/0/properties/pattern",
"type": "string",
"title": "The pattern to match against",
"description": "Matches using GLOB patterns",
"default": "",
"examples": [
"**/*.jar"
]
}
}
}
]
}
}
}
},
Expand Down
31 changes: 27 additions & 4 deletions src/main/java/com/superzanti/serversync/ServerSync.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.superzanti.serversync;

import com.superzanti.serversync.client.ClientWorker;
import com.superzanti.serversync.config.ConfigLoader;
import com.superzanti.serversync.config.SyncConfig;
import com.superzanti.serversync.gui.GUI_Client;
import com.superzanti.serversync.gui.GUI_Client_Mock;
import com.superzanti.serversync.server.ServerSetup;
import com.superzanti.serversync.util.Logger;
import com.superzanti.serversync.util.enums.EConfigType;
import com.superzanti.serversync.util.enums.EServerMode;
import picocli.CommandLine;
import picocli.CommandLine.*;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Locale;
import java.util.MissingResourceException;
Expand All @@ -21,12 +27,16 @@ public class ServerSync implements Callable<Integer> {
/* AWT EVENT DISPATCHER THREAD */

public static final String APPLICATION_TITLE = "Serversync";
public static final String HANDSHAKE = "HANDSHAKE";
public static final String GET_SERVER_INFO = "SERVER_INFO";
public static EServerMode MODE;

public static GUI_Client clientGUI;
public static ResourceBundle strings;

public static Path rootDir = Paths.get(System.getProperty("user.dir"));

@Option(names = {"-r", "--root"}, description = "The root directory of the game, defaults to the current working directory.")
private String rootDirectory = System.getProperty("user.dir");
@Option(names = {"-o", "--progress", "progress-only"}, description = "Only show progress indication. Ignored if '-s', '--server' is specified.")
private boolean modeProgressOnly = false;
@Option(names = {"-q", "--quiet", "silent"}, description = "Remove all GUI interaction. Ignored if '-s', '--server' is specified.")
Expand All @@ -49,6 +59,7 @@ public static void main(String[] args) {

@Override
public Integer call() {
ServerSync.rootDir = Paths.get(rootDirectory);
if (modeServer) {
runInServerMode();
} else {
Expand Down Expand Up @@ -82,6 +93,12 @@ private void runInServerMode() {
ServerSync.MODE = EServerMode.SERVER;
new Logger("server");
Logger.setSystemOutput(true);
try {
ConfigLoader.load(EConfigType.SERVER);
} catch (IOException e) {
Logger.error("Failed to load server config");
Logger.debug(e);
}
commonInit();

ServerSetup setup = new ServerSetup();
Expand All @@ -93,11 +110,17 @@ private void runInClientMode() {
ServerSync.MODE = EServerMode.CLIENT;
new Logger("client");
SyncConfig config = SyncConfig.getConfig();
try {
ConfigLoader.load(EConfigType.CLIENT);
} catch (IOException e) {
Logger.error("Failed to load client config");
e.printStackTrace();
}
commonInit();

Thread clientThread;
if (modeQuiet) {
clientGUI = new GUI_Client_Mock();
clientGUI = null;
new Thread(new ClientWorker()).start();
} else if (modeProgressOnly) {
// TODO setup a progress only version of the GUI
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/superzanti/serversync/ServerSyncServer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.superzanti.serversync;

/**
* Wrapper for executables to call when starting in server mode
*/
public class ServerSyncServer {
public static void main(String[] args) {
ServerSync.main(new String[]{"server"});
Expand Down
Loading

0 comments on commit b08da75

Please sign in to comment.