mirror of
https://github.com/ProjectSWGCore/forwarder.git
synced 2026-10-03 20:12:54 -04:00
Updated Forwarder with gradle and the PSWGCommon library
This commit is contained in:
+5
-1
@@ -1,7 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/">
|
||||
<accessrules>
|
||||
<accessrule kind="accessible" pattern="javafx/**"/>
|
||||
</accessrules>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
include ':PSWGCommon', ':Client Holocore'
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***********************************************************************************/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user