diff --git a/.classpath b/.classpath
index 19a2f0421..16ca8f86e 100644
--- a/.classpath
+++ b/.classpath
@@ -27,5 +27,6 @@
+
diff --git a/lib/PSWGCommon.jar b/lib/PSWGCommon.jar
new file mode 100644
index 000000000..9d38bbf75
Binary files /dev/null and b/lib/PSWGCommon.jar differ
diff --git a/src/intents/BuffIntent.java b/src/intents/BuffIntent.java
index 50e9b0b90..00b6b3221 100644
--- a/src/intents/BuffIntent.java
+++ b/src/intents/BuffIntent.java
@@ -27,37 +27,35 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-public class BuffIntent extends Intent {
+import com.projectswg.common.control.Intent;
- public static final String TYPE = "BuffIntent";
+public class BuffIntent extends Intent {
private final String buffName;
private final CreatureObject buffer, receiver;
private final boolean remove;
public BuffIntent(String buffName, CreatureObject buffer, CreatureObject receiver, boolean remove) {
- super(TYPE);
this.buffName = buffName;
this.buffer = buffer;
this.receiver = receiver;
this.remove = remove;
}
-
+
public CreatureObject getReceiver() {
return receiver;
}
-
+
public CreatureObject getBuffer() {
return buffer;
}
-
+
public String getBuffName() {
return buffName;
}
-
+
public boolean isRemove() {
return remove;
}
diff --git a/src/intents/DanceIntent.java b/src/intents/DanceIntent.java
index 4c02e7f1c..6e1921d0d 100644
--- a/src/intents/DanceIntent.java
+++ b/src/intents/DanceIntent.java
@@ -27,26 +27,22 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-/**
- *
- * @author Mads
- */
+import com.projectswg.common.control.Intent;
+
public class DanceIntent extends Intent {
- public static final String TYPE = "DanceIntent";
private final String danceName;
private final CreatureObject creatureObject;
private final boolean changeDance;
/**
* Start dancing
+ *
* @param danceName
- * @param creatureObject
+ * @param creatureObject
*/
public DanceIntent(String danceName, CreatureObject creatureObject, boolean changeDance) {
- super(TYPE);
this.danceName = danceName;
this.creatureObject = creatureObject;
this.changeDance = changeDance;
@@ -54,16 +50,17 @@ public class DanceIntent extends Intent {
/**
* Stop dancing
- * @param creatureObject
+ *
+ * @param creatureObject
*/
public DanceIntent(CreatureObject creatureObject) {
this(null, creatureObject, false);
}
-
+
public String getDanceName() {
return danceName;
}
-
+
public CreatureObject getCreatureObject() {
return creatureObject;
}
@@ -71,7 +68,7 @@ public class DanceIntent extends Intent {
public boolean isStartDance() {
return danceName != null;
}
-
+
public boolean isChangeDance() {
return changeDance;
}
diff --git a/src/intents/FactionIntent.java b/src/intents/FactionIntent.java
index 9cceb1025..ba50ad789 100644
--- a/src/intents/FactionIntent.java
+++ b/src/intents/FactionIntent.java
@@ -29,19 +29,18 @@ package intents;
import resources.PvpFaction;
import resources.PvpStatus;
-import resources.control.Intent;
import resources.objects.tangible.TangibleObject;
-public class FactionIntent extends Intent {
+import com.projectswg.common.control.Intent;
- public static final String TYPE = "FactionIntent";
+public class FactionIntent extends Intent {
+
private TangibleObject target;
private PvpFaction newFaction;
private FactionIntentType updateType;
private PvpStatus newStatus;
private FactionIntent(TangibleObject target) {
- super(TYPE);
this.target = target;
}
@@ -71,7 +70,7 @@ public class FactionIntent extends Intent {
public FactionIntentType getUpdateType() {
return updateType;
}
-
+
public PvpStatus getNewStatus() {
return newStatus;
}
@@ -83,4 +82,4 @@ public class FactionIntent extends Intent {
FACTIONUPDATE // Is automatically set in the correct constructor, don't use manually.
}
-}
\ No newline at end of file
+}
diff --git a/src/intents/FlourishIntent.java b/src/intents/FlourishIntent.java
index f83e30b69..5c8c5f233 100644
--- a/src/intents/FlourishIntent.java
+++ b/src/intents/FlourishIntent.java
@@ -27,30 +27,24 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
import resources.player.Player;
-/**
- *
- * @author Mads
- */
+import com.projectswg.common.control.Intent;
+
public class FlourishIntent extends Intent {
- public static final String TYPE = "FlourishIntent";
-
private final Player performer;
private final String flourishName;
-
+
public FlourishIntent(Player performer, String flourishName) {
- super(TYPE);
this.performer = performer;
this.flourishName = flourishName;
}
-
+
public Player getPerformer() {
return performer;
}
-
+
public String getFlourishName() {
return flourishName;
}
diff --git a/src/intents/GalacticIntent.java b/src/intents/GalacticIntent.java
index ca62db586..831e4b559 100644
--- a/src/intents/GalacticIntent.java
+++ b/src/intents/GalacticIntent.java
@@ -27,7 +27,8 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
+import com.projectswg.common.control.Intent;
+
import services.galaxy.GalacticManager;
import services.objects.ObjectManager;
import services.player.PlayerManager;
@@ -36,12 +37,11 @@ public abstract class GalacticIntent extends Intent {
private GalacticManager galacticManager;
- protected GalacticIntent(String type) {
- super(type);
+ protected GalacticIntent() {
+
}
protected GalacticIntent(GalacticIntent i) {
- super(i.getType());
setGalacticManager(i.getGalacticManager());
}
diff --git a/src/intents/GrantBadgeIntent.java b/src/intents/GrantBadgeIntent.java
index 1fbd6d036..d33ec3c35 100644
--- a/src/intents/GrantBadgeIntent.java
+++ b/src/intents/GrantBadgeIntent.java
@@ -26,27 +26,26 @@
******************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
+import com.projectswg.common.control.Intent;
+
public class GrantBadgeIntent extends Intent {
- public static final String TYPE = "GrantBadgeIntent";
private CreatureObject creature;
private String collectionBadgeName;
- public GrantBadgeIntent(CreatureObject creature, String collectionBadgeName){
- super(TYPE);
+ public GrantBadgeIntent(CreatureObject creature, String collectionBadgeName) {
this.creature = creature;
this.collectionBadgeName = collectionBadgeName;
}
- public CreatureObject getCreature(){
+ public CreatureObject getCreature() {
return creature;
}
- public String getCollectionBadgeName(){
+ public String getCollectionBadgeName() {
return collectionBadgeName;
}
}
diff --git a/src/intents/GrantClickyCollectionIntent.java b/src/intents/GrantClickyCollectionIntent.java
index 616652953..49406b093 100644
--- a/src/intents/GrantClickyCollectionIntent.java
+++ b/src/intents/GrantClickyCollectionIntent.java
@@ -26,36 +26,32 @@
******************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.objects.collections.CollectionItem;
import resources.objects.creature.CreatureObject;
-/**
- * Created by Yakattak on 9/8/16.
- */
-public class GrantClickyCollectionIntent extends Intent {
- public static final String TYPE = "GrantClickyCollectionIntent";
+import com.projectswg.common.control.Intent;
+public class GrantClickyCollectionIntent extends Intent {
+
private CreatureObject creature;
private SWGObject inventoryItem;
private CollectionItem collection;
-
+
public GrantClickyCollectionIntent(CreatureObject creature, SWGObject inventoryItem, CollectionItem collection) {
- super(TYPE);
this.creature = creature;
this.inventoryItem = inventoryItem;
this.collection = collection;
}
-
+
public CreatureObject getCreature() {
return creature;
}
-
+
public SWGObject getInventoryItem() {
return inventoryItem;
}
-
+
public CollectionItem getCollection() {
return collection;
}
diff --git a/src/intents/GroupEventIntent.java b/src/intents/GroupEventIntent.java
index 960952403..f6c654588 100644
--- a/src/intents/GroupEventIntent.java
+++ b/src/intents/GroupEventIntent.java
@@ -24,48 +24,41 @@
* You should have received a copy of the GNU Affero General Public License
* along with Holocore. If not, see
******************************************************************************/
-
package intents;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
-/**
- * Created by Waverunner on 10/4/2015
- */
-public class GroupEventIntent extends Intent {
- public static final String TYPE = "GroupEventIntent";
+import com.projectswg.common.control.Intent;
+public class GroupEventIntent extends Intent {
private GroupEventType eventType;
private Player player;
private CreatureObject target;
-
+
public GroupEventIntent(GroupEventType eventType, Player player, CreatureObject target) {
- super(TYPE);
this.eventType = eventType;
this.player = player;
this.target = target;
}
-
+
public GroupEventIntent(GroupEventType eventType, Player player) {
- super(TYPE);
this.eventType = eventType;
this.player = player;
}
-
+
public GroupEventType getEventType() {
return eventType;
}
-
+
public Player getPlayer() {
return player;
}
-
+
public CreatureObject getTarget() {
return target;
}
-
+
public enum GroupEventType {
GROUP_INVITE,
GROUP_UNINVITE,
@@ -77,4 +70,4 @@ public class GroupEventIntent extends Intent {
GROUP_KICK,
GROUP_MAKE_MASTER_LOOTER
}
-}
\ No newline at end of file
+}
diff --git a/src/intents/LoginEventIntent.java b/src/intents/LoginEventIntent.java
index ef705b4c3..4a24bd20a 100644
--- a/src/intents/LoginEventIntent.java
+++ b/src/intents/LoginEventIntent.java
@@ -27,17 +27,14 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
+import com.projectswg.common.control.Intent;
public class LoginEventIntent extends Intent {
- public static final String TYPE = "LoginEventIntent";
-
private LoginEvent event;
private long networkId;
public LoginEventIntent(long networkId, LoginEvent event) {
- super(TYPE);
setNetworkId(networkId);
setEvent(event);
}
@@ -59,11 +56,7 @@ public class LoginEventIntent extends Intent {
}
public enum LoginEvent {
- LOGIN_FAIL_INVALID_VERSION_CODE,
- LOGIN_FAIL_INVALID_USER_PASS,
- LOGIN_FAIL_SERVER_ERROR,
- LOGIN_FAIL_BANNED,
- LOGIN_SUCCESS
+ LOGIN_FAIL_INVALID_VERSION_CODE, LOGIN_FAIL_INVALID_USER_PASS, LOGIN_FAIL_SERVER_ERROR, LOGIN_FAIL_BANNED, LOGIN_SUCCESS
}
}
diff --git a/src/intents/NotifyPlayersPacketIntent.java b/src/intents/NotifyPlayersPacketIntent.java
index 64da68fae..12df53e5c 100644
--- a/src/intents/NotifyPlayersPacketIntent.java
+++ b/src/intents/NotifyPlayersPacketIntent.java
@@ -27,55 +27,64 @@
***********************************************************************************/
package intents;
-import network.packets.Packet;
-import resources.Terrain;
-import resources.control.Intent;
-import resources.player.Player;
-
import java.util.List;
-public class NotifyPlayersPacketIntent extends Intent {
+import network.packets.Packet;
+import resources.Terrain;
+import resources.player.Player;
- public static final String TYPE = "GalaxyWidePacketIntent";
+import com.projectswg.common.control.Intent;
+
+public class NotifyPlayersPacketIntent extends Intent {
private Packet packet;
private Terrain terrain;
private List networkIds;
private ConditionalNotify condition;
-
+
public NotifyPlayersPacketIntent(Packet packet, Terrain terrain, ConditionalNotify condition, List networkIds) {
- super(TYPE);
this.packet = packet;
this.terrain = terrain;
this.condition = condition;
this.networkIds = networkIds;
}
-
+
public NotifyPlayersPacketIntent(Packet packet, Terrain terrain, ConditionalNotify condition) {
this(packet, terrain, condition, null);
}
-
+
public NotifyPlayersPacketIntent(Packet packet, ConditionalNotify condition, List networkIds) {
this(packet, null, condition, networkIds);
}
-
+
public NotifyPlayersPacketIntent(Packet packet, List networkIds) {
this(packet, null, null, networkIds);
}
-
+
public NotifyPlayersPacketIntent(Packet packet, Terrain terrain) {
this(packet, terrain, null);
}
-
+
public NotifyPlayersPacketIntent(Packet p) {
this(p, null, null, null);
}
-
- public Packet getPacket() { return packet; }
- public Terrain getTerrain() { return terrain; }
- public ConditionalNotify getCondition() { return condition; }
- public List getNetworkIds() { return networkIds; }
-
+
+ public Packet getPacket() {
+ return packet;
+ }
+
+ public Terrain getTerrain() {
+ return terrain;
+ }
+
+ public ConditionalNotify getCondition() {
+ return condition;
+ }
+
+ public List getNetworkIds() {
+ return networkIds;
+ }
+
public interface ConditionalNotify {
boolean meetsCondition(Player player);
}
diff --git a/src/intents/PlayerEventIntent.java b/src/intents/PlayerEventIntent.java
index 246c58ebb..43698258e 100644
--- a/src/intents/PlayerEventIntent.java
+++ b/src/intents/PlayerEventIntent.java
@@ -27,19 +27,17 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
+import com.projectswg.common.control.Intent;
+
import resources.player.Player;
import resources.player.PlayerEvent;
public class PlayerEventIntent extends Intent {
- public static final String TYPE = "PlayerEventIntent";
-
private Player player;
private PlayerEvent event;
public PlayerEventIntent(Player p, PlayerEvent event) {
- super(TYPE);
setPlayer(p);
setEvent(event);
}
diff --git a/src/intents/RequestZoneInIntent.java b/src/intents/RequestZoneInIntent.java
index 2f5423b0f..9a1249192 100644
--- a/src/intents/RequestZoneInIntent.java
+++ b/src/intents/RequestZoneInIntent.java
@@ -27,19 +27,17 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
+import com.projectswg.common.control.Intent;
+
public class RequestZoneInIntent extends Intent {
- public static final String TYPE = "ZoneInIntent";
-
private Player player;
private CreatureObject creature;
public RequestZoneInIntent(Player player, CreatureObject creature) {
- super(TYPE);
setPlayer(player);
setCreature(creature);
}
diff --git a/src/intents/SkillModIntent.java b/src/intents/SkillModIntent.java
index f8b147df9..317845960 100644
--- a/src/intents/SkillModIntent.java
+++ b/src/intents/SkillModIntent.java
@@ -27,12 +27,11 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-public class SkillModIntent extends Intent {
+import com.projectswg.common.control.Intent;
- public static final String TYPE = "SkillModIntent";
+public class SkillModIntent extends Intent {
private final String skillModName;
private final int adjustBase;
@@ -40,21 +39,20 @@ public class SkillModIntent extends Intent {
private final CreatureObject[] affectedCreatures;
public SkillModIntent(String skillModName, int adjustBase, int adjustModifier, CreatureObject... affectedCreatures) {
- super(TYPE);
this.skillModName = skillModName;
this.adjustBase = adjustBase;
this.adjustModifier = adjustModifier;
this.affectedCreatures = affectedCreatures;
}
-
+
public int getAdjustModifier() {
return adjustModifier;
}
-
+
public int getAdjustBase() {
return adjustBase;
}
-
+
public String getSkillModName() {
return skillModName;
}
diff --git a/src/intents/WatchIntent.java b/src/intents/WatchIntent.java
index d1085e73e..defe4145e 100644
--- a/src/intents/WatchIntent.java
+++ b/src/intents/WatchIntent.java
@@ -27,36 +27,31 @@
***********************************************************************************/
package intents;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
-/**
- *
- * @author Mads
- */
+import com.projectswg.common.control.Intent;
+
public class WatchIntent extends Intent {
- public static final String TYPE = "WatchIntent";
private final CreatureObject actor;
private final SWGObject target;
private final boolean startWatch;
public WatchIntent(CreatureObject actor, SWGObject target, boolean startWatch) {
- super(TYPE);
this.actor = actor;
this.target = target;
this.startWatch = startWatch;
}
-
+
public CreatureObject getActor() {
return actor;
}
-
+
public SWGObject getTarget() {
return target;
}
-
+
public boolean isStartWatch() {
return startWatch;
}
diff --git a/src/intents/chat/ChatAvatarRequestIntent.java b/src/intents/chat/ChatAvatarRequestIntent.java
index 1e3902148..9f1c88c49 100644
--- a/src/intents/chat/ChatAvatarRequestIntent.java
+++ b/src/intents/chat/ChatAvatarRequestIntent.java
@@ -24,41 +24,36 @@
* You should have received a copy of the GNU Affero General Public License
* along with Holocore. If not, see
******************************************************************************/
-
package intents.chat;
-import resources.control.Intent;
import resources.player.Player;
-/**
- * @author Waverunner
- */
-public class ChatAvatarRequestIntent extends Intent{
- public static final String TYPE = "ChatAvatarRequestIntent";
+import com.projectswg.common.control.Intent;
+public class ChatAvatarRequestIntent extends Intent {
+
private Player player;
private String target;
private RequestType requestType;
-
+
public ChatAvatarRequestIntent(Player player, String target, RequestType requestType) {
- super(TYPE);
this.player = player;
this.target = target;
this.requestType = requestType;
}
-
+
public Player getPlayer() {
return player;
}
-
+
public String getTarget() {
return target;
}
-
+
public RequestType getRequestType() {
return requestType;
}
-
+
public enum RequestType {
FRIEND_LIST,
TARGET_STATUS,
diff --git a/src/intents/chat/ChatBroadcastIntent.java b/src/intents/chat/ChatBroadcastIntent.java
index f5ac2592c..119efe10a 100644
--- a/src/intents/chat/ChatBroadcastIntent.java
+++ b/src/intents/chat/ChatBroadcastIntent.java
@@ -27,15 +27,14 @@
***********************************************************************************/
package intents.chat;
+import com.projectswg.common.control.Intent;
+
import resources.Terrain;
-import resources.control.Intent;
import resources.encodables.ProsePackage;
import resources.player.Player;
public class ChatBroadcastIntent extends Intent {
- public static final String TYPE = "ChatBroadcastIntent";
-
private BroadcastType broadcastType;
private Player broadcaster;
private Terrain terrain;
@@ -43,7 +42,6 @@ public class ChatBroadcastIntent extends Intent {
private ProsePackage prose;
public ChatBroadcastIntent(String message, Player broadcaster, Terrain terrain, BroadcastType type) {
- super(TYPE);
this.message = message;
this.broadcastType = type;
this.broadcaster = broadcaster;
diff --git a/src/intents/chat/ChatCommandIntent.java b/src/intents/chat/ChatCommandIntent.java
index 8a7969c41..9e8acf6aa 100644
--- a/src/intents/chat/ChatCommandIntent.java
+++ b/src/intents/chat/ChatCommandIntent.java
@@ -27,22 +27,20 @@
***********************************************************************************/
package intents.chat;
+import com.projectswg.common.control.Intent;
+
import resources.commands.Command;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
public class ChatCommandIntent extends Intent {
- public static final String TYPE = "ChatCommandIntent";
-
private CreatureObject source;
private SWGObject target;
private Command command;
private String [] arguments;
public ChatCommandIntent() {
- super(TYPE);
setSource(null);
setTarget(null);
setCommand(null);
@@ -50,7 +48,6 @@ public class ChatCommandIntent extends Intent {
}
public ChatCommandIntent(CreatureObject source, SWGObject target, Command command, String [] arguments) {
- super(TYPE);
setSource(source);
setTarget(target);
setCommand(command);
diff --git a/src/intents/chat/ChatRoomUpdateIntent.java b/src/intents/chat/ChatRoomUpdateIntent.java
index 79ae01c7a..4fa75891e 100644
--- a/src/intents/chat/ChatRoomUpdateIntent.java
+++ b/src/intents/chat/ChatRoomUpdateIntent.java
@@ -24,19 +24,15 @@
* You should have received a copy of the GNU Affero General Public License
* along with Holocore. If not, see
******************************************************************************/
-
package intents.chat;
import resources.chat.ChatAvatar;
-import resources.control.Intent;
import resources.player.Player;
-/**
- * @author Waverunner
- */
-public class ChatRoomUpdateIntent extends Intent {
- public static final String TYPE = "ChatRoomUpdateIntent";
+import com.projectswg.common.control.Intent;
+public class ChatRoomUpdateIntent extends Intent {
+
private String path;
private String title;
private String target;
@@ -46,30 +42,36 @@ public class ChatRoomUpdateIntent extends Intent {
private boolean isPublic;
private Player player;
private boolean ignoreInvitation;
-
+
public ChatRoomUpdateIntent(String path, String title, String target, ChatAvatar avatar, String message, UpdateType updateType) {
- super(TYPE);
this.path = path;
this.updateType = updateType;
this.avatar = avatar;
-
- switch(updateType) {
- case DESTROY: break;
- case CREATE: this.title = title; break;
- case SEND_MESSAGE: this.message = message; break;
- default: this.target = target; break;
+
+ switch (updateType) {
+ case DESTROY:
+ break;
+ case CREATE:
+ this.title = title;
+ break;
+ case SEND_MESSAGE:
+ this.message = message;
+ break;
+ default:
+ this.target = target;
+ break;
}
}
-
+
public ChatRoomUpdateIntent(ChatAvatar avatar, String path, String title, boolean isPublic) {
this(path, title, null, avatar, null, UpdateType.CREATE);
this.isPublic = isPublic;
}
-
+
public ChatRoomUpdateIntent(ChatAvatar avatar, String path, UpdateType updateType) {
this(path, null, null, avatar, null, updateType);
}
-
+
public ChatRoomUpdateIntent(Player player, String path, String title, String target, String message, UpdateType updateType, boolean ignoreInvitation) {
this(path, title, target, ChatAvatar.getFromPlayer(player), message, updateType);
this.player = player;
@@ -84,35 +86,35 @@ public class ChatRoomUpdateIntent extends Intent {
public String getPath() {
return path;
}
-
+
public String getTitle() {
return title;
}
-
+
public String getTarget() {
return target;
}
-
+
public ChatAvatar getAvatar() {
return avatar;
}
-
+
public String getMessage() {
return message;
}
-
+
public UpdateType getUpdateType() {
return updateType;
}
-
+
public boolean isPublic() {
return isPublic;
}
-
+
public Player getPlayer() {
return player;
}
-
+
public boolean isIgnoreInvitation() {
return ignoreInvitation;
}
diff --git a/src/intents/chat/PersistentMessageIntent.java b/src/intents/chat/PersistentMessageIntent.java
index d21e16c2e..79768e7b0 100644
--- a/src/intents/chat/PersistentMessageIntent.java
+++ b/src/intents/chat/PersistentMessageIntent.java
@@ -27,25 +27,32 @@
***********************************************************************************/
package intents.chat;
-import resources.control.Intent;
import resources.encodables.player.Mail;
import resources.objects.SWGObject;
+import com.projectswg.common.control.Intent;
+
public class PersistentMessageIntent extends Intent {
- public static final String TYPE = "PersistentMessageIntent";
private Mail mail;
private SWGObject receiver;
private String galaxy;
public PersistentMessageIntent(SWGObject receiver, Mail mail, String galaxy) {
- super(TYPE);
this.receiver = receiver;
this.mail = mail;
this.galaxy = galaxy;
}
-
- public Mail getMail() { return this.mail; }
- public SWGObject getReceiver() { return this.receiver; }
- public String getGalaxy() { return this.galaxy; }
+
+ public Mail getMail() {
+ return this.mail;
+ }
+
+ public SWGObject getReceiver() {
+ return this.receiver;
+ }
+
+ public String getGalaxy() {
+ return this.galaxy;
+ }
}
diff --git a/src/intents/chat/SpatialChatIntent.java b/src/intents/chat/SpatialChatIntent.java
index 38aac9378..30613da39 100644
--- a/src/intents/chat/SpatialChatIntent.java
+++ b/src/intents/chat/SpatialChatIntent.java
@@ -27,27 +27,37 @@
***********************************************************************************/
package intents.chat;
-import resources.control.Intent;
import resources.player.Player;
-public class SpatialChatIntent extends Intent {
- public static final String TYPE = "SpatialChatIntent";
+import com.projectswg.common.control.Intent;
+public class SpatialChatIntent extends Intent {
+
private Player player;
private String message;
private int chatType;
private int moodId;
public SpatialChatIntent(Player player, int chatType, String message, int moodId) {
- super(TYPE);
this.player = player;
this.message = message;
this.chatType = chatType;
this.moodId = moodId;
}
-
- public Player getPlayer() { return player; }
- public String getMessage() { return message; }
- public int getChatType() { return chatType; }
- public int getMoodId() { return moodId; }
+
+ public Player getPlayer() {
+ return player;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public int getChatType() {
+ return chatType;
+ }
+
+ public int getMoodId() {
+ return moodId;
+ }
}
diff --git a/src/intents/combat/CreatureKilledIntent.java b/src/intents/combat/CreatureKilledIntent.java
index dd830d403..0099463b9 100644
--- a/src/intents/combat/CreatureKilledIntent.java
+++ b/src/intents/combat/CreatureKilledIntent.java
@@ -27,28 +27,26 @@
***********************************************************************************/
package intents.combat;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-public class CreatureKilledIntent extends Intent {
+import com.projectswg.common.control.Intent;
- public static final String TYPE = "CreatureKilledIntent";
+public class CreatureKilledIntent extends Intent {
private final CreatureObject killer;
private final CreatureObject corpse;
-
+
public CreatureKilledIntent(CreatureObject killer, CreatureObject corpse) {
- super(TYPE);
this.killer = killer;
this.corpse = corpse;
}
-
+
public CreatureObject getKiller() {
return killer;
}
-
+
public CreatureObject getCorpse() {
return corpse;
}
-
+
}
diff --git a/src/intents/combat/DeathblowIntent.java b/src/intents/combat/DeathblowIntent.java
index 67eb4d146..903e9ab01 100644
--- a/src/intents/combat/DeathblowIntent.java
+++ b/src/intents/combat/DeathblowIntent.java
@@ -27,30 +27,28 @@
***********************************************************************************/
package intents.combat;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-public class DeathblowIntent extends Intent {
+import com.projectswg.common.control.Intent;
- public static final String TYPE = "DeathblowIntent";
+public class DeathblowIntent extends Intent {
private final CreatureObject killer;
private final CreatureObject corpse;
-
+
/**
* @param killer {@code CreatureObject} that's deathblowing
* @param corpse {@code CreatureObject} that's being deathblown
*/
public DeathblowIntent(CreatureObject killer, CreatureObject corpse) {
- super(TYPE);
this.killer = killer;
this.corpse = corpse;
}
-
+
public CreatureObject getKiller() {
return killer;
}
-
+
public CreatureObject getCorpse() {
return corpse;
}
diff --git a/src/intents/experience/ExperienceIntent.java b/src/intents/experience/ExperienceIntent.java
index 084064381..4b1dafcd4 100644
--- a/src/intents/experience/ExperienceIntent.java
+++ b/src/intents/experience/ExperienceIntent.java
@@ -27,36 +27,30 @@
***********************************************************************************/
package intents.experience;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-/**
- *
- * @author Mads
- */
+import com.projectswg.common.control.Intent;
+
public final class ExperienceIntent extends Intent {
- public static final String TYPE = "ExperienceIntent";
-
private final CreatureObject creatureObject;
private final String xpType;
private final int experienceGained;
public ExperienceIntent(CreatureObject creatureObject, String xpType, int experienceGained) {
- super(TYPE);
this.creatureObject = creatureObject;
this.xpType = xpType;
this.experienceGained = experienceGained;
}
-
+
public CreatureObject getCreatureObject() {
return creatureObject;
}
-
+
public String getXpType() {
return xpType;
}
-
+
public int getExperienceGained() {
return experienceGained;
}
diff --git a/src/intents/experience/GrantSkillIntent.java b/src/intents/experience/GrantSkillIntent.java
index 71afc815b..fdb237498 100644
--- a/src/intents/experience/GrantSkillIntent.java
+++ b/src/intents/experience/GrantSkillIntent.java
@@ -27,48 +27,43 @@
***********************************************************************************/
package intents.experience;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-/**
- *
- * @author Mads
- */
+import com.projectswg.common.control.Intent;
+
public final class GrantSkillIntent extends Intent {
- public static final String TYPE = "GrantSkillIntent";
-
private final IntentType intentType;
private final String skillName;
private final CreatureObject target;
private final boolean grantRequiredSkills;
public GrantSkillIntent(IntentType type, String skillName, CreatureObject target, boolean grantRequiredSkills) {
- super(TYPE);
this.intentType = type;
this.skillName = skillName;
this.target = target;
this.grantRequiredSkills = grantRequiredSkills;
}
-
+
public IntentType getIntentType() {
return intentType;
}
-
+
public String getSkillName() {
return skillName;
}
-
+
public CreatureObject getTarget() {
return target;
}
-
+
public boolean isGrantRequiredSkills() {
return grantRequiredSkills;
}
public static enum IntentType {
- GRANT, GIVEN
+ GRANT,
+ GIVEN
}
}
diff --git a/src/intents/experience/LevelChangedIntent.java b/src/intents/experience/LevelChangedIntent.java
index 2176816af..c0510f26e 100644
--- a/src/intents/experience/LevelChangedIntent.java
+++ b/src/intents/experience/LevelChangedIntent.java
@@ -27,38 +27,32 @@
***********************************************************************************/
package intents.experience;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-/**
- *
- * @author Mads
- */
+import com.projectswg.common.control.Intent;
+
public final class LevelChangedIntent extends Intent {
-
- public static final String TYPE = "LevelChangedIntent";
-
+
private final CreatureObject creatureObject;
private final short previousLevel;
private final short newLevel;
-
+
public LevelChangedIntent(CreatureObject creatureObject, short previousLevel, short newLevel) {
- super(TYPE);
this.creatureObject = creatureObject;
this.previousLevel = previousLevel;
this.newLevel = newLevel;
}
-
+
public CreatureObject getCreatureObject() {
return creatureObject;
}
-
+
public short getPreviousLevel() {
return previousLevel;
}
-
+
public short getNewLevel() {
return newLevel;
}
-
+
}
diff --git a/src/intents/network/CloseConnectionIntent.java b/src/intents/network/CloseConnectionIntent.java
index 3cf6d9eb4..062ef0dbb 100644
--- a/src/intents/network/CloseConnectionIntent.java
+++ b/src/intents/network/CloseConnectionIntent.java
@@ -27,19 +27,16 @@
***********************************************************************************/
package intents.network;
-import resources.control.Intent;
import resources.network.DisconnectReason;
+import com.projectswg.common.control.Intent;
public class CloseConnectionIntent extends Intent {
- public static final String TYPE = "CloseConnectionIntent";
-
private long networkId;
private DisconnectReason reason;
public CloseConnectionIntent(long networkId, DisconnectReason reason) {
- super(TYPE);
setNetworkId(networkId);
setDisconnectReason(reason);
}
diff --git a/src/intents/network/ConnectionClosedIntent.java b/src/intents/network/ConnectionClosedIntent.java
index b4d95a20d..ba458a19b 100644
--- a/src/intents/network/ConnectionClosedIntent.java
+++ b/src/intents/network/ConnectionClosedIntent.java
@@ -28,18 +28,15 @@
package intents.network;
import network.packets.swg.holo.HoloConnectionStopped.ConnectionStoppedReason;
-import resources.control.Intent;
+import com.projectswg.common.control.Intent;
public class ConnectionClosedIntent extends Intent {
- public static final String TYPE = "ConnectionClosedIntent";
-
private long networkId;
private ConnectionStoppedReason reason;
public ConnectionClosedIntent(long networkId, ConnectionStoppedReason reason) {
- super(TYPE);
setNetworkId(networkId);
setReason(reason);
}
diff --git a/src/intents/network/ConnectionOpenedIntent.java b/src/intents/network/ConnectionOpenedIntent.java
index e46254cb6..2efa78b26 100644
--- a/src/intents/network/ConnectionOpenedIntent.java
+++ b/src/intents/network/ConnectionOpenedIntent.java
@@ -27,17 +27,13 @@
***********************************************************************************/
package intents.network;
-import resources.control.Intent;
-
+import com.projectswg.common.control.Intent;
public class ConnectionOpenedIntent extends Intent {
- public static final String TYPE = "ConnectionOpenedIntent";
-
private long networkId;
public ConnectionOpenedIntent(long networkId) {
- super(TYPE);
setNetworkId(networkId);
}
diff --git a/src/intents/network/GalacticPacketIntent.java b/src/intents/network/GalacticPacketIntent.java
index 17bb14bd6..49aa7a36f 100644
--- a/src/intents/network/GalacticPacketIntent.java
+++ b/src/intents/network/GalacticPacketIntent.java
@@ -33,13 +33,10 @@ import network.packets.Packet;
public class GalacticPacketIntent extends GalacticIntent {
- public static final String TYPE = "GalacticPacketIntent";
-
private Packet packet;
private Player player;
public GalacticPacketIntent(Packet packet, Player player) {
- super(TYPE);
setPacket(packet);
setPlayer(player);
}
diff --git a/src/intents/network/InboundPacketIntent.java b/src/intents/network/InboundPacketIntent.java
index cebbd0b5e..5fe0833bc 100644
--- a/src/intents/network/InboundPacketIntent.java
+++ b/src/intents/network/InboundPacketIntent.java
@@ -28,17 +28,15 @@
package intents.network;
import network.packets.Packet;
-import resources.control.Intent;
+
+import com.projectswg.common.control.Intent;
public class InboundPacketIntent extends Intent {
- public static final String TYPE = "InboundPacketIntent";
-
private Packet packet;
private long networkId;
public InboundPacketIntent(Packet p, long networkId) {
- super(TYPE);
setPacket(p);
setNetworkId(networkId);
}
diff --git a/src/intents/network/InboundPacketPendingIntent.java b/src/intents/network/InboundPacketPendingIntent.java
index 237d806b7..3e1e63ef8 100644
--- a/src/intents/network/InboundPacketPendingIntent.java
+++ b/src/intents/network/InboundPacketPendingIntent.java
@@ -28,12 +28,11 @@
package intents.network;
import network.NetworkClient;
-import resources.control.Intent;
+
+import com.projectswg.common.control.Intent;
public class InboundPacketPendingIntent extends Intent {
- public static final String TYPE = "InboundPacketPendingIntent";
-
private NetworkClient client;
public InboundPacketPendingIntent() {
@@ -41,7 +40,6 @@ public class InboundPacketPendingIntent extends Intent {
}
public InboundPacketPendingIntent(NetworkClient client) {
- super(TYPE);
setClient(client);
}
diff --git a/src/intents/network/OutboundPacketIntent.java b/src/intents/network/OutboundPacketIntent.java
index fab4e69dc..b28b33775 100644
--- a/src/intents/network/OutboundPacketIntent.java
+++ b/src/intents/network/OutboundPacketIntent.java
@@ -28,17 +28,15 @@
package intents.network;
import network.packets.Packet;
-import resources.control.Intent;
+
+import com.projectswg.common.control.Intent;
public class OutboundPacketIntent extends Intent {
- public static final String TYPE = "OutboundPacketIntent";
-
private Packet packet;
private long networkId;
public OutboundPacketIntent(Packet p, long networkId) {
- super(TYPE);
setPacket(p);
setNetworkId(networkId);
}
diff --git a/src/intents/network/PingIntent.java b/src/intents/network/PingIntent.java
deleted file mode 100644
index 5ea5a8595..000000000
--- a/src/intents/network/PingIntent.java
+++ /dev/null
@@ -1,40 +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 intents.network;
-
-import resources.control.Intent;
-
-public class PingIntent extends Intent {
-
- public static final String TYPE = "PingIntent";
-
- public PingIntent() {
- super(TYPE);
- }
-
-}
diff --git a/src/intents/object/ContainerTransferIntent.java b/src/intents/object/ContainerTransferIntent.java
index 7372a5d76..4927fb666 100644
--- a/src/intents/object/ContainerTransferIntent.java
+++ b/src/intents/object/ContainerTransferIntent.java
@@ -27,13 +27,12 @@
***********************************************************************************/
package intents.object;
-import resources.control.Intent;
import resources.objects.SWGObject;
+import com.projectswg.common.control.Intent;
+
public class ContainerTransferIntent extends Intent {
- public static final String TYPE = "ContainerTransferIntent";
-
private SWGObject obj;
private SWGObject container;
@@ -42,7 +41,6 @@ public class ContainerTransferIntent extends Intent {
}
public ContainerTransferIntent(SWGObject obj, SWGObject container) {
- super(TYPE);
setObject(obj);
setContainer(container);
}
diff --git a/src/intents/object/CreateStaticItemIntent.java b/src/intents/object/CreateStaticItemIntent.java
index bb3e9ee6a..361f9db58 100644
--- a/src/intents/object/CreateStaticItemIntent.java
+++ b/src/intents/object/CreateStaticItemIntent.java
@@ -27,45 +27,39 @@
***********************************************************************************/
package intents.object;
-import resources.control.Intent;
import resources.objects.SWGObject;
import services.objects.StaticItemService.ObjectCreationHandler;
-/**
- *
- * @author mads
- */
+import com.projectswg.common.control.Intent;
+
public final class CreateStaticItemIntent extends Intent {
- public static final String TYPE = "CreateStaticItemIntent";
-
private final SWGObject requester;
private final SWGObject container;
private final ObjectCreationHandler objectCreationHandler;
private final String[] itemNames;
public CreateStaticItemIntent(SWGObject requester, SWGObject container, ObjectCreationHandler objectCreationHandler, String... itemNames) {
- super(TYPE);
this.requester = requester;
this.container = container;
this.objectCreationHandler = objectCreationHandler;
this.itemNames = itemNames;
}
-
+
public SWGObject getContainer() {
return container;
}
-
+
public String[] getItemNames() {
return itemNames;
}
-
+
public SWGObject getRequester() {
return requester;
}
-
+
public ObjectCreationHandler getObjectCreationHandler() {
return objectCreationHandler;
}
-}
\ No newline at end of file
+}
diff --git a/src/intents/object/DestroyObjectIntent.java b/src/intents/object/DestroyObjectIntent.java
index 957f16209..188e1c1de 100644
--- a/src/intents/object/DestroyObjectIntent.java
+++ b/src/intents/object/DestroyObjectIntent.java
@@ -27,17 +27,15 @@
***********************************************************************************/
package intents.object;
-import resources.control.Intent;
import resources.objects.SWGObject;
+import com.projectswg.common.control.Intent;
+
public class DestroyObjectIntent extends Intent {
- public static final String TYPE = "DestroyObjectIntent";
-
private final SWGObject obj;
public DestroyObjectIntent(SWGObject obj) {
- super(TYPE);
this.obj = obj;
}
diff --git a/src/intents/object/MoveObjectIntent.java b/src/intents/object/MoveObjectIntent.java
index f3b8b6a52..4a3a7e9e8 100644
--- a/src/intents/object/MoveObjectIntent.java
+++ b/src/intents/object/MoveObjectIntent.java
@@ -28,13 +28,12 @@
package intents.object;
import resources.Location;
-import resources.control.Intent;
import resources.objects.SWGObject;
+import com.projectswg.common.control.Intent;
+
public class MoveObjectIntent extends Intent {
- public static final String TYPE = "MoveObjectIntent";
-
private SWGObject object;
private SWGObject parent;
private Location newLocation;
@@ -42,7 +41,6 @@ public class MoveObjectIntent extends Intent {
private int updateCounter;
public MoveObjectIntent(SWGObject object, Location newLocation, double speed, int updateCounter) {
- super(TYPE);
this.object = object;
this.parent = null;
this.newLocation = newLocation;
@@ -51,7 +49,6 @@ public class MoveObjectIntent extends Intent {
}
public MoveObjectIntent(SWGObject object, SWGObject parent, Location newLocation, double speed, int updateCounter) {
- super(TYPE);
this.object = object;
this.parent = parent;
this.newLocation = newLocation;
diff --git a/src/intents/object/ObjectCreatedIntent.java b/src/intents/object/ObjectCreatedIntent.java
index b1d017285..4b4f57533 100644
--- a/src/intents/object/ObjectCreatedIntent.java
+++ b/src/intents/object/ObjectCreatedIntent.java
@@ -27,17 +27,15 @@
***********************************************************************************/
package intents.object;
-import resources.control.Intent;
import resources.objects.SWGObject;
+import com.projectswg.common.control.Intent;
+
public class ObjectCreatedIntent extends Intent {
- public static final String TYPE = "ObjectCreatedIntent";
-
private final SWGObject obj;
public ObjectCreatedIntent(SWGObject obj) {
- super(TYPE);
this.obj = obj;
}
diff --git a/src/intents/object/ObjectTeleportIntent.java b/src/intents/object/ObjectTeleportIntent.java
index bc593cfa0..c34e3deec 100644
--- a/src/intents/object/ObjectTeleportIntent.java
+++ b/src/intents/object/ObjectTeleportIntent.java
@@ -28,26 +28,23 @@
package intents.object;
import resources.Location;
-import resources.control.Intent;
import resources.objects.SWGObject;
+import com.projectswg.common.control.Intent;
+
public class ObjectTeleportIntent extends Intent {
- public static final String TYPE = "ObjectTeleportIntent";
-
private SWGObject object;
private SWGObject parent;
private Location newLocation;
public ObjectTeleportIntent(SWGObject object, Location newLocation) {
- super(TYPE);
this.object = object;
this.parent = null;
this.newLocation = newLocation;
}
public ObjectTeleportIntent(SWGObject object, SWGObject parent, Location newLocation) {
- super(TYPE);
this.object = object;
this.parent = parent;
this.newLocation = newLocation;
@@ -56,7 +53,7 @@ public class ObjectTeleportIntent extends Intent {
public SWGObject getObject() {
return object;
}
-
+
public void setObject(SWGObject object) {
this.object = object;
}
@@ -68,13 +65,13 @@ public class ObjectTeleportIntent extends Intent {
public void setParent(SWGObject parent) {
this.parent = parent;
}
-
+
public Location getNewLocation() {
return newLocation;
}
-
+
public void setNewLocation(Location newLocation) {
this.newLocation = newLocation;
- }
-
+ }
+
}
diff --git a/src/intents/player/DeleteCharacterIntent.java b/src/intents/player/DeleteCharacterIntent.java
index fb78bbfd6..ece2f126a 100644
--- a/src/intents/player/DeleteCharacterIntent.java
+++ b/src/intents/player/DeleteCharacterIntent.java
@@ -26,17 +26,15 @@
******************************************************************************/
package intents.player;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
+import com.projectswg.common.control.Intent;
+
public class DeleteCharacterIntent extends Intent {
- public static final String TYPE = "DeleteCharacterIntent";
-
private final CreatureObject creature;
public DeleteCharacterIntent(CreatureObject creature) {
- super(TYPE);
this.creature = creature;
}
diff --git a/src/intents/player/PlayerTransformedIntent.java b/src/intents/player/PlayerTransformedIntent.java
index bc62b7409..ceac63e71 100644
--- a/src/intents/player/PlayerTransformedIntent.java
+++ b/src/intents/player/PlayerTransformedIntent.java
@@ -27,16 +27,15 @@
***********************************************************************************/
package intents.player;
+import com.projectswg.common.control.Intent;
+
import resources.Location;
import resources.Terrain;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
public class PlayerTransformedIntent extends Intent {
- public static final String TYPE = "PlayerTransformedIntent";
-
private final CreatureObject object;
private final SWGObject oldParent;
private final SWGObject newParent;
@@ -44,7 +43,6 @@ public class PlayerTransformedIntent extends Intent {
private final Location newLocation;
public PlayerTransformedIntent(CreatureObject object, SWGObject oldParent, SWGObject newParent, Location oldLocation, Location newLocation) {
- super(TYPE);
this.object = object;
this.oldParent = oldParent;
this.newParent = newParent;
diff --git a/src/intents/radial/RadialRegisterIntent.java b/src/intents/radial/RadialRegisterIntent.java
index 0346f39e0..b568c9071 100644
--- a/src/intents/radial/RadialRegisterIntent.java
+++ b/src/intents/radial/RadialRegisterIntent.java
@@ -29,22 +29,18 @@ package intents.radial;
import java.util.Set;
-import resources.control.Intent;
+import com.projectswg.common.control.Intent;
public class RadialRegisterIntent extends Intent {
-
- public static final String TYPE = "RadialRegisterIntent";
private Set templates;
private boolean register;
public RadialRegisterIntent(boolean register) {
- super(TYPE);
setRegister(register);
}
public RadialRegisterIntent(Set templates, boolean register) {
- super(TYPE);
setTemplates(templates);
setRegister(register);
}
diff --git a/src/intents/radial/RadialRequestIntent.java b/src/intents/radial/RadialRequestIntent.java
index 2b26330bd..5785a4bd0 100644
--- a/src/intents/radial/RadialRequestIntent.java
+++ b/src/intents/radial/RadialRequestIntent.java
@@ -28,20 +28,18 @@
package intents.radial;
import network.packets.swg.zone.object_controller.ObjectMenuRequest;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.player.Player;
+import com.projectswg.common.control.Intent;
+
public class RadialRequestIntent extends Intent {
- public static final String TYPE = "RadialRequestIntent";
-
private Player player;
private SWGObject target;
private ObjectMenuRequest request;
public RadialRequestIntent(Player player, SWGObject target, ObjectMenuRequest request) {
- super(TYPE);
setPlayer(player);
setTarget(target);
setRequest(request);
diff --git a/src/intents/radial/RadialResponseIntent.java b/src/intents/radial/RadialResponseIntent.java
index 8d822e477..110775877 100644
--- a/src/intents/radial/RadialResponseIntent.java
+++ b/src/intents/radial/RadialResponseIntent.java
@@ -29,22 +29,20 @@ package intents.radial;
import java.util.List;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.player.Player;
import resources.radial.RadialOption;
+import com.projectswg.common.control.Intent;
+
public class RadialResponseIntent extends Intent {
- public static final String TYPE = "RadialResponseIntent";
-
private Player player;
private SWGObject target;
private List options;
private int counter;
public RadialResponseIntent(Player player, SWGObject target, List options, int counter) {
- super(TYPE);
setPlayer(player);
setTarget(target);
setOptions(options);
diff --git a/src/intents/radial/RadialSelectionIntent.java b/src/intents/radial/RadialSelectionIntent.java
index 731853da4..7e37ff43b 100644
--- a/src/intents/radial/RadialSelectionIntent.java
+++ b/src/intents/radial/RadialSelectionIntent.java
@@ -27,21 +27,19 @@
***********************************************************************************/
package intents.radial;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.player.Player;
import resources.radial.RadialItem;
+import com.projectswg.common.control.Intent;
+
public class RadialSelectionIntent extends Intent {
- public static final String TYPE = "RadialSelectionIntent";
-
private Player player;
private SWGObject target;
private RadialItem selection;
public RadialSelectionIntent(Player player, SWGObject target, RadialItem selection) {
- super(TYPE);
setPlayer(player);
setTarget(target);
setSelection(selection);
diff --git a/src/intents/server/ConfigChangedIntent.java b/src/intents/server/ConfigChangedIntent.java
index e1caf0a30..3a15a423b 100644
--- a/src/intents/server/ConfigChangedIntent.java
+++ b/src/intents/server/ConfigChangedIntent.java
@@ -27,19 +27,18 @@
***********************************************************************************/
package intents.server;
+import com.projectswg.common.control.Intent;
+
import resources.config.ConfigFile;
-import resources.control.Intent;
public final class ConfigChangedIntent extends Intent {
-
- public static final String TYPE = "ConfigChangedIntent";
- private final ConfigFile changedConfig;
- private final String key, oldValue, newValue;
- public ConfigChangedIntent(ConfigFile changedConfig,
- String key, String oldValue, String newValue) {
- super(TYPE);
-
+ private final ConfigFile changedConfig;
+ private final String key;
+ private final String oldValue;
+ private final String newValue;
+
+ public ConfigChangedIntent(ConfigFile changedConfig, String key, String oldValue, String newValue) {
this.changedConfig = changedConfig;
this.key = key;
this.oldValue = oldValue;
diff --git a/src/intents/server/ServerManagementIntent.java b/src/intents/server/ServerManagementIntent.java
index e9170a0d2..29e73d794 100644
--- a/src/intents/server/ServerManagementIntent.java
+++ b/src/intents/server/ServerManagementIntent.java
@@ -29,11 +29,11 @@ package intents.server;
import java.util.concurrent.TimeUnit;
-import resources.control.Intent;
import resources.player.Player;
+import com.projectswg.common.control.Intent;
+
public class ServerManagementIntent extends Intent {
- public static final String TYPE = "ServerManagementIntent";
private Player player;
private String target;
@@ -42,7 +42,6 @@ public class ServerManagementIntent extends Intent {
private TimeUnit timeUnit;
public ServerManagementIntent(Player p, String target, ServerManagementEvent event) {
- super(TYPE);
this.player = p;
this.target = target;
this.event = event;
@@ -54,11 +53,25 @@ public class ServerManagementIntent extends Intent {
this.timeUnit = timeUnit;
}
- public long getTime() { return time; }
- public TimeUnit getTimeUnit() { return timeUnit; }
- public Player getPlayer() { return player; }
- public String getTarget() { return target; }
- public ServerManagementEvent getEvent() { return event; }
+ public long getTime() {
+ return time;
+ }
+
+ public TimeUnit getTimeUnit() {
+ return timeUnit;
+ }
+
+ public Player getPlayer() {
+ return player;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public ServerManagementEvent getEvent() {
+ return event;
+ }
public enum ServerManagementEvent {
LOCK,
@@ -68,4 +81,5 @@ public class ServerManagementIntent extends Intent {
BAN,
UNBAN
}
+
}
diff --git a/src/intents/server/ServerStatusIntent.java b/src/intents/server/ServerStatusIntent.java
index bf227ea27..72f43700c 100644
--- a/src/intents/server/ServerStatusIntent.java
+++ b/src/intents/server/ServerStatusIntent.java
@@ -29,24 +29,21 @@ package intents.server;
import java.util.concurrent.TimeUnit;
-import resources.control.Intent;
import resources.control.ServerStatus;
+import com.projectswg.common.control.Intent;
+
public class ServerStatusIntent extends Intent {
- public static final String TYPE = "ServerStatusIntent";
-
private ServerStatus status;
private long time;
private TimeUnit timeUnit;
public ServerStatusIntent() {
- super(TYPE);
- setStatus(null);
+ this(null);
}
public ServerStatusIntent(ServerStatus status) {
- super(TYPE);
setStatus(status);
}
@@ -59,7 +56,7 @@ public class ServerStatusIntent extends Intent {
public void setTime(long time) {
this.time = time;
}
-
+
public long getTime() {
return time;
}
@@ -71,7 +68,7 @@ public class ServerStatusIntent extends Intent {
public ServerStatus getStatus() {
return status;
}
-
+
public TimeUnit getTimeUnit() {
return timeUnit;
}
diff --git a/src/intents/sui/SuiWindowIntent.java b/src/intents/sui/SuiWindowIntent.java
index a3acdbb58..be3102657 100644
--- a/src/intents/sui/SuiWindowIntent.java
+++ b/src/intents/sui/SuiWindowIntent.java
@@ -27,34 +27,44 @@
***********************************************************************************/
package intents.sui;
-import resources.control.Intent;
import resources.player.Player;
import resources.sui.SuiBaseWindow;
+import com.projectswg.common.control.Intent;
+
public class SuiWindowIntent extends Intent {
- public static final String TYPE = "SuiWindowIntent";
private SuiBaseWindow window;
private int windowId;
private Player player;
private SuiWindowEvent event;
-
+
public SuiWindowIntent(Player player, SuiBaseWindow window, int windowId, SuiWindowEvent event) {
- super(TYPE);
this.player = player;
this.window = window;
this.windowId = windowId;
this.event = event;
}
-
+
public SuiWindowIntent(Player player, SuiBaseWindow window, SuiWindowEvent event) {
this(player, window, -1, event);
}
-
- public SuiBaseWindow getWindow() { return this.window; }
- public int getWindowId() { return windowId; }
- public Player getPlayer() { return this.player; }
- public SuiWindowEvent getEvent() { return event; }
+
+ public SuiBaseWindow getWindow() {
+ return this.window;
+ }
+
+ public int getWindowId() {
+ return windowId;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public SuiWindowEvent getEvent() {
+ return event;
+ }
public enum SuiWindowEvent {
NEW,
diff --git a/src/intents/travel/TicketPurchaseIntent.java b/src/intents/travel/TicketPurchaseIntent.java
index 970e1a487..ac674960e 100644
--- a/src/intents/travel/TicketPurchaseIntent.java
+++ b/src/intents/travel/TicketPurchaseIntent.java
@@ -27,12 +27,11 @@
***********************************************************************************/
package intents.travel;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
-public final class TicketPurchaseIntent extends Intent {
+import com.projectswg.common.control.Intent;
- public static final String TYPE = "TicketPurchaseIntent";
+public final class TicketPurchaseIntent extends Intent {
private final CreatureObject purchaser;
private final boolean roundTrip;
@@ -40,7 +39,6 @@ public final class TicketPurchaseIntent extends Intent {
private final String destinationPlanet;
public TicketPurchaseIntent(CreatureObject purchaser, String destinationPlanet, String destinationName, boolean roundTrip) {
- super(TYPE);
this.purchaser = purchaser;
this.destinationPlanet = destinationPlanet;
this.destinationName = destinationName;
diff --git a/src/intents/travel/TicketUseIntent.java b/src/intents/travel/TicketUseIntent.java
index 0bb6be14f..42ae54125 100644
--- a/src/intents/travel/TicketUseIntent.java
+++ b/src/intents/travel/TicketUseIntent.java
@@ -27,24 +27,21 @@
***********************************************************************************/
package intents.travel;
-import resources.control.Intent;
import resources.objects.SWGObject;
import resources.player.Player;
+import com.projectswg.common.control.Intent;
+
public class TicketUseIntent extends Intent {
- public static final String TYPE = "TicketUseIntent";
-
private final Player player;
private final SWGObject ticket;
-
public TicketUseIntent(Player player) {
this(player, null);
}
public TicketUseIntent(Player player, SWGObject ticket) {
- super(TYPE);
this.player = player;
this.ticket = ticket;
}
diff --git a/src/intents/travel/TravelPointSelectionIntent.java b/src/intents/travel/TravelPointSelectionIntent.java
index e4e28278a..5234dcc63 100644
--- a/src/intents/travel/TravelPointSelectionIntent.java
+++ b/src/intents/travel/TravelPointSelectionIntent.java
@@ -27,18 +27,16 @@
***********************************************************************************/
package intents.travel;
-import resources.control.Intent;
import resources.objects.creature.CreatureObject;
+import com.projectswg.common.control.Intent;
+
public class TravelPointSelectionIntent extends Intent {
- public static final String TYPE = "TravelPointSelectionIntent";
-
private CreatureObject creature;
private boolean instant;
public TravelPointSelectionIntent(CreatureObject creature, boolean instant) {
- super(TYPE);
this.creature = creature;
this.instant = instant;
}
diff --git a/src/main/ProjectSWG.java b/src/main/ProjectSWG.java
index e85e88ffe..eb97c0cc8 100644
--- a/src/main/ProjectSWG.java
+++ b/src/main/ProjectSWG.java
@@ -27,6 +27,8 @@
***********************************************************************************/
package main;
+import intents.server.ServerStatusIntent;
+
import java.lang.Thread.State;
import java.util.HashMap;
import java.util.List;
@@ -34,13 +36,15 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
-import intents.server.ServerStatusIntent;
import resources.Galaxy.GalaxyStatus;
-import resources.control.IntentManager;
import resources.control.ServerStatus;
+import resources.server_info.DataManager;
import resources.server_info.Log;
import services.CoreManager;
+import com.projectswg.common.concurrency.Delay;
+import com.projectswg.common.control.IntentManager;
+
public class ProjectSWG {
private static ProjectSWG server;
@@ -59,7 +63,7 @@ public class ProjectSWG {
server.forceShutdown();
}, "main-shutdown-hook"));
try {
- startupIntentManager();
+ startupStaticClasses();
server.run(args);
} catch (Throwable t) {
Log.e(t);
@@ -68,7 +72,7 @@ public class ProjectSWG {
server.stop();
server.terminate();
} finally {
- shutdownIntentManager();
+ shutdownStaticClasses();
printFinalPswgState();
Log.i("Server shut down.");
if (!forcingShutdown.get())
@@ -93,12 +97,14 @@ public class ProjectSWG {
return (long) (System.currentTimeMillis()/1E3 - 1309996800L); // Date is 07/07/2011 GMT
}
- private static void startupIntentManager() {
+ private static void startupStaticClasses() {
+ DataManager.initialize();
IntentManager.getInstance().initialize();
}
- private static void shutdownIntentManager() {
+ private static void shutdownStaticClasses() {
IntentManager.getInstance().terminate();
+ DataManager.terminate();
}
private static void printFinalPswgState() {
@@ -207,11 +213,8 @@ public class ProjectSWG {
private void loop() {
setStatus((manager.getGalaxyStatus() == GalaxyStatus.UP) ? ServerStatus.OPEN : ServerStatus.LOCKED);
while (!shutdownRequested && !manager.isShutdownRequested() && manager.isOperational()) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- throw new CoreException("Main Thread Interrupted.");
- }
+ if (!Delay.sleepMicro(50))
+ throw new CoreException("Main Thread Interrupted");
}
}
diff --git a/src/network/NetworkClient.java b/src/network/NetworkClient.java
index afeb4e8e2..ec57ee04c 100644
--- a/src/network/NetworkClient.java
+++ b/src/network/NetworkClient.java
@@ -36,18 +36,19 @@ import java.net.SocketAddress;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import resources.control.Assert;
-import resources.network.NetBufferStream;
-import resources.server_info.Log;
-import services.network.HolocoreSessionManager;
-import services.network.NetworkProtocol;
-import services.network.PacketSender;
-import services.network.HolocoreSessionManager.ResponseAction;
-import utilities.IntentChain;
import network.packets.Packet;
import network.packets.swg.admin.AdminPacket;
import network.packets.swg.holo.HoloConnectionStopped;
import network.packets.swg.holo.HoloConnectionStopped.ConnectionStoppedReason;
+import resources.network.NetBufferStream;
+import resources.server_info.Log;
+import services.network.HolocoreSessionManager;
+import services.network.HolocoreSessionManager.ResponseAction;
+import services.network.NetworkProtocol;
+import services.network.PacketSender;
+
+import com.projectswg.common.control.IntentChain;
+import com.projectswg.common.debug.Assert;
public class NetworkClient {
diff --git a/src/network/packets/swg/zone/resource/ResourceWeight.java b/src/network/packets/swg/zone/resource/ResourceWeight.java
index a833a2601..b187f541f 100644
--- a/src/network/packets/swg/zone/resource/ResourceWeight.java
+++ b/src/network/packets/swg/zone/resource/ResourceWeight.java
@@ -34,9 +34,10 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import resources.control.Assert;
import network.packets.swg.zone.object_controller.ObjectController;
+import com.projectswg.common.debug.Assert;
+
public class ResourceWeight extends ObjectController {
public static final int CRC = 0x0207;
diff --git a/src/resources/callback/BaseCallbackManager.java b/src/resources/callback/BaseCallbackManager.java
deleted file mode 100644
index 663031878..000000000
--- a/src/resources/callback/BaseCallbackManager.java
+++ /dev/null
@@ -1,106 +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 resources.callback;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import utilities.ThreadUtilities;
-
-class BaseCallbackManager {
-
- private final Object executorMutex;
- private final String name;
- private final int threadCount;
- private final AtomicBoolean shutdown;
- private ExecutorService executor;
-
- public BaseCallbackManager(String name) {
- this(name, 1);
- }
-
- public BaseCallbackManager(String name, int threadCount) {
- this.executorMutex = new Object();
- this.name = name;
- this.threadCount = threadCount;
- this.shutdown = new AtomicBoolean(false);
- this.executor = null;
- }
-
- public void start() {
- synchronized (executorMutex) {
- if (executor != null && !shutdown.get())
- executor.shutdown();
- shutdown.set(false);
- if (threadCount <= 1)
- executor = Executors.newSingleThreadExecutor(ThreadUtilities.newThreadFactory(name+"-callback-manager"));
- else
- executor = Executors.newFixedThreadPool(threadCount, ThreadUtilities.newThreadFactory(name+"-callback-manager-%d"));
- }
- }
-
- public void stop() {
- synchronized (executorMutex) {
- executor.shutdown();
- shutdown.set(true);
- }
- }
-
- public boolean awaitTermination(long timeout, TimeUnit unit) {
- synchronized (executorMutex) {
- if (executor == null)
- return true;
- if (!shutdown.get())
- throw new IllegalStateException("Cannot wait for termination when never stopped!");
- try {
- return executor.awaitTermination(timeout, unit);
- } catch (InterruptedException e) {
- return false;
- }
- }
- }
-
- protected boolean call(Runnable r) {
- synchronized (executorMutex) {
- if (executor == null)
- throw new IllegalStateException("Manager has not been started!");
- if (shutdown.get())
- return false;
- try {
- executor.execute(r);
- return true;
- } catch (RejectedExecutionException e) {
- return false;
- }
- }
- }
-
-}
diff --git a/src/resources/callback/CallbackManager.java b/src/resources/callback/CallbackManager.java
deleted file mode 100644
index b03614a82..000000000
--- a/src/resources/callback/CallbackManager.java
+++ /dev/null
@@ -1,110 +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 resources.callback;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import resources.control.Assert;
-import resources.server_info.Log;
-
-public class CallbackManager extends BaseCallbackManager {
-
- private final List callbacks;
- private final AtomicInteger running;
-
- public CallbackManager(String name) {
- this(name, 1);
- }
-
- public CallbackManager(String name, int threadCount) {
- super(name, threadCount);
- this.callbacks = new ArrayList<>();
- this.running = new AtomicInteger(0);
- }
-
- public void addCallback(T callback) {
- synchronized (callbacks) {
- callbacks.add(callback);
- }
- }
-
- public void removeCallback(T callback) {
- synchronized (callbacks) {
- callbacks.remove(callback);
- }
- }
-
- public void setCallback(T callback) {
- synchronized (callbacks) {
- callbacks.clear();
- callbacks.add(callback);
- }
- }
-
- public void clearCallbacks() {
- synchronized (callbacks) {
- callbacks.clear();
- }
- }
-
- public boolean isQueueEmpty() {
- Assert.test(running.get() >= 0);
- return running.get() == 0;
- }
-
- public boolean callOnEach(CallCallback call) {
- synchronized (callbacks) {
- running.incrementAndGet();
- boolean ret = call(() -> {
- try {
- for (T callback : callbacks) {
- try {
- call.run(callback);
- } catch (Throwable t) {
- Log.e(t);
- }
- }
- } catch (Throwable t) {
- Log.e(t);
- } finally {
- running.decrementAndGet();
- }
- });
- if (!ret)
- running.decrementAndGet();
- return ret;
- }
- }
-
-
- public interface CallCallback {
- void run(T callback);
- }
-}
diff --git a/src/resources/collections/SWGList.java b/src/resources/collections/SWGList.java
index 94820430b..5045eeed0 100644
--- a/src/resources/collections/SWGList.java
+++ b/src/resources/collections/SWGList.java
@@ -29,12 +29,10 @@ package resources.collections;
import network.packets.Packet;
import network.packets.swg.zone.baselines.Baseline.BaselineType;
-import resources.control.Assert;
import resources.encodables.Encodable;
import resources.network.NetBuffer;
import resources.objects.SWGObject;
import resources.server_info.Log;
-import resources.server_info.SynchronizedList;
import utilities.Encoder;
import utilities.Encoder.StringType;
@@ -45,6 +43,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+import com.projectswg.common.concurrency.SynchronizedList;
+import com.projectswg.common.debug.Assert;
+
/**
* Supports a list of elements which automatically sends data as a delta when changed for baselines.
*
diff --git a/src/resources/collections/SWGMap.java b/src/resources/collections/SWGMap.java
index 00aedba7f..fb41dc797 100644
--- a/src/resources/collections/SWGMap.java
+++ b/src/resources/collections/SWGMap.java
@@ -27,20 +27,20 @@
***********************************************************************************/
package resources.collections;
-import resources.encodables.Encodable;
-import resources.network.NetBuffer;
-import resources.objects.SWGObject;
-import resources.server_info.Log;
-import resources.server_info.SynchronizedMap;
-import utilities.Encoder;
-import utilities.Encoder.StringType;
-
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import network.packets.Packet;
+import resources.encodables.Encodable;
+import resources.network.NetBuffer;
+import resources.objects.SWGObject;
+import resources.server_info.Log;
+import utilities.Encoder;
+import utilities.Encoder.StringType;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
public class SWGMap extends SynchronizedMap implements Encodable {
diff --git a/src/resources/collections/SWGSet.java b/src/resources/collections/SWGSet.java
index 4e06a443a..cac052d7e 100644
--- a/src/resources/collections/SWGSet.java
+++ b/src/resources/collections/SWGSet.java
@@ -27,17 +27,6 @@
***********************************************************************************/
package resources.collections;
-import network.packets.Packet;
-import network.packets.swg.zone.baselines.Baseline;
-import resources.encodables.Encodable;
-import resources.network.NetBuffer;
-import resources.objects.SWGObject;
-import resources.server_info.Log;
-import resources.server_info.SynchronizedList;
-import resources.server_info.SynchronizedSet;
-import utilities.Encoder;
-import utilities.Encoder.StringType;
-
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.AbstractSet;
@@ -47,6 +36,18 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import network.packets.Packet;
+import network.packets.swg.zone.baselines.Baseline;
+import resources.encodables.Encodable;
+import resources.network.NetBuffer;
+import resources.objects.SWGObject;
+import resources.server_info.Log;
+import utilities.Encoder;
+import utilities.Encoder.StringType;
+
+import com.projectswg.common.concurrency.SynchronizedList;
+import com.projectswg.common.concurrency.SynchronizedSet;
+
public class SWGSet extends SynchronizedSet implements Encodable {
private final int view;
diff --git a/src/resources/commands/callbacks/GotoCmdCallback.java b/src/resources/commands/callbacks/GotoCmdCallback.java
index 131f1381a..b21f015bc 100644
--- a/src/resources/commands/callbacks/GotoCmdCallback.java
+++ b/src/resources/commands/callbacks/GotoCmdCallback.java
@@ -41,11 +41,12 @@ import resources.objects.building.BuildingObject;
import resources.objects.cell.CellObject;
import resources.player.Player;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import services.galaxy.GalacticManager;
import services.objects.ObjectManager;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class GotoCmdCallback implements ICmdCallback {
@Override
diff --git a/src/resources/commands/callbacks/QaToolCmdCallback.java b/src/resources/commands/callbacks/QaToolCmdCallback.java
index 80fdf672b..f33d01d2a 100644
--- a/src/resources/commands/callbacks/QaToolCmdCallback.java
+++ b/src/resources/commands/callbacks/QaToolCmdCallback.java
@@ -30,11 +30,16 @@ package resources.commands.callbacks;
import intents.chat.ChatBroadcastIntent;
import intents.experience.ExperienceIntent;
import intents.network.CloseConnectionIntent;
+import intents.object.CreateStaticItemIntent;
import intents.object.DestroyObjectIntent;
import intents.object.ObjectTeleportIntent;
-import intents.object.CreateStaticItemIntent;
import intents.player.DeleteCharacterIntent;
+
import java.io.FileNotFoundException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
import resources.Location;
import resources.Terrain;
import resources.commands.ICmdCallback;
@@ -45,8 +50,6 @@ import resources.objects.cell.CellObject;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import resources.sui.ISuiCallback;
import resources.sui.SuiButtons;
import resources.sui.SuiEvent;
@@ -55,13 +58,12 @@ import resources.sui.SuiListBox;
import resources.sui.SuiMessageBox;
import services.galaxy.GalacticManager;
import services.objects.ObjectManager;
+import services.objects.StaticItemService.ObjectCreationHandler;
import services.player.PlayerManager;
import utilities.Scripts;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
-import services.objects.StaticItemService.ObjectCreationHandler;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
/**
* Created by Waverunner on 8/19/2015
diff --git a/src/resources/commands/callbacks/TransferItemCallback.java b/src/resources/commands/callbacks/TransferItemCallback.java
index e0243af2e..1b75b72fe 100644
--- a/src/resources/commands/callbacks/TransferItemCallback.java
+++ b/src/resources/commands/callbacks/TransferItemCallback.java
@@ -30,7 +30,6 @@ package resources.commands.callbacks;
import intents.chat.ChatBroadcastIntent;
import resources.commands.ICmdCallback;
-import resources.control.Assert;
import resources.objects.GameObjectType;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
@@ -38,6 +37,8 @@ import resources.objects.weapon.WeaponObject;
import resources.player.Player;
import services.galaxy.GalacticManager;
+import com.projectswg.common.debug.Assert;
+
/**
* This callback is used for all three kinds of transfer commands. The commands
* differ based on object type (misc, armor and weapon). We should NOT trust
diff --git a/src/resources/concurrency/PswgBasicScheduledThread.java b/src/resources/concurrency/PswgBasicScheduledThread.java
deleted file mode 100644
index 6763d2028..000000000
--- a/src/resources/concurrency/PswgBasicScheduledThread.java
+++ /dev/null
@@ -1,64 +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 resources.concurrency;
-
-public class PswgBasicScheduledThread extends PswgScheduledThreadPool {
-
- private final Runnable runnable;
-
- public PswgBasicScheduledThread(String name, Runnable runnable) {
- super(1, name);
- this.runnable = runnable;
- }
-
- @Override
- public void start() {
- throw new UnsupportedOperationException("Cannot use this function. Must use startX(initialDelay, periodicDelay)");
- }
-
- public void startWithFixedRate(long initialDelay, long periodicDelay) {
- super.start();
- super.executeWithFixedRate(initialDelay, periodicDelay, runnable);
- }
-
- public void startWithFixedDelay(long initialDelay, long periodicDelay) {
- super.start();
- super.executeWithFixedDelay(initialDelay, periodicDelay, runnable);
- }
-
- @Override
- public void executeWithFixedRate(long initialDelay, long periodicDelay, Runnable runnable) {
- throw new UnsupportedOperationException("Runnable is defined in the constructor!");
- }
-
- @Override
- public void executeWithFixedDelay(long initialDelay, long periodicDelay, Runnable runnable) {
- throw new UnsupportedOperationException("Runnable is defined in the constructor!");
- }
-
-}
diff --git a/src/resources/concurrency/PswgBasicThread.java b/src/resources/concurrency/PswgBasicThread.java
deleted file mode 100644
index 66ff6f4fa..000000000
--- a/src/resources/concurrency/PswgBasicThread.java
+++ /dev/null
@@ -1,65 +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 resources.concurrency;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class PswgBasicThread extends PswgThreadPool {
-
- private final AtomicBoolean executing;
- private final Runnable runnable;
-
- public PswgBasicThread(String name, Runnable runnable) {
- super(1, name);
- this.executing = new AtomicBoolean(false);
- this.runnable = runnable;
- }
-
- @Override
- public void start() {
- super.start();
- super.execute(() -> {
- executing.set(true);
- try {
- runnable.run();
- } finally {
- executing.set(false);
- }
- });
- }
-
- public boolean isExecuting() {
- return executing.get();
- }
-
- @Override
- public boolean execute(Runnable runnable) {
- throw new UnsupportedOperationException("Runnable is defined in the constructor!");
- }
-
-}
diff --git a/src/resources/concurrency/PswgScheduledThreadPool.java b/src/resources/concurrency/PswgScheduledThreadPool.java
deleted file mode 100644
index 9fc7b106e..000000000
--- a/src/resources/concurrency/PswgScheduledThreadPool.java
+++ /dev/null
@@ -1,115 +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 resources.concurrency;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import resources.control.Assert;
-
-public class PswgScheduledThreadPool {
-
- private final AtomicBoolean running;
- private final int nThreads;
- private final ThreadFactory threadFactory;
- private ScheduledExecutorService executor;
-
- public PswgScheduledThreadPool(int nThreads, String nameFormat) {
- this.running = new AtomicBoolean(false);
- this.nThreads = nThreads;
- this.threadFactory = new CustomThreadFactory(nameFormat);
- this.executor = null;
- }
-
- public void start() {
- Assert.test(!running.getAndSet(true));
- executor = Executors.newScheduledThreadPool(nThreads, threadFactory);
- }
-
- public void stop() {
- Assert.test(running.getAndSet(false));
- executor.shutdownNow();
- }
-
- public void executeWithFixedRate(long initialDelay, long time, Runnable runnable) {
- Assert.test(running.get());
- executor.scheduleAtFixedRate(() -> {
- try {
- runnable.run();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }, initialDelay, time, TimeUnit.MILLISECONDS);
- }
-
- public void executeWithFixedDelay(long initialDelay, long time, Runnable runnable) {
- Assert.test(running.get());
- executor.scheduleWithFixedDelay(() -> {
- try {
- runnable.run();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }, initialDelay, time, TimeUnit.MILLISECONDS);
- }
-
- public boolean awaitTermination(long time) {
- Assert.notNull(executor);
- try {
- return executor.awaitTermination(time, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- return false;
- }
- }
-
- 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);
- }
-
- }
-
-}
diff --git a/src/resources/concurrency/PswgTaskThreadPool.java b/src/resources/concurrency/PswgTaskThreadPool.java
deleted file mode 100644
index 400dffd3b..000000000
--- a/src/resources/concurrency/PswgTaskThreadPool.java
+++ /dev/null
@@ -1,73 +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 resources.concurrency;
-
-import java.util.ArrayDeque;
-import java.util.Queue;
-
-public class PswgTaskThreadPool extends PswgThreadPool {
-
- private final Queue tasks;
- private final Runnable runner;
-
- public PswgTaskThreadPool(int nThreads, String namePattern, TaskExecutor executor) {
- super(nThreads, namePattern);
- this.tasks = new ArrayDeque<>();
- this.runner = () -> {
- T t = null;
- synchronized (tasks) {
- t = tasks.poll();
- }
- if (t != null)
- executor.run(t);
- };
- }
-
- @Override
- public boolean execute(Runnable runnable) {
- throw new UnsupportedOperationException("Runnable are posted automatically by addTask!");
- }
-
- public void addTask(T t) {
- synchronized (tasks) {
- tasks.add(t);
- }
- super.execute(runner);
- }
-
- public int getTasks() {
- synchronized (tasks) {
- return tasks.size();
- }
- }
-
- public interface TaskExecutor {
- void run(T t);
- }
-
-}
diff --git a/src/resources/concurrency/PswgThreadPool.java b/src/resources/concurrency/PswgThreadPool.java
deleted file mode 100644
index e91b55190..000000000
--- a/src/resources/concurrency/PswgThreadPool.java
+++ /dev/null
@@ -1,119 +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 resources.concurrency;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import resources.control.Assert;
-
-public class PswgThreadPool {
-
- private final AtomicBoolean running;
- private final int nThreads;
- private final ThreadFactory threadFactory;
- private ExecutorService executor;
- private volatile boolean waitForTermination;
-
- public PswgThreadPool(int nThreads, String nameFormat) {
- this.running = new AtomicBoolean(false);
- this.nThreads = nThreads;
- this.threadFactory = new CustomThreadFactory(nameFormat);
- this.executor = null;
- this.waitForTermination = false;
- }
-
- public void setWaitForTermination(boolean wait) {
- this.waitForTermination = wait;
- }
-
- public void start() {
- Assert.test(!running.getAndSet(true));
- executor = Executors.newFixedThreadPool(nThreads, threadFactory);
- }
-
- public void stop() {
- Assert.test(running.getAndSet(false));
- if (waitForTermination)
- executor.shutdownNow();
- else
- executor.shutdown();
- }
-
- public boolean execute(Runnable runnable) {
- if (!running.get())
- return false;
- executor.execute(() -> {
- try {
- runnable.run();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- });
- return true;
- }
-
- public boolean awaitTermination(long time) {
- Assert.notNull(executor);
- try {
- return executor.awaitTermination(time, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- return false;
- }
- }
-
- public boolean isRunning() {
- return running.get();
- }
-
- 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);
- }
-
- }
-
-}
diff --git a/src/resources/concurrency/SmartLock.java b/src/resources/concurrency/SmartLock.java
deleted file mode 100644
index 30f0eb8fc..000000000
--- a/src/resources/concurrency/SmartLock.java
+++ /dev/null
@@ -1,129 +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 resources.concurrency;
-
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class SmartLock {
-
- private final Lock lock;
- private final Condition condition;
-
- public SmartLock() {
- this.lock = new ReentrantLock(true);
- this.condition = lock.newCondition();
- }
-
- public void lock() {
- lock.lock();
- }
-
- public void lockInterruptibly() throws InterruptedException {
- lock.lockInterruptibly();
- }
-
- public boolean tryLock() {
- return lock.tryLock();
- }
-
- public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
- return lock.tryLock(time, unit);
- }
-
- public void unlock() {
- lock.unlock();
- }
-
- public void await() throws InterruptedException {
- lock();
- try {
- condition.await();
- } finally {
- unlock();
- }
- }
-
- public void awaitUninterruptibly() {
- lock();
- try {
- condition.awaitUninterruptibly();
- } finally {
- unlock();
- }
- }
-
- public long awaitNanos(long nanosTimeout) throws InterruptedException {
- lock();
- try {
- return condition.awaitNanos(nanosTimeout);
- } finally {
- unlock();
- }
- }
-
- public boolean await(long time, TimeUnit unit) throws InterruptedException {
- lock();
- try {
- return condition.await(time, unit);
- } finally {
- unlock();
- }
- }
-
- public boolean awaitUntil(Date deadline) throws InterruptedException {
- lock();
- try {
- return condition.awaitUntil(deadline);
- } finally {
- unlock();
- }
- }
-
- public void signal() {
- lock();
- try {
- condition.signal();
- } finally {
- unlock();
- }
- }
-
- public void signalAll() {
- lock();
- try {
- condition.signalAll();
- } finally {
- unlock();
- }
- }
-
-}
diff --git a/src/resources/concurrency/SynchronizedQueue.java b/src/resources/concurrency/SynchronizedQueue.java
deleted file mode 100644
index 098527c81..000000000
--- a/src/resources/concurrency/SynchronizedQueue.java
+++ /dev/null
@@ -1,151 +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 resources.concurrency;
-
-import java.util.ArrayDeque;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Queue;
-import java.util.Spliterator;
-import java.util.function.Consumer;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-
-public class SynchronizedQueue implements Queue {
-
- private final Queue queue;
-
- public SynchronizedQueue() {
- this(new ArrayDeque<>());
- }
-
- public SynchronizedQueue(Queue queue) {
- this.queue = queue;
- }
-
- public synchronized void forEach(Consumer super T> action) {
- queue.forEach(action);
- }
-
- public synchronized boolean add(T e) {
- return queue.add(e);
- }
-
- public synchronized boolean offer(T e) {
- return queue.offer(e);
- }
-
- public synchronized int size() {
- return queue.size();
- }
-
- public synchronized boolean isEmpty() {
- return queue.isEmpty();
- }
-
- public synchronized boolean contains(Object o) {
- return queue.contains(o);
- }
-
- public synchronized T remove() {
- return queue.remove();
- }
-
- public synchronized T poll() {
- return queue.poll();
- }
-
- public synchronized T element() {
- return queue.element();
- }
-
- public synchronized Iterator iterator() {
- return queue.iterator();
- }
-
- public synchronized T peek() {
- return queue.peek();
- }
-
- public synchronized Object[] toArray() {
- return queue.toArray();
- }
-
- public synchronized E[] toArray(E[] a) {
- return queue.toArray(a);
- }
-
- public synchronized boolean remove(Object o) {
- return queue.remove(o);
- }
-
- public synchronized boolean containsAll(Collection> c) {
- return queue.containsAll(c);
- }
-
- public synchronized boolean addAll(Collection extends T> c) {
- return queue.addAll(c);
- }
-
- public synchronized boolean removeAll(Collection> c) {
- return queue.removeAll(c);
- }
-
- public synchronized boolean removeIf(Predicate super T> filter) {
- return queue.removeIf(filter);
- }
-
- public synchronized boolean retainAll(Collection> c) {
- return queue.retainAll(c);
- }
-
- public synchronized void clear() {
- queue.clear();
- }
-
- public synchronized boolean equals(Object o) {
- return queue.equals(o);
- }
-
- public synchronized int hashCode() {
- return queue.hashCode();
- }
-
- public synchronized Spliterator spliterator() {
- return queue.spliterator();
- }
-
- public synchronized Stream stream() {
- return queue.stream();
- }
-
- public synchronized Stream parallelStream() {
- return queue.parallelStream();
- }
-
-}
diff --git a/src/resources/control/Assert.java b/src/resources/control/Assert.java
deleted file mode 100644
index d76ee55f6..000000000
--- a/src/resources/control/Assert.java
+++ /dev/null
@@ -1,117 +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 resources.control;
-
-import resources.server_info.Log;
-
-public class Assert {
-
- private static volatile AssertLevel level = AssertLevel.ASSERT;
-
- public static void setLevel(AssertLevel level) {
- Assert.level = level;
- }
-
- public static boolean debug() {
- return level != AssertLevel.IGNORE;
- }
-
- public static void notNull(Object o) {
- notNull(o, "");
- }
-
- public static void notNull(Object o, String message) {
- if (debug() && o == null)
- handle(new NullPointerException(message));
- }
-
- public static void isNull(Object o) {
- isNull(o, "");
- }
-
- public static void isNull(Object o, String message) {
- if (debug() && o != null)
- handle(new AssertionException(message));
- }
-
- public static void test(boolean expr) {
- test(expr, "");
- }
-
- public static void test(boolean expr, String message) {
- if (debug() && !expr)
- handle(new AssertionException(message));
- }
-
- public static void fail() {
- fail("");
- }
-
- public static void fail(String message) {
- if (debug())
- handle(new AssertionException(message));
- }
-
- private static void handle(RuntimeException e) {
- AssertLevel level = Assert.level;
- switch (level) {
- case WARN:
- warn(e);
- break;
- case ASSERT:
- throw e;
- default:
- break;
- }
- }
-
- private static void warn(Exception e) {
- StackTraceElement [] elements = e.getStackTrace();
- if (elements.length <= 1)
- Log.e(e);
- else
- Log.e(e);
- }
-
- private static class AssertionException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public AssertionException(String message) {
- super(message);
- }
-
- }
-
- public enum AssertLevel {
- IGNORE,
- WARN,
- ASSERT
- }
-
-}
diff --git a/src/resources/control/Intent.java b/src/resources/control/Intent.java
deleted file mode 100644
index 13aba1c1d..000000000
--- a/src/resources/control/Intent.java
+++ /dev/null
@@ -1,151 +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 resources.control;
-
-
-public abstract class Intent {
-
- private final String type;
- private boolean broadcasted;
- private boolean complete;
- private Intent parallel;
- private Intent sequential;
-
- protected Intent(String type) {
- this.type = type;
- this.broadcasted = false;
- this.complete = false;
- this.parallel = null;
- this.sequential = null;
- }
-
- /**
- * Called when the intent has been completed
- */
- public synchronized void markAsComplete() {
- this.complete = true;
- if (sequential != null)
- sequential.broadcast();
- sequential = null;
- parallel = null;
- }
-
- /**
- * Returns the type of intent
- * @return the type of intent
- */
- public synchronized String getType() {
- return type;
- }
-
- /**
- * Determines whether or not the intent has been broadcasted and processed
- * by the system
- * @return TRUE if the intent has been broadcasted and processed, FALSE
- * otherwise
- */
- public synchronized boolean isComplete() {
- return complete;
- }
-
- /**
- * Determines whether or not the intent has been broadcasted to the system
- * @return TRUE if the intent has been broadcasted, FALSE otherwise
- */
- public synchronized boolean isBroadcasted() {
- return broadcasted;
- }
-
- /**
- * Waits for the intent as the parameter to finish before this intent
- * starts
- * @param i the intent to execute after
- */
- public synchronized void broadcastAfterIntent(Intent i) {
- if (i == null) {
- broadcast();
- return;
- }
- synchronized (i) {
- if (i.isComplete())
- broadcast();
- else
- i.setAsSequential(this);
- }
- }
-
- /**
- * Waits for the intent as the parameter to start before this intent starts
- * @param i the intent to execute with
- */
- public synchronized void broadcastWithIntent(Intent i) {
- if (i == null) {
- broadcast();
- return;
- }
- synchronized (i) {
- if (!isComplete()) {
- setAsParallel(i);
- }
- broadcast();
- }
- }
-
- /**
- * Broadcasts this node to the system
- */
- public synchronized void broadcast() {
- if (broadcasted)
- throw new IllegalStateException("Intent has already been broadcasted!");
- broadcasted = true;
- IntentManager.getInstance().broadcastIntent(this);
- if (parallel != null)
- parallel.broadcast();
- parallel = null;
- }
-
- @Override
- public synchronized String toString() {
- return getType();
- }
-
- private synchronized void setAsParallel(Intent i) {
- if (parallel == null)
- parallel = i;
- else
- parallel.setAsParallel(i);
- }
-
- private synchronized void setAsSequential(Intent i) {
- if (sequential == null)
- sequential = i;
- else
- sequential.setAsParallel(i);
- }
-
-}
diff --git a/src/resources/control/IntentManager.java b/src/resources/control/IntentManager.java
deleted file mode 100644
index 7f87c6597..000000000
--- a/src/resources/control/IntentManager.java
+++ /dev/null
@@ -1,140 +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 resources.control;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import resources.concurrency.PswgTaskThreadPool;
-import resources.server_info.Log;
-
-
-public class IntentManager {
-
- private static final IntentManager INSTANCE = new IntentManager();
-
- private final Map > intentRegistrations;
- private final PswgTaskThreadPool broadcastThreads;
- private final AtomicBoolean initialized;
-
- private IntentManager() {
- intentRegistrations = new HashMap>();
- initialized = new AtomicBoolean(false);
- int threadCount = Runtime.getRuntime().availableProcessors() * 10;
- broadcastThreads = new PswgTaskThreadPool<>(threadCount, "intent-processor-%d", i -> broadcast(i));
- broadcastThreads.setWaitForTermination(true);
- initialize();
- }
-
- public void initialize() {
- if (initialized.getAndSet(true))
- return;
- broadcastThreads.start();
- }
-
- public void terminate() {
- if (!initialized.getAndSet(false))
- return;
- broadcastThreads.stop();
- broadcastThreads.awaitTermination(5000);
- }
-
- protected void broadcastIntent(Intent i) {
- if (i == null)
- throw new NullPointerException("Intent cannot be null!");
- broadcastThreads.addTask(i);
- }
-
- public void registerForIntent(String intentType, IntentReceiver r) {
- if (r == null)
- throw new NullPointerException("Cannot register a null value for an intent");
- synchronized (intentRegistrations) {
- List intents = intentRegistrations.get(intentType);
- if (intents == null) {
- intents = new CopyOnWriteArrayList<>();
- intentRegistrations.put(intentType, intents);
- }
- synchronized (intents) {
- intents.add(r);
- }
- }
- }
-
- protected void unregisterForIntent(String intentType, IntentReceiver r) {
- if (r == null)
- return;
- synchronized (intentRegistrations) {
- if (!intentRegistrations.containsKey(intentType))
- return;
- List receivers = intentRegistrations.get(intentType);
- for (IntentReceiver recv : receivers) {
- if (r == recv || r.equals(recv)) {
- r = recv;
- break;
- }
- }
- receivers.remove(r);
- }
- }
-
- private void broadcast(Intent i) {
- List receivers;
- synchronized (intentRegistrations) {
- receivers = intentRegistrations.get(i.getType());
- }
- if (receivers == null) {
- i.markAsComplete();
- return;
- }
- for (IntentReceiver r : receivers) {
- broadcast(r, i);
- }
- i.markAsComplete();
- }
-
- private void broadcast(IntentReceiver r, Intent i) {
- try {
- r.onIntentReceived(i);
- } catch (Throwable t) {
- Log.e("Fatal Exception while processing intent: " + i);
- Log.e(t);
- }
- }
-
- public static int getIntentsQueued() {
- return getInstance().broadcastThreads.getTasks();
- }
-
- public static IntentManager getInstance() {
- return INSTANCE;
- }
-
-}
diff --git a/src/resources/control/IntentQueue.java b/src/resources/control/IntentQueue.java
deleted file mode 100644
index 84c79906b..000000000
--- a/src/resources/control/IntentQueue.java
+++ /dev/null
@@ -1,235 +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 resources.control;
-
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.NoSuchElementException;
-import java.util.Queue;
-
-class IntentQueue implements Queue {
-
- private final Node head;
- private int size;
- private int modificationCount;
-
- public IntentQueue() {
- head = new Node(null, null, null); // Left = Forward, Right = Reverse
- head.left = head;
- head.right = head;
- modificationCount = 0;
- }
-
- @Override
- public int size() {
- return size;
- }
-
- @Override
- public boolean isEmpty() {
- return size == 0;
- }
-
- @Override
- public boolean contains(Object o) {
- Node n = head;
- while (n.left != head) {
- if (n.left.intent == o)
- return true;
- }
- return false;
- }
-
- @Override
- public Iterator iterator() {
- return new Iterator();
- }
-
- @Override
- public Object [] toArray() {
- return null;
- }
-
- @Override
- public T [] toArray(T [] a) {
- return null;
- }
-
- @Override
- public boolean remove(Object o) {
- modificationCount++;
- Node n = head;
- while (n.left != head) {
- if (n.left.intent == o) {
- n.left = n.left.left;
- n.left.right = n;
- }
- }
- return false;
- }
-
- @Override
- public boolean containsAll(Collection> c) {
- for (Object o : c)
- if (!contains(o))
- return false;
- return true;
- }
-
- @Override
- public boolean addAll(Collection extends Intent> c) {
- boolean added = false;
- for (Intent i : c)
- added = add(i) || added;
- return added;
- }
-
- @Override
- public boolean removeAll(Collection> c) {
- boolean changed = false;
- for (Object o : c)
- changed = remove(o) || changed;
- return changed;
- }
-
- @Override
- public boolean retainAll(Collection> c) {
- boolean changed = false;
- Node n = head;
- while (n.left != head) {
- if (!c.contains(n.left.intent)) {
- n.left.left.right = n;
- n.left = n.left.left;
- }
- }
- return changed;
- }
-
- @Override
- public void clear() {
- modificationCount++;
- size = 0;
- head.left = head;
- head.right = head;
- }
-
- @Override
- public boolean add(Intent e) {
- head.right.left = new Node(e, head, head.right);
- head.right = head.right.left;
- modificationCount++;
- size++;
- return true;
- }
-
- @Override
- public boolean offer(Intent e) {
- return add(e);
- }
-
- @Override
- public Intent remove() {
- if (isEmpty())
- throw new NoSuchElementException("Queue is empty!");
- modificationCount++;
- Intent i = head.left.intent;
- head.left = head.left.left;
- head.left.right = head;
- size--;
- return i;
- }
-
- @Override
- public Intent poll() {
- if (isEmpty())
- return null;
- modificationCount++;
- Intent i = head.left.intent;
- head.left = head.left.left;
- head.left.right = head;
- size--;
- return i;
- }
-
- @Override
- public Intent element() {
- if (isEmpty())
- throw new NoSuchElementException("Queue is empty!");
- return head.left.intent;
- }
-
- @Override
- public Intent peek() {
- if (isEmpty())
- return null;
- return head.left.intent;
- }
-
- private class Iterator implements java.util.Iterator {
-
- private final int modificationCount;
- private Node currentNode;
-
- public Iterator() {
- this.modificationCount = IntentQueue.this.modificationCount;
- this.currentNode = IntentQueue.this.head;
- }
-
- @Override
- public boolean hasNext() {
- if (this.modificationCount != IntentQueue.this.modificationCount)
- throw new ConcurrentModificationException();
- return currentNode.left != IntentQueue.this.head;
- }
-
- @Override
- public Intent next() {
- if (!hasNext())
- throw new NoSuchElementException("Iterator has reached the end of the queue!");
- Intent i = currentNode.left.intent;
- currentNode = currentNode.left;
- return i;
- }
-
- }
-
- private static class Node {
-
- public final Intent intent;
- public Node left;
- public Node right;
-
- public Node(Intent intent, Node left, Node right) {
- this.intent = intent;
- this.left = left;
- this.right = right;
- }
-
- }
-
-}
diff --git a/src/resources/control/IntentReceiver.java b/src/resources/control/IntentReceiver.java
deleted file mode 100644
index b234a1c58..000000000
--- a/src/resources/control/IntentReceiver.java
+++ /dev/null
@@ -1,41 +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 resources.control;
-
-
-public interface IntentReceiver {
-
- /**
- * This function will be called if an intent is broadcasted and this
- * manager is listening for it, or if this manager is specifically given
- * this intent.
- * @param i the intent received
- */
- public void onIntentReceived(Intent i);
-
-}
diff --git a/src/resources/control/Manager.java b/src/resources/control/Manager.java
deleted file mode 100644
index ea98d97b3..000000000
--- a/src/resources/control/Manager.java
+++ /dev/null
@@ -1,183 +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 resources.control;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import resources.server_info.Log;
-
-
-/**
- * A Manager is a class that will manage services, and generally controls the
- * program as a whole
- */
-public abstract class Manager extends Service {
-
- private final Set children;
-
- public Manager() {
- children = new HashSet<>();
- }
-
- /**
- * Initializes this manager. If the manager returns false on this method
- * then the initialization failed and may not work as intended. This will
- * initialize all children automatically.
- * @return TRUE if initialization was successful, FALSE otherwise
- */
- @Override
- public boolean initialize() {
- boolean success = super.initialize();
- synchronized (children) {
- for (Service child : children) {
- if (!child.initialize()) {
- Log.e(child.getClass().getSimpleName() + " failed to initialize!");
- success = false;
- break;
- }
- }
- }
- return success;
- }
-
- /**
- * Starts this manager. If the manager returns false on this method then
- * the manger failed to start and may not work as intended. This will start
- * all children automatically.
- * @return TRUE if starting was successful, FALSE otherwise
- */
- @Override
- public boolean start() {
- boolean success = super.start();
- synchronized (children) {
- for (Service child : children) {
- if (!child.start()) {
- Log.e(child.getClass().getSimpleName() + " failed to start!");
- success = false;
- break;
- }
- }
- }
- return success;
- }
-
- /**
- * Stops this manager. If the manager returns false on this method then
- * the manger failed to stop and may not have fully locked down. This will
- * start all children automatically.
- * @return TRUE if stopping was successful, FALSE otherwise
- */
- @Override
- public boolean stop() {
- boolean success = super.stop(), cSuccess = true;
- synchronized (children) {
- for (Service child : children) {
- if (!success)
- break;
- cSuccess = child.stop();
- if (!cSuccess) {
- Log.e(child.getClass().getSimpleName() + " failed to stop!");
- success = false;
- }
- }
- }
- return success;
- }
-
- /**
- * Terminates this manager. If the manager returns false on this method
- * then the manager failed to shut down and resources may not have been
- * cleaned up. This will terminate all children automatically.
- * @return TRUE if termination was successful, FALSE otherwise
- */
- @Override
- public boolean terminate() {
- boolean success = super.terminate();
- synchronized (children) {
- for (Service child : children) {
- if (!child.terminate())
- success = false;
- }
- }
- return success;
- }
-
- /**
- * Determines whether or not this manager is operational
- * @return TRUE if this manager is operational, FALSE otherwise
- */
- @Override
- public boolean isOperational() {
- boolean success = true;
- synchronized (children) {
- for (Service child : children) {
- if (!child.isOperational())
- success = false;
- }
- }
- return success;
- }
-
- /**
- * Adds a child to the manager's list of children. This creates a tree of
- * services that allows information to propogate freely through the network
- * in an easy way.
- * @param s the service to add as a child.
- */
- protected final void addChildService(Service s) {
- if (s == null)
- throw new NullPointerException("Child service cannot be null!");
- synchronized (children) {
- children.add(s);
- }
- }
-
- /**
- * Removes the service from the list of children
- * @param s the service to remove
- */
- protected final void removeChildService(Service s) {
- if (s == null)
- return;
- synchronized (children) {
- children.remove(s);
- }
- }
-
- /**
- * Returns a copied {@code Set] of the children of this manager
- * @return a copied {@code Set] of the children of this manager
- */
- public Set getManagerChildren() {
- synchronized (children) {
- return new HashSet<>(children);
- }
- }
-
-}
diff --git a/src/resources/control/Service.java b/src/resources/control/Service.java
deleted file mode 100644
index 4ebaa7172..000000000
--- a/src/resources/control/Service.java
+++ /dev/null
@@ -1,138 +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 resources.control;
-
-import java.util.function.Consumer;
-
-import resources.config.ConfigFile;
-import resources.server_info.Config;
-import resources.server_info.DataManager;
-import resources.server_info.Log;
-
-
-/**
- * A Service is a class that does a specific job for the application
- */
-public abstract class Service implements IntentReceiver {
-
- public Service() {
-
- }
-
- /**
- * Initializes this service. If the service returns false on this method
- * then the initialization failed and may not work as intended.
- * @return TRUE if initialization was successful, FALSE otherwise
- */
- public boolean initialize() {
- return DataManager.getInstance().isInitialized();
- }
-
- /**
- * Starts this service. If the service returns false on this method then
- * the service failed to start and may not work as intended.
- * @return TRUE if starting was successful, FALSE otherwise
- */
- public boolean start() {
- return DataManager.getInstance().isInitialized();
- }
-
- /**
- * Stops the service. If the service returns false on this method then the
- * service failed to stop and may not have fully locked down.
- * @return TRUE if stopping was successful, FALSe otherwise
- */
- public boolean stop() {
- return true;
- }
-
- /**
- * Terminates this service. If the service returns false on this method
- * then the service failed to shut down and resources may not have been
- * cleaned up.
- * @return TRUE if termination was successful, FALSE otherwise
- */
- public boolean terminate() {
- DataManager.terminate();
- return true;
- }
-
- /**
- * Determines whether or not this service is operational
- * @return TRUE if this service is operational, FALSE otherwise
- */
- public boolean isOperational() {
- return true;
- }
-
- /**
- * Registers for the specified intent string
- * @param type the intent string
- */
- protected final void registerForIntent(String type) {
- IntentManager.getInstance().registerForIntent(type, this);
- }
-
- @SuppressWarnings("unchecked")
- protected final void registerForIntent(Class c, Consumer consumer) {
- try {
- String type = (String) c.getDeclaredField("TYPE").get(null);
- IntentManager.getInstance().registerForIntent(type, (i) -> consumer.accept((T) i));
- } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Unregisters for the specified intent string
- * @param type the intent string
- */
- protected final void unregisterForIntent(String type) {
- IntentManager.getInstance().unregisterForIntent(type, this);
- }
-
- /**
- * Callback when an intent is received from the system
- */
- @Override
- public void onIntentReceived(Intent i) {
- Log.w("Warning: " + getClass().getSimpleName() + " did not override onIntentReceived");
- }
-
- /**
- * Gets the config object associated with a certain file, or NULL if the
- * file failed to load on startup
- * @param file the file to get the config for
- * @return the config object associated with the file, or NULL if the
- * config failed to load
- */
- public synchronized final Config getConfig(ConfigFile file) {
- return DataManager.getInstance().getConfig(file);
- }
-
-}
diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java
index 7f6faa72f..4784c2559 100644
--- a/src/resources/objects/SWGObject.java
+++ b/src/resources/objects/SWGObject.java
@@ -27,6 +27,18 @@
***********************************************************************************/
package resources.objects;
+import intents.object.ContainerTransferIntent;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
import network.packets.Packet;
import network.packets.swg.zone.SceneCreateObjectByCrc;
import network.packets.swg.zone.SceneDestroyObject;
@@ -40,7 +52,6 @@ import resources.client_info.visitors.ObjectData.ObjectDataAttribute;
import resources.common.CRC;
import resources.containers.ContainerPermissionsType;
import resources.containers.ContainerResult;
-import resources.control.Assert;
import resources.encodables.StringId;
import resources.network.BaselineBuilder;
import resources.network.BaselineObject;
@@ -54,22 +65,13 @@ import resources.persistable.Persistable;
import resources.persistable.SWGObjectFactory;
import resources.player.Player;
import resources.server_info.Log;
-import resources.server_info.SynchronizedMap;
-import resources.server_info.SynchronizedSet;
import services.CoreManager;
import services.objects.ObjectCreator;
import utilities.AwarenessUtilities;
-import intents.object.ContainerTransferIntent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.concurrency.SynchronizedSet;
+import com.projectswg.common.debug.Assert;
public abstract class SWGObject extends BaselineObject implements Comparable, Persistable {
diff --git a/src/resources/objects/awareness/AwarenessHandler.java b/src/resources/objects/awareness/AwarenessHandler.java
index 91b710ef9..ff0b84815 100644
--- a/src/resources/objects/awareness/AwarenessHandler.java
+++ b/src/resources/objects/awareness/AwarenessHandler.java
@@ -32,11 +32,12 @@ import java.util.Map;
import resources.Location;
import resources.Terrain;
-import resources.control.Assert;
import resources.objects.SWGObject;
import resources.objects.awareness.TerrainMap.TerrainMapCallback;
import resources.server_info.Log;
+import com.projectswg.common.debug.Assert;
+
public class AwarenessHandler implements AutoCloseable {
private final Map terrains;
diff --git a/src/resources/objects/awareness/TerrainMap.java b/src/resources/objects/awareness/TerrainMap.java
index d0d03adef..f3bfd4736 100644
--- a/src/resources/objects/awareness/TerrainMap.java
+++ b/src/resources/objects/awareness/TerrainMap.java
@@ -32,13 +32,14 @@ import java.util.Set;
import resources.Location;
import resources.Terrain;
-import resources.callback.CallbackManager;
-import resources.control.Assert;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.objects.waypoint.WaypointObject;
import resources.server_info.Log;
+import com.projectswg.common.callback.CallbackManager;
+import com.projectswg.common.debug.Assert;
+
public class TerrainMap {
private static final int CHUNK_COUNT_ACROSS = 16;
diff --git a/src/resources/objects/awareness/TerrainMapChunk.java b/src/resources/objects/awareness/TerrainMapChunk.java
index 332c6a0be..0e11145a1 100644
--- a/src/resources/objects/awareness/TerrainMapChunk.java
+++ b/src/resources/objects/awareness/TerrainMapChunk.java
@@ -34,7 +34,8 @@ import java.util.Set;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
-import resources.server_info.SynchronizedSet;
+
+import com.projectswg.common.concurrency.SynchronizedSet;
class TerrainMapChunk {
diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java
index be349956d..020a943a8 100644
--- a/src/resources/objects/building/BuildingObject.java
+++ b/src/resources/objects/building/BuildingObject.java
@@ -27,24 +27,26 @@
***********************************************************************************/
package resources.objects.building;
-import network.packets.swg.zone.baselines.Baseline.BaselineType;
-import resources.Location;
-import resources.client_info.ClientFactory;
-import resources.client_info.visitors.PortalLayoutData;
-import resources.client_info.visitors.ObjectData.ObjectDataAttribute;
-import resources.control.Assert;
-import resources.network.NetBufferStream;
-import resources.objects.SWGObject;
-import resources.objects.cell.CellObject;
-import resources.objects.tangible.TangibleObject;
-import resources.server_info.SynchronizedMap;
-import services.objects.ObjectCreator;
import intents.object.ObjectCreatedIntent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import network.packets.swg.zone.baselines.Baseline.BaselineType;
+import resources.Location;
+import resources.client_info.ClientFactory;
+import resources.client_info.visitors.ObjectData.ObjectDataAttribute;
+import resources.client_info.visitors.PortalLayoutData;
+import resources.network.NetBufferStream;
+import resources.objects.SWGObject;
+import resources.objects.cell.CellObject;
+import resources.objects.tangible.TangibleObject;
+import services.objects.ObjectCreator;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.debug.Assert;
+
public class BuildingObject extends TangibleObject {
private final Map nameToCell;
diff --git a/src/resources/objects/creature/CreatureObjectSharedNP.java b/src/resources/objects/creature/CreatureObjectSharedNP.java
index 203218e7b..19668f958 100644
--- a/src/resources/objects/creature/CreatureObjectSharedNP.java
+++ b/src/resources/objects/creature/CreatureObjectSharedNP.java
@@ -36,7 +36,6 @@ import resources.HologramColour;
import resources.collections.SWGList;
import resources.collections.SWGMap;
import resources.common.CRC;
-import resources.control.Assert;
import resources.encodables.player.Equipment;
import resources.network.BaselineBuilder;
import resources.network.NetBuffer;
@@ -48,6 +47,8 @@ import resources.persistable.SWGObjectFactory;
import resources.player.Player;
import services.group.GroupInviterData;
+import com.projectswg.common.debug.Assert;
+
class CreatureObjectSharedNP implements Persistable {
private transient GroupInviterData inviterData = new GroupInviterData(0, null, "", 0);
diff --git a/src/resources/objects/group/GroupObject.java b/src/resources/objects/group/GroupObject.java
index 74efed318..98630eaf0 100644
--- a/src/resources/objects/group/GroupObject.java
+++ b/src/resources/objects/group/GroupObject.java
@@ -26,20 +26,6 @@
******************************************************************************/
package resources.objects.group;
-import network.packets.Packet;
-import network.packets.swg.zone.baselines.Baseline;
-import resources.Location;
-import resources.Terrain;
-import resources.collections.SWGList;
-import resources.control.Assert;
-import resources.encodables.Encodable;
-import resources.network.BaselineBuilder;
-import resources.objects.SWGObject;
-import resources.objects.creature.CreatureObject;
-import resources.player.Player;
-import resources.server_info.SynchronizedMap;
-import utilities.Encoder;
-
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.HashSet;
@@ -48,6 +34,21 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import network.packets.Packet;
+import network.packets.swg.zone.baselines.Baseline;
+import resources.Location;
+import resources.Terrain;
+import resources.collections.SWGList;
+import resources.encodables.Encodable;
+import resources.network.BaselineBuilder;
+import resources.objects.SWGObject;
+import resources.objects.creature.CreatureObject;
+import resources.player.Player;
+import utilities.Encoder;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.debug.Assert;
+
public class GroupObject extends SWGObject {
private final SWGList groupMembers = new SWGList<>(6, 2, Encoder.StringType.ASCII);
diff --git a/src/resources/player/Player.java b/src/resources/player/Player.java
index 3f7ead461..937a7c4c7 100644
--- a/src/resources/player/Player.java
+++ b/src/resources/player/Player.java
@@ -29,12 +29,13 @@ package resources.player;
import intents.network.OutboundPacketIntent;
import network.packets.Packet;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.objects.player.PlayerObject;
import services.player.PlayerManager;
-import utilities.IntentChain;
+
+import com.projectswg.common.control.IntentChain;
+import com.projectswg.common.control.Service;
public class Player implements Comparable {
diff --git a/src/resources/server_info/Config.java b/src/resources/server_info/Config.java
deleted file mode 100644
index 6785b0a15..000000000
--- a/src/resources/server_info/Config.java
+++ /dev/null
@@ -1,183 +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 resources.server_info;
-
-import java.io.File;
-import java.util.Map;
-
-/**
- * Reads and stores configuration data from a file
- */
-public class Config {
-
- private final ConfigData configData;
-
- /**
- * Initilizes the Config and loads the data in the file
- * @param filename the file to load
- */
- public Config(String filename) {
- this(new File(filename));
- }
-
- /**
- * Initilizes the Config and loads the data in the file
- * @param file the file to load
- */
- public Config(File file) {
- if (!file.exists() || !file.isFile())
- throw new IllegalArgumentException("Filepath does not point to a valid file!");
- configData = new ConfigData(file);
- load();
- save();
- }
-
- /**
- * Determines whether or not the key-value pair exists in the config
- * @param key the key to check
- * @return TRUE if the key-value pair exists, FALSE otherwise
- */
- public boolean containsKey(String key) {
- return configData.containsKey(key);
- }
-
- /**
- * Gets the parameter with the specified key. If no such parameter exists,
- * it returns the default
- * @param key the key to get the value for
- * @param def the default value
- * @return the value represented by the key, or the default value
- */
- public String getString(String key, String def) {
- if (!containsKey(key)) {
- setProperty(key, def);
- return def;
- }
- return configData.get(key);
- }
-
- /**
- * Gets the parameter with the specified key. If no such parameter exists,
- * or if the value isn't an integer then it returns the default
- * @param key the key to get the value for
- * @param def the default value
- * @return the value represented by the key, or the default value
- */
- public int getInt(String key, int def) {
- try {
- return Integer.parseInt(getString(key, Integer.toString(def)));
- } catch (NumberFormatException e) {
- return def;
- }
- }
-
- /**
- * Gets the parameter with the specified key. If no such parameter exists,
- * or if the value isn't a double then it returns the default
- * @param key the key to get the value for
- * @param def the default value
- * @return the value represented by the key, or the default value
- */
- public double getDouble(String key, double def) {
- try {
- return Double.parseDouble(getString(key, Double.toString(def)));
- } catch (NumberFormatException e) {
- return def;
- }
- }
-
- /**
- * Gets the parameter with the specified key. If no such parameter exists,
- * or if the value isn't a boolean then it returns the default
- * @param key the key to get the value for
- * @param def the default value
- * @return the value represented by the key, or the default value
- */
- public boolean getBoolean(String key, boolean def) {
- String val = getString(key, def?"true":"false");
- if (val.equalsIgnoreCase("true") || val.equals("1"))
- return true;
- if (val.equalsIgnoreCase("false") || val.equals("0"))
- return false;
- return def;
- }
-
- /**
- * Sets the property value for the specified key
- * @param key the key of the value to set
- * @param value the value to set
- */
- public void setProperty(String key, String value) {
- configData.put(key, value);
- save();
- }
-
- /**
- * Sets the property value for the specified key
- * @param key the key of the value to set
- * @param value the value to set
- */
- public void setProperty(String key, int value) {
- setProperty(key, Integer.toString(value));
- }
-
- /**
- * Sets the property value for the specified key
- * @param key the key of the value to set
- * @param value the value to set
- */
- public void setProperty(String key, boolean value) {
- setProperty(key, value ? "true" : "false");
- }
-
- /**
- * Sets the property value for the specified key
- * @param key the key of the value to set
- * @param value the value to set
- */
- public void setProperty(String key, double value) {
- setProperty(key, Double.toString(value));
- }
-
- /**
- * Reloads the config data from the file
- * @return TRUE if the data was successfully loaded, FALSE otherwise
- */
- public Map load() {
- return configData.load();
- }
-
- /**
- * Saves the config data to the file
- * @return TRUE if the data was successfully saved, FALSE otherwise
- */
- public boolean save() {
- return configData.save();
- }
-
-}
diff --git a/src/resources/server_info/ConfigData.java b/src/resources/server_info/ConfigData.java
deleted file mode 100644
index e98392d08..000000000
--- a/src/resources/server_info/ConfigData.java
+++ /dev/null
@@ -1,152 +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 resources.server_info;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-class ConfigData {
-
- private final DateFormat FORMAT = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss zzz");
- private final Map data;
- private final File file;
-
- public ConfigData(File file) {
- this.data = new TreeMap<>();
- this.file = file;
- }
-
- public boolean containsKey(String key) {
- synchronized (data) {
- return data.containsKey(key);
- }
- }
-
- public String get(String key) {
- synchronized (data) {
- return data.get(key);
- }
- }
-
- public String put(String key, String value) {
- synchronized (data) {
- return data.put(key, value);
- }
- }
-
- /**
- * @return null on an I/O failure, an empty {@code Map} on the first load and
- * a populated {@code Map} when called afterwards
- */
- public Map load() {
- Map delta = new HashMap<>();
- BufferedReader reader = null;
-
- synchronized (data) {
- delta.putAll(data); // Copy the current data
-
- try {
- reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
- String line = reader.readLine();
- while (line != null) {
- loadLine(line);
- line = reader.readLine();
- }
- } catch (IOException e) {
- Log.e(e);
- return null;
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- return null;
- }
- }
- }
- for(Entry entry : data.entrySet())
- delta.remove(entry.getKey(), entry.getValue());
- }
-
- return delta;
- }
-
- public boolean save() {
- BufferedWriter writer = null;
- synchronized (data) {
- try {
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
- writer.write("# "+FORMAT.format(System.currentTimeMillis()));
- writer.newLine();
- for (Entry e : data.entrySet()) {
- writer.write(e.getKey() + "=" + e.getValue());
- writer.newLine();
- }
- return true;
- } catch (IOException e) {
- Log.e(e);
- return false;
- } finally {
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
-
- }
- }
- }
- }
- }
-
- private void loadLine(String line) {
- String beforeComment = line;
- if (line.contains("#"))
- beforeComment = line.substring(0, line.indexOf('#'));
- if (!beforeComment.contains("="))
- return;
- String key = beforeComment.substring(0, beforeComment.indexOf('='));
- String val = beforeComment.substring(key.length()+1);
- synchronized (data) {
- data.put(key, val);
- }
- }
-
-}
diff --git a/src/resources/server_info/ConfigWatcher.java b/src/resources/server_info/ConfigWatcher.java
index 7b1a41a8d..7edd0cab3 100644
--- a/src/resources/server_info/ConfigWatcher.java
+++ b/src/resources/server_info/ConfigWatcher.java
@@ -33,106 +33,95 @@ import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
-import java.nio.file.WatchEvent.Kind;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import com.projectswg.common.concurrency.PswgBasicThread;
+import com.projectswg.common.info.Config;
import resources.config.ConfigFile;
-import static java.nio.file.StandardWatchEventKinds.OVERFLOW;
-import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
public final class ConfigWatcher {
-
- private final WatchService watcher;
- private final Map configMap;
- private final Path directory;
- private ExecutorService executor;
- private boolean stop;
+
private static final String CFGPATH = "cfg/";
- public ConfigWatcher(Map configMap) throws IOException {
+ private final Map configMap;
+ private final Path directory;
+ private final PswgBasicThread watcherThread;
+ private final AtomicBoolean running;
+
+ private WatchService watcher;
+
+ public ConfigWatcher(Map configMap) {
this.configMap = configMap;
- watcher = FileSystems.getDefault().newWatchService();
- directory = Paths.get(CFGPATH);
-
- directory.register(watcher, ENTRY_MODIFY);
+ this.directory = Paths.get(CFGPATH);
+ this.watcherThread = new PswgBasicThread("config-watcher", () -> watch());
+ this.running = new AtomicBoolean(false);
+
+ try {
+ this.watcher = FileSystems.getDefault().newWatchService();
+ directory.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
+ } catch (IOException e) {
+ this.watcher = null;
+ }
+ watcherThread.setWaitForTermination(false);
}
-
- @SuppressWarnings("unchecked")
+
public void start() {
- executor = Executors.newSingleThreadExecutor();
- executor.execute(() -> {
- WatchKey key;
- Kind> eventKind;
- WatchEvent ev;
- Path filename;
- ConfigFile cfgFile;
- Config cfg;
-
- while (!stop) {
- try {
- key = watcher.take(); // We're stuck here until a change is made.
- if (key == null)
- break;
- } catch (Exception e) {
+ watcherThread.start();
+ }
+
+ public void stop() {
+ watcherThread.stop();
+ watcherThread.awaitTermination(1000);
+ }
+
+ private void watch() {
+ if (watcher == null) {
+ Log.e("WatcherService is null!");
+ return;
+ }
+ WatchKey key;
+
+ try {
+ while (running.get()) {
+ key = watcher.take(); // We're stuck here until a change is made.
+ if (key == null)
break;
- }
-
+
for (WatchEvent> event : key.pollEvents()) {
- eventKind = event.kind();
-
- // This key is registered only
- // for ENTRY_CREATE events,
- // but an OVERFLOW event can
- // occur regardless if events
- // are lost or discarded.
- if (eventKind == OVERFLOW) {
- key.reset();
- continue;
- }
-
- // The context is the name of the file.
- ev = (WatchEvent) event;
- filename = ev.context();
-
- cfgFile = ConfigFile.configFileForName(CFGPATH + filename);
- cfg = configMap.get(cfgFile);
-
- if(cfg == null) {
- key.reset();
- continue;
- }
-
- Map delta = cfg.load();
-
- for (Entry entry : delta.entrySet()) {
- String entryKey = entry.getKey();
-
- new ConfigChangedIntent(cfgFile, entryKey, entry.getValue(),
- cfg.getString(entryKey, null)).broadcast();
- }
-
- // We want to receive further watch
- // events from this key - reset it.
+ processEvents(event);
key.reset();
}
}
+ } catch (Exception e) {
+ // Ignored
+ } finally {
try {
watcher.close();
} catch (Exception e) {
Log.e(e);
}
- });
+ }
}
- public void stop() {
- stop = true;
- if (executor != null)
- executor.shutdownNow();
+ private void processEvents(WatchEvent> event) {
+ if (event.kind() == StandardWatchEventKinds.OVERFLOW)
+ return;
+
+ @SuppressWarnings("unchecked")
+ ConfigFile cfgFile = ConfigFile.configFileForName(CFGPATH + ((WatchEvent) event).context());
+ Config cfg = configMap.get(cfgFile);
+ if (cfg == null)
+ return;
+
+ for (Entry entry : cfg.load().entrySet()) {
+ new ConfigChangedIntent(cfgFile, entry.getKey(), entry.getValue(), cfg.getString(entry.getKey(), null)).broadcast();
+ }
}
}
diff --git a/src/resources/server_info/CrcDatabase.java b/src/resources/server_info/CrcDatabase.java
index 29a33ca1d..6482b98dd 100644
--- a/src/resources/server_info/CrcDatabase.java
+++ b/src/resources/server_info/CrcDatabase.java
@@ -35,6 +35,9 @@ import java.util.Map;
import resources.common.CRC;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class CrcDatabase implements AutoCloseable {
private static final String INSERT_CRC_SQL = "INSERT INTO crcs (string, crc) VALUES (?, ?)";
diff --git a/src/resources/server_info/DataManager.java b/src/resources/server_info/DataManager.java
index a2effbc14..1e755c7eb 100644
--- a/src/resources/server_info/DataManager.java
+++ b/src/resources/server_info/DataManager.java
@@ -27,147 +27,115 @@
***********************************************************************************/
package resources.server_info;
-import intents.server.ConfigChangedIntent;
-
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.debug.Assert;
+import com.projectswg.common.info.Config;
+import com.projectswg.common.info.RelationalServerFactory;
import resources.config.ConfigFile;
-import resources.control.Intent;
-import resources.control.IntentManager;
-import resources.control.IntentReceiver;
-
-public class DataManager implements IntentReceiver {
+public class DataManager {
+
private static final Object instanceLock = new Object();
- private static final String ENABLE_LOGGING = "ENABLE-LOGGING";
private static DataManager instance = null;
-
- private Map config;
- private List watchers;
- private boolean initialized;
-
+
+ private final Map configs;
+ private final ConfigWatcher watcher;
+ private final AtomicBoolean initialized;
+
private DataManager() {
- initialized = false;
- IntentManager.getInstance().registerForIntent(ConfigChangedIntent.TYPE, this);
- watchers = new ArrayList<>();
- }
-
- private synchronized void initialize() {
- initializeConfig();
- if (getConfig(ConfigFile.PRIMARY).getBoolean(ENABLE_LOGGING, true))
- Log.start();
- initialized = true;
+ this.configs = new SynchronizedMap<>();
+ this.watcher = new ConfigWatcher(configs);
+ this.initialized = new AtomicBoolean(false);
}
- private synchronized void shutdown() {
- for (ConfigWatcher watcher : watchers)
- watcher.stop();
+ private void initializeImpl() {
+ if (initialized.getAndSet(true))
+ return;
+ initializeConfig();
+ RelationalServerFactory.setBasePath("serverdata/");
}
-
- private synchronized void initializeConfig() {
- config = new ConcurrentHashMap();
+
+ private void terminateImpl() {
+ if (!initialized.getAndSet(false))
+ return;
+ watcher.stop();
+ configs.clear();
+ }
+
+ private Config getConfigImpl(ConfigFile file) {
+ return configs.get(file);
+ }
+
+ private void initializeConfig() {
+ Assert.test(configs.isEmpty(), "Internal error in DataManager!");
for (ConfigFile file : ConfigFile.values()) {
File f = new File(file.getFilename());
- try {
- if (!createFilesAndDirectories(f)) {
- Log.w("ConfigFile could not be loaded! " + file.getFilename());
- } else {
- config.put(file, new Config(f));
- }
-
- ConfigWatcher watcher = new ConfigWatcher(config);
- watcher.start();
- watchers.add(watcher);
- } catch (IOException e) {
- Log.e(e);
+ if (!createConfig(f)) {
+ Log.w("ConfigFile could not be loaded! " + file.getFilename());
+ } else {
+ configs.put(file, new Config(f));
}
}
+ watcher.start();
}
- private boolean createFilesAndDirectories(File file) {
+ private boolean createConfig(File file) {
if (file.exists())
- return true;
+ return file.isFile();
try {
- String parentName = file.getParent();
- if (parentName != null && !parentName.isEmpty()) {
- File parent = new File(file.getParent());
- if (!parent.exists() && !parent.mkdirs())
- Log.e("Failed to create parent directories for ODB: " + file.getCanonicalPath());
+ File parent = file.getParentFile();
+ if (parent != null && !parent.exists() && !parent.mkdirs()) {
+ Log.e("Failed to create parent directories for config: " + file.getCanonicalPath());
+ return false;
+ }
+ if (!file.createNewFile()) {
+ Log.e("Failed to create new config: " + file.getCanonicalPath());
+ return false;
}
- } catch (IOException e) {
- Log.e(e);
- }
- try {
- if (!file.createNewFile())
- Log.e("Failed to create new ODB: " + file.getCanonicalPath());
} catch (IOException e) {
Log.e(e);
}
return file.exists();
}
-
+
/**
- * Gets the config object associated with a certain file, or NULL if the
- * file failed to load on startup
+ * Gets the config object associated with a certain file, or NULL if the file failed to load on startup
*
- * @param file
- * the file to get the config for
- * @return the config object associated with the file, or NULL if the config
- * failed to load
+ * @param file the file to get the config for
+ * @return the config object associated with the file, or NULL if the config failed to load
*/
- public synchronized final Config getConfig(ConfigFile file) {
- Config c = config.get(file);
- if (c == null)
- return new Config(file.getFilename());
- return c;
+ public static Config getConfig(ConfigFile file) {
+ return getInstance().getConfigImpl(file);
}
-
- public synchronized final boolean isInitialized() {
- return initialized;
+
+ public static void initialize() {
+ synchronized (instanceLock) {
+ if (instance != null)
+ return;
+ instance = new DataManager();
+ instance.initializeImpl();
+ }
}
-
- public synchronized static final DataManager getInstance() {
+
+ public static void terminate() {
+ synchronized (instanceLock) {
+ if (instance == null)
+ return;
+ instance.terminateImpl();
+ instance = null;
+ }
+ }
+
+ private static final DataManager getInstance() {
synchronized (instanceLock) {
- if (instance == null) {
- instance = new DataManager();
- instance.initialize();
- }
return instance;
}
}
- public synchronized static final void terminate() {
- synchronized (instanceLock) {
- if (instance != null) {
- instance.shutdown();
- instance = null;
- }
- }
- }
-
- @Override
- public void onIntentReceived(Intent i) {
- if (!(i instanceof ConfigChangedIntent))
- return;
- ConfigChangedIntent cci = (ConfigChangedIntent) i;
- if(!cci.getKey().equals(ENABLE_LOGGING))
- return;
- boolean log = Boolean.valueOf(cci.getNewValue());
- boolean oldValue = Boolean.valueOf(cci.getOldValue());
-
- // If the value hasn't changed, then do nothing.
- if(log == oldValue)
- return;
-
- if (log)
- Log.start();
- else
- Log.stop();
- }
-
}
diff --git a/src/resources/server_info/ObjectDatabase.java b/src/resources/server_info/ObjectDatabase.java
index 30e7d5c33..ec62955e9 100644
--- a/src/resources/server_info/ObjectDatabase.java
+++ b/src/resources/server_info/ObjectDatabase.java
@@ -31,9 +31,10 @@ import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import resources.concurrency.PswgBasicScheduledThread;
import resources.persistable.Persistable;
+import com.projectswg.common.concurrency.PswgBasicScheduledThread;
+
public abstract class ObjectDatabase {
private final File file;
diff --git a/src/resources/server_info/PostgresqlDatabase.java b/src/resources/server_info/PostgresqlDatabase.java
deleted file mode 100644
index ec7f08552..000000000
--- a/src/resources/server_info/PostgresqlDatabase.java
+++ /dev/null
@@ -1,36 +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 resources.server_info;
-
-public class PostgresqlDatabase extends RelationalDatabase {
-
- public PostgresqlDatabase(String host, String db, String user, String pass) {
- super("org.postgresql.Driver", "postgresql", host, db, user, pass, "");
- }
-
-}
diff --git a/src/resources/server_info/RelationalDatabase.java b/src/resources/server_info/RelationalDatabase.java
deleted file mode 100644
index 964187a10..000000000
--- a/src/resources/server_info/RelationalDatabase.java
+++ /dev/null
@@ -1,190 +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 resources.server_info;
-
-import java.io.Closeable;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.Statement;
-
-public abstract class RelationalDatabase implements Closeable {
-
- private DatabaseMetaData metaData;
- private Connection connection;
- private boolean online;
-
- protected RelationalDatabase(String jdbcClass, String url) {
- try {
- Class.forName(jdbcClass);
- initialize(url);
- } catch (ClassNotFoundException e) {
- Log.e(e);
- online = false;
- }
- }
-
- protected RelationalDatabase(String jdbcClass, String url, String user, String pass) {
- try {
- Class.forName(jdbcClass);
- initialize(url, user, pass);
- } catch (ClassNotFoundException e) {
- Log.e(e);
- online = false;
- }
- }
-
- public RelationalDatabase(String jdbcClass, String url, String user, String pass, String params) {
- try {
- Class.forName(jdbcClass);
- if (params != null && params.length() > 0)
- url += "?" + params;
- initialize(url, user, pass);
- } catch (ClassNotFoundException e) {
- Log.e(e);
- online = false;
- }
- }
-
- public RelationalDatabase(String jdbcClass, String type, String host, String db, String user, String pass, String params) {
- try {
- Class.forName(jdbcClass);
- String url = "jdbc:" + type + "://" + host + "/" + db;
- if (params != null && params.length() > 0)
- url += "?" + params;
- initialize(url, user, pass);
- } catch (ClassNotFoundException e) {
- Log.e(e);
- online = false;
- }
- }
-
- private void initialize(String url) {
- try {
- connection = DriverManager.getConnection(url);
- metaData = connection.getMetaData();
- online = true;
- } catch (SQLException e) {
- Log.e("Failed to initialize relational database! %s - %s", e.getClass().getSimpleName(), e.getMessage());
- online = false;
- }
- }
-
- private void initialize(String url, String user, String pass) {
- try {
- connection = DriverManager.getConnection(url, user, pass);
- metaData = connection.getMetaData();
- online = true;
- } catch (SQLException e) {
- Log.e("Failed to initialize relational database! %s - %s", e.getClass().getSimpleName(), e.getMessage());
- online = false;
- }
- }
-
- public void close() {
- try {
- connection.close();
- online = false;
- } catch (SQLException e) {
- Log.e(e);
- }
- }
-
- public boolean isOnline() {
- if (connection == null)
- return false;
- try {
- return online && !connection.isClosed();
- } catch (SQLException e) {
- return online;
- }
- }
-
- public PreparedStatement prepareStatement(String sql) {
- if (connection == null) {
- Log.e("Cannot prepare statement! Connection is null");
- return null;
- }
- try {
- return connection.prepareStatement(sql);
- } catch (SQLException e) {
- Log.e(e);
- return null;
- }
- }
-
- public ResultSet executeQuery(String query) {
- if (connection == null)
- return null;
- Statement s = null;
- try {
- s = connection.createStatement();
- s.execute(query);
- try {
- s.closeOnCompletion();
- } catch (SQLFeatureNotSupportedException e) {
- // It was worth a shot
- }
- return s.getResultSet();
- } catch (SQLException e) {
- Log.e(e);
- if (s != null) {
- try { s.close(); } catch (SQLException ex) { }
- }
- return null;
- }
- }
-
- public int updateQuery(String query) {
- if (connection == null)
- return 0;
- try {
- try (Statement s = connection.createStatement()) {
- return s.executeUpdate(query);
- }
- } catch (SQLException e) {
- Log.e(e);
- return 0;
- }
- }
-
- public boolean isTable(String name) {
- if (metaData == null)
- return false;
- try {
- return metaData.getTables(null, null, name, null).next();
- } catch (SQLException e) {
- return false;
- }
- }
-
-}
diff --git a/src/resources/server_info/RelationalServerData.java b/src/resources/server_info/RelationalServerData.java
deleted file mode 100644
index 842cbad5a..000000000
--- a/src/resources/server_info/RelationalServerData.java
+++ /dev/null
@@ -1,445 +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 resources.server_info;
-
-import java.io.BufferedReader;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class RelationalServerData extends RelationalDatabase {
-
- private static final Charset ASCII = Charset.forName("ASCII");
-
- private static final String META_TABLE = "__server_table_metadata__";
- private final PreparedStatement getTableMetadata;
- private final PreparedStatement updateTableMetadata;
- private final PreparedStatement insertTableMetadata;
-
- public RelationalServerData(String file) {
- super("org.sqlite.JDBC", "jdbc:sqlite:" + file);
- /*
- * GREATLY speeds up INSERT speeds. This makes it so SQLite will not
- * wait until the previous write finishes before starting to write the
- * next INSERT. All imports will only take milliseconds. A caveat of
- * this is that if the power ever cuts or the application is force
- * killed it may result in database corruption.
- */
- updateQuery("PRAGMA synchronous=OFF");
- updateQuery("CREATE TABLE IF NOT EXISTS "+META_TABLE+" (table_name TEXT, last_imported INTEGER)");
- getTableMetadata = prepareStatement("SELECT * FROM "+META_TABLE+" WHERE table_name=?");
- updateTableMetadata = prepareStatement("UPDATE "+META_TABLE+" SET last_imported=? WHERE table_name=?");
- insertTableMetadata = prepareStatement("INSERT INTO "+META_TABLE+" (table_name, last_imported) VALUES (?, ?)");
- }
-
- public boolean linkTableWithSdb(String table, String filepath) {
- File sdb = new File(filepath);
- if (!sdb.isFile())
- return false;
- if (testLastModified(table, sdb) || testMasterSdbModified(table, sdb)) {
- updateQuery("DROP TABLE IF EXISTS " + table);
- importFromSdb(table, sdb);
- updateLastImported(table, System.currentTimeMillis());
- }
- return true;
- }
-
- private boolean testLastModified(String table, File sdb) {
- return sdb.lastModified() > getLastImported(table);
- }
-
- private boolean testMasterSdbModified(String table, File sdb) {
- if (!sdb.getName().endsWith(".msdb"))
- return false;
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(sdb), ASCII))) {
- reader.readLine();
- reader.readLine();
- String line;
- while ((line = reader.readLine()) != null) {
- if (testLastModified(table, new File(sdb.getParent(), line.substring(0, line.indexOf('\t')))))
- return true;
- }
- } catch (IOException e) {
- Log.e(e);
- }
- return false;
- }
-
- /**
- * Inserts a record with the specified information into the database
- * @param table the table to insert into
- * @param columns the columns to insert into
- * @param params the parameters to insert
- * @return TRUE on success, FALSE on failure
- * @throws SQLException upon error
- */
- public boolean insert(String table, String [] columns, Object ... params) throws SQLException {
- StringBuilder columnStr = new StringBuilder("");
- StringBuilder valuesStr = new StringBuilder("");
- if (columns == null)
- columns = getColumnsForTable(table);
- for (int i = 0; i < columns.length; i++) {
- columnStr.append(columns[i]);
- valuesStr.append('?');
- if (i+1 < columns.length) {
- columnStr.append(',');
- valuesStr.append(',');
- }
- }
- final String sql = String.format("INSERT INTO %s (%s) VALUES (%s)", table, columnStr, valuesStr);
- try (PreparedStatement statement = prepareStatement(sql)) {
- if (statement == null || params.length < getSqlParameterCount(sql))
- return false;
- assignParameters(statement, params);
- return statement.executeUpdate() > 0;
- }
- }
-
- /**
- * Selects from the specified table with the supplied where clause, given
- * the supplied parameters
- * @param tables the tables to query, separated by commas
- * @param columns the columns to select, null to select all
- * @param where the where clause
- * @param params the parameters to put into the ?s in the where clause
- * @return the result set
- * @throws SQLException upon error
- */
- public ResultSet selectFromTable(String tables, String [] columns, String where, Object ... params) throws SQLException {
- final String sql = createSelectQuery(tables, columns, where, params);
- PreparedStatement statement = prepareStatement(sql);
- if (statement == null || params.length < getSqlParameterCount(sql))
- return null;
- assignParameters(statement, params);
- return statement.executeQuery();
- }
-
- private void assignParameters(PreparedStatement statement, Object ... params) throws SQLException {
- for (int i = 0; i < params.length; i++) {
- if (params[i] instanceof Integer || params[i] instanceof Long)
- statement.setLong(i+1, ((Number) params[i]).longValue());
- else if (params[i] instanceof Float || params[i] instanceof Double)
- statement.setDouble(i+1, ((Number) params[i]).doubleValue());
- else if (params[i] instanceof String)
- statement.setString(i+1, (String) params[i]);
- else if (params[i] != null)
- throw new IllegalArgumentException("Unknown object type: " + params[i].getClass().getSimpleName());
- else
- throw new NullPointerException("Parameters cannot have null elements!");
- }
- }
-
- private int getSqlParameterCount(String sql) {
- int ret = 0;
- for (int i = 0; i < sql.length(); i++) {
- if (sql.charAt(i) == '?')
- ret++;
- }
- return ret;
- }
-
- private String createSelectQuery(String tables, String [] columns, String where, Object ... params) {
- String columnStr = "*";
- if (columns == null && tables.contains(",")) {
- StringBuilder bldr = new StringBuilder("");
- for (String table : tables.split(",")) {
- bldr.append(table.trim());
- bldr.append(".*, ");
- }
- columnStr = bldr.substring(0, columnStr.length()-2);
- } else if (columns != null) {
- StringBuilder bldr = new StringBuilder("");
- for (String column : columns) {
- bldr.append(column);
- bldr.append(", ");
- }
- columnStr = bldr.substring(0, bldr.length()-2);
- }
- return "SELECT " + columnStr + " FROM " + tables + " WHERE " + where;
- }
-
- private String [] getColumnsForTable(String table) throws SQLException {
- List columns = new ArrayList<>();
- try (ResultSet set = executeQuery("PRAGMA table_info('"+table+"')")) {
- int colInd = set.findColumn("name");
- while (set.next()) {
- columns.add(set.getString(colInd));
- }
- }
- return columns.toArray(new String[columns.size()]);
- }
-
- private long getLastImported(String table) {
- synchronized (getTableMetadata) {
- ResultSet set = null;
- try {
- getTableMetadata.setString(1, table);
- set = getTableMetadata.executeQuery();
- if (set.next())
- return set.getLong("last_imported");
- } catch (SQLException e) {
- Log.e(e);
- } finally {
- if (set != null) {
- try {
- set.close();
- } catch (SQLException e) {
- Log.e(e);
- }
- }
- }
- return -1;
- }
- }
-
- private void updateLastImported(String table, long lastImported) {
- synchronized (updateTableMetadata) {
- try {
- updateTableMetadata.setLong(1, lastImported);
- updateTableMetadata.setString(2, table);
- if (updateTableMetadata.executeUpdate() > 0)
- return;
- } catch (SQLException e) {
- Log.e(e);
- return;
- }
- }
- synchronized (insertTableMetadata) {
- try {
- insertTableMetadata.setString(1, table);
- insertTableMetadata.setLong(2, lastImported);
- insertTableMetadata.executeUpdate();
- } catch (SQLException e) {
- Log.e(e);
- }
- }
- }
-
- private boolean importFromSdb(String table, File sdb) {
- try (TableReader reader = new TableReader(table, sdb)) {
- Log.i("Importing sdb... '" + sdb + "'");
- if (sdb.getName().endsWith(".msdb"))
- reader.readMaster();
- else
- reader.readNormal();
- return true;
- } catch (IOException e) {
- Log.e(e);
- } catch (SQLException e) {
- Log.e(e);
- } catch (IllegalArgumentException e) {
- Log.e("Invalid file format. Aborting read of %s! Message: %s", sdb, e.getMessage());
- }
- return false;
- }
-
- private class TableReader implements Closeable {
-
- private final String table;
- private final File file;
- private String [] columnNames;
- private String [] columnTypes;
- private PreparedStatement insert;
-
- public TableReader(String table, File file) {
- this.table = table;
- this.file = file;
- this.columnNames = null;
- this.columnTypes = null;
- this.insert = null;
- }
-
- @Override
- public void close() {
- if (insert != null) {
- try {
- insert.close();
- } catch (SQLException e) {
- Log.e(e);
- }
- }
- }
-
- public void readNormal() throws IOException, SQLException {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), ASCII))) {
- readNormalRemainder(reader, 1);
- }
- }
-
- public void readMaster() throws SQLException, IOException {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), ASCII))) {
- int lineNum = 1;
- readLine(reader.readLine(), lineNum++);
- readLine(reader.readLine(), lineNum++);
- readMasterRemainder(reader, lineNum);
- }
- }
-
- private void readSlave() throws IOException, SQLException {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), ASCII))) {
- int lineNum = 3;
- reader.readLine();
- reader.readLine(); // Skip column names and types
- readNormalRemainder(reader, lineNum);
- }
- }
-
- private void readMasterRemainder(BufferedReader reader, int lineNum) throws IOException, SQLException {
- String line;
- while ((line = reader.readLine()) != null) {
- String [] parts = line.split("\t");
- if (parts.length != 2) {
- Log.e("Invalid line [%d]: %s", lineNum, line);
- continue;
- }
- boolean load = Boolean.parseBoolean(parts[1]);
- if (load) {
- File sdb = new File(file.getParent(), parts[0]);
- Log.i(" Importing sdb... '" + sdb + "'");
- if (!sdb.isFile()) {
- Log.e(" Failed to import sdb! File is not file or does not exist");
- continue;
- }
- @SuppressWarnings("resource") // This closes the database.. we don't want to do that yet
- TableReader slave = new TableReader(table, sdb);
- slave.columnNames = columnNames;
- slave.columnTypes = columnTypes;
- slave.insert = insert;
- slave.readSlave();
- }
- }
- }
-
- private void readNormalRemainder(BufferedReader reader, int lineNum) throws IOException, SQLException {
- String line;
- while ((line = reader.readLine()) != null) {
- readLine(line, lineNum++);
- }
- if (insert != null)
- insert.executeBatch();
- }
-
- private void readLine(String line, int lineNum) throws SQLException {
- if (line == null)
- return;
- switch (lineNum) {
- case 1:
- columnNames = fastTabSplit(line);
- break;
- case 2:
- columnTypes = fastTabSplit(line);
- createTable();
- createPreparedStatement();
- break;
- default:
- generateInsert(fastTabSplit(line), lineNum);
- break;
- }
- }
-
- private String [] fastTabSplit(String str) {
- int count = 1;
- for (int i = 0; i < str.length(); i++) {
- if (str.charAt(i) == '\t') {
- count++;
- }
- }
- String [] tabs = new String[count];
- int tabInd = 0;
- int prevInd = 0;
- for (int i = 0; i < str.length(); i++) {
- if (str.charAt(i) == '\t') {
- tabs[tabInd++] = str.substring(prevInd, i);
- prevInd = i+1;
- }
- }
- if (prevInd < str.length())
- tabs[tabInd++] = str.substring(prevInd);
- return tabs;
- }
-
- private void createTable() {
- if (columnNames.length != columnTypes.length)
- throw new IllegalArgumentException("Names length and types length mismatch");
- StringBuilder sql = new StringBuilder("CREATE TABLE "+table+" (");
- for (int i = 0; i < columnNames.length; i++) {
- if (i > 0)
- sql.append(", ");
- sql.append(columnNames[i]);
- sql.append(' ');
- sql.append(columnTypes[i]);
- }
- sql.append(')');
- updateQuery(sql.toString());
- }
-
- private void createPreparedStatement() {
- StringBuilder sql = new StringBuilder("INSERT INTO " + table + " VALUES (");
- for (int i = 0; i < columnNames.length; i++) {
- if (i > 0)
- sql.append(", ");
- sql.append('?');
- }
- sql.append(')');
- insert = prepareStatement(sql.toString());
- }
-
- private void generateInsert(String [] data, int line) throws SQLException {
- if (columnTypes.length != data.length) {
- Log.e("Could not load record: Types length and data length mismatch. Line: " + line);
- return;
- }
- int column = 0;
- try {
- for (int i = 0; i < data.length; i++, column++) {
- if (columnTypes[i].startsWith("TEXT"))
- insert.setString(i+1, data[i]);
- else if (columnTypes[i].startsWith("REAL"))
- insert.setDouble(i+1, Double.parseDouble(data[i]));
- else if (columnTypes[i].startsWith("INTEGER"))
- insert.setLong(i+1, Long.parseLong(data[i]));
- else
- throw new SQLException("Data type unsupported by sdb/sqlite! Type: " + columnTypes[i]);
- }
- insert.addBatch();
- } catch (NumberFormatException e) {
- Log.e("Could not load record: Record has invalid data. Line: " + line + " Column: " + column);
- }
- }
-
- }
-
-}
diff --git a/src/resources/server_info/RelationalServerFactory.java b/src/resources/server_info/RelationalServerFactory.java
deleted file mode 100644
index c52332008..000000000
--- a/src/resources/server_info/RelationalServerFactory.java
+++ /dev/null
@@ -1,160 +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 resources.server_info;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class RelationalServerFactory {
-
- private static final RelationalServerFactory INSTANCE = new RelationalServerFactory();
- private static final String BASE_PATH = "serverdata" + File.separator;
- private static final Map FILE_LOAD_LOCKING = new HashMap<>();
-
- public static RelationalServerData getServerData(String file, String ... tables) {
- return INSTANCE.getData(file, tables);
- }
-
- public static RelationalServerData getServerDatabase(String file) {
- return INSTANCE.getDatabase(file);
- }
-
- private RelationalServerData getData(String file, String ... tables) {
- if (!file.endsWith(".db"))
- throw new IllegalArgumentException("File path for database must end in .db!");
- file = file.replace('/', File.separatorChar);
- final Object lock = getFileLocking(file);
- synchronized (lock) {
- File f = new File(BASE_PATH + file);
- RelationalServerData data = new RelationalServerData(BASE_PATH + file);
- if (loadServerData(data, f, tables))
- return data;
- return null;
- }
- }
-
- private boolean loadServerData(RelationalServerData data, File file, String ... tables) {
- File parent = file.getParentFile();
- try {
- if (loadTables(data, parent, tables))
- return true;
- data.close();
- } catch (Exception e) {
- Log.e(e);
- data.close();
- }
- return false;
- }
-
- private RelationalServerData getDatabase(String file) {
- if (!file.endsWith(".db"))
- throw new IllegalArgumentException("File path for database must end in .db!");
- final Object lock = getFileLocking(file);
- synchronized (lock) {
- File f = new File(BASE_PATH + file);
- RelationalServerData data = new RelationalServerData(BASE_PATH + file);
- try {
- String [] commands = getCommandsFromSchema(f.getPath().substring(0, f.getPath().length()-3) + ".sql");
- for (String command : commands)
- executeCommand(data, command);
- return data;
- } catch (Exception e) {
- Log.e(e);
- }
- data.close();
- return null;
- }
- }
-
- private boolean loadTables(RelationalServerData data, File parent, String [] tables) {
- for (String table : tables) {
- table = table.replace('/', File.separatorChar);
- String path = generatePath(parent, table);
- table = path.substring(path.lastIndexOf(File.separatorChar)+1, path.lastIndexOf('.'));
- if (!data.linkTableWithSdb(table, path))
- return false;
- }
- return true;
- }
-
- private String generatePath(File parent, String table) {
- String base;
- if (table.contains(File.separator))
- base = BASE_PATH + table;
- else
- base = parent.getPath() + File.separator + table;
- if (new File(base + ".msdb").isFile())
- return base + ".msdb";
- return base + ".sdb";
- }
-
- private void executeCommand(RelationalServerData data, String command) {
- command = command.trim();
- if (command.startsWith("SELECT")) {
- try (ResultSet set = data.executeQuery(command)) {
-
- } catch (SQLException e) {
- Log.e(e);
- }
- } else {
- data.updateQuery(command);
- }
- }
-
- private String [] getCommandsFromSchema(String schema) throws IOException {
- String command;
- try (InputStream input = new FileInputStream(new File(schema))) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(input.available());
- byte [] block = new byte[1024];
- while (input.available() > 0) {
- int size = input.read(block);
- baos.write(block, 0, size);
- }
- command = new String(baos.toByteArray(), Charset.forName("ASCII"));
- }
- return command.split(";");
- }
-
- private Object getFileLocking(String file) {
- synchronized (FILE_LOAD_LOCKING) {
- Object o = FILE_LOAD_LOCKING.get(file);
- if (o == null)
- FILE_LOAD_LOCKING.put(file, o = new Object());
- return o;
- }
- }
-
-}
diff --git a/src/resources/server_info/SynchronizedList.java b/src/resources/server_info/SynchronizedList.java
deleted file mode 100644
index 294600405..000000000
--- a/src/resources/server_info/SynchronizedList.java
+++ /dev/null
@@ -1,182 +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 synchronized 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 synchronized License for more details. *
- * *
- * You should have received a copy of the GNU Affero General public synchronized License *
- * along with Holocore. If not, see . *
- * *
- ***********************************************************************************/
-package resources.server_info;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Spliterator;
-import java.util.function.Consumer;
-import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
-import java.util.stream.Stream;
-
-public class SynchronizedList implements List {
-
- private final List list;
-
- public SynchronizedList() {
- this.list = new ArrayList<>();
- }
-
- public SynchronizedList(List list) {
- this.list = list;
- }
-
- public synchronized void forEach(Consumer super E> action) {
- list.forEach(action);
- }
-
- public synchronized int size() {
- return list.size();
- }
-
- public synchronized boolean isEmpty() {
- return list.isEmpty();
- }
-
- public synchronized boolean contains(Object o) {
- return list.contains(o);
- }
-
- public synchronized Iterator iterator() {
- return list.iterator();
- }
-
- public synchronized Object[] toArray() {
- return list.toArray();
- }
-
- public synchronized T[] toArray(T[] a) {
- return list.toArray(a);
- }
-
- public synchronized boolean add(E e) {
- return list.add(e);
- }
-
- public synchronized boolean remove(Object o) {
- return list.remove(o);
- }
-
- public synchronized boolean containsAll(Collection> c) {
- return list.containsAll(c);
- }
-
- public synchronized boolean addAll(Collection extends E> c) {
- return list.addAll(c);
- }
-
- public synchronized boolean addAll(int index, Collection extends E> c) {
- return list.addAll(index, c);
- }
-
- public synchronized boolean removeAll(Collection> c) {
- return list.removeAll(c);
- }
-
- public synchronized boolean retainAll(Collection> c) {
- return list.retainAll(c);
- }
-
- public synchronized void replaceAll(UnaryOperator operator) {
- list.replaceAll(operator);
- }
-
- public synchronized boolean removeIf(Predicate super E> filter) {
- return list.removeIf(filter);
- }
-
- public synchronized void sort(Comparator super E> c) {
- list.sort(c);
- }
-
- public synchronized void clear() {
- list.clear();
- }
-
- public synchronized boolean equals(Object o) {
- return list.equals(o);
- }
-
- public synchronized int hashCode() {
- return list.hashCode();
- }
-
- public synchronized E get(int index) {
- return list.get(index);
- }
-
- public synchronized E set(int index, E element) {
- return list.set(index, element);
- }
-
- public synchronized void add(int index, E element) {
- list.add(index, element);
- }
-
- public synchronized Stream stream() {
- return list.stream();
- }
-
- public synchronized E remove(int index) {
- return list.remove(index);
- }
-
- public synchronized Stream parallelStream() {
- return list.parallelStream();
- }
-
- public synchronized int indexOf(Object o) {
- return list.indexOf(o);
- }
-
- public synchronized int lastIndexOf(Object o) {
- return list.lastIndexOf(o);
- }
-
- public synchronized ListIterator listIterator() {
- return list.listIterator();
- }
-
- public synchronized ListIterator listIterator(int index) {
- return list.listIterator(index);
- }
-
- public synchronized List subList(int fromIndex, int toIndex) {
- return list.subList(fromIndex, toIndex);
- }
-
- public synchronized Spliterator spliterator() {
- return list.spliterator();
- }
-
-}
diff --git a/src/resources/server_info/SynchronizedMap.java b/src/resources/server_info/SynchronizedMap.java
deleted file mode 100644
index 7dbb55671..000000000
--- a/src/resources/server_info/SynchronizedMap.java
+++ /dev/null
@@ -1,107 +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 synchronized 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 synchronized License for more details. *
- * *
- * You should have received a copy of the GNU Affero General public synchronized License *
- * along with Holocore. If not, see . *
- * *
- ***********************************************************************************/
-package resources.server_info;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-public class SynchronizedMap implements Map {
-
- private final Map map;
-
- public SynchronizedMap() {
- this.map = new HashMap<>();
- }
-
- public SynchronizedMap(Map map) {
- this.map = map;
- }
-
- public synchronized int hashCode() {
- return map.hashCode();
- }
-
- public synchronized String toString() {
- return map.toString();
- }
-
- public synchronized int size() {
- return map.size();
- }
-
- public synchronized boolean isEmpty() {
- return map.isEmpty();
- }
-
- public synchronized V get(Object key) {
- return map.get(key);
- }
-
- public synchronized boolean containsKey(Object key) {
- return map.containsKey(key);
- }
-
- public synchronized V put(K key, V value) {
- return map.put(key, value);
- }
-
- public synchronized void putAll(Map extends K, ? extends V> m) {
- map.putAll(m);
- }
-
- public synchronized V remove(Object key) {
- return map.remove(key);
- }
-
- public synchronized void clear() {
- map.clear();
- }
-
- public synchronized boolean containsValue(Object value) {
- return map.containsValue(value);
- }
-
- public synchronized Set keySet() {
- return map.keySet();
- }
-
- public synchronized Collection values() {
- return map.values();
- }
-
- public synchronized Set> entrySet() {
- return map.entrySet();
- }
-
- public synchronized V replace(K key, V value) {
- return map.replace(key, value);
- }
-
-}
diff --git a/src/resources/server_info/SynchronizedSet.java b/src/resources/server_info/SynchronizedSet.java
deleted file mode 100644
index ae69df8a3..000000000
--- a/src/resources/server_info/SynchronizedSet.java
+++ /dev/null
@@ -1,131 +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 synchronized 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 synchronized License for more details. *
- * *
- * You should have received a copy of the GNU Affero General public synchronized License *
- * along with Holocore. If not, see . *
- * *
- ***********************************************************************************/
-package resources.server_info;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.function.Consumer;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-
-public class SynchronizedSet implements Set {
-
- private final Set set;
-
- public SynchronizedSet() {
- this.set = new HashSet<>();
- }
-
- public SynchronizedSet(Set set) {
- this.set = set;
- }
-
- public synchronized void forEach(Consumer super E> action) {
- set.forEach(action);
- }
-
- public synchronized int size() {
- return set.size();
- }
-
- public synchronized boolean isEmpty() {
- return set.isEmpty();
- }
-
- public synchronized boolean contains(Object o) {
- return set.contains(o);
- }
-
- public synchronized Iterator iterator() {
- return set.iterator();
- }
-
- public synchronized Object[] toArray() {
- return set.toArray();
- }
-
- public synchronized T[] toArray(T[] a) {
- return set.toArray(a);
- }
-
- public synchronized boolean add(E e) {
- return set.add(e);
- }
-
- public synchronized boolean remove(Object o) {
- return set.remove(o);
- }
-
- public synchronized boolean containsAll(Collection> c) {
- return set.containsAll(c);
- }
-
- public synchronized boolean addAll(Collection extends E> c) {
- return set.addAll(c);
- }
-
- public synchronized boolean retainAll(Collection> c) {
- return set.retainAll(c);
- }
-
- public synchronized boolean removeAll(Collection> c) {
- return set.removeAll(c);
- }
-
- public synchronized void clear() {
- set.clear();
- }
-
- public synchronized boolean equals(Object o) {
- return set.equals(o);
- }
-
- public synchronized int hashCode() {
- return set.hashCode();
- }
-
- public synchronized Spliterator spliterator() {
- return set.spliterator();
- }
-
- public synchronized boolean removeIf(Predicate super E> filter) {
- return set.removeIf(filter);
- }
-
- public synchronized Stream stream() {
- return set.stream();
- }
-
- public synchronized Stream parallelStream() {
- return set.parallelStream();
- }
-
-}
diff --git a/src/services/CoreManager.java b/src/services/CoreManager.java
index 7d85b35b7..935fe53b6 100644
--- a/src/services/CoreManager.java
+++ b/src/services/CoreManager.java
@@ -27,6 +27,11 @@
***********************************************************************************/
package services;
+import intents.network.InboundPacketIntent;
+import intents.network.OutboundPacketIntent;
+import intents.server.ServerManagementIntent;
+import intents.server.ServerStatusIntent;
+
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
@@ -39,10 +44,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import intents.network.InboundPacketIntent;
-import intents.network.OutboundPacketIntent;
-import intents.server.ServerManagementIntent;
-import intents.server.ServerStatusIntent;
import network.packets.Packet;
import network.packets.swg.admin.AdminShutdownServer;
import network.packets.swg.zone.baselines.Baseline;
@@ -51,17 +52,18 @@ import network.packets.swg.zone.object_controller.ObjectController;
import resources.Galaxy;
import resources.Galaxy.GalaxyStatus;
import resources.config.ConfigFile;
-import resources.control.Manager;
import resources.control.ServerStatus;
-import resources.server_info.Config;
+import resources.server_info.DataManager;
import resources.server_info.Log;
import resources.server_info.Log.LogLevel;
-import services.admin.OnlineInterfaceService;
import services.galaxy.GalacticManager;
import utilities.CrcDatabaseGenerator;
import utilities.ScheduledUtilities;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Manager;
+import com.projectswg.common.info.Config;
+
public class CoreManager extends Manager {
private static final DateFormat LOG_FORMAT = new SimpleDateFormat("dd-MM-yy HH:mm:ss.SSS");
@@ -69,7 +71,6 @@ public class CoreManager extends Manager {
private static final int GALAXY_ID = 1;
private final ScheduledExecutorService shutdownService;
- private final OnlineInterfaceService onlineInterfaceService;
private final EngineManager engineManager;
private final GalacticManager galacticManager;
private final PrintStream packetStream;
@@ -79,7 +80,7 @@ public class CoreManager extends Manager {
private boolean shutdownRequested;
public CoreManager(int adminServerPort) {
- Config c = getConfig(ConfigFile.PRIMARY);
+ Config c = DataManager.getConfig(ConfigFile.PRIMARY);
Log.setLogLevel(LogLevel.valueOf(c.getString("LOG-LEVEL", LogLevel.DEBUG.name())));
setupGalaxy(c);
setupCrcDatabase();
@@ -90,11 +91,9 @@ public class CoreManager extends Manager {
packetDebug = packetStream != null;
shutdownService = Executors.newSingleThreadScheduledExecutor(ThreadUtilities.newThreadFactory("core-shutdown-service"));
shutdownRequested = false;
- onlineInterfaceService = new OnlineInterfaceService();
engineManager = new EngineManager();
galacticManager = new GalacticManager();
- addChildService(onlineInterfaceService);
addChildService(engineManager);
addChildService(galacticManager);
diff --git a/src/services/EngineManager.java b/src/services/EngineManager.java
index 97780dbb0..1cf52ab38 100644
--- a/src/services/EngineManager.java
+++ b/src/services/EngineManager.java
@@ -32,13 +32,15 @@ import java.io.IOException;
import resources.client_info.ServerFactory;
import resources.config.ConfigFile;
-import resources.control.Manager;
-import resources.server_info.Config;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import services.network.NetworkManager;
+import com.projectswg.common.control.Manager;
+import com.projectswg.common.info.Config;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class EngineManager extends Manager {
private ShutdownService shutdownService;
@@ -56,7 +58,7 @@ public class EngineManager extends Manager {
@Override
public boolean initialize() {
- Config config = getConfig(ConfigFile.PRIMARY);
+ Config config = DataManager.getConfig(ConfigFile.PRIMARY);
if (config.getInt("CLEAN-CHARACTER-DATA", 0) == 1)
wipeCharacterDatabase();
diff --git a/src/services/ShutdownService.java b/src/services/ShutdownService.java
index 85ec5c6bf..582c9c3cc 100644
--- a/src/services/ShutdownService.java
+++ b/src/services/ShutdownService.java
@@ -27,6 +27,10 @@
***********************************************************************************/
package services;
+import intents.chat.ChatBroadcastIntent;
+import intents.chat.ChatBroadcastIntent.BroadcastType;
+import intents.server.ServerStatusIntent;
+
import java.util.Locale;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -34,13 +38,11 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import intents.chat.ChatBroadcastIntent;
-import intents.chat.ChatBroadcastIntent.BroadcastType;
-import intents.server.ServerStatusIntent;
import resources.control.ServerStatus;
-import resources.control.Service;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Service;
+
public class ShutdownService extends Service {
private static final String SHUTDOWN_PERIODIC = "The server will be shutting down in %d %s.";
diff --git a/src/services/admin/OnlineInterfaceService.java b/src/services/admin/OnlineInterfaceService.java
deleted file mode 100644
index 251ab70e4..000000000
--- a/src/services/admin/OnlineInterfaceService.java
+++ /dev/null
@@ -1,241 +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 services.admin;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import intents.PlayerEventIntent;
-import resources.common.BCrypt;
-import resources.config.ConfigFile;
-import resources.control.Service;
-import resources.server_info.Config;
-import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
-import services.admin.http.HttpServer;
-import services.admin.http.HttpServer.HttpServerCallback;
-import services.admin.http.HttpSession;
-import services.admin.http.HttpSocket;
-import services.admin.http.HttpSocket.HttpRequest;
-import services.admin.http.HttpsServer;
-import utilities.ThreadUtilities;
-
-public class OnlineInterfaceService extends Service implements HttpServerCallback {
-
- private static final String GET_USER_SQL = "SELECT password, banned FROM users WHERE LOWER(username) = LOWER(?)";
-
- private final WebserverData data;
- private final WebserverHandler handler;
- private final Runnable dataCollectionRunnable;
- private RelationalDatabase database;
- private PreparedStatement getUser;
- private ScheduledExecutorService executor;
- private HttpsServer httpsServer;
- private HttpServer httpServer;
- private boolean authorized;
-
- public OnlineInterfaceService() {
- data = new WebserverData();
- handler = new WebserverHandler(data);
- dataCollectionRunnable = () -> collectData();
- authorized = false;
- }
-
- @Override
- public boolean initialize() {
- database = RelationalServerFactory.getServerDatabase("login/login.db");
- getUser = database.prepareStatement(GET_USER_SQL);
- Config network = getConfig(ConfigFile.NETWORK);
- authorized = !network.getString("HTTPS-KEYSTORE-PASSWORD", "").isEmpty();
- if (!authorized)
- return super.initialize();
- httpServer = new HttpServer(getBindAddr(network, "HTTP-BIND-ADDR", "BIND-ADDR"), network.getInt("HTTP-PORT", 8080));
- httpsServer = new HttpsServer(getBindAddr(network, "HTTPS-BIND-ADDR", "BIND-ADDR"), network.getInt("HTTPS-PORT", 8081));
- httpServer.setMaxConnections(network.getInt("HTTP-MAX-CONNECTIONS", 2));
- httpsServer.setMaxConnections(network.getInt("HTTPS-MAX-CONNECTIONS", 5));
- if (!httpsServer.initialize(network)) {
- Log.e("Failed to initialize HTTPS server! Incorrect password?");
- httpServer.stop();
- httpsServer.stop();
- super.initialize();
- return false;
- }
- executor = Executors.newSingleThreadScheduledExecutor(ThreadUtilities.newThreadFactory("ServerInterface-DataCollection"));
- registerForIntent(PlayerEventIntent.class, pei -> handlePlayerEventIntent(pei));
- return super.initialize();
- }
-
- @Override
- public boolean start() {
- if (authorized) {
- httpServer.setServerCallback(this);
- httpsServer.setServerCallback(this);
- httpServer.start();
- httpsServer.start();
- executor.scheduleAtFixedRate(dataCollectionRunnable, 0, 1, TimeUnit.SECONDS);
- Log.i("Web server is now online.");
- }
- return super.start();
- }
-
- @Override
- public boolean stop() {
- if (authorized) {
- httpServer.stop();
- httpsServer.stop();
- executor.shutdownNow();
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- Log.e(e);
- }
- }
- return super.stop();
- }
-
- @Override
- public boolean terminate() {
- database.close();
- return super.terminate();
- }
-
- @Override
- public void onSocketCreated(HttpSocket socket) {
- Log.i("Received connection from: %s:%d [%s]", socket.getInetAddress(), socket.getPort(), socket.isSecure() ? "secure" : "insecure");
- }
-
- @Override
- public void onRequestReceived(HttpSocket socket, HttpRequest request) {
- try {
- if (request.getType().equals("POST")) {
- String [] variables = request.getBody().split("&");
- if (variables.length == 2) {
- Map varMap = new HashMap<>();
- for (String str : variables) {
- String [] var = str.split("=");
- if (var.length == 2)
- varMap.put(var[0], var[1]);
- }
- if (varMap.containsKey("username") && varMap.containsKey("password"))
- login(socket, varMap.get("username"), varMap.get("password"));
- }
- }
- if (!socket.isSecure()) {
- try {
- socket.redirect(new URL(request.getURI().getPath()).toString());
- } catch (MalformedURLException e) {
- Log.w("Malformed URL: " + request.getURI().getPath());
- }
- return;
- }
- handler.handleRequest(socket, request);
- } catch (IOException e) {
- Log.e(e);
- }
- }
-
- private void handlePlayerEventIntent(PlayerEventIntent pei){
- switch (pei.getEvent()) {
- case PE_ZONE_IN_CLIENT:
- data.addOnlinePlayer(pei.getPlayer());
- break;
- case PE_LOGGED_OUT:
- data.removeOnlinePlayer(pei.getPlayer());
- break;
- default:
- break;
- }
- }
-
- private void collectData() {
- data.updateResourceUsage();
- }
-
- private InetAddress getBindAddr(Config c, String firstTry, String secondTry) {
- String t = firstTry;
- try {
- if (c.containsKey(firstTry))
- return InetAddress.getByName(c.getString(firstTry, "127.0.0.1"));
- t = secondTry;
- if (c.containsKey(secondTry))
- return InetAddress.getByName(c.getString(secondTry, "127.0.0.1"));
- } catch (UnknownHostException e) {
- Log.e("Unknown host for IP: " + t);
- }
- return null;
- }
-
- private void login(HttpSocket socket, String username, String password) {
- HttpSession session = socket.getSession();
- if (session == null)
- return;
- synchronized (getUser) {
- try {
- getUser.setString(1, username);
- boolean prevAuthenticated = session.isAuthenticated();
- session.setAuthenticated(false);
- try (ResultSet cursor = getUser.executeQuery()) {
- session.setAuthenticated(cursor.next() && isUserValid(cursor, password));
- if (session.isAuthenticated()) {
- if (!prevAuthenticated)
- Log.i("[%s] Successfully logged in to online interface", username);
- } else {
- Log.w("[%s] Failed to login to online interface. Incorrect user/pass", username);
- }
- }
- } catch (SQLException e) {
- Log.e(e);
- }
- }
- }
-
- private boolean isUserValid(ResultSet set, String password) throws SQLException {
- if (password.isEmpty())
- return false;
- if (set.getBoolean("banned"))
- return false;
- String psqlPass = set.getString("password");
- if (psqlPass.length() != 60 && !psqlPass.startsWith("$2"))
- return psqlPass.equals(password);
- password = BCrypt.hashpw(BCrypt.hashpw(password, psqlPass), psqlPass);
- return psqlPass.equals(password);
- }
-
-}
diff --git a/src/services/admin/WebserverData.java b/src/services/admin/WebserverData.java
deleted file mode 100644
index f82fcd4f7..000000000
--- a/src/services/admin/WebserverData.java
+++ /dev/null
@@ -1,131 +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 services.admin;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.management.ManagementFactory;
-import java.lang.management.OperatingSystemMXBean;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import resources.player.Player;
-
-class WebserverData {
-
- private static final Charset ASCII = Charset.forName("ASCII");
-
- private final double [] memoryUsage;
- private final double [] cpuUsage;
- private final double [] systemMemoryUsage;
- private final double [] systemCpuUsage;
- private final Set onlinePlayers;
-
- public WebserverData() {
- memoryUsage = new double[60 * 5];
- cpuUsage = new double[memoryUsage.length];
- systemMemoryUsage = new double[memoryUsage.length];
- systemCpuUsage = new double[memoryUsage.length];
- onlinePlayers = new HashSet<>();
- }
-
- @SuppressWarnings("restriction")
- public void updateResourceUsage() {
- OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- if (os instanceof com.sun.management.OperatingSystemMXBean) {
- com.sun.management.OperatingSystemMXBean castedOS = (com.sun.management.OperatingSystemMXBean) os;
- updateMemory(castedOS);
- updateCPU(castedOS);
- }
- }
-
- public void addOnlinePlayer(Player player) {
- onlinePlayers.add(player);
- }
-
- public void removeOnlinePlayer(Player player) {
- onlinePlayers.remove(player);
- }
-
- public double [] getMemoryUsage() {
- return Arrays.copyOf(memoryUsage, memoryUsage.length);
- }
-
- public double [] getCpuUsage() {
- return Arrays.copyOf(cpuUsage, cpuUsage.length);
- }
-
- public double [] getSystemMemoryUsage() {
- return Arrays.copyOf(systemMemoryUsage, systemMemoryUsage.length);
- }
-
- public double [] getSystemCpuUsage() {
- return Arrays.copyOf(systemCpuUsage, systemCpuUsage.length);
- }
-
- public Set getOnlinePlayers() {
- return Collections.unmodifiableSet(onlinePlayers);
- }
-
- public String getLog() throws IOException {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File("log.txt")), ASCII))) {
- StringBuilder builder = new StringBuilder();
- while (reader.ready()) {
- builder.append(reader.readLine() + System.lineSeparator());
- }
- reader.close();
- return builder.toString();
- }
- }
-
- @SuppressWarnings("restriction")
- private void updateMemory(com.sun.management.OperatingSystemMXBean os) {
- Runtime r = Runtime.getRuntime();
- appendData(memoryUsage, (double) r.totalMemory() / os.getTotalPhysicalMemorySize());
- appendData(systemMemoryUsage, 1 - ((double) os.getFreePhysicalMemorySize() / os.getTotalPhysicalMemorySize()));
- }
-
- @SuppressWarnings("restriction")
- private void updateCPU(com.sun.management.OperatingSystemMXBean os) {
- appendData(cpuUsage, os.getProcessCpuLoad());
- appendData(systemCpuUsage, os.getSystemCpuLoad());
- }
-
- private void appendData(double [] data, double value) {
- for (int i = 1; i < data.length; i++)
- data[i-1] = data[i];
- data[data.length-1] = value;
- }
-
-}
diff --git a/src/services/admin/WebserverHandler.java b/src/services/admin/WebserverHandler.java
deleted file mode 100644
index 61397ea89..000000000
--- a/src/services/admin/WebserverHandler.java
+++ /dev/null
@@ -1,362 +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 services.admin;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import resources.Location;
-import resources.objects.SWGObject;
-import resources.objects.cell.CellObject;
-import resources.player.Player;
-import resources.server_info.Log;
-import services.admin.http.HttpImageType;
-import services.admin.http.HttpSession;
-import services.admin.http.HttpSocket;
-import services.admin.http.HttpSocket.HttpRequest;
-import services.admin.http.HttpStatusCode;
-
-class WebserverHandler {
-
- private static final Charset ASCII = Charset.forName("ASCII");
-
- private static final String REQUIRED_PREFIX = new File("res/webserver").getAbsolutePath().replace('/', File.separatorChar);
- private static final String INDEX_PATH = new File("res/webserver/index.html".replace('/', File.separatorChar)).getAbsolutePath();
- private static final String AUTHENTICATED_PATH = new File("res/webserver/authenticated.html".replace('/', File.separatorChar)).getAbsolutePath();
-
- private final WebserverData data;
- private final Pattern variablePattern;
-
- public WebserverHandler(WebserverData data) {
- this.data = data;
- variablePattern = Pattern.compile("\\$\\{.+\\}"); // Looks for variables: ${VAR_NAME}
- }
-
- public void handleRequest(HttpSocket socket, HttpRequest request) throws IOException {
- String file = request.getURI().toASCIIString();
- Map getVariables = new HashMap<>();
- if (file.contains("?")) {
- String vars = file.substring(file.indexOf('?')+1);
- String [] variables = vars.split("&");
- for (String var : variables) {
- String [] parts = var.split("=", 2);
- if (parts.length == 2)
- getVariables.put(parts[0], parts[1]);
- }
- file = file.substring(0, file.indexOf('?'));
- }
- if (file.contains("#"))
- file = file.substring(0, file.indexOf('#'));
- switch (file) {
- case "/memory_usage.png":
- if (socket.getSession().isAuthenticated())
- socket.send(createMemoryUsage(), HttpImageType.PNG);
- else
- socket.send(HttpStatusCode.NOT_FOUND, request.getURI() + " is not found!");
- break;
- default: {
- byte [] response = parseFile(socket.getSession(), file, getVariables);
- if (response == null)
- socket.send(HttpStatusCode.NOT_FOUND, request.getURI() + " is not found!");
- else
- socket.send(getFileType(file), response);
- break;
- }
- }
- }
-
- private BufferedImage createMemoryUsage() {
- double [] memoryUsage = data.getMemoryUsage();
- final int graphHeight = 300;
- BufferedImage image = new BufferedImage(900, graphHeight + 25, BufferedImage.TYPE_3BYTE_BGR);
- Graphics2D g = image.createGraphics();
- Font font = g.getFont();
- g.setFont(font.deriveFont(Font.TRUETYPE_FONT, Math.min(image.getHeight()/10.0f, 25.0f)));
- Map hints = new HashMap<>();
- hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g.setRenderingHints(new RenderingHints(hints));
- g.setColor(Color.WHITE);
- renderGraph(g, image.getWidth(), image.getHeight(), graphHeight);
- FontMetrics fm = g.getFontMetrics();
- String inUse = getMemoryInUse();
- int width = fm.stringWidth(inUse);
- int x = 5;
- x += drawStr(g, image.getHeight(), x, "Proc:");
- g.drawString(inUse, image.getWidth()-width - 5, image.getHeight() - 5);
- x += drawDataSet(g, Color.RED, " M:", image.getWidth(), image.getHeight(), graphHeight, x, memoryUsage);
- x += drawDataSet(g, Color.CYAN, " C:", image.getWidth(), image.getHeight(), graphHeight, x, data.getCpuUsage());
- g.setColor(Color.WHITE);
- x += drawStr(g, image.getHeight(), x, " Sys:");
- x += drawDataSet(g, Color.YELLOW, " M:", image.getWidth(), image.getHeight(), graphHeight, x, data.getSystemMemoryUsage());
- drawDataSet(g, Color.GREEN, " C:", image.getWidth(), image.getHeight(), graphHeight, x, data.getSystemCpuUsage());
- return image;
- }
-
- private void renderGraph(Graphics2D g, int width, int height, int graphHeight) {
- g.drawRect(0, 0, width-1, graphHeight-1);
- g.drawLine(0, height-1, width, height-1);
- for (int i = 1; i < 10; i++) {
- g.drawLine(0, (int) ((i/10.0)*graphHeight), 10, (int) ((i/10.0)*graphHeight));
- }
- }
-
- private int drawDataSet(Graphics2D g, Color c, String pre, int width, int height, int graphHeight, int x, double [] data) {
- g.setColor(c);
- drawLines(g, data, width, graphHeight-1);
- return drawStr(g, height, x, String.format("%s%.2f%%", pre, (int) (data[data.length-1] * 10000) / 100.0));
- }
-
- private int drawStr(Graphics2D g, int height, int x, String str) {
- g.drawString(str, x, height - 5);
- return g.getFontMetrics().stringWidth(str);
- }
-
- private void drawLines(Graphics2D g, double [] data, int width, int height) {
- int start = 0;
- for (double d : data) {
- if (d == 0)
- start++;
- else
- break;
- }
- int prevX = -1;
- int prevY = -1;
- for (int i = start; i < data.length; i++) {
- int x = (int) ((double) i / data.length * width);
- int y = (int) ((1-data[i]) * height);
- if (prevX != -1 && prevY != -1)
- g.drawLine(prevX, prevY, x, y);
- prevX = x;
- prevY = y;
- }
- }
-
- private String getMemoryInUse() {
- double memory = Runtime.getRuntime().totalMemory();
- String [] types = new String[]{"B", "KB", "MB", "GB"};
- String type = types[0];
- for (int i = 0; i < types.length && memory >= 1024; i++) {
- memory /= 1024;
- type = types[i];
- }
- return String.format("In-Use: %.2f%s", memory, type);
- }
-
- private String getFileType(String filepath) {
- if (!filepath.contains("."))
- return "text/html";
- String type = filepath.substring(filepath.lastIndexOf('.')+1).toLowerCase(Locale.US);
- switch (type) {
- case "png":
- case "gif":
- case "jpg":
- case "jpeg":
- case "ico":
- return "image/" + type;
- default:
- return "text/" + type;
- }
- }
-
- private byte [] parseFile(HttpSession session, String filepath, Map getVariables) throws IOException {
- String type = getFileType(filepath);
- File file = verifyAndModifyFile(session, filepath, type);
- if (file == null)
- return null;
- if (type.equalsIgnoreCase("text/html"))
- return parseHtmlFile(file, getVariables).getBytes(ASCII);
- try (InputStream is = new FileInputStream(file)) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(is.available());
- byte [] buffer = new byte[Math.min(1024, is.available())];
- while (is.available() > 0) {
- if (is.available() > buffer.length && buffer.length < 1024)
- buffer = new byte[Math.min(1024, is.available())];
- int len = is.read(buffer);
- baos.write(buffer, 0, len);
- }
- return baos.toByteArray();
- }
- }
-
- private File verifyAndModifyFile(HttpSession session, String filepath, String type) {
- File file = new File("res/webserver" + filepath);
- if (File.separatorChar != '/')
- file = new File(file.getAbsolutePath().replace('/', File.separatorChar));
- if (file.isDirectory())
- file = new File(file, "index.html");
- if (file.getAbsolutePath().equals(INDEX_PATH)) {
- if (session.isAuthenticated()) {
- file = new File(AUTHENTICATED_PATH);
- }
- } else if (!session.isAuthenticated() && !type.equals("text/css") && !type.equals("text/js") && !type.startsWith("image"))
- return null;
- if (!verifyPath(file)) {
- Log.e("Cannot access %s - not a valid path", file);
- return null;
- }
- return file;
- }
-
- private boolean verifyPath(File file) {
- if (!file.getAbsolutePath().startsWith(REQUIRED_PREFIX))
- return false;
- if (!file.isFile())
- return false;
- return true;
- }
-
- private String parseHtmlFile(File file, Map getVariables) throws IOException {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), ASCII))) {
- String line = null;
- StringBuilder builder = new StringBuilder();
- while (reader.ready()) {
- line = reader.readLine();
- if (line == null)
- break;
- Matcher matcher = variablePattern.matcher(line);
- while (matcher.find()) {
- String var = matcher.group();
- var = var.substring(2, var.length()-1);
- line = line.replaceAll("\\$\\{"+var+"\\}", getVariable(var, getVariables));
- matcher.reset(line);
- }
- builder.append(line + System.lineSeparator());
- }
- return builder.toString();
- }
- }
-
- private String getVariable(String var, Map getVariables) throws IOException {
- var = var.toLowerCase(Locale.US);
- switch (var) {
- case "log":
- return data.getLog().replace("\n", "\n
");
- case "online_player_count":
- return getOnlinePlayerCount();
- case "online_players":
- return getOnlinePlayerData();
- case "character_info": {
- if (!getVariables.containsKey("character_id"))
- return "";
- long i = Long.parseLong(getVariables.get("character_id"));
- for (Player p : data.getOnlinePlayers()) {
- if (p.getCreatureObject().getObjectId() == i) {
- return getCreatureData(p.getCreatureObject());
- }
- }
- return "No Creature Found!";
- }
- default:
- return "";
- }
- }
-
- private String getOnlinePlayerCount() {
- Set players = data.getOnlinePlayers();
- return "Online Players: [" + players.size() + "]";
- }
-
- private String getOnlinePlayerData() {
- Set players = data.getOnlinePlayers();
- StringBuilder ret = new StringBuilder("| Username | User ID | Character | Character ID |
");
- for (Player p : players) {
- ret.append("");
- long id = p.getCreatureObject().getObjectId();
- ret.append(String.format("| %s | ", id, p.getUsername()));
- ret.append(String.format("%d | ", id, p.getUserId()));
- ret.append(String.format("%s | ", id, p.getCharacterName()));
- ret.append(String.format("%d | ", id, p.getCreatureObject().getObjectId()));
- ret.append("
");
- }
- ret.append("
");
- return ret.toString();
- }
-
- private String getCreatureData(SWGObject creature) {
- StringBuilder str = new StringBuilder("");
- Location world = creature.getWorldLocation();
- str.append(String.format(" Object ID: %s
", creature.getObjectId()));
- str.append(String.format(" Name: %s
", creature.getObjectName()));
- str.append(String.format("World:
"));
- str.append(addLocationData(world));
- if (creature.getParent() != null) {
- Location cell = creature.getLocation();
- str.append(String.format("Local:
"));
- str.append(addLocationData(cell));
- SWGObject parent = creature.getParent();
- if (parent != null) {
- str.append(String.format(" Parent:
"));
- str.append(addParentData(parent, " "));
- parent = parent.getParent();
- if (parent != null) {
- str.append(String.format(" Grandparent:
"));
- str.append(addParentData(parent, " "));
- }
- }
- }
- return str.toString().replace(" ", " ").replace("
", "
");
- }
-
- private String addParentData(SWGObject obj, String indent) {
- StringBuilder str = new StringBuilder("");
- str.append(indent + String.format(" Object ID: %d
", obj.getObjectId()));
- str.append(indent + String.format(" Template: %s
", obj.getTemplate()));
- if (obj instanceof CellObject) {
- str.append(indent + String.format(" Cell Index: %d
", ((CellObject) obj).getNumber()));
- str.append(indent + String.format(" Cell Name: %s
", ((CellObject) obj).getCellName()));
- }
- return str.toString();
- }
-
- private String addLocationData(Location l) {
- StringBuilder str = new StringBuilder("");
- str.append(String.format(" Location: %.2f, %.2f, %.2f [%s]
", l.getX(), l.getY(), l.getZ(), l.getTerrain()));
- str.append(String.format("Orientation: %.2f, %.2f, %.2f, %.2f
", l.getOrientationX(), l.getOrientationY(), l.getOrientationZ(), l.getOrientationW()));
- return str.toString();
- }
-
-}
diff --git a/src/services/admin/http/HttpCookie.java b/src/services/admin/http/HttpCookie.java
deleted file mode 100644
index 3022d0231..000000000
--- a/src/services/admin/http/HttpCookie.java
+++ /dev/null
@@ -1,239 +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 services.admin.http;
-
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Set;
-
-public class HttpCookie implements Comparable {
-
- private static final String EXPIRES_FORMAT = "EEE, dd-MM-yyyy HH:mm:ss zzz"; // Wed, 18-05-2015 16:00:00 GMT
-
- private String key;
- private String value;
- private String domain;
- private String path;
- private long expires;
- private Set flags;
-
- public HttpCookie(String value, CookieFlag ... flags) {
- if (value == null)
- throw new IllegalArgumentException("Value for cookie cannot be null!");
- this.key = null;
- this.value = value;
- if (flags.length == 0)
- this.flags = EnumSet.noneOf(CookieFlag.class);
- else
- this.flags = EnumSet.copyOf(Arrays.asList(flags));
- this.domain = null;
- this.path = null;
- this.expires = 0;
- }
-
- public HttpCookie(String key, String value, CookieFlag ... flags) {
- this(value, flags);
- this.key = key;
- }
-
- public HttpCookie(String key, String value, long expires, CookieFlag ... flags) {
- this(key, value, flags);
- this.expires = expires;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public String getPath() {
- return path;
- }
-
- public long getExpires() {
- return expires;
- }
-
- public Set getFlags() {
- return Collections.unmodifiableSet(flags);
- }
-
- public boolean hasFlag(CookieFlag flag) {
- return flags.contains(flag);
- }
-
- public boolean hasExpired() {
- return expires != 0 && System.currentTimeMillis() >= expires;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public void setExpires(long expires) {
- this.expires = expires;
- }
-
- public void addFlag(CookieFlag flag) {
- flags.add(flag);
- }
-
- public void removeFlag(CookieFlag flag) {
- flags.remove(flag);
- }
-
- @Override
- public int compareTo(HttpCookie c) {
- if (key != null && c.key == null)
- return 1;
- if (key == null && c.key != null)
- return -1;
- if (!value.equals(c.value))
- return value.compareTo(c.value);
- if (expires < c.expires)
- return -1;
- if (expires > c.expires)
- return 1;
- return 0;
- }
-
- @Override
- public int hashCode() {
- int code = 0;
- if (key != null)
- code += key.hashCode();
- code ^= value.hashCode();
- if (expires != 0)
- code ^= Long.valueOf(expires).hashCode();
- return code;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null)
- return false;
- if (!(obj instanceof HttpCookie))
- return false;
- HttpCookie c = (HttpCookie) obj;
- if (key != null && c.key == null)
- return false;
- if (c.key != null && key == null)
- return false;
- if (!c.value.equals(value))
- return false;
- return c.expires == expires;
- }
-
- public String encode() {
- StringBuilder str = new StringBuilder("");
- if (key == null)
- str.append(value);
- else
- str.append(encodeCookieString(key) + "=" + encodeCookieString(value));
- if (expires != 0)
- str.append("; expires=" + encodeCookieString(new SimpleDateFormat(EXPIRES_FORMAT).format(expires)));
- if (domain != null)
- str.append("; domain=" + encodeCookieString(domain));
- if (path != null)
- str.append("; path=" + encodeCookieString(path));
- for (CookieFlag flag : flags)
- str.append("; " + flag.encode());
- return str.toString();
- }
-
- private String encodeCookieString(String str) {
- return str.replace(" ", "%20").replace("\t", "%09").replace("\n", "%0A").replace("&", "%26").replace(";", "%3B");
- }
-
- public static HttpCookie [] decodeCookies(String str) {
- String [] parts = str.split("; ");
- HttpCookie [] cookies = new HttpCookie[parts.length];
- for (int i = 0; i < parts.length; i++) {
- cookies[i] = decodeCookie(decodeCookieString(parts[i]));
- }
- return cookies;
- }
-
- private static HttpCookie decodeCookie(String str) {
- String [] parts = str.split("=", 2);
- if (parts.length == 0)
- return new HttpCookie("");
- if (parts.length == 1)
- return new HttpCookie(parts[0]);
- return new HttpCookie(parts[0], parts[1]);
- }
-
- private static String decodeCookieString(String str) {
- return str.replace("%20", " ").replace("%09", "\t").replace("%0A", "\n").replace("%26", "&").replace("%3B", ";");
- }
-
- public static enum CookieFlag {
- /**
- * Security feature where this cookie is only sent from the client
- * over a secure HTTPS connection.
- */
- SECURE ("secure"),
- /**
- * Security feature to avoid Cross Site Scripting (XSS), where this
- * cookie is unable to be accessed through javascript - only via HTTP.
- */
- HTTP_ONLY ("HttpOnly");
-
- private String encoded;
-
- CookieFlag(String encoded) {
- this.encoded = encoded;
- }
-
- protected String encode() {
- return encoded;
- }
- }
-
-}
diff --git a/src/services/admin/http/HttpImageType.java b/src/services/admin/http/HttpImageType.java
deleted file mode 100644
index 469864c1a..000000000
--- a/src/services/admin/http/HttpImageType.java
+++ /dev/null
@@ -1,34 +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 services.admin.http;
-
-public enum HttpImageType {
- GIF,
- PNG,
- JPG
-}
diff --git a/src/services/admin/http/HttpServer.java b/src/services/admin/http/HttpServer.java
deleted file mode 100644
index 136bff31b..000000000
--- a/src/services/admin/http/HttpServer.java
+++ /dev/null
@@ -1,263 +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 services.admin.http;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import resources.server_info.Log;
-import services.admin.http.HttpSocket.HttpRequest;
-import utilities.ThreadUtilities;
-
-public class HttpServer {
-
- private static final String TAG = "HttpServer";
-
- private final InetAddress addr;
- private final int port;
- private final Map sessions;
-
- private ExecutorService executor;
- private ServerSocket serverSocket;
- private AtomicInteger currentConnections;
- private HttpServerCallback callback;
- private int maxConnections;
- private boolean secure;
-
- protected HttpServer(InetAddress addr, int port, boolean secure) {
- this.addr = addr;
- this.port = port;
- this.sessions = new HashMap<>();
- this.currentConnections = new AtomicInteger(0);
- this.callback = null;
- this.maxConnections = 2;
- this.secure = secure;
- }
-
- public HttpServer(InetAddress addr, int port) {
- this(addr, port, false);
- }
-
- public void start() {
- executor = Executors.newCachedThreadPool(ThreadUtilities.newThreadFactory(getThreadFactoryName()));
- try {
- serverSocket = createSocket();
- startAcceptThread(serverSocket, secure);
- } catch (IOException e) {
- Log.e(e);
- }
- }
-
- public void stop() {
- if (serverSocket != null) {
- try {
- serverSocket.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- if (executor != null) {
- executor.shutdownNow();
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- Log.e(e);
- }
- }
- }
-
- public void setServerCallback(HttpServerCallback callback) {
- this.callback = callback;
- }
-
- public void setMaxConnections(int maxConnections) {
- this.maxConnections = maxConnections;
- }
-
- public final InetAddress getBindAddress() {
- return addr;
- }
-
- public final int getBindPort() {
- return port;
- }
-
- protected String getThreadFactoryName() {
- return "HttpServer-%d";
- }
-
- protected ServerSocket createSocket() throws IOException {
- return new ServerSocket(port, 0, addr);
- }
-
- private void startAcceptThread(ServerSocket serverSocket, boolean secure) {
- executor.execute(() -> {
- try {
- acceptThread(serverSocket, secure);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- });
- }
-
- private void startSocketThread(HttpSocket socket) {
- executor.execute(() -> {
- try {
- socketThread(socket);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- try {
- socket.close();
- } catch (IOException e) {
- Log.e(e);
- }
- synchronized (currentConnections) {
- currentConnections.decrementAndGet();
- }
- });
- }
-
- private void acceptThread(ServerSocket serverSocket, boolean secure) {
- Log.i("Now listening over HTTP%s. Address: %s:%d", secure?"S":"", serverSocket.getInetAddress(), serverSocket.getLocalPort());
- while (serverSocket.isBound() && !serverSocket.isClosed()) {
- try {
- Socket socket = serverSocket.accept();
- HttpSocket httpSocket = new HttpSocket(socket, secure);
- if (!httpSocket.isOpened()) {
- httpSocket.close();
- continue;
- }
- if (currentConnections.get() >= maxConnections) {
- httpSocket.send(HttpStatusCode.SERVICE_UNAVAILABLE, "The server has reached it's maximum connection limit: " + maxConnections);
- socket.close();
- } else {
- if (currentConnections.incrementAndGet() > maxConnections) {
- socket.close();
- currentConnections.decrementAndGet();
- } else {
- startSocketThread(httpSocket);
- }
- }
- } catch (SocketException e) {
- if (serverSocket.isClosed())
- break;
- Log.e(e);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- Log.i("No longer listening over HTTP%s!", secure?"S":"");
- }
-
- private void socketThread(HttpSocket socket) throws IOException {
- onSocketCreated(socket);
- HttpRequest request;
- while (socket.isOpened() && !socket.isClosed()) {
- request = socket.waitForRequest();
- if (request == null)
- break;
- if (request.getType() == null || request.getURI() == null || request.getHttpVersion() == null) {
- socket.send(HttpStatusCode.BAD_REQUEST);
- continue;
- }
- onRequestReceived(socket, request);
- }
- }
-
- private HttpSession getSessionForRequest(HttpRequest request) {
- String token = null;
- for (HttpCookie cookie : request.getCookies()) {
- if (cookie.getKey() != null && cookie.getKey().equals("sessionToken")) {
- if (sessions.containsKey(cookie.getValue()))
- token = cookie.getValue();
- }
- }
- if (token == null)
- token = generateSessionToken();
- HttpSession session = sessions.get(token);
- if (session == null) {
- session = new HttpSession(token);
- sessions.put(token, session);
- }
- return session;
- }
-
- private String generateSessionToken() {
- Random r = new Random();
- StringBuilder builder = new StringBuilder(24);
- int rand;
- for (int i = 0; i < 24; i++) {
- rand = r.nextInt(26*2+10);
- if (rand < 26)
- builder.append((char) ('A' + rand));
- else if (rand < 52)
- builder.append((char) ('a' + (rand-26)));
- else
- builder.append((char) ('0' + (rand-52)));
- }
- return builder.toString();
- }
-
- private void onSocketCreated(HttpSocket socket) {
- if (callback == null)
- return;
- try {
- callback.onSocketCreated(socket);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- private void onRequestReceived(HttpSocket socket, HttpRequest request) {
- socket.setSession(getSessionForRequest(request));
- if (callback == null)
- return;
- try {
- callback.onRequestReceived(socket, request);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- public interface HttpServerCallback {
- void onSocketCreated(HttpSocket socket);
- void onRequestReceived(HttpSocket socket, HttpRequest request);
- }
-
-}
diff --git a/src/services/admin/http/HttpSession.java b/src/services/admin/http/HttpSession.java
deleted file mode 100644
index 00b236587..000000000
--- a/src/services/admin/http/HttpSession.java
+++ /dev/null
@@ -1,52 +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 services.admin.http;
-
-public class HttpSession {
-
- private final String token;
- private boolean authenticated;
-
- public HttpSession(String token) {
- this.token = token;
- this.authenticated = false;
- }
-
- public String getToken() {
- return token;
- }
-
- public boolean isAuthenticated() {
- return authenticated;
- }
-
- public void setAuthenticated(boolean authenticated) {
- this.authenticated = authenticated;
- }
-
-}
diff --git a/src/services/admin/http/HttpSocket.java b/src/services/admin/http/HttpSocket.java
deleted file mode 100644
index 10c56ae54..000000000
--- a/src/services/admin/http/HttpSocket.java
+++ /dev/null
@@ -1,362 +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 services.admin.http;
-
-import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.URI;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.imageio.ImageIO;
-
-import resources.server_info.Log;
-import services.admin.http.HttpCookie.CookieFlag;
-
-public class HttpSocket implements Closeable {
-
- private static final Charset ASCII = Charset.forName("ASCII");
-
- private final Socket socket;
- private final BufferedReader reader;
- private final BufferedWriter writer;
- private final OutputStream rawOutputStream;
- private final boolean secure;
- private HttpSession session;
-
- public HttpSocket(Socket socket, boolean secure) {
- this.socket = socket;
- this.reader = createBufferedReader();
- this.writer = createBufferedWriter();
- this.rawOutputStream = getOutputStream();
- this.secure = secure;
- this.session = null;
- }
-
- /**
- * Waits for the next HTTP request to come in, then returns the request
- * sent by the client - or null if the client closes the connection.
- * @return the HttpRequest sent by the client, or null if the connection is
- * closed
- */
- public HttpRequest waitForRequest() {
- while (!socket.isClosed()) {
- String line = readLine();
- boolean hasData = line != null && !line.isEmpty();
- String [] req = null;
- Map params = new HashMap<>();
- Set cookies = new HashSet<>();
- StringBuilder body = new StringBuilder("");
- while (line != null && !line.isEmpty()) {
- if (req == null)
- req = line.split(" ", 3);
- String [] parts = line.split(": ", 2);
- if (parts.length == 2) {
- if (parts[0].equals("Cookie")) {
- cookies.addAll(Arrays.asList(HttpCookie.decodeCookies(parts[1])));
- } else {
- params.put(parts[0], parts[1]);
- }
- }
- hasData = !line.isEmpty();
- line = readLine();
- }
- if (params.containsKey("Content-Length")) {
- Integer i = Integer.valueOf(params.get("Content-Length"));
- if (i.intValue() > 0) {
- String bodyStr = readBytes(i.intValue());
- if (bodyStr == null)
- Log.e("Failed to read data in %s request: %s - returned null", req.length==0?"null":req[0], req.length<2?"null":req[1]);
- else {
- if (bodyStr.length() != i.intValue())
- Log.w("Failed to read all data in %s request: %s", req.length==0?"null":req[0], req.length<2?"null":req[1]);
- body.append(bodyStr);
- }
- }
- }
- if (hasData) {
- String type = null;
- URI uri = null;
- String version = null;
- if (req.length >= 1)
- type = req[0];
- if (req.length >= 2)
- uri = URI.create(req[1]);
- if (req.length >= 3)
- version = req[2];
- return new HttpRequest(type, uri, version, params, cookies, body.toString());
- }
- if (line == null)
- break;
- }
- return null;
- }
-
- public void setSession(HttpSession session) {
- this.session = session;
- }
-
- public HttpSession getSession() {
- return session;
- }
-
- public void redirect(String url) throws IOException {
- Map params = new HashMap<>();
- params.put("Location", url);
- send(HttpStatusCode.MOVED_PERMANENTLY, params, new HashSet<>(), "text/html", "");
- }
-
- public void send(HttpStatusCode code) throws IOException {
- send(code, "");
- }
-
- public void send(String response) throws IOException {
- send(HttpStatusCode.OK, response);
- }
-
- public void send(String contentType, byte [] response) throws IOException {
- send(HttpStatusCode.OK, new HashMap<>(), new HashSet<>(), contentType, response);
- }
-
- public void send(BufferedImage image, HttpImageType type) throws IOException {
- String contentType = "image";
- switch (type) {
- case GIF:
- contentType = "image/gif";
- break;
- case JPG:
- contentType = "image/jpeg";
- break;
- case PNG:
- contentType = "image/png";
- break;
- }
- ByteArrayOutputStream baos = new ByteArrayOutputStream(image.getWidth() * image.getHeight() * 3);
- if (!ImageIO.write(image, type.name().toLowerCase(Locale.US), baos))
- throw new IllegalArgumentException("Cannot write image with type: " + type);
- send(HttpStatusCode.OK, new HashMap<>(), new HashSet<>(), contentType, baos.toByteArray());
- }
-
- public void send(HttpStatusCode code, String response) throws IOException {
- if (code == HttpStatusCode.OK && response.isEmpty())
- code = HttpStatusCode.NO_CONTENT;
- send(code, new HashMap<>(), new HashSet<>(), "text/html", response);
- }
-
- private void send(HttpStatusCode code, Map params, Set cookies, String contentType, String response) throws IOException {
- params.put("Content-Length", Integer.toString(response.length()));
- params.put("Content-Type", contentType);
- sendHeader(code, params, cookies);
- writer.write(response);
- writer.flush();
- }
-
- private void send(HttpStatusCode code, Map params, Set cookies, String contentType, byte [] data) throws IOException {
- params.put("Content-Length", Integer.toString(data.length));
- params.put("Content-Type", contentType);
- sendHeader(code, params, cookies);
- writer.flush();
- rawOutputStream.write(data);
- rawOutputStream.flush();
- }
-
- private void sendHeader(HttpStatusCode code, Map params, Set cookies) throws IOException {
- if (session != null)
- cookies.add(new HttpCookie("sessionToken", session.getToken(), CookieFlag.SECURE, CookieFlag.HTTP_ONLY));
- write("HTTP/1.1 %d %s", code.getCode(), code.getName());
- for (Entry param : params.entrySet())
- write(param.getKey() + ": " + param.getValue());
- for (HttpCookie cookie : cookies)
- write("Set-Cookie: " + cookie.encode());
- writer.newLine();
- }
-
- private String readLine() {
- try {
- return reader.readLine();
- } catch (Exception e) {
- return null;
- }
- }
-
- private String readBytes(int length) {
- try {
- if (length == 0)
- return "";
- char [] data = new char[length];
- int read = reader.read(data);
- if (read == -1)
- return null;
- return new String(data, 0, read);
- } catch (IOException e) {
- Log.e(e);
- }
- return null;
- }
-
- @Override
- public void close() throws IOException {
- socket.close();
- }
-
- public boolean isOpened() {
- return reader != null && writer != null;
- }
-
- public boolean isClosed() {
- return socket.isClosed();
- }
-
- public boolean isSecure() {
- return secure;
- }
-
- public InetAddress getInetAddress() {
- return socket.getInetAddress();
- }
-
- public int getPort() {
- return socket.getPort();
- }
-
- private void write(String str, Object ... args) throws IOException {
- writer.write(String.format(str, args) + System.lineSeparator());
- }
-
- private BufferedReader createBufferedReader() {
- try {
- return new BufferedReader(new InputStreamReader(socket.getInputStream(), ASCII));
- } catch (IOException e) {
- Log.e(e);
- return null;
- }
- }
-
- private BufferedWriter createBufferedWriter() {
- try {
- return new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), ASCII));
- } catch (IOException e) {
- Log.e(e);
- return null;
- }
- }
-
- private OutputStream getOutputStream() {
- try {
- return socket.getOutputStream();
- } catch (IOException e) {
- Log.e(e);
- return null;
- }
- }
-
- public static class HttpRequest {
- private final String type;
- private final URI uri;
- private final String httpVersion;
- private final Map params;
- private final Set cookies;
- private final String body;
-
- private HttpRequest(String requestType, URI uri, String httpVersion, Map params, Set cookies, String body) {
- this.type = requestType;
- this.uri = uri;
- this.httpVersion = httpVersion;
- this.params = params;
- this.cookies = cookies;
- this.body = body;
- }
-
- /**
- * Gets the type of HTTP request sent. It could be one of: GET, POST,
- * HEAD.
- * @return the type of HTTP request
- */
- public String getType() {
- return type;
- }
-
- /**
- * Gets the requested URI sent
- * @return the requested URI
- */
- public URI getURI() {
- return uri;
- }
-
- /**
- * Gets the HTTP version of the client, typical format is: HTTP/1.1
- * @return the HTTP version of the client
- */
- public String getHttpVersion() {
- return httpVersion;
- }
-
- /**
- * Gets all the paramters sent in the HTTP request, such as:
- * "User-Agent", "Accept", etc.
- * @return the HTTP request parameters
- */
- public Map getParams() {
- return Collections.unmodifiableMap(params);
- }
-
- /**
- * Gets all the cookies sent in the HTTP request
- * @return the cookies
- */
- public Set getCookies() {
- return Collections.unmodifiableSet(cookies);
- }
-
- /**
- * Gets the request body
- * @return the request body
- */
- public String getBody() {
- return body;
- }
- }
-
-}
diff --git a/src/services/admin/http/HttpStatusCode.java b/src/services/admin/http/HttpStatusCode.java
deleted file mode 100644
index ea28004fd..000000000
--- a/src/services/admin/http/HttpStatusCode.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 services.admin.http;
-
-public enum HttpStatusCode {
- /** The request is OK (this is the standard response for successful HTTP requests) */
- OK (200, "OK"),
- /** The request has been successfully processed, but is not returning any content */
- NO_CONTENT (204, "No Content"),
- /** The requested page has moved to a new URL */
- MOVED_PERMANENTLY (301, "Moved Permanently"),
- /** The requested page has moved temporarily to a new URL */
- FOUND (302, "Found"),
- /** The requested page can be found under a different URL */
- SEE_OTHER (303, "See Other"),
- /** The requested page has moved temporarily to a new URL */
- TEMPORARY_REDIRECT (307, "Temporary Redirect"),
- /** The request cannot be fulfilled due to bad syntax */
- BAD_REQUEST (400, "Bad Request"),
- /** The request was a legal request, but the server is refusing to respond to it.
- For use when authentication is possible but has failed or not yet been provided */
- UNAUTHORIZED (401, "Unauthorized"),
- /** The request was a legal request, but the server is refusing to respond to it */
- FORBIDDEN (403, "Forbidden"),
- /** The requested page could not be found but may be available again in the future */
- NOT_FOUND (404, "Not Found"),
- /** A request was made of a page using a request method not supported by that page */
- METHOD_NOT_ALLOWED (405, "Method Not Allowed"),
- /** A generic error message, given when no more specific message is suitable */
- INTERNAL_ERROR (500, "Internal Error"),
- /** The server is currently unavailable (overloaded or down) */
- SERVICE_UNAVAILABLE (503, "");
-
- private int code;
- private String name;
-
- HttpStatusCode(int code, String name) {
- this.code = code;
- this.name = name;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getName() {
- return name;
- }
-
-}
diff --git a/src/services/admin/http/HttpsServer.java b/src/services/admin/http/HttpsServer.java
deleted file mode 100644
index baea49fe8..000000000
--- a/src/services/admin/http/HttpsServer.java
+++ /dev/null
@@ -1,107 +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 services.admin.http;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLServerSocketFactory;
-
-import resources.server_info.Config;
-import resources.server_info.Log;
-
-public class HttpsServer extends HttpServer {
-
- private static final String SERVER_KEYSTORE = "server.keystore";
-
- private SSLContext sslContext;
- private SSLServerSocketFactory sslServerSocketFactory;
-
- public HttpsServer(InetAddress addr, int port) {
- super(addr, port, true);
- }
-
- public boolean initialize(Config config) {
- String pass = config.getString("HTTPS-KEYSTORE-PASSWORD", "");
- System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
- System.setProperty("javax.net.ssl.keyStorePassword", pass);
- try {
- sslContext = SSLContext.getInstance("TLSv1.2");
- KeyManager [] managers = createKeyManagers(pass.toCharArray());
- if (managers == null)
- return false;
- sslContext.init(managers, null, null);
- sslServerSocketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
- return true;
- } catch (Exception e) {
- Log.e(e);
- return false;
- }
- }
-
- protected String getThreadFactoryName() {
- return "HttpsServer-%d";
- }
-
- protected ServerSocket createSocket() throws IOException {
- try {
- return sslServerSocketFactory.createServerSocket(getBindPort(), 0, getBindAddress());
- } catch (IOException e) {
- Log.e("Failed to start HTTPS server!");
- Log.e(e);
- }
- return null;
- }
-
- private KeyManager [] createKeyManagers(char [] password) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
- KeyStore ks = KeyStore.getInstance("JKS");
- InputStream ksIs = new FileInputStream(SERVER_KEYSTORE);
- try {
- ks.load(ksIs, password);
- } catch (IOException e) {
- return null; // Password invalid
- } finally {
- ksIs.close();
- }
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- kmf.init(ks, password);
- return kmf.getKeyManagers();
- }
-
-}
diff --git a/src/services/chat/ChatMailService.java b/src/services/chat/ChatMailService.java
index 827ad70fa..34b28b7a6 100644
--- a/src/services/chat/ChatMailService.java
+++ b/src/services/chat/ChatMailService.java
@@ -47,7 +47,6 @@ import network.packets.swg.zone.chat.ChatPersistentMessageToClient;
import network.packets.swg.zone.chat.ChatPersistentMessageToServer;
import network.packets.swg.zone.chat.ChatRequestPersistentMessage;
import resources.chat.ChatResult;
-import resources.control.Service;
import resources.encodables.player.Mail;
import resources.objects.SWGObject;
import resources.objects.player.PlayerObject;
@@ -55,13 +54,15 @@ import resources.player.Player;
import resources.server_info.CachedObjectDatabase;
import resources.server_info.Log;
import resources.server_info.ObjectDatabase;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import services.CoreManager;
import services.chat.ChatManager.ChatRange;
import services.chat.ChatManager.ChatType;
import services.player.PlayerManager;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class ChatMailService extends Service {
private final ObjectDatabase mails;
diff --git a/src/services/chat/ChatManager.java b/src/services/chat/ChatManager.java
index cb009b44e..a72fb93b0 100644
--- a/src/services/chat/ChatManager.java
+++ b/src/services/chat/ChatManager.java
@@ -27,16 +27,17 @@
***********************************************************************************/
package services.chat;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Locale;
-
import intents.NotifyPlayersPacketIntent;
import intents.PlayerEventIntent;
import intents.chat.ChatAvatarRequestIntent;
import intents.chat.ChatBroadcastIntent;
import intents.chat.SpatialChatIntent;
import intents.network.GalacticPacketIntent;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Locale;
+
import network.packets.Packet;
import network.packets.swg.SWGPacket;
import network.packets.swg.zone.chat.ChatFriendsListUpdate;
@@ -49,8 +50,6 @@ import network.packets.swg.zone.object_controller.SpatialChat;
import resources.Terrain;
import resources.chat.ChatAvatar;
import resources.chat.ChatResult;
-import resources.control.Assert;
-import resources.control.Manager;
import resources.encodables.OutOfBandPackage;
import resources.encodables.ProsePackage;
import resources.objects.SWGObject;
@@ -58,8 +57,11 @@ import resources.objects.player.PlayerObject;
import resources.player.Player;
import resources.player.PlayerState;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
+
+import com.projectswg.common.control.Manager;
+import com.projectswg.common.debug.Assert;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
public class ChatManager extends Manager {
diff --git a/src/services/chat/ChatRoomContainer.java b/src/services/chat/ChatRoomContainer.java
index 12e130f8c..351ecf9b0 100644
--- a/src/services/chat/ChatRoomContainer.java
+++ b/src/services/chat/ChatRoomContainer.java
@@ -33,9 +33,10 @@ import java.util.List;
import java.util.Map;
import resources.chat.ChatRoom;
-import resources.control.Assert;
import resources.server_info.Log;
+import com.projectswg.common.debug.Assert;
+
public class ChatRoomContainer {
private final Object mapMutex;
diff --git a/src/services/chat/ChatRoomHandler.java b/src/services/chat/ChatRoomHandler.java
index a197cd630..db5507167 100644
--- a/src/services/chat/ChatRoomHandler.java
+++ b/src/services/chat/ChatRoomHandler.java
@@ -33,6 +33,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+import com.projectswg.common.debug.Assert;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
import network.packets.swg.zone.chat.ChatOnDestroyRoom;
import network.packets.swg.zone.chat.ChatOnEnteredRoom;
import network.packets.swg.zone.chat.ChatOnLeaveRoom;
@@ -43,15 +47,12 @@ import resources.chat.ChatResult;
import resources.chat.ChatRoom;
import resources.client_info.ServerFactory;
import resources.client_info.visitors.DatatableData;
-import resources.control.Assert;
import resources.encodables.OutOfBandPackage;
import resources.player.AccessLevel;
import resources.player.Player;
import resources.server_info.CachedObjectDatabase;
import resources.server_info.Log;
import resources.server_info.ObjectDatabase;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import services.CoreManager;
import services.chat.ChatManager.ChatRange;
import services.chat.ChatManager.ChatType;
diff --git a/src/services/chat/ChatRoomService.java b/src/services/chat/ChatRoomService.java
index 9ae9b4b27..08dd0b660 100644
--- a/src/services/chat/ChatRoomService.java
+++ b/src/services/chat/ChatRoomService.java
@@ -61,9 +61,10 @@ import network.packets.swg.zone.insertion.ChatRoomList;
import resources.chat.ChatAvatar;
import resources.chat.ChatResult;
import resources.chat.ChatRoom;
-import resources.control.Service;
-import resources.player.Player;
import resources.encodables.OutOfBandPackage;
+import resources.player.Player;
+
+import com.projectswg.common.control.Service;
public class ChatRoomService extends Service {
diff --git a/src/services/collections/CollectionBadgeManager.java b/src/services/collections/CollectionBadgeManager.java
index cf3b96899..7cac13184 100644
--- a/src/services/collections/CollectionBadgeManager.java
+++ b/src/services/collections/CollectionBadgeManager.java
@@ -29,16 +29,15 @@
package services.collections;
-import java.util.BitSet;
-
import intents.GrantBadgeIntent;
import intents.GrantClickyCollectionIntent;
import intents.object.DestroyObjectIntent;
+
+import java.util.BitSet;
+
import network.packets.swg.zone.PlayMusicMessage;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
-import resources.control.Intent;
-import resources.control.Manager;
import resources.objects.SWGObject;
import resources.objects.collections.ClickyCollectionItem;
import resources.objects.collections.CollectionItem;
@@ -47,6 +46,8 @@ import resources.objects.player.PlayerObject;
import resources.player.Player;
import utilities.IntentFactory;
+import com.projectswg.common.control.Manager;
+
public class CollectionBadgeManager extends Manager {
// TODO grant item rewards and/or schematics
diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java
index d190cfd9e..c55563cff 100644
--- a/src/services/collections/CollectionService.java
+++ b/src/services/collections/CollectionService.java
@@ -31,15 +31,6 @@ import intents.GrantClickyCollectionIntent;
import intents.radial.RadialRequestIntent;
import intents.radial.RadialResponseIntent;
import intents.radial.RadialSelectionIntent;
-import resources.control.Intent;
-import resources.control.Service;
-import resources.objects.collections.ClickyCollectionItem;
-import resources.objects.collections.CollectionItem;
-import resources.radial.RadialOption;
-import resources.radial.Radials;
-import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -47,6 +38,16 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
+import resources.objects.collections.ClickyCollectionItem;
+import resources.objects.collections.CollectionItem;
+import resources.radial.RadialOption;
+import resources.radial.Radials;
+import resources.server_info.Log;
+
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
/**
* Created by skylerlehan on 8/21/16.
*/
diff --git a/src/services/collections/ExplorationBadgeService.java b/src/services/collections/ExplorationBadgeService.java
index 4769f3ca9..7d337b4e0 100644
--- a/src/services/collections/ExplorationBadgeService.java
+++ b/src/services/collections/ExplorationBadgeService.java
@@ -28,6 +28,9 @@
***********************************************************************************/
package services.collections;
+import intents.GrantBadgeIntent;
+import intents.player.PlayerTransformedIntent;
+
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Locale;
@@ -35,14 +38,13 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
-import intents.GrantBadgeIntent;
-import intents.player.PlayerTransformedIntent;
import resources.Point3D;
-import resources.control.Service;
import resources.objects.creature.CreatureObject;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
+
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
public class ExplorationBadgeService extends Service {
diff --git a/src/services/combat/CombatManager.java b/src/services/combat/CombatManager.java
index b65ff5951..83d5b5906 100644
--- a/src/services/combat/CombatManager.java
+++ b/src/services/combat/CombatManager.java
@@ -27,6 +27,14 @@
***********************************************************************************/
package services.combat;
+import intents.BuffIntent;
+import intents.chat.ChatBroadcastIntent;
+import intents.chat.ChatCommandIntent;
+import intents.combat.CreatureKilledIntent;
+import intents.combat.DeathblowIntent;
+import intents.object.DestroyObjectIntent;
+import intents.object.ObjectCreatedIntent;
+
import java.awt.Color;
import java.util.Collection;
import java.util.HashMap;
@@ -41,13 +49,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import intents.BuffIntent;
-import intents.chat.ChatBroadcastIntent;
-import intents.chat.ChatCommandIntent;
-import intents.combat.CreatureKilledIntent;
-import intents.combat.DeathblowIntent;
-import intents.object.DestroyObjectIntent;
-import intents.object.ObjectCreatedIntent;
import network.packets.swg.zone.PlayClientEffectObjectMessage;
import network.packets.swg.zone.object_controller.ShowFlyText;
import network.packets.swg.zone.object_controller.ShowFlyText.Scale;
@@ -63,7 +64,6 @@ import resources.combat.TrailLocation;
import resources.commands.CombatCommand;
import resources.common.CRC;
import resources.common.RGB;
-import resources.control.Manager;
import resources.encodables.ProsePackage;
import resources.encodables.StringId;
import resources.objects.SWGObject;
@@ -75,6 +75,8 @@ import resources.server_info.Log;
import services.objects.ObjectCreator;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Manager;
+
public class CombatManager extends Manager {
private static final byte INCAP_TIMER = 10; // Amount of seconds to be incapacitated
diff --git a/src/services/combat/CombatXpService.java b/src/services/combat/CombatXpService.java
index d866345e5..f14783b4a 100644
--- a/src/services/combat/CombatXpService.java
+++ b/src/services/combat/CombatXpService.java
@@ -37,20 +37,17 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureDifficulty;
import resources.objects.creature.CreatureObject;
import resources.objects.group.GroupObject;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import resources.server_info.StandardLog;
-/**
- *
- * @author mads
- */
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class CombatXpService extends Service {
private final Map xpData;
diff --git a/src/services/combat/CorpseService.java b/src/services/combat/CorpseService.java
index 3fd510c8a..4f95ecf8c 100644
--- a/src/services/combat/CorpseService.java
+++ b/src/services/combat/CorpseService.java
@@ -31,12 +31,6 @@ import intents.BuffIntent;
import intents.FactionIntent;
import intents.PlayerEventIntent;
import intents.chat.ChatBroadcastIntent;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import network.packets.swg.zone.PlayClientEffectObjectMessage;
import intents.combat.CreatureKilledIntent;
import intents.object.DestroyObjectIntent;
import intents.object.ObjectCreatedIntent;
@@ -49,16 +43,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+import network.packets.swg.zone.PlayClientEffectObjectMessage;
import resources.Location;
import resources.Posture;
import resources.PvpFaction;
import resources.PvpStatus;
import resources.Terrain;
import resources.client_info.ClientFactory;
-import resources.control.Service;
import resources.encodables.ProsePackage;
import resources.encodables.StringId;
import resources.objects.SWGObject;
@@ -67,8 +64,6 @@ import resources.objects.cell.CellObject;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import resources.server_info.StandardLog;
import resources.sui.SuiButtons;
import resources.sui.SuiEvent;
@@ -76,6 +71,10 @@ import resources.sui.SuiListBox;
import resources.sui.SuiWindow;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
/**
* The {@code CorpseService} removes corpses from the world a while after
* they've died. It also lets players clone at a cloning facility.
diff --git a/src/services/commands/BuffService.java b/src/services/commands/BuffService.java
index cc0f2409d..4045ebbba 100644
--- a/src/services/commands/BuffService.java
+++ b/src/services/commands/BuffService.java
@@ -27,6 +27,11 @@
***********************************************************************************/
package services.commands;
+import intents.BuffIntent;
+import intents.PlayerEventIntent;
+import intents.SkillModIntent;
+import intents.combat.CreatureKilledIntent;
+
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
@@ -35,15 +40,8 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
-import intents.BuffIntent;
-import intents.PlayerEventIntent;
-import intents.SkillModIntent;
-import intents.combat.CreatureKilledIntent;
import network.packets.swg.zone.PlayClientEffectObjectMessage;
import resources.common.CRC;
-import resources.concurrency.PswgBasicScheduledThread;
-import resources.control.Assert;
-import resources.control.Service;
import resources.objects.creature.Buff;
import resources.objects.creature.CreatureObject;
import resources.server_info.Log;
@@ -52,6 +50,10 @@ import services.commands.buff.BuffData;
import services.commands.buff.BuffMap;
import utilities.Scripts;
+import com.projectswg.common.concurrency.PswgBasicScheduledThread;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+
public class BuffService extends Service {
/*
diff --git a/src/services/commands/CommandService.java b/src/services/commands/CommandService.java
index 3ef5b343c..82b9c8c78 100644
--- a/src/services/commands/CommandService.java
+++ b/src/services/commands/CommandService.java
@@ -32,7 +32,9 @@ import intents.chat.ChatBroadcastIntent;
import intents.chat.ChatCommandIntent;
import intents.network.GalacticPacketIntent;
import intents.player.PlayerTransformedIntent;
+
import java.io.FileNotFoundException;
+
import network.packets.Packet;
import network.packets.swg.zone.object_controller.CommandQueueDequeue;
import network.packets.swg.zone.object_controller.CommandQueueEnqueue;
@@ -46,8 +48,6 @@ import resources.commands.Command;
import resources.commands.ICmdCallback;
import resources.commands.callbacks.*;
import resources.common.CRC;
-import resources.control.Intent;
-import resources.control.Service;
import resources.encodables.ProsePackage;
import resources.encodables.StringId;
import resources.objects.SWGObject;
@@ -71,15 +71,17 @@ import java.util.concurrent.Executors;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.control.Service;
+
import network.packets.swg.zone.object_controller.CommandTimer;
import resources.combat.DelayAttackEggPosition;
import resources.combat.HitType;
import resources.commands.DefaultPriority;
import resources.objects.creature.CreatureObject;
-import resources.server_info.SynchronizedMap;
import utilities.ThreadUtilities;
-
public class CommandService extends Service {
private final Map commands; // NOTE: CRC's are all lowercased for commands!
diff --git a/src/services/commands/EntertainmentService.java b/src/services/commands/EntertainmentService.java
index 8cf815636..05d0cb2c3 100644
--- a/src/services/commands/EntertainmentService.java
+++ b/src/services/commands/EntertainmentService.java
@@ -27,6 +27,14 @@
***********************************************************************************/
package services.commands;
+import intents.DanceIntent;
+import intents.FlourishIntent;
+import intents.PlayerEventIntent;
+import intents.WatchIntent;
+import intents.chat.ChatBroadcastIntent;
+import intents.experience.ExperienceIntent;
+import intents.player.PlayerTransformedIntent;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -36,19 +44,11 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import intents.DanceIntent;
-import intents.FlourishIntent;
-import intents.PlayerEventIntent;
-import intents.WatchIntent;
-import intents.chat.ChatBroadcastIntent;
-import intents.experience.ExperienceIntent;
-import intents.player.PlayerTransformedIntent;
import network.packets.swg.zone.object_controller.Animation;
import resources.Location;
import resources.Posture;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
-import resources.control.Service;
import resources.encodables.ProsePackage;
import resources.encodables.StringId;
import resources.objects.SWGObject;
@@ -56,6 +56,8 @@ import resources.objects.creature.CreatureObject;
import resources.player.Player;
import resources.server_info.Log;
+import com.projectswg.common.control.Service;
+
/**
*
* @author Mads
diff --git a/src/services/commands/buff/BuffData.java b/src/services/commands/buff/BuffData.java
index 65948def9..5899a4e92 100644
--- a/src/services/commands/buff/BuffData.java
+++ b/src/services/commands/buff/BuffData.java
@@ -30,7 +30,8 @@ package services.commands.buff;
import java.util.Locale;
import resources.common.CRC;
-import resources.control.Assert;
+
+import com.projectswg.common.debug.Assert;
public class BuffData {
diff --git a/src/services/commands/buff/BuffMap.java b/src/services/commands/buff/BuffMap.java
index ebf856dd6..f9f3f7cc8 100644
--- a/src/services/commands/buff/BuffMap.java
+++ b/src/services/commands/buff/BuffMap.java
@@ -33,7 +33,8 @@ import java.util.Map;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
import resources.common.CRC;
-import resources.server_info.SynchronizedMap;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
public class BuffMap {
diff --git a/src/services/dev/DeveloperService.java b/src/services/dev/DeveloperService.java
index 9192fc7a9..7749b0e84 100644
--- a/src/services/dev/DeveloperService.java
+++ b/src/services/dev/DeveloperService.java
@@ -32,12 +32,14 @@ import resources.Location;
import resources.PvpFlag;
import resources.Terrain;
import resources.config.ConfigFile;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.custom.DefaultAIObject;
import resources.objects.tangible.TangibleObject;
+import resources.server_info.DataManager;
import services.objects.ObjectCreator;
+import com.projectswg.common.control.Service;
+
public class DeveloperService extends Service {
public DeveloperService() {
@@ -48,7 +50,7 @@ public class DeveloperService extends Service {
public boolean start() {
setupDeveloperArea();
- if (getConfig(ConfigFile.FEATURES).getBoolean("CHARACTER-BUILDER", false))
+ if (DataManager.getConfig(ConfigFile.FEATURES).getBoolean("CHARACTER-BUILDER", false))
setupCharacterBuilders();
return super.start();
diff --git a/src/services/experience/ExperienceManager.java b/src/services/experience/ExperienceManager.java
index bded45a5c..b041389cc 100644
--- a/src/services/experience/ExperienceManager.java
+++ b/src/services/experience/ExperienceManager.java
@@ -27,26 +27,29 @@
***********************************************************************************/
package services.experience;
+import intents.experience.ExperienceIntent;
+import intents.experience.LevelChangedIntent;
+
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
-import intents.experience.ExperienceIntent;
-import intents.experience.LevelChangedIntent;
import network.packets.swg.zone.object_controller.ShowFlyText;
import network.packets.swg.zone.object_controller.ShowFlyText.Scale;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
import resources.common.RGB;
import resources.config.ConfigFile;
-import resources.control.Manager;
import resources.encodables.OutOfBandPackage;
import resources.encodables.ProsePackage;
import resources.encodables.StringId;
import resources.objects.creature.CreatureObject;
import resources.objects.player.PlayerObject;
+import resources.server_info.DataManager;
import resources.server_info.Log;
+import com.projectswg.common.control.Manager;
+
/**
* The {@code ExperienceManager} listens for {@link ExperienceIntent} and
* grants XP based on it.
@@ -63,7 +66,7 @@ public final class ExperienceManager extends Manager {
skillManager = new SkillManager();
skillTemplateService = new SkillTemplateService();
levelXpMap = new HashMap<>();
- xpMultiplier = getConfig(ConfigFile.FEATURES).getDouble("XP-MULTIPLIER", 1);
+ xpMultiplier = DataManager.getConfig(ConfigFile.FEATURES).getDouble("XP-MULTIPLIER", 1);
registerForIntent(ExperienceIntent.class, ei -> handleExperienceIntent(ei));
diff --git a/src/services/experience/ExpertiseService.java b/src/services/experience/ExpertiseService.java
index 51acefe25..dc84a3ae7 100644
--- a/src/services/experience/ExpertiseService.java
+++ b/src/services/experience/ExpertiseService.java
@@ -42,17 +42,18 @@ import network.packets.Packet;
import network.packets.swg.zone.ExpertiseRequestMessage;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
-import resources.control.Intent;
-import resources.control.Service;
import resources.objects.creature.CreatureObject;
import resources.objects.player.PlayerObject;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import resources.server_info.StandardLog;
import resources.sui.SuiButtons;
import resources.sui.SuiMessageBox;
+import com.projectswg.common.control.Intent;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
/**
*
* @author Mads
diff --git a/src/services/experience/SkillManager.java b/src/services/experience/SkillManager.java
index 786b84a7a..f4de904f3 100644
--- a/src/services/experience/SkillManager.java
+++ b/src/services/experience/SkillManager.java
@@ -27,23 +27,25 @@
***********************************************************************************/
package services.experience;
+import intents.SkillModIntent;
+import intents.experience.GrantSkillIntent;
+import intents.network.GalacticPacketIntent;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import intents.SkillModIntent;
-import intents.experience.GrantSkillIntent;
-import intents.network.GalacticPacketIntent;
import network.packets.Packet;
import network.packets.swg.zone.object_controller.ChangeRoleIconChoice;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
-import resources.control.Assert;
-import resources.control.Manager;
import resources.objects.creature.CreatureObject;
import resources.server_info.Log;
+import com.projectswg.common.control.Manager;
+import com.projectswg.common.debug.Assert;
+
/**
*
* @author Mads
diff --git a/src/services/experience/SkillTemplateService.java b/src/services/experience/SkillTemplateService.java
index 10ffa7ac4..da12ab56e 100644
--- a/src/services/experience/SkillTemplateService.java
+++ b/src/services/experience/SkillTemplateService.java
@@ -27,17 +27,18 @@
***********************************************************************************/
package services.experience;
+import intents.GrantBadgeIntent;
+import intents.experience.GrantSkillIntent;
+import intents.experience.LevelChangedIntent;
+import intents.object.CreateStaticItemIntent;
+import intents.object.ObjectCreatedIntent;
+
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import intents.GrantBadgeIntent;
-import intents.experience.GrantSkillIntent;
-import intents.experience.LevelChangedIntent;
-import intents.object.CreateStaticItemIntent;
-import intents.object.ObjectCreatedIntent;
import network.packets.swg.zone.PlayClientEffectObjectMessage;
import network.packets.swg.zone.PlayMusicMessage;
import network.packets.swg.zone.object_controller.ShowFlyText;
@@ -46,7 +47,6 @@ import resources.Race;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
import resources.common.RGB;
-import resources.control.Service;
import resources.encodables.StringId;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
@@ -57,6 +57,8 @@ import resources.server_info.Log;
import services.objects.ObjectCreator;
import services.objects.StaticItemService;
+import com.projectswg.common.control.Service;
+
/**
* This is a service that listens for {@link LevelChangedIntent} and grants
* everything linked to a skillbox.
diff --git a/src/services/faction/FactionService.java b/src/services/faction/FactionService.java
index 6a801fe25..f4e71ace6 100644
--- a/src/services/faction/FactionService.java
+++ b/src/services/faction/FactionService.java
@@ -27,6 +27,9 @@
***********************************************************************************/
package services.faction;
+import intents.FactionIntent;
+import intents.chat.ChatBroadcastIntent;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -35,20 +38,19 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import intents.FactionIntent;
-import intents.chat.ChatBroadcastIntent;
import network.packets.swg.zone.UpdatePvpStatusMessage;
import network.packets.swg.zone.chat.ChatSystemMessage;
import network.packets.swg.zone.chat.ChatSystemMessage.SystemChatType;
import resources.PvpFaction;
import resources.PvpFlag;
import resources.PvpStatus;
-import resources.control.Service;
import resources.objects.creature.CreatureObject;
import resources.objects.tangible.TangibleObject;
import resources.player.Player;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Service;
+
public final class FactionService extends Service {
private final ScheduledExecutorService executor;
diff --git a/src/services/galaxy/ConnectionService.java b/src/services/galaxy/ConnectionService.java
index 0d276af4c..edc54bac7 100644
--- a/src/services/galaxy/ConnectionService.java
+++ b/src/services/galaxy/ConnectionService.java
@@ -27,18 +27,16 @@
***********************************************************************************/
package services.galaxy;
+import intents.PlayerEventIntent;
+import intents.network.GalacticPacketIntent;
+
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import intents.PlayerEventIntent;
-import intents.network.GalacticPacketIntent;
import network.packets.swg.zone.HeartBeat;
-import resources.control.Assert;
-import resources.control.Intent;
-import resources.control.Service;
import resources.network.DisconnectReason;
import resources.objects.creature.CreatureObject;
import resources.objects.player.PlayerObject;
@@ -46,10 +44,14 @@ import resources.player.Player;
import resources.player.PlayerEvent;
import resources.player.PlayerFlags;
import resources.server_info.Log;
-import resources.server_info.SynchronizedSet;
import services.CoreManager;
import utilities.ThreadUtilities;
+import com.projectswg.common.concurrency.SynchronizedSet;
+import com.projectswg.common.control.Intent;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+
public class ConnectionService extends Service {
private static final double DISAPPEAR_THRESHOLD = TimeUnit.MINUTES.toMillis(3); // Time after the LD
diff --git a/src/services/galaxy/EnvironmentService.java b/src/services/galaxy/EnvironmentService.java
index 88bf64fb9..912c4f99c 100644
--- a/src/services/galaxy/EnvironmentService.java
+++ b/src/services/galaxy/EnvironmentService.java
@@ -27,6 +27,9 @@
***********************************************************************************/
package services.galaxy;
+import intents.NotifyPlayersPacketIntent;
+import intents.PlayerEventIntent;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@@ -34,19 +37,18 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import intents.NotifyPlayersPacketIntent;
-import intents.PlayerEventIntent;
import main.ProjectSWG;
import network.packets.swg.SWGPacket;
import network.packets.swg.zone.ServerTimeMessage;
import network.packets.swg.zone.ServerWeatherMessage;
import resources.Terrain;
import resources.WeatherType;
-import resources.control.Service;
import resources.player.Player;
import resources.player.PlayerEvent;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Service;
+
public final class EnvironmentService extends Service {
private final long cycleDuration;
diff --git a/src/services/galaxy/GalacticManager.java b/src/services/galaxy/GalacticManager.java
index b97ed7795..b22b5784a 100644
--- a/src/services/galaxy/GalacticManager.java
+++ b/src/services/galaxy/GalacticManager.java
@@ -27,16 +27,14 @@
***********************************************************************************/
package services.galaxy;
-import java.util.Map;
-
import intents.network.ConnectionClosedIntent;
import intents.network.ConnectionOpenedIntent;
import intents.network.GalacticPacketIntent;
import intents.network.InboundPacketIntent;
-import resources.control.Assert;
-import resources.control.Manager;
+
+import java.util.Map;
+
import resources.player.Player;
-import resources.server_info.SynchronizedMap;
import services.CoreManager;
import services.chat.ChatManager;
import services.dev.DeveloperService;
@@ -44,7 +42,11 @@ import services.galaxy.travel.TravelService;
import services.objects.ObjectManager;
import services.objects.UniformBoxService;
import services.player.PlayerManager;
-import utilities.IntentChain;
+
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.control.IntentChain;
+import com.projectswg.common.control.Manager;
+import com.projectswg.common.debug.Assert;
public class GalacticManager extends Manager {
@@ -95,9 +97,7 @@ public class GalacticManager extends Manager {
}
private void handleConnectionOpenedIntent(ConnectionOpenedIntent coi){
- IntentChain chain = new IntentChain();
- chain.waitUntilComplete(coi);
- prevIntentMap.put(((ConnectionOpenedIntent) coi).getNetworkId(), chain);
+ prevIntentMap.put(((ConnectionOpenedIntent) coi).getNetworkId(), new IntentChain(coi));
}
private void handleConnectionClosedIntent(ConnectionClosedIntent cci){
diff --git a/src/services/galaxy/GameManager.java b/src/services/galaxy/GameManager.java
index 3a8f3800d..872c006d8 100644
--- a/src/services/galaxy/GameManager.java
+++ b/src/services/galaxy/GameManager.java
@@ -27,18 +27,19 @@
***********************************************************************************/
package services.galaxy;
-import resources.control.Manager;
-import services.commands.BuffService;
-import services.collections.CollectionService;
import services.collections.CollectionBadgeManager;
+import services.collections.CollectionService;
import services.combat.CombatManager;
+import services.commands.BuffService;
import services.commands.CommandService;
import services.commands.EntertainmentService;
import services.experience.ExperienceManager;
import services.faction.FactionService;
import services.galaxy.terminals.TerminalService;
-import services.sui.SuiService;
import services.group.GroupService;
+import services.sui.SuiService;
+
+import com.projectswg.common.control.Manager;
public class GameManager extends Manager {
@@ -47,7 +48,7 @@ public class GameManager extends Manager {
private final SuiService suiService;
private final CollectionService collectionService;
private final CollectionBadgeManager collectionBadgeManager;
- private final EnvironmentService weatherService;
+ private final EnvironmentService environmentService;
private final TerminalService terminalManager;
private final FactionService factionService;
private final GroupService groupService;
@@ -63,7 +64,7 @@ public class GameManager extends Manager {
suiService = new SuiService();
collectionService = new CollectionService();
collectionBadgeManager = new CollectionBadgeManager();
- weatherService = new EnvironmentService();
+ environmentService = new EnvironmentService();
terminalManager = new TerminalService();
factionService = new FactionService();
groupService = new GroupService();
@@ -78,7 +79,7 @@ public class GameManager extends Manager {
addChildService(suiService);
addChildService(collectionService);
addChildService(collectionBadgeManager);
- addChildService(weatherService);
+ addChildService(environmentService);
addChildService(terminalManager);
addChildService(factionService);
addChildService(groupService);
diff --git a/src/services/galaxy/SkillModService.java b/src/services/galaxy/SkillModService.java
index 3d6d4029d..023c90aaa 100644
--- a/src/services/galaxy/SkillModService.java
+++ b/src/services/galaxy/SkillModService.java
@@ -28,9 +28,10 @@
package services.galaxy;
import intents.SkillModIntent;
-import resources.control.Service;
import resources.objects.creature.CreatureObject;
+import com.projectswg.common.control.Service;
+
public class SkillModService extends Service {
public SkillModService() {
diff --git a/src/services/galaxy/terminals/TerminalService.java b/src/services/galaxy/terminals/TerminalService.java
index 6cfd064ac..5ee202de8 100644
--- a/src/services/galaxy/terminals/TerminalService.java
+++ b/src/services/galaxy/terminals/TerminalService.java
@@ -27,6 +27,11 @@
***********************************************************************************/
package services.galaxy.terminals;
+import intents.radial.RadialRegisterIntent;
+import intents.radial.RadialRequestIntent;
+import intents.radial.RadialResponseIntent;
+import intents.radial.RadialSelectionIntent;
+
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -35,16 +40,13 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import intents.radial.RadialRegisterIntent;
-import intents.radial.RadialRequestIntent;
-import intents.radial.RadialResponseIntent;
-import intents.radial.RadialSelectionIntent;
-import resources.control.Service;
import resources.radial.RadialOption;
import resources.radial.Radials;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
+
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
public class TerminalService extends Service {
diff --git a/src/services/galaxy/travel/TravelService.java b/src/services/galaxy/travel/TravelService.java
index 75cb585ff..c63dfa98d 100644
--- a/src/services/galaxy/travel/TravelService.java
+++ b/src/services/galaxy/travel/TravelService.java
@@ -27,6 +27,15 @@
***********************************************************************************/
package services.galaxy.travel;
+import intents.chat.ChatBroadcastIntent;
+import intents.network.GalacticPacketIntent;
+import intents.object.DestroyObjectIntent;
+import intents.object.ObjectCreatedIntent;
+import intents.object.ObjectTeleportIntent;
+import intents.travel.TicketPurchaseIntent;
+import intents.travel.TicketUseIntent;
+import intents.travel.TravelPointSelectionIntent;
+
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -43,12 +52,6 @@ import network.packets.Packet;
import network.packets.swg.zone.EnterTicketPurchaseModeMessage;
import network.packets.swg.zone.PlanetTravelPointListRequest;
import network.packets.swg.zone.PlanetTravelPointListResponse;
-import intents.chat.ChatBroadcastIntent;
-import intents.network.GalacticPacketIntent;
-import intents.object.DestroyObjectIntent;
-import intents.object.ObjectCreatedIntent;
-import intents.object.ObjectTeleportIntent;
-import intents.travel.*;
import resources.Location;
import resources.Posture;
import resources.Terrain;
@@ -56,7 +59,6 @@ import resources.TravelPoint;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
import resources.config.ConfigFile;
-import resources.control.Service;
import resources.encodables.ProsePackage;
import resources.encodables.StringId;
import resources.objects.SWGObject;
@@ -64,17 +66,20 @@ import resources.objects.creature.CreatureObject;
import resources.objects.staticobject.StaticObject;
import resources.objects.tangible.OptionFlag;
import resources.player.Player;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import resources.sui.SuiButtons;
import resources.sui.SuiListBox;
import resources.sui.SuiMessageBox;
-import services.galaxy.travel.TravelGroup;
import services.galaxy.travel.TravelGroup.ShuttleStatus;
import services.objects.ObjectCreator;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.Config;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class TravelService extends Service {
private static final String DB_TABLE_NAME = "travel";
@@ -98,9 +103,10 @@ public class TravelService extends Service {
travelFeeTable = (DatatableData) ClientFactory.getInfoFromFile("datatables/travel/travel.iff");
travel = new HashMap<>();
- ticketPriceFactor = getConfig(ConfigFile.FEATURES).getDouble("TICKET-PRICE-FACTOR", 1);
- groundTime = new AtomicInteger(getConfig(ConfigFile.FEATURES).getInt("SHUTTLE-GROUND-TIME", 120));
- airTime = new AtomicInteger(getConfig(ConfigFile.FEATURES).getInt("SHUTTLE-AIR-TIME", 60));
+ Config config = DataManager.getConfig(ConfigFile.FEATURES);
+ ticketPriceFactor = config.getDouble("TICKET-PRICE-FACTOR", 1);
+ groundTime = new AtomicInteger(config.getInt("SHUTTLE-GROUND-TIME", 120));
+ airTime = new AtomicInteger(config.getInt("SHUTTLE-AIR-TIME", 60));
createGalaxyTravel("object/creature/npc/theme_park/shared_player_shuttle.iff", 17000);
createGalaxyTravel("object/creature/npc/theme_park/shared_player_transport.iff", 21000);
diff --git a/src/services/group/GroupService.java b/src/services/group/GroupService.java
index 9bee32124..3cc477e6a 100644
--- a/src/services/group/GroupService.java
+++ b/src/services/group/GroupService.java
@@ -26,9 +26,6 @@
******************************************************************************/
package services.group;
-import java.util.Map;
-import java.util.Set;
-
import intents.GroupEventIntent;
import intents.PlayerEventIntent;
import intents.chat.ChatBroadcastIntent;
@@ -36,18 +33,23 @@ import intents.chat.ChatRoomUpdateIntent;
import intents.chat.ChatRoomUpdateIntent.UpdateType;
import intents.object.DestroyObjectIntent;
import intents.object.ObjectCreatedIntent;
+
+import java.util.Map;
+import java.util.Set;
+
import resources.chat.ChatAvatar;
-import resources.control.Assert;
-import resources.control.Service;
import resources.encodables.ProsePackage;
import resources.objects.creature.CreatureObject;
import resources.objects.group.GroupObject;
import resources.player.Player;
import resources.player.Player.PlayerServer;
-import resources.server_info.SynchronizedMap;
import services.objects.ObjectCreator;
import utilities.IntentFactory;
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+
public class GroupService extends Service {
private final Map groups;
diff --git a/src/services/map/CityService.java b/src/services/map/CityService.java
index 6869656ee..31c262102 100644
--- a/src/services/map/CityService.java
+++ b/src/services/map/CityService.java
@@ -27,6 +27,10 @@
***********************************************************************************/
package services.map;
+import intents.PlayerEventIntent;
+import intents.network.GalacticPacketIntent;
+import intents.object.ObjectCreatedIntent;
+
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -34,21 +38,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import intents.PlayerEventIntent;
-import intents.network.GalacticPacketIntent;
-import intents.object.ObjectCreatedIntent;
import network.packets.Packet;
import network.packets.swg.zone.object_controller.DataTransform;
import resources.Terrain;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.objects.tangible.TangibleObject;
import resources.player.Player;
import resources.player.PlayerEvent;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
+
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
public class CityService extends Service {
diff --git a/src/services/map/MapManager.java b/src/services/map/MapManager.java
index 70d426767..96fd26f8d 100644
--- a/src/services/map/MapManager.java
+++ b/src/services/map/MapManager.java
@@ -29,16 +29,6 @@ package services.map;
import intents.network.GalacticPacketIntent;
import intents.object.ObjectCreatedIntent;
-import network.packets.Packet;
-import network.packets.swg.SWGPacket;
-import network.packets.swg.zone.spatial.GetMapLocationsMessage;
-import network.packets.swg.zone.spatial.GetMapLocationsResponseMessage;
-import resources.client_info.ClientFactory;
-import resources.client_info.ServerFactory;
-import resources.client_info.visitors.DatatableData;
-import resources.control.Manager;
-import resources.objects.SWGObject;
-import resources.player.Player;
import java.util.ArrayList;
import java.util.HashMap;
@@ -47,6 +37,19 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
+import network.packets.Packet;
+import network.packets.swg.SWGPacket;
+import network.packets.swg.zone.spatial.GetMapLocationsMessage;
+import network.packets.swg.zone.spatial.GetMapLocationsResponseMessage;
+import resources.client_info.ClientFactory;
+import resources.client_info.ServerFactory;
+import resources.client_info.visitors.DatatableData;
+import resources.objects.SWGObject;
+import resources.player.Player;
+
+import com.projectswg.common.control.Manager;
+import com.sun.prism.PhongMaterial.MapType;
+
public class MapManager extends Manager {
private final Map mapCategories;
diff --git a/src/services/network/InboundNetworkManager.java b/src/services/network/InboundNetworkManager.java
index 010507ef0..8ea7a5974 100644
--- a/src/services/network/InboundNetworkManager.java
+++ b/src/services/network/InboundNetworkManager.java
@@ -33,9 +33,10 @@ import java.net.SocketAddress;
import java.util.Arrays;
import network.NetworkClient;
-import resources.control.Service;
import resources.server_info.Log;
+import com.projectswg.common.control.Service;
+
public class InboundNetworkManager extends Service {
private final ClientManager clientManager;
diff --git a/src/services/network/NetworkClientManager.java b/src/services/network/NetworkClientManager.java
index a71655a02..c90d4c731 100644
--- a/src/services/network/NetworkClientManager.java
+++ b/src/services/network/NetworkClientManager.java
@@ -27,6 +27,8 @@
***********************************************************************************/
package services.network;
+import intents.network.CloseConnectionIntent;
+
import java.io.IOException;
import java.net.BindException;
import java.net.InetAddress;
@@ -34,21 +36,22 @@ import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
-import intents.network.CloseConnectionIntent;
import main.ProjectSWG.CoreException;
import network.AdminNetworkClient;
import network.NetworkClient;
import network.packets.swg.holo.HoloConnectionStopped.ConnectionStoppedReason;
import resources.config.ConfigFile;
-import resources.control.Manager;
import resources.network.NetBuffer;
import resources.network.NetworkCallback;
import resources.network.TCPServer;
import resources.network.UDPServer;
import resources.network.UDPServer.UDPPacket;
+import resources.server_info.DataManager;
import resources.server_info.Log;
import services.CoreManager;
+import com.projectswg.common.control.Manager;
+
public class NetworkClientManager extends Manager {
private final InboundNetworkManager inboundManager;
@@ -125,11 +128,11 @@ public class NetworkClientManager extends Manager {
}
private int getBindPort() {
- return getConfig(ConfigFile.NETWORK).getInt("BIND-PORT", 44463);
+ return DataManager.getConfig(ConfigFile.NETWORK).getInt("BIND-PORT", 44463);
}
private int getBufferSize() {
- return getConfig(ConfigFile.NETWORK).getInt("BUFFER-SIZE", 4096);
+ return DataManager.getConfig(ConfigFile.NETWORK).getInt("BUFFER-SIZE", 4096);
}
private void onUdpPacket(UDPPacket packet) {
diff --git a/src/services/network/NetworkManager.java b/src/services/network/NetworkManager.java
index 0a5100b83..615e0fa25 100644
--- a/src/services/network/NetworkManager.java
+++ b/src/services/network/NetworkManager.java
@@ -27,7 +27,7 @@
***********************************************************************************/
package services.network;
-import resources.control.Manager;
+import com.projectswg.common.control.Manager;
public class NetworkManager extends Manager {
diff --git a/src/services/network/NetworkProtocol.java b/src/services/network/NetworkProtocol.java
index af1d6d70b..2da42d1a9 100644
--- a/src/services/network/NetworkProtocol.java
+++ b/src/services/network/NetworkProtocol.java
@@ -31,13 +31,14 @@ import java.io.EOFException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import resources.control.Assert;
-import resources.network.NetBufferStream;
import network.PacketType;
import network.encryption.Compression;
import network.packets.Packet;
import network.packets.swg.SWGPacket;
import network.packets.swg.zone.object_controller.ObjectController;
+import resources.network.NetBufferStream;
+
+import com.projectswg.common.debug.Assert;
public class NetworkProtocol {
diff --git a/src/services/network/OutboundNetworkManager.java b/src/services/network/OutboundNetworkManager.java
index 28947893c..93667cf33 100644
--- a/src/services/network/OutboundNetworkManager.java
+++ b/src/services/network/OutboundNetworkManager.java
@@ -29,10 +29,11 @@ package services.network;
import intents.network.OutboundPacketIntent;
import network.NetworkClient;
-import resources.control.Assert;
-import resources.control.Service;
import resources.network.TCPServer;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+
public class OutboundNetworkManager extends Service {
private final ClientManager clientManager;
diff --git a/src/services/objects/ClientBuildoutService.java b/src/services/objects/ClientBuildoutService.java
index ff01d514e..afb1c8550 100644
--- a/src/services/objects/ClientBuildoutService.java
+++ b/src/services/objects/ClientBuildoutService.java
@@ -27,6 +27,9 @@
***********************************************************************************/
package services.objects;
+import intents.object.ObjectCreatedIntent;
+import intents.player.PlayerTransformedIntent;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@@ -42,25 +45,25 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-import intents.object.ObjectCreatedIntent;
-import intents.player.PlayerTransformedIntent;
import resources.Location;
import resources.Terrain;
import resources.buildout.BuildoutArea;
import resources.buildout.BuildoutArea.BuildoutAreaBuilder;
import resources.buildout.BuildoutAreaGrid;
import resources.config.ConfigFile;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.SWGObject.ObjectClassification;
import resources.objects.building.BuildingObject;
import resources.objects.cell.CellObject;
import resources.server_info.CrcDatabase;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import resources.server_info.StandardLog;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class ClientBuildoutService extends Service {
private static final String GET_BUILDOUT_AREAS = "SELECT * FROM areas ORDER BY area_name ASC, event ASC";
@@ -85,7 +88,7 @@ public class ClientBuildoutService extends Service {
long startTime = StandardLog.onStartLoad("client objects");
try {
loadAreas(getEvents());
- if (getConfig(ConfigFile.PRIMARY).getBoolean("LOAD-OBJECTS", true))
+ if (DataManager.getConfig(ConfigFile.PRIMARY).getBoolean("LOAD-OBJECTS", true))
objects = loadObjects();
else
objects = new HashMap<>();
@@ -209,7 +212,7 @@ public class ClientBuildoutService extends Service {
private List getEvents() {
List events = new ArrayList<>();
- String eventStr = getConfig(ConfigFile.FEATURES).getString("EVENTS", "");
+ String eventStr = DataManager.getConfig(ConfigFile.FEATURES).getString("EVENTS", "");
String [] eventArray = eventStr.split(",");
for (String event : eventArray) {
event = event.toLowerCase(Locale.US);
diff --git a/src/services/objects/ObjectAwareness.java b/src/services/objects/ObjectAwareness.java
index a9f09bfd1..b9804a577 100644
--- a/src/services/objects/ObjectAwareness.java
+++ b/src/services/objects/ObjectAwareness.java
@@ -52,9 +52,6 @@ import resources.Location;
import resources.Point3D;
import resources.Terrain;
import resources.config.ConfigFile;
-import resources.control.Assert;
-import resources.control.Intent;
-import resources.control.Service;
import resources.network.DisconnectReason;
import resources.objects.SWGObject;
import resources.objects.awareness.AwarenessHandler;
@@ -64,8 +61,13 @@ import resources.objects.creature.CreatureObject;
import resources.player.Player;
import resources.player.PlayerEvent;
import resources.player.PlayerState;
+import resources.server_info.DataManager;
import resources.server_info.Log;
+import com.projectswg.common.control.Intent;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+
public class ObjectAwareness extends Service implements TerrainMapCallback {
private static final Location GONE_LOCATION = new Location(0, 0, 0, Terrain.GONE);
@@ -76,7 +78,7 @@ public class ObjectAwareness extends Service implements TerrainMapCallback {
public ObjectAwareness() {
awarenessHandler = new AwarenessHandler(this);
dataTransformHandler = new DataTransformHandler();
- dataTransformHandler.setSpeedCheck(getConfig(ConfigFile.FEATURES).getBoolean("SPEED-HACK-CHECK", true));
+ dataTransformHandler.setSpeedCheck(DataManager.getConfig(ConfigFile.FEATURES).getBoolean("SPEED-HACK-CHECK", true));
registerForIntent(PlayerEventIntent.class, pei -> handlePlayerEventIntent(pei));
registerForIntent(ObjectCreatedIntent.class, oci -> handleObjectCreatedIntent(oci));
diff --git a/src/services/objects/ObjectManager.java b/src/services/objects/ObjectManager.java
index c6cd62041..2afd812c5 100644
--- a/src/services/objects/ObjectManager.java
+++ b/src/services/objects/ObjectManager.java
@@ -27,6 +27,11 @@
***********************************************************************************/
package services.objects;
+import intents.RequestZoneInIntent;
+import intents.network.GalacticPacketIntent;
+import intents.object.DestroyObjectIntent;
+import intents.object.ObjectCreatedIntent;
+
import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.Executors;
@@ -34,15 +39,10 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import intents.object.DestroyObjectIntent;
-import intents.object.ObjectCreatedIntent;
-import intents.RequestZoneInIntent;
-import intents.network.GalacticPacketIntent;
import network.packets.Packet;
import network.packets.swg.ErrorMessage;
import network.packets.swg.zone.insertion.SelectCharacter;
import network.packets.swg.zone.object_controller.IntendedTarget;
-import resources.control.Manager;
import resources.objects.SWGObject;
import resources.objects.building.BuildingObject;
import resources.objects.cell.CellObject;
@@ -59,6 +59,8 @@ import services.player.PlayerManager;
import services.spawn.SpawnerService;
import services.spawn.StaticService;
+import com.projectswg.common.control.Manager;
+
public class ObjectManager extends Manager {
private final ObjectAwareness objectAwareness;
diff --git a/src/services/objects/RadialService.java b/src/services/objects/RadialService.java
index 46b99ab40..5a5bfac86 100644
--- a/src/services/objects/RadialService.java
+++ b/src/services/objects/RadialService.java
@@ -27,20 +27,20 @@
***********************************************************************************/
package services.objects;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import intents.network.GalacticPacketIntent;
import intents.radial.RadialRegisterIntent;
import intents.radial.RadialRequestIntent;
import intents.radial.RadialResponseIntent;
import intents.radial.RadialSelectionIntent;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import network.packets.Packet;
import network.packets.swg.zone.ObjectMenuSelect;
import network.packets.swg.zone.object_controller.ObjectMenuRequest;
import network.packets.swg.zone.object_controller.ObjectMenuResponse;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
@@ -49,6 +49,8 @@ import resources.radial.RadialOption;
import resources.server_info.Log;
import services.galaxy.GalacticManager;
+import com.projectswg.common.control.Service;
+
public class RadialService extends Service {
private final Set templatesRegistered;
diff --git a/src/services/objects/StaticItemService.java b/src/services/objects/StaticItemService.java
index a88fe40bc..6f0b700b7 100644
--- a/src/services/objects/StaticItemService.java
+++ b/src/services/objects/StaticItemService.java
@@ -27,30 +27,33 @@
***********************************************************************************/
package services.objects;
+import intents.chat.ChatBroadcastIntent;
+import intents.object.CreateStaticItemIntent;
+import intents.object.ObjectCreatedIntent;
+import intents.server.ConfigChangedIntent;
+
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
-import intents.chat.ChatBroadcastIntent;
-import intents.object.CreateStaticItemIntent;
-import intents.object.ObjectCreatedIntent;
-import intents.server.ConfigChangedIntent;
import network.packets.swg.zone.object_controller.ShowLootBox;
import resources.client_info.ClientFactory;
import resources.combat.DamageType;
import resources.config.ConfigFile;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.objects.weapon.WeaponObject;
import resources.objects.weapon.WeaponType;
import resources.player.Player;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import resources.server_info.StandardLog;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
/**
* @author mads
*/
@@ -73,7 +76,7 @@ public final class StaticItemService extends Service {
@Override
public boolean initialize() {
- boolean configEnable = getConfig(ConfigFile.FEATURES).getBoolean(CONFIG_OPTION_NAME, true);
+ boolean configEnable = DataManager.getConfig(ConfigFile.FEATURES).getBoolean(CONFIG_OPTION_NAME, true);
if (configEnable) {
if (!loadStaticItems())
diff --git a/src/services/objects/UniformBoxService.java b/src/services/objects/UniformBoxService.java
index 17b7e4cb6..fb2b00a5a 100644
--- a/src/services/objects/UniformBoxService.java
+++ b/src/services/objects/UniformBoxService.java
@@ -27,23 +27,25 @@
***********************************************************************************/
package services.objects;
+import intents.object.CreateStaticItemIntent;
+import intents.object.DestroyObjectIntent;
+import intents.radial.RadialSelectionIntent;
+
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
-import intents.object.CreateStaticItemIntent;
-import intents.object.DestroyObjectIntent;
-import intents.radial.RadialSelectionIntent;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
import resources.radial.RadialItem;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
+
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
public class UniformBoxService extends Service {
diff --git a/src/services/player/CharacterCreationService.java b/src/services/player/CharacterCreationService.java
index bc72b1594..0477ad07d 100644
--- a/src/services/player/CharacterCreationService.java
+++ b/src/services/player/CharacterCreationService.java
@@ -44,32 +44,34 @@ import network.packets.Packet;
import network.packets.swg.login.creation.ClientCreateCharacter;
import network.packets.swg.login.creation.ClientVerifyAndLockNameRequest;
import network.packets.swg.login.creation.ClientVerifyAndLockNameResponse;
+import network.packets.swg.login.creation.ClientVerifyAndLockNameResponse.ErrorMessage;
import network.packets.swg.login.creation.CreateCharacterFailure;
+import network.packets.swg.login.creation.CreateCharacterFailure.NameFailureReason;
import network.packets.swg.login.creation.CreateCharacterSuccess;
import network.packets.swg.login.creation.RandomNameRequest;
import network.packets.swg.login.creation.RandomNameResponse;
-import network.packets.swg.login.creation.ClientVerifyAndLockNameResponse.ErrorMessage;
-import network.packets.swg.login.creation.CreateCharacterFailure.NameFailureReason;
import resources.Race;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.ProfTemplateData;
import resources.config.ConfigFile;
-import resources.control.Assert;
-import resources.control.Service;
import resources.objects.creature.CreatureObject;
import resources.player.AccessLevel;
import resources.player.Player;
import resources.player.PlayerEvent;
import resources.player.PlayerState;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import resources.zone.NameFilter;
import services.objects.ObjectManager;
import services.player.TerrainZoneInsertion.SpawnInformation;
import services.player.creation.CharacterCreation;
import utilities.namegen.SWGNameGenerator;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class CharacterCreationService extends Service {
private static final String CREATE_CHARACTER_SQL = "INSERT INTO players (id, name, race, userId) VALUES (?, ?, ?, ?)";
@@ -115,7 +117,7 @@ public class CharacterCreationService extends Service {
@Override
public boolean start() {
- creationRestriction.setCreationsPerPeriod(getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS-PER-PERIOD", 2));
+ creationRestriction.setCreationsPerPeriod(DataManager.getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS-PER-PERIOD", 2));
return super.start();
}
@@ -180,7 +182,7 @@ public class CharacterCreationService extends Service {
private void handleApproveNameRequest(PlayerManager playerMgr, Player player, ClientVerifyAndLockNameRequest request) {
String name = request.getName();
ErrorMessage err = getNameValidity(name, player.getAccessLevel() != AccessLevel.PLAYER);
- int max = getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS", 0);
+ int max = DataManager.getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS", 0);
if (max != 0 && getCharacterCount(player.getUserId()) >= max)
err = ErrorMessage.SERVER_CHARACTER_CREATION_MAX_CHARS;
if (err == ErrorMessage.NAME_APPROVED_MODIFIED)
@@ -213,7 +215,7 @@ public class CharacterCreationService extends Service {
return null;
}
// Too many characters
- int max = getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS", 0);
+ int max = DataManager.getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS", 0);
if (max != 0 && getCharacterCount(player.getUserId()) >= max) {
sendCharCreationFailure(player, create, ErrorMessage.SERVER_CHARACTER_CREATION_MAX_CHARS);
return null;
@@ -325,7 +327,7 @@ public class CharacterCreationService extends Service {
}
private CreatureObject createCharacter(ObjectManager objManager, Player player, ClientCreateCharacter create) {
- String spawnLocation = getConfig(ConfigFile.PRIMARY).getString("PRIMARY-SPAWN-LOCATION", "tat_moseisley");
+ String spawnLocation = DataManager.getConfig(ConfigFile.PRIMARY).getString("PRIMARY-SPAWN-LOCATION", "tat_moseisley");
SpawnInformation info = insertion.generateSpawnLocation(spawnLocation);
if (info == null) {
Log.e("Failed to get spawn information for location: " + spawnLocation);
diff --git a/src/services/player/LoginService.java b/src/services/player/LoginService.java
index 6a66cf8e6..a3614c31f 100644
--- a/src/services/player/LoginService.java
+++ b/src/services/player/LoginService.java
@@ -46,13 +46,13 @@ import network.packets.swg.ErrorMessage;
import network.packets.swg.login.CharacterCreationDisabled;
import network.packets.swg.login.EnumerateCharacterId;
import network.packets.swg.login.EnumerateCharacterId.SWGCharacter;
-import network.packets.swg.login.creation.DeleteCharacterRequest;
-import network.packets.swg.login.creation.DeleteCharacterResponse;
import network.packets.swg.login.LoginClientId;
import network.packets.swg.login.LoginClientToken;
import network.packets.swg.login.LoginClusterStatus;
import network.packets.swg.login.LoginEnumCluster;
import network.packets.swg.login.LoginIncorrectClientId;
+import network.packets.swg.login.creation.DeleteCharacterRequest;
+import network.packets.swg.login.creation.DeleteCharacterResponse;
import network.packets.swg.zone.GameServerLagResponse;
import network.packets.swg.zone.LagRequest;
import network.packets.swg.zone.ServerNowEpochTime;
@@ -60,20 +60,22 @@ import resources.Galaxy;
import resources.Race;
import resources.common.BCrypt;
import resources.config.ConfigFile;
-import resources.control.Assert;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.creature.CreatureObject;
import resources.player.AccessLevel;
import resources.player.Player;
-import resources.player.PlayerState;
import resources.player.Player.PlayerServer;
-import resources.server_info.Config;
+import resources.player.PlayerState;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import services.CoreManager;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+import com.projectswg.common.info.Config;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class LoginService extends Service {
private static final String REQUIRED_VERSION = "20111130-15:46";
@@ -137,7 +139,7 @@ public class LoginService extends Service {
}
private String getServerString() {
- Config c = getConfig(ConfigFile.NETWORK);
+ Config c = DataManager.getConfig(ConfigFile.NETWORK);
String name = c.getString("LOGIN-SERVER-NAME", "LoginServer");
int id = c.getInt("LOGIN-SERVER-ID", 1);
return name + ":" + id;
@@ -169,7 +171,7 @@ public class LoginService extends Service {
Assert.test(player.getPlayerServer() == PlayerServer.NONE);
player.setPlayerState(PlayerState.LOGGING_IN);
player.setPlayerServer(PlayerServer.LOGIN);
- final boolean doClientCheck = getConfig(ConfigFile.NETWORK).getBoolean("LOGIN-VERSION-CHECKS", true);
+ final boolean doClientCheck = DataManager.getConfig(ConfigFile.NETWORK).getBoolean("LOGIN-VERSION-CHECKS", true);
if (!id.getVersion().equals(REQUIRED_VERSION) && doClientCheck) {
onLoginClientVersionError(player, id);
return;
@@ -259,7 +261,7 @@ public class LoginService extends Service {
cluster.addGalaxy(g);
clusterStatus.addGalaxy(g);
}
- cluster.setMaxCharacters(getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS", 2));
+ cluster.setMaxCharacters(DataManager.getConfig(ConfigFile.PRIMARY).getInt("GALAXY-MAX-CHARACTERS", 2));
player.sendPacket(new ServerNowEpochTime((int)(System.currentTimeMillis()/1E3)));
player.sendPacket(token);
player.sendPacket(cluster);
diff --git a/src/services/player/PlayerManager.java b/src/services/player/PlayerManager.java
index 9ab9c8188..f21577b2c 100644
--- a/src/services/player/PlayerManager.java
+++ b/src/services/player/PlayerManager.java
@@ -27,26 +27,28 @@
***********************************************************************************/
package services.player;
+import intents.NotifyPlayersPacketIntent;
+import intents.PlayerEventIntent;
+import intents.network.ConnectionClosedIntent;
+import intents.network.ConnectionOpenedIntent;
+
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.BiConsumer;
-import intents.NotifyPlayersPacketIntent;
-import intents.PlayerEventIntent;
-import intents.network.ConnectionClosedIntent;
-import intents.network.ConnectionOpenedIntent;
import network.packets.Packet;
import resources.Terrain;
-import resources.control.Assert;
-import resources.control.Manager;
import resources.player.Player;
import resources.player.Player.PlayerServer;
import resources.player.PlayerEvent;
import resources.player.PlayerState;
-import resources.server_info.SynchronizedMap;
import services.CoreManager;
+import com.projectswg.common.concurrency.SynchronizedMap;
+import com.projectswg.common.control.Manager;
+import com.projectswg.common.debug.Assert;
+
public class PlayerManager extends Manager {
private final Map players;
diff --git a/src/services/player/TerrainZoneInsertion.java b/src/services/player/TerrainZoneInsertion.java
index 61d9677a9..1c7241f99 100644
--- a/src/services/player/TerrainZoneInsertion.java
+++ b/src/services/player/TerrainZoneInsertion.java
@@ -33,8 +33,9 @@ import java.sql.SQLException;
import resources.Location;
import resources.Terrain;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
+
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
public class TerrainZoneInsertion {
diff --git a/src/services/player/ZoneManager.java b/src/services/player/ZoneManager.java
index e2153204c..550b380fa 100644
--- a/src/services/player/ZoneManager.java
+++ b/src/services/player/ZoneManager.java
@@ -31,6 +31,10 @@ import intents.GalacticIntent;
import intents.PlayerEventIntent;
import intents.chat.ChatBroadcastIntent;
import intents.network.GalacticPacketIntent;
+
+import java.io.File;
+import java.io.IOException;
+
import network.packets.Packet;
import network.packets.swg.login.AccountFeatureBits;
import network.packets.swg.login.ClientIdMsg;
@@ -50,18 +54,17 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import resources.config.ConfigFile;
-import resources.control.Manager;
import resources.objects.creature.CreatureMood;
import resources.objects.player.PlayerObject;
import resources.objects.waypoint.WaypointObject;
import resources.objects.waypoint.WaypointObject.WaypointColor;
import resources.player.Player;
-import resources.player.PlayerEvent;
import resources.player.Player.PlayerServer;
+import resources.player.PlayerEvent;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import java.io.File;
-import java.io.IOException;
+import com.projectswg.common.control.Manager;
public class ZoneManager extends Manager {
@@ -155,7 +158,7 @@ public class ZoneManager extends Manager {
}
private void sendMessageOfTheDay(Player player) {
- String message = getConfig(ConfigFile.FEATURES).getString("FIRST-ZONE-MESSAGE", "");
+ String message = DataManager.getConfig(ConfigFile.FEATURES).getString("FIRST-ZONE-MESSAGE", "");
if(!message.isEmpty()) // If the message isn't nothing
new ChatBroadcastIntent(player, message).broadcast(); // Send it
diff --git a/src/services/player/creation/CharacterCreation.java b/src/services/player/creation/CharacterCreation.java
index ee3de1179..b0390ff4c 100644
--- a/src/services/player/creation/CharacterCreation.java
+++ b/src/services/player/creation/CharacterCreation.java
@@ -27,17 +27,17 @@
***********************************************************************************/
package services.player.creation;
-import java.util.Calendar;
-
import intents.experience.GrantSkillIntent;
import intents.object.ObjectCreatedIntent;
+
+import java.util.Calendar;
+
import network.packets.swg.login.creation.ClientCreateCharacter;
import resources.PvpFlag;
import resources.Race;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.ProfTemplateData;
import resources.containers.ContainerPermissionsType;
-import resources.control.Assert;
import resources.objects.SWGObject;
import resources.objects.building.BuildingObject;
import resources.objects.cell.CellObject;
@@ -52,6 +52,8 @@ import services.objects.ObjectCreator;
import services.objects.ObjectManager;
import services.player.TerrainZoneInsertion.SpawnInformation;
+import com.projectswg.common.debug.Assert;
+
public class CharacterCreation {
private final ObjectManager objManager;
diff --git a/src/services/spawn/SpawnerService.java b/src/services/spawn/SpawnerService.java
index b5ca80e02..7501e094b 100644
--- a/src/services/spawn/SpawnerService.java
+++ b/src/services/spawn/SpawnerService.java
@@ -27,6 +27,10 @@
***********************************************************************************/
package services.spawn;
+import intents.object.DestroyObjectIntent;
+import intents.object.ObjectCreatedIntent;
+import intents.server.ConfigChangedIntent;
+
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
@@ -35,15 +39,11 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import intents.object.DestroyObjectIntent;
-import intents.object.ObjectCreatedIntent;
-import intents.server.ConfigChangedIntent;
import resources.Location;
import resources.PvpFlag;
import resources.Terrain;
import resources.config.ConfigFile;
import resources.containers.ContainerPermissionsType;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.building.BuildingObject;
import resources.objects.creature.CreatureDifficulty;
@@ -51,9 +51,8 @@ import resources.objects.creature.CreatureObject;
import resources.objects.custom.AIBehavior;
import resources.objects.custom.DefaultAIObject;
import resources.objects.tangible.OptionFlag;
+import resources.server_info.DataManager;
import resources.server_info.Log;
-import resources.server_info.RelationalDatabase;
-import resources.server_info.RelationalServerFactory;
import resources.server_info.StandardLog;
import resources.spawn.Spawner;
import resources.spawn.SpawnerType;
@@ -61,6 +60,10 @@ import services.objects.ObjectCreator;
import services.objects.ObjectManager;
import utilities.ThreadUtilities;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.info.RelationalDatabase;
+import com.projectswg.common.info.RelationalServerFactory;
+
public final class SpawnerService extends Service {
private static final String GET_ALL_SPAWNERS_SQL = "SELECT static.x, static.y, static.z, static.heading, " // static columns
@@ -88,7 +91,7 @@ public final class SpawnerService extends Service {
@Override
public boolean initialize() {
- if(getConfig(ConfigFile.FEATURES).getBoolean("SPAWN-EGGS-ENABLED", true))
+ if(DataManager.getConfig(ConfigFile.FEATURES).getBoolean("SPAWN-EGGS-ENABLED", true))
loadSpawners();
return super.initialize();
diff --git a/src/services/spawn/StaticService.java b/src/services/spawn/StaticService.java
index 7d0634f03..38a689f8f 100644
--- a/src/services/spawn/StaticService.java
+++ b/src/services/spawn/StaticService.java
@@ -39,15 +39,16 @@ import java.util.List;
import java.util.Map;
import resources.Location;
-import resources.control.Assert;
-import resources.control.Service;
import resources.objects.SWGObject;
import resources.objects.building.BuildingObject;
import resources.server_info.Log;
-import resources.server_info.RelationalServerData;
-import resources.server_info.RelationalServerFactory;
import services.objects.ObjectCreator;
+import com.projectswg.common.control.Service;
+import com.projectswg.common.debug.Assert;
+import com.projectswg.common.info.RelationalServerData;
+import com.projectswg.common.info.RelationalServerFactory;
+
public class StaticService extends Service {
private static final String GET_SUPPORTING_SQL = "SELECT spawns.* FROM spawns, types WHERE types.iff = ? AND spawns.iff_type = types.iff_type";
diff --git a/src/services/sui/SuiService.java b/src/services/sui/SuiService.java
index 8455869e1..24dd90730 100644
--- a/src/services/sui/SuiService.java
+++ b/src/services/sui/SuiService.java
@@ -27,6 +27,9 @@
***********************************************************************************/
package services.sui;
+import intents.network.GalacticPacketIntent;
+import intents.sui.SuiWindowIntent;
+
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,14 +37,11 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import intents.network.GalacticPacketIntent;
-import intents.sui.SuiWindowIntent;
import network.packets.Packet;
import network.packets.swg.SWGPacket;
import network.packets.swg.zone.server_ui.SuiCreatePageMessage;
import network.packets.swg.zone.server_ui.SuiEventNotification;
import network.packets.swg.zone.server_ui.SuiForceClosePage;
-import resources.control.Service;
import resources.player.Player;
import resources.server_info.Log;
import resources.sui.ISuiCallback;
@@ -50,6 +50,8 @@ import resources.sui.SuiComponent;
import resources.sui.SuiEvent;
import utilities.Scripts;
+import com.projectswg.common.control.Service;
+
public class SuiService extends Service {
private final Map> windows;
diff --git a/src/utilities/IntentChain.java b/src/utilities/IntentChain.java
deleted file mode 100644
index 9ce51de48..000000000
--- a/src/utilities/IntentChain.java
+++ /dev/null
@@ -1,61 +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 utilities;
-
-import resources.control.Intent;
-
-public class IntentChain {
-
- private final Object mutex;
- private Intent i;
-
- public IntentChain() {
- mutex = new Object();
- i = null;
- }
-
- public void reset() {
- synchronized (mutex) {
- i = null;
- }
- }
-
- public void waitUntilComplete(Intent i) {
- synchronized (mutex) {
- this.i = i;
- }
- }
-
- public void broadcastAfter(Intent i) {
- synchronized (mutex) {
- i.broadcastAfterIntent(this.i);
- this.i = i;
- }
- }
-
-}
diff --git a/src/utilities/IntentFactory.java b/src/utilities/IntentFactory.java
index 587bfe467..4ced27797 100644
--- a/src/utilities/IntentFactory.java
+++ b/src/utilities/IntentFactory.java
@@ -27,6 +27,9 @@
***********************************************************************************/
package utilities;
+import intents.chat.ChatBroadcastIntent;
+import intents.chat.ChatBroadcastIntent.BroadcastType;
+import intents.chat.PersistentMessageIntent;
import network.packets.swg.zone.chat.ChatSystemMessage;
import resources.Terrain;
import resources.encodables.OutOfBandPackage;
@@ -36,11 +39,10 @@ import resources.encodables.player.Mail;
import resources.objects.SWGObject;
import resources.objects.waypoint.WaypointObject;
import resources.player.Player;
-import intents.chat.ChatBroadcastIntent;
-import intents.chat.ChatBroadcastIntent.BroadcastType;
-import intents.chat.PersistentMessageIntent;
import resources.server_info.Log;
+import com.projectswg.common.control.IntentChain;
+
/**
* @author Mads
* This class is to be used exclusively in cases where using the intents directly isn't practical.
diff --git a/test/resources/control/TestIntentQueue.java b/test/resources/control/TestIntentQueue.java
deleted file mode 100644
index 5b23c66eb..000000000
--- a/test/resources/control/TestIntentQueue.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package resources.control;
-
-import java.util.Arrays;
-
-import intents.LoginEventIntent;
-import intents.PlayerEventIntent;
-import intents.object.ObjectCreatedIntent;
-import intents.object.ObjectTeleportIntent;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class TestIntentQueue {
-
- @Test
- public void testQueue() {
- Intent [] intents = new Intent[5];
- intents[0] = new PlayerEventIntent(null, null);
- intents[1] = new ObjectTeleportIntent(null, null);
- intents[2] = new ObjectCreatedIntent(null);
- intents[3] = new ObjectCreatedIntent(null);
- intents[4] = new LoginEventIntent(0, null);
- IntentQueue queue = new IntentQueue();
- long start = System.nanoTime();
- queue.addAll(Arrays.asList(intents));
- long end = System.nanoTime();
- System.out.println((end-start)/1E6/5 + "ms");
- int iterI = 0;
- Assert.assertEquals(queue.size(), 5);
- Assert.assertFalse(queue.isEmpty());
- for (Intent i : queue) {
- Assert.assertEquals("Failed for intent #"+iterI, intents[iterI], i);
- iterI++;
- }
- Assert.assertEquals(queue.size(), 5);
- Assert.assertFalse(queue.isEmpty());
- for (int i = 0; i < intents.length; i++) {
- Intent intent = queue.poll();
- Assert.assertEquals(5 - i - 1, queue.size());
- Assert.assertEquals("Failed for intent #"+i, intents[i], intent);
- }
- Assert.assertEquals(queue.size(), 0);
- Assert.assertTrue(queue.isEmpty());
- }
-
-}
diff --git a/test/resources/objects/awareness/TestAwareness.java b/test/resources/objects/awareness/TestAwareness.java
index ec2f01527..7470e23b9 100644
--- a/test/resources/objects/awareness/TestAwareness.java
+++ b/test/resources/objects/awareness/TestAwareness.java
@@ -32,6 +32,8 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
+import com.projectswg.common.info.RelationalServerFactory;
+
import utilities.CrcDatabaseGenerator;
@RunWith(Suite.class)
@@ -45,6 +47,7 @@ public class TestAwareness {
@BeforeClass
public static void setupCrcDatabase() {
+ RelationalServerFactory.setBasePath("serverdata/");
CrcDatabaseGenerator.generate(false);
}
diff --git a/test/resources/services/TestConfig.java b/test/resources/services/TestConfig.java
index 4ba803346..f9ba6999b 100644
--- a/test/resources/services/TestConfig.java
+++ b/test/resources/services/TestConfig.java
@@ -35,9 +35,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import resources.server_info.Config;
import resources.server_info.Log;
+import com.projectswg.common.info.Config;
+
@RunWith(JUnit4.class)
public class TestConfig {