diff --git a/.classpath b/.classpath
index 2ebdd55..8b7d01e 100644
--- a/.classpath
+++ b/.classpath
@@ -1,7 +1,11 @@
-
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..ee48e35
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,45 @@
+apply plugin: 'application'
+apply plugin: 'com.github.johnrengelman.shadow'
+apply plugin: 'java'
+
+mainClassName = 'com.projectswg.Forwarder'
+
+manifest {
+ attributes 'Main-Class': 'com.projectswg.Forwarder'
+}
+
+sourceSets {
+ main {
+ java {
+ srcDirs = ['src']
+ includes ['**/*.java']
+ }
+ }
+}
+
+shadowJar {
+ archiveName = "Forwarder.jar"
+}
+
+dependencies {
+ compile project(':PSWGCommon')
+ compile project(':Client Holocore')
+ compileOnly fileTree(dir: 'lib', include: ['*.jar'])
+}
+
+repositories {
+ jcenter()
+}
+
+dependencies {
+
+}
+
+buildscript {
+ repositories {
+ maven { url 'https://plugins.gradle.org/m2/' }
+ }
+ dependencies {
+ classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.0'
+ }
+}
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..dbdb1bd
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':PSWGCommon', ':Client Holocore'
diff --git a/src/com/projectswg/Connections.java b/src/com/projectswg/Connections.java
index 625318e..8b3106d 100644
--- a/src/com/projectswg/Connections.java
+++ b/src/com/projectswg/Connections.java
@@ -4,6 +4,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.atomic.AtomicLong;
+import com.projectswg.common.concurrency.Delay;
import com.projectswg.common.control.IntentManager;
import com.projectswg.common.control.Manager;
import com.projectswg.common.debug.Log;
@@ -18,7 +19,6 @@ import com.projectswg.networking.client.ClientConnectionService;
import com.projectswg.networking.server.ServerConnectionService;
import com.projectswg.networking.soe.Disconnect.DisconnectReason;
import com.projectswg.services.PacketRecordingService;
-import com.projectswg.utilities.ThreadUtilities;
import network.packets.swg.ErrorMessage;
@@ -130,7 +130,7 @@ public class Connections extends Manager {
}
client.sendPackaged(new ErrorMessage(title, text, false));
client.waitForClientAcknowledge();
- ThreadUtilities.sleep(100);
+ Delay.sleepMilli(100);
client.disconnect(DisconnectReason.OTHER_SIDE_TERMINATED);
}
}
diff --git a/src/com/projectswg/HolocoreConnection.java b/src/com/projectswg/HolocoreConnection.java
index 3f55961..f465070 100644
--- a/src/com/projectswg/HolocoreConnection.java
+++ b/src/com/projectswg/HolocoreConnection.java
@@ -5,10 +5,10 @@ import java.net.UnknownHostException;
import java.util.concurrent.atomic.AtomicBoolean;
import com.projectswg.Connections.ConnectionCallback;
+import com.projectswg.common.concurrency.Delay;
import com.projectswg.common.debug.Log;
import com.projectswg.networking.NetInterceptor.InterceptorProperties;
import com.projectswg.resources.HolocorePreferences;
-import com.projectswg.utilities.ThreadUtilities;
public class HolocoreConnection {
@@ -58,7 +58,7 @@ public class HolocoreConnection {
Log.e("Failed to initialize");
connections.stop();
connections.terminate();
- if (!ThreadUtilities.sleep(50)) {
+ if (Delay.sleepMilli(50)) {
Log.e("Interrupted while connecting!");
return;
}
diff --git a/src/com/projectswg/networking/UDPServer.java b/src/com/projectswg/networking/UDPServer.java
index c4bc9db..ffdeda5 100644
--- a/src/com/projectswg/networking/UDPServer.java
+++ b/src/com/projectswg/networking/UDPServer.java
@@ -39,9 +39,9 @@ import java.util.Locale;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.projectswg.common.concurrency.Delay;
import com.projectswg.common.debug.Assert;
import com.projectswg.common.debug.Log;
-import com.projectswg.utilities.ThreadUtilities;
/**
* This class represents a UDP server that listens for packets and
@@ -97,7 +97,7 @@ public class UDPServer {
int port = socket.getLocalPort();
while (port == 0) {
port = socket.getLocalPort();
- if (!ThreadUtilities.sleep(5))
+ if (Delay.sleepMilli(5))
break;
}
return port;
diff --git a/src/com/projectswg/networking/client/ClientConnectionService.java b/src/com/projectswg/networking/client/ClientConnectionService.java
index f7ffe2d..9e39045 100644
--- a/src/com/projectswg/networking/client/ClientConnectionService.java
+++ b/src/com/projectswg/networking/client/ClientConnectionService.java
@@ -16,7 +16,7 @@ import com.projectswg.networking.soe.Disconnect.DisconnectReason;
import com.projectswg.resources.ClientConnectionStatus;
import network.packets.swg.SWGPacket;
-import network.packets.swg.zone.HeartBeat;
+import com.projectswg.common.network.packets.swg.zone.HeartBeat;
public class ClientConnectionService extends Manager implements ClientPacketSender {
diff --git a/src/com/projectswg/networking/server/ServerConnectionService.java b/src/com/projectswg/networking/server/ServerConnectionService.java
index 6f85c7d..2b02da7 100644
--- a/src/com/projectswg/networking/server/ServerConnectionService.java
+++ b/src/com/projectswg/networking/server/ServerConnectionService.java
@@ -7,6 +7,7 @@ import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import com.projectswg.common.concurrency.Delay;
import com.projectswg.common.concurrency.PswgBasicScheduledThread;
import com.projectswg.common.concurrency.PswgBasicThread;
import com.projectswg.common.control.IntentChain;
@@ -21,9 +22,8 @@ import com.projectswg.intents.ClientConnectionChangedIntent;
import com.projectswg.intents.ClientToServerPacketIntent;
import com.projectswg.intents.ServerConnectionChangedIntent;
import com.projectswg.intents.ServerToClientPacketIntent;
-import com.projectswg.utilities.ThreadUtilities;
-import network.packets.swg.zone.HeartBeat;
+import com.projectswg.common.network.packets.swg.zone.HeartBeat;
public class ServerConnectionService extends Service {
@@ -158,7 +158,7 @@ public class ServerConnectionService extends Service {
try {
while (thread.isRunning()) {
if (connection.isDisconnected() && !tryConnect()) {
- ThreadUtilities.sleep(1000);
+ Delay.sleepMilli(1000);
continue;
}
Assert.test(connection.isConnected());
diff --git a/src/com/projectswg/utilities/ThreadUtilities.java b/src/com/projectswg/utilities/ThreadUtilities.java
deleted file mode 100644
index 91ba007..0000000
--- a/src/com/projectswg/utilities/ThreadUtilities.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/***********************************************************************************
-* Copyright (c) 2015 /// Project SWG /// www.projectswg.com *
-* *
-* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
-* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
-* Our goal is to create an emulator which will provide a server for players to *
-* continue playing a game similar to the one they used to play. We are basing *
-* it on the final publish of the game prior to end-game events. *
-* *
-* This file is part of Holocore. *
-* *
-* -------------------------------------------------------------------------------- *
-* *
-* Holocore is free software: you can redistribute it and/or modify *
-* it under the terms of the GNU Affero General Public License as *
-* published by the Free Software Foundation, either version 3 of the *
-* License, or (at your option) any later version. *
-* *
-* Holocore is distributed in the hope that it will be useful, *
-* but WITHOUT ANY WARRANTY; without even the implied warranty of *
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-* GNU Affero General Public License for more details. *
-* *
-* You should have received a copy of the GNU Affero General Public License *
-* along with Holocore. If not, see . *
-* *
-***********************************************************************************/
-package com.projectswg.utilities;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.locks.LockSupport;
-
-public class ThreadUtilities {
-
- public static boolean sleep(long time) {
- return sleepNano(time * 1000000);
- }
-
- public static boolean sleepNano(long time) {
- LockSupport.parkNanos(time);
- return Thread.currentThread().isInterrupted();
- }
-
- public static boolean sleepUntil(long milliSinceEpoch) {
- LockSupport.parkUntil(milliSinceEpoch);
- return Thread.currentThread().isInterrupted();
- }
-
- public static ThreadFactory newThreadFactory(String pattern) {
- return new CustomThreadFactory(pattern);
- }
-
- private static class CustomThreadFactory implements ThreadFactory {
-
- private final String pattern;
- private int counter;
-
- public CustomThreadFactory(String pattern) {
- this.pattern = pattern;
- this.counter = 0;
- }
-
- @Override
- public Thread newThread(Runnable r) {
- String name;
- if (pattern.contains("%d"))
- name = String.format(pattern, counter++);
- else
- name = pattern;
- return new Thread(r, name);
- }
-
- }
-
-}