rename stuff and add stuff

This commit is contained in:
sirjonasxx 2020-04-24 23:16:02 +02:00
parent 007bffbc69
commit 530abc3139
30 changed files with 126 additions and 134 deletions

View File

@ -27,7 +27,7 @@ public class AdminOnConnect extends Extension {
private boolean done = true; private boolean done = true;
protected void initExtension() { protected void initExtension() {
intercept(HMessage.Side.TOCLIENT, message -> { intercept(HMessage.Direction.TOCLIENT, message -> {
if (!done) { if (!done) {
HPacket packet = message.getPacket(); HPacket packet = message.getPacket();
if (packet.length() == 11) { if (packet.length() == 11) {
@ -42,7 +42,7 @@ public class AdminOnConnect extends Extension {
} }
}); });
intercept(HMessage.Side.TOSERVER, 4000, message -> done = false); intercept(HMessage.Direction.TOSERVER, 4000, message -> done = false);
} }
// protected void onStartConnection() { // protected void onStartConnection() {

View File

@ -7,8 +7,6 @@ import gearth.protocol.HMessage;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
import gearth.ui.GEarthController; import gearth.ui.GEarthController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
@ -180,8 +178,8 @@ public class BlockAndReplacePackets extends ExtensionForm {
} }
}; };
intercept(HMessage.Side.TOSERVER, messageListener); intercept(HMessage.Direction.TOSERVER, messageListener);
intercept(HMessage.Side.TOCLIENT, messageListener); intercept(HMessage.Direction.TOCLIENT, messageListener);
} }
@Override @Override

View File

@ -1,7 +1,6 @@
package extensions.blockreplacepackets.rules; package extensions.blockreplacepackets.rules;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.HPacket;
/** /**
* Created by Jonas on 6/11/2018. * Created by Jonas on 6/11/2018.
@ -19,8 +18,8 @@ public class BlockPacketRule extends BlockReplaceRule{
@Override @Override
public void appendRuleToMessage(HMessage message) { public void appendRuleToMessage(HMessage message) {
if (side == Side.ALL if (side == Side.ALL
|| (message.getDestination() == HMessage.Side.TOSERVER && side == Side.OUTGOING) || (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|| (message.getDestination() == HMessage.Side.TOCLIENT && side ==Side.INCOMING)) { || (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
if (message.getPacket().headerId() == headerId) { if (message.getPacket().headerId() == headerId) {
message.setBlocked(true); message.setBlocked(true);
} }

View File

@ -20,8 +20,8 @@ public class ReplaceIntegerRule extends BlockReplaceRule {
@Override @Override
public void appendRuleToMessage(HMessage message) { public void appendRuleToMessage(HMessage message) {
if (side == Side.ALL if (side == Side.ALL
|| (message.getDestination() == HMessage.Side.TOSERVER && side == Side.OUTGOING) || (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|| (message.getDestination() == HMessage.Side.TOCLIENT && side ==Side.INCOMING)) { || (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
message.getPacket().replaceAllIntegers(value, replacement); message.getPacket().replaceAllIntegers(value, replacement);
} }
} }

View File

@ -21,8 +21,8 @@ public class ReplacePacketRule extends BlockReplaceRule {
@Override @Override
public void appendRuleToMessage(HMessage message) { public void appendRuleToMessage(HMessage message) {
if (side == Side.ALL if (side == Side.ALL
|| (message.getDestination() == HMessage.Side.TOSERVER && side == Side.OUTGOING) || (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|| (message.getDestination() == HMessage.Side.TOCLIENT && side ==Side.INCOMING)) { || (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
if (message.getPacket().headerId() == headerId) { if (message.getPacket().headerId() == headerId) {
message.getPacket().constructFromString(replacement.stringify()); message.getPacket().constructFromString(replacement.stringify());
message.getPacket().overrideEditedField(true); message.getPacket().overrideEditedField(true);

View File

@ -20,8 +20,8 @@ public class ReplaceStringRule extends BlockReplaceRule {
@Override @Override
public void appendRuleToMessage(HMessage message) { public void appendRuleToMessage(HMessage message) {
if (side == Side.ALL if (side == Side.ALL
|| (message.getDestination() == HMessage.Side.TOSERVER && side == Side.OUTGOING) || (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|| (message.getDestination() == HMessage.Side.TOCLIENT && side ==Side.INCOMING)) { || (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
message.getPacket().replaceAllStrings(value, replacement); message.getPacket().replaceAllStrings(value, replacement);
} }
} }

View File

@ -20,8 +20,8 @@ public class ReplaceSubstringRule extends BlockReplaceRule {
@Override @Override
public void appendRuleToMessage(HMessage message) { public void appendRuleToMessage(HMessage message) {
if (side == Side.ALL if (side == Side.ALL
|| (message.getDestination() == HMessage.Side.TOSERVER && side == Side.OUTGOING) || (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|| (message.getDestination() == HMessage.Side.TOCLIENT && side ==Side.INCOMING)) { || (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
message.getPacket().replaceAllSubstrings(value, replacement); message.getPacket().replaceAllSubstrings(value, replacement);
} }
} }

View File

@ -172,7 +172,7 @@ public abstract class Extension implements IExtension{
HPacket habboPacket = habboMessage.getPacket(); HPacket habboPacket = habboMessage.getPacket();
Map<Integer, List<MessageListener>> listeners = Map<Integer, List<MessageListener>> listeners =
habboMessage.getDestination() == HMessage.Side.TOCLIENT ? habboMessage.getDestination() == HMessage.Direction.TOCLIENT ?
incomingMessageListeners : incomingMessageListeners :
outgoingMessageListeners; outgoingMessageListeners;
@ -235,7 +235,7 @@ public abstract class Extension implements IExtension{
* @return success or failure * @return success or failure
*/ */
public boolean sendToClient(HPacket packet) { public boolean sendToClient(HPacket packet) {
return send(packet, HMessage.Side.TOCLIENT); return send(packet, HMessage.Direction.TOCLIENT);
} }
/** /**
@ -244,11 +244,11 @@ public abstract class Extension implements IExtension{
* @return success or failure * @return success or failure
*/ */
public boolean sendToServer(HPacket packet) { public boolean sendToServer(HPacket packet) {
return send(packet, HMessage.Side.TOSERVER); return send(packet, HMessage.Direction.TOSERVER);
} }
private boolean send(HPacket packet, HMessage.Side side) { private boolean send(HPacket packet, HMessage.Direction direction) {
HPacket packet1 = new HPacket(Extensions.INCOMING_MESSAGES_IDS.SENDMESSAGE); HPacket packet1 = new HPacket(Extensions.INCOMING_MESSAGES_IDS.SENDMESSAGE);
packet1.appendByte(side == HMessage.Side.TOCLIENT ? (byte)0 : (byte)1); packet1.appendByte(direction == HMessage.Direction.TOCLIENT ? (byte)0 : (byte)1);
packet1.appendInt(packet.getBytesLength()); packet1.appendInt(packet.getBytesLength());
packet1.appendBytes(packet.toBytes()); packet1.appendBytes(packet.toBytes());
try { try {
@ -261,13 +261,13 @@ public abstract class Extension implements IExtension{
/** /**
* Register a listener on a specific packet Type * Register a listener on a specific packet Type
* @param side ToClient or ToServer * @param direction ToClient or ToServer
* @param headerId the packet header ID * @param headerId the packet header ID
* @param messageListener the callback * @param messageListener the callback
*/ */
public void intercept(HMessage.Side side, int headerId, MessageListener messageListener) { public void intercept(HMessage.Direction direction, int headerId, MessageListener messageListener) {
Map<Integer, List<MessageListener>> listeners = Map<Integer, List<MessageListener>> listeners =
side == HMessage.Side.TOCLIENT ? direction == HMessage.Direction.TOCLIENT ?
incomingMessageListeners : incomingMessageListeners :
outgoingMessageListeners; outgoingMessageListeners;
@ -283,11 +283,11 @@ public abstract class Extension implements IExtension{
/** /**
* Register a listener on all packets * Register a listener on all packets
* @param side ToClient or ToServer * @param direction ToClient or ToServer
* @param messageListener the callback * @param messageListener the callback
*/ */
public void intercept(HMessage.Side side, MessageListener messageListener) { public void intercept(HMessage.Direction direction, MessageListener messageListener) {
intercept(side, -1, messageListener); intercept(direction, -1, messageListener);
} }
/** /**

View File

@ -1,13 +1,10 @@
package gearth.extensions; package gearth.extensions;
import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.stage.Stage; import javafx.stage.Stage;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
import java.util.concurrent.Semaphore;
/** /**
* Created by Jonas on 22/09/18. * Created by Jonas on 22/09/18.
*/ */
@ -31,11 +28,11 @@ public abstract class ExtensionForm implements IExtension{
public void writeToConsole(String s) { public void writeToConsole(String s) {
extension.writeToConsole(s); extension.writeToConsole(s);
} }
public void intercept(HMessage.Side side, Extension.MessageListener messageListener) { public void intercept(HMessage.Direction direction, Extension.MessageListener messageListener) {
extension.intercept(side, messageListener); extension.intercept(direction, messageListener);
} }
public void intercept(HMessage.Side side, int headerId, Extension.MessageListener messageListener){ public void intercept(HMessage.Direction direction, int headerId, Extension.MessageListener messageListener){
extension.intercept(side, headerId, messageListener); extension.intercept(direction, headerId, messageListener);
} }
public boolean sendToServer(HPacket packet){ public boolean sendToServer(HPacket packet){
return extension.sendToServer(packet); return extension.sendToServer(packet);

View File

@ -10,8 +10,8 @@ public interface IExtension {
boolean sendToClient(HPacket packet); boolean sendToClient(HPacket packet);
boolean sendToServer(HPacket packet); boolean sendToServer(HPacket packet);
void intercept(HMessage.Side side, int headerId, Extension.MessageListener messageListener); void intercept(HMessage.Direction direction, int headerId, Extension.MessageListener messageListener);
void intercept(HMessage.Side side, Extension.MessageListener messageListener); void intercept(HMessage.Direction direction, Extension.MessageListener messageListener);
boolean requestFlags(Extension.FlagsCheckListener flagRequestCallback); boolean requestFlags(Extension.FlagsCheckListener flagRequestCallback);
void writeToConsole(String s); // not implemented in g-earth yet void writeToConsole(String s); // not implemented in g-earth yet
void onConnect(Extension.OnConnectionListener listener); void onConnect(Extension.OnConnectionListener listener);

View File

@ -45,7 +45,7 @@ public class ChatConsole {
extension.onConnect((s, i, s1, h1) -> doOncePerConnection[0] = true); extension.onConnect((s, i, s1, h1) -> doOncePerConnection[0] = true);
extension.intercept(HMessage.Side.TOSERVER, hMessage -> { extension.intercept(HMessage.Direction.TOSERVER, hMessage -> {
// if the first packet on init is not 4000, the extension was already running, so we open the chat instantly // if the first packet on init is not 4000, the extension was already running, so we open the chat instantly
if (firstTime) { if (firstTime) {
firstTime = false; firstTime = false;
@ -56,7 +56,7 @@ public class ChatConsole {
} }
}); });
hashSupport.intercept(HMessage.Side.TOCLIENT, "Friends", hMessage -> { hashSupport.intercept(HMessage.Direction.TOCLIENT, "Friends", hMessage -> {
if (doOncePerConnection[0]) { if (doOncePerConnection[0]) {
doOncePerConnection[0] = false; doOncePerConnection[0] = false;
@ -72,7 +72,7 @@ public class ChatConsole {
} }
}); });
hashSupport.intercept(HMessage.Side.TOSERVER, "FriendPrivateMessage", hMessage -> { hashSupport.intercept(HMessage.Direction.TOSERVER, "FriendPrivateMessage", hMessage -> {
HPacket packet = hMessage.getPacket(); HPacket packet = hMessage.getPacket();
if (packet.readInteger() == chatid) { if (packet.readInteger() == chatid) {
hMessage.setBlocked(true); hMessage.setBlocked(true);

View File

@ -1,15 +1,11 @@
package gearth.extensions.extra.harble; package gearth.extensions.extra.harble;
import gearth.Main;
import gearth.extensions.Extension; import gearth.extensions.Extension;
import gearth.extensions.IExtension; import gearth.extensions.IExtension;
import gearth.misc.harble_api.HarbleAPI; import gearth.misc.harble_api.HarbleAPI;
import gearth.misc.harble_api.HarbleAPIFetcher;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
import java.io.File;
import java.net.URISyntaxException;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -38,9 +34,9 @@ public class HashSupport {
// } // }
}); });
extension.intercept(HMessage.Side.TOSERVER, message -> { extension.intercept(HMessage.Direction.TOSERVER, message -> {
// synchronized (lock) { // synchronized (lock) {
HarbleAPI.HarbleMessage haMessage = harbleAPI.getHarbleMessageFromHeaderId(HMessage.Side.TOSERVER, message.getPacket().headerId()); HarbleAPI.HarbleMessage haMessage = harbleAPI.getHarbleMessageFromHeaderId(HMessage.Direction.TOSERVER, message.getPacket().headerId());
if (haMessage != null) { if (haMessage != null) {
List<Extension.MessageListener> listeners_hash = outgoingMessageListeners.get(haMessage.getHash()); List<Extension.MessageListener> listeners_hash = outgoingMessageListeners.get(haMessage.getHash());
List<Extension.MessageListener> listeners_name = outgoingMessageListeners.get(haMessage.getName()); List<Extension.MessageListener> listeners_name = outgoingMessageListeners.get(haMessage.getName());
@ -59,9 +55,9 @@ public class HashSupport {
} }
// } // }
}); });
extension.intercept(HMessage.Side.TOCLIENT, message -> { extension.intercept(HMessage.Direction.TOCLIENT, message -> {
// synchronized (lock) { // synchronized (lock) {
HarbleAPI.HarbleMessage haMessage = harbleAPI.getHarbleMessageFromHeaderId(HMessage.Side.TOCLIENT, message.getPacket().headerId()); HarbleAPI.HarbleMessage haMessage = harbleAPI.getHarbleMessageFromHeaderId(HMessage.Direction.TOCLIENT, message.getPacket().headerId());
if (haMessage != null) { if (haMessage != null) {
List<Extension.MessageListener> listeners_hash = incomingMessageListeners.get(haMessage.getHash()); List<Extension.MessageListener> listeners_hash = incomingMessageListeners.get(haMessage.getHash());
List<Extension.MessageListener> listeners_name = incomingMessageListeners.get(haMessage.getName()); List<Extension.MessageListener> listeners_name = incomingMessageListeners.get(haMessage.getName());
@ -82,9 +78,9 @@ public class HashSupport {
}); });
} }
public void intercept(HMessage.Side side, String hashOrName, Extension.MessageListener messageListener) { public void intercept(HMessage.Direction direction, String hashOrName, Extension.MessageListener messageListener) {
Map<String, List<Extension.MessageListener>> messageListeners = Map<String, List<Extension.MessageListener>> messageListeners =
(side == HMessage.Side.TOSERVER (direction == HMessage.Direction.TOSERVER
? outgoingMessageListeners ? outgoingMessageListeners
: incomingMessageListeners); : incomingMessageListeners);
@ -92,14 +88,14 @@ public class HashSupport {
messageListeners.get(hashOrName).add(messageListener); messageListeners.get(hashOrName).add(messageListener);
} }
private boolean send(HMessage.Side side, String hashOrName, Object... objects) { private boolean send(HMessage.Direction direction, String hashOrName, Object... objects) {
int headerId; int headerId;
HarbleAPI.HarbleMessage fromname = harbleAPI.getHarbleMessageFromName(side, hashOrName); HarbleAPI.HarbleMessage fromname = harbleAPI.getHarbleMessageFromName(direction, hashOrName);
if (fromname != null) { if (fromname != null) {
headerId = fromname.getHeaderId(); headerId = fromname.getHeaderId();
} }
else { else {
List<HarbleAPI.HarbleMessage> possibilities = harbleAPI.getHarbleMessagesFromHash(side, hashOrName); List<HarbleAPI.HarbleMessage> possibilities = harbleAPI.getHarbleMessagesFromHash(direction, hashOrName);
if (possibilities.size() == 0) return false; if (possibilities.size() == 0) return false;
headerId = possibilities.get(0).getHeaderId(); headerId = possibilities.get(0).getHeaderId();
} }
@ -107,7 +103,7 @@ public class HashSupport {
try { try {
HPacket packetToSend = new HPacket(headerId, objects); HPacket packetToSend = new HPacket(headerId, objects);
return (side == HMessage.Side.TOCLIENT return (direction == HMessage.Direction.TOCLIENT
? extension.sendToClient(packetToSend) ? extension.sendToClient(packetToSend)
: extension.sendToServer(packetToSend)); : extension.sendToServer(packetToSend));
} }
@ -121,7 +117,7 @@ public class HashSupport {
* @return if no errors occurred (invalid hash/invalid parameters/connection error) * @return if no errors occurred (invalid hash/invalid parameters/connection error)
*/ */
public boolean sendToClient(String hashOrName, Object... objects) { public boolean sendToClient(String hashOrName, Object... objects) {
return send(HMessage.Side.TOCLIENT, hashOrName, objects); return send(HMessage.Direction.TOCLIENT, hashOrName, objects);
} }
/** /**
@ -129,7 +125,7 @@ public class HashSupport {
* @return if no errors occurred (invalid hash/invalid parameters/connection error) * @return if no errors occurred (invalid hash/invalid parameters/connection error)
*/ */
public boolean sendToServer(String hashOrName, Object... objects) { public boolean sendToServer(String hashOrName, Object... objects) {
return send(HMessage.Side.TOSERVER, hashOrName, objects); return send(HMessage.Direction.TOSERVER, hashOrName, objects);
} }
} }

View File

@ -19,14 +19,14 @@ import java.util.Map;
public class HarbleAPI { public class HarbleAPI {
public class HarbleMessage { public class HarbleMessage {
private HMessage.Side destination; private HMessage.Direction destination;
private int headerId; private int headerId;
private String hash; private String hash;
private String name; private String name;
private String structure; private String structure;
//name can be NULL //name can be NULL
public HarbleMessage(HMessage.Side destination, int headerId, String hash, String name, String structure) { public HarbleMessage(HMessage.Direction destination, int headerId, String hash, String name, String structure) {
this.destination = destination; this.destination = destination;
this.headerId = headerId; this.headerId = headerId;
this.hash = hash; this.hash = hash;
@ -42,7 +42,7 @@ public class HarbleAPI {
return headerId; return headerId;
} }
public HMessage.Side getDestination() { public HMessage.Direction getDestination() {
return destination; return destination;
} }
@ -116,7 +116,7 @@ public class HarbleAPI {
} }
} }
private void addMessage(HMessage.Side side, JSONObject object) { private void addMessage(HMessage.Direction direction, JSONObject object) {
String name; String name;
try { try {
name = object.getString("Name"); name = object.getString("Name");
@ -134,21 +134,21 @@ public class HarbleAPI {
} }
HarbleMessage message = new HarbleMessage(side, headerId, hash, name, structure); HarbleMessage message = new HarbleMessage(direction, headerId, hash, name, structure);
Map<Integer, HarbleMessage> headerIdToMessage = Map<Integer, HarbleMessage> headerIdToMessage =
message.getDestination() == HMessage.Side.TOCLIENT message.getDestination() == HMessage.Direction.TOCLIENT
? headerIdToMessage_incoming : ? headerIdToMessage_incoming :
headerIdToMessage_outgoing; headerIdToMessage_outgoing;
Map<String, List<HarbleMessage>> hashToMessage = Map<String, List<HarbleMessage>> hashToMessage =
message.getDestination() == HMessage.Side.TOCLIENT message.getDestination() == HMessage.Direction.TOCLIENT
? hashToMessage_incoming ? hashToMessage_incoming
: hashToMessage_outgoing; : hashToMessage_outgoing;
Map<String, HarbleMessage> nameToMessag = Map<String, HarbleMessage> nameToMessag =
message.getDestination() == HMessage.Side.TOCLIENT message.getDestination() == HMessage.Direction.TOCLIENT
? nameToMessage_incoming ? nameToMessage_incoming
: nameToMessage_outgoing; : nameToMessage_outgoing;
@ -169,7 +169,7 @@ public class HarbleAPI {
for (int i = 0; i < incoming.length(); i++) { for (int i = 0; i < incoming.length(); i++) {
try { try {
JSONObject message = incoming.getJSONObject(i); JSONObject message = incoming.getJSONObject(i);
addMessage(HMessage.Side.TOCLIENT, message); addMessage(HMessage.Direction.TOCLIENT, message);
} }
catch (Exception e){ catch (Exception e){
e.printStackTrace(); e.printStackTrace();
@ -178,7 +178,7 @@ public class HarbleAPI {
for (int i = 0; i < outgoing.length(); i++) { for (int i = 0; i < outgoing.length(); i++) {
try{ try{
JSONObject message = outgoing.getJSONObject(i); JSONObject message = outgoing.getJSONObject(i);
addMessage(HMessage.Side.TOSERVER, message); addMessage(HMessage.Direction.TOSERVER, message);
} }
catch (Exception e){ catch (Exception e){
e.printStackTrace(); e.printStackTrace();
@ -190,18 +190,18 @@ public class HarbleAPI {
} }
} }
public HarbleMessage getHarbleMessageFromHeaderId(HMessage.Side side, int headerId) { public HarbleMessage getHarbleMessageFromHeaderId(HMessage.Direction direction, int headerId) {
Map<Integer, HarbleMessage> headerIdToMessage = Map<Integer, HarbleMessage> headerIdToMessage =
(side == HMessage.Side.TOSERVER (direction == HMessage.Direction.TOSERVER
? headerIdToMessage_outgoing ? headerIdToMessage_outgoing
: headerIdToMessage_incoming); : headerIdToMessage_incoming);
return headerIdToMessage.get(headerId); return headerIdToMessage.get(headerId);
} }
public List<HarbleMessage> getHarbleMessagesFromHash(HMessage.Side side, String hash) { public List<HarbleMessage> getHarbleMessagesFromHash(HMessage.Direction direction, String hash) {
Map<String, List<HarbleMessage>> hashToMessage = Map<String, List<HarbleMessage>> hashToMessage =
(side == HMessage.Side.TOSERVER (direction == HMessage.Direction.TOSERVER
? hashToMessage_outgoing ? hashToMessage_outgoing
: hashToMessage_incoming); : hashToMessage_incoming);
@ -209,9 +209,9 @@ public class HarbleAPI {
return result == null ? new ArrayList<>() : result; return result == null ? new ArrayList<>() : result;
} }
public HarbleMessage getHarbleMessageFromName(HMessage.Side side, String name) { public HarbleMessage getHarbleMessageFromName(HMessage.Direction direction, String name) {
Map<String, HarbleMessage> nameToMessage = Map<String, HarbleMessage> nameToMessage =
(side == HMessage.Side.TOSERVER (direction == HMessage.Direction.TOSERVER
? nameToMessage_outgoing ? nameToMessage_outgoing
: nameToMessage_incoming); : nameToMessage_incoming);

View File

@ -2,10 +2,8 @@ package gearth.misc.harble_api;
import gearth.misc.Cacher; import gearth.misc.Cacher;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import org.json.JSONObject;
import org.jsoup.Connection; import org.jsoup.Connection;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException; import java.io.IOException;
@ -66,7 +64,7 @@ public class HarbleAPIFetcher {
fetch("PRODUCTION-201901141210-114421986"); fetch("PRODUCTION-201901141210-114421986");
HarbleAPI api = HARBLEAPI; HarbleAPI api = HARBLEAPI;
HarbleAPI.HarbleMessage haMessage = api.getHarbleMessageFromHeaderId(HMessage.Side.TOSERVER, 525); HarbleAPI.HarbleMessage haMessage = api.getHarbleMessageFromHeaderId(HMessage.Direction.TOSERVER, 525);
System.out.println(haMessage); System.out.println(haMessage);
} }
} }

View File

@ -258,7 +258,7 @@ public class HConnection {
if (state == State.PREPARED) { if (state == State.PREPARED) {
setState(State.WAITING_FOR_CLIENT); setState(State.WAITING_FOR_CLIENT);
if (!hostRedirected) { if (!hostRedirected && !connectionInfoOverrider.mustOverrideConnection()) {
addToHosts(); addToHosts();
} }
@ -271,7 +271,7 @@ public class HConnection {
new Thread(() -> { new Thread(() -> {
try { try {
Thread.sleep(100); Thread.sleep(30);
while ((state == State.WAITING_FOR_CLIENT) && !proxy_server.isClosed()) { while ((state == State.WAITING_FOR_CLIENT) && !proxy_server.isClosed()) {
try { try {
Socket client = proxy_server.accept(); Socket client = proxy_server.accept();
@ -413,14 +413,14 @@ public class HConnection {
} }
} }
private void onConnect() { private void onConnect() {
if (hostRedirected) { if (hostRedirected && !connectionInfoOverrider.mustOverrideConnection()) {
removeFromHosts(); removeFromHosts();
} }
clearAllProxies(); clearAllProxies();
} }
public void abort() { public void abort() {
if (hostRedirected) { if (hostRedirected && !connectionInfoOverrider.mustOverrideConnection()) {
removeFromHosts(); removeFromHosts();
} }
@ -520,11 +520,11 @@ public class HConnection {
stateChangeListeners.remove(listener); stateChangeListeners.remove(listener);
} }
public int getPort() { public int getServerPort() {
if (actual_proxy == null) return -1; if (actual_proxy == null) return -1;
return actual_proxy.getIntercept_port(); return actual_proxy.getIntercept_port();
} }
public String getHost() { public String getServerHost() {
if (actual_proxy == null) return "<auto-detect>"; if (actual_proxy == null) return "<auto-detect>";
return actual_proxy.getActual_domain(); return actual_proxy.getActual_domain();
} }
@ -557,11 +557,18 @@ public class HConnection {
} }
} }
public String getClientHostAndPort() { public String getClientHost() {
if (actual_proxy == null || actual_proxy.getIntercept_host() == null || actual_proxy.getIntercept_port() == -1) { if (actual_proxy == null) {
return ""; return "";
} }
return actual_proxy.getIntercept_host() + ":" + actual_proxy.getIntercept_port(); return actual_proxy.getIntercept_host();
}
public int getClientPort() {
if (actual_proxy == null) {
return -1;
}
return actual_proxy.getIntercept_port();
} }
public String getHotelVersion() { public String getHotelVersion() {

View File

@ -4,13 +4,13 @@ import gearth.misc.StringifyAble;
public class HMessage implements StringifyAble { public class HMessage implements StringifyAble {
public enum Side { public enum Direction {
TOSERVER, TOSERVER,
TOCLIENT TOCLIENT
} }
private HPacket hPacket; private HPacket hPacket;
private Side side; private Direction direction;
private int index; private int index;
private boolean isBlocked; private boolean isBlocked;
@ -23,8 +23,8 @@ public class HMessage implements StringifyAble {
constructFromHMessage(message); constructFromHMessage(message);
} }
public HMessage(HPacket packet, Side side, int index) { public HMessage(HPacket packet, Direction direction, int index) {
this.side = side; this.direction = direction;
this.hPacket = packet; this.hPacket = packet;
this.index = index; this.index = index;
isBlocked = false; isBlocked = false;
@ -44,8 +44,8 @@ public class HMessage implements StringifyAble {
public HPacket getPacket() { public HPacket getPacket() {
return hPacket; return hPacket;
} }
public Side getDestination() { public Direction getDestination() {
return side; return direction;
} }
public boolean isCorrupted() { public boolean isCorrupted() {
@ -55,7 +55,7 @@ public class HMessage implements StringifyAble {
@Override @Override
public String stringify() { public String stringify() {
String s = (isBlocked ? "1" : "0") + "\t" + index + "\t" + side.name() + "\t" + hPacket.stringify(); String s = (isBlocked ? "1" : "0") + "\t" + index + "\t" + direction.name() + "\t" + hPacket.stringify();
return s; return s;
} }
@ -64,7 +64,7 @@ public class HMessage implements StringifyAble {
String[] parts = str.split("\t", 4); String[] parts = str.split("\t", 4);
this.isBlocked = parts[0].equals("1"); this.isBlocked = parts[0].equals("1");
this.index = Integer.parseInt(parts[1]); this.index = Integer.parseInt(parts[1]);
this.side = parts[2].equals("TOCLIENT") ? Side.TOCLIENT : Side.TOSERVER; this.direction = parts[2].equals("TOCLIENT") ? Direction.TOCLIENT : Direction.TOSERVER;
HPacket p = new HPacket(new byte[0]); HPacket p = new HPacket(new byte[0]);
p.constructFromString(parts[3]); p.constructFromString(parts[3]);
this.hPacket = p; this.hPacket = p;
@ -73,7 +73,7 @@ public class HMessage implements StringifyAble {
public void constructFromHMessage(HMessage message) { public void constructFromHMessage(HMessage message) {
this.isBlocked = message.isBlocked(); this.isBlocked = message.isBlocked();
this.index = message.getIndex(); this.index = message.getIndex();
this.side = message.getDestination(); this.direction = message.getDestination();
this.hPacket = new HPacket(message.getPacket()); this.hPacket = new HPacket(message.getPacket());
} }
@ -83,7 +83,7 @@ public class HMessage implements StringifyAble {
HMessage message = (HMessage) obj; HMessage message = (HMessage) obj;
return message.hPacket.equals(hPacket) && (side == message.side) && (index == message.index); return message.hPacket.equals(hPacket) && (direction == message.direction) && (index == message.index);
} }
// public static void gearth(String[] args) { // public static void gearth(String[] args) {

View File

@ -719,12 +719,12 @@ public class HPacket implements StringifyAble {
} }
} }
public String toExpression(HMessage.Side side) { public String toExpression(HMessage.Direction direction) {
if (isCorrupted()) return ""; if (isCorrupted()) return "";
HarbleAPI.HarbleMessage msg; HarbleAPI.HarbleMessage msg;
if (HarbleAPIFetcher.HARBLEAPI != null && if (HarbleAPIFetcher.HARBLEAPI != null &&
((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(side, headerId())) != null)) { ((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(direction, headerId())) != null)) {
if (msg.getStructure() != null) { if (msg.getStructure() != null) {
return toExpressionFromGivenStructure(msg.getStructure()); return toExpressionFromGivenStructure(msg.getStructure());
} }

View File

@ -19,7 +19,6 @@ import javafx.scene.web.WebView;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
public class Rc4Obtainer { public class Rc4Obtainer {
@ -119,7 +118,7 @@ public class Rc4Obtainer {
byte[] keycpy = Arrays.copyOf(possible, possible.length); byte[] keycpy = Arrays.copyOf(possible, possible.length);
RC4 rc4Tryout = new RC4(keycpy, i, j); RC4 rc4Tryout = new RC4(keycpy, i, j);
if (packetHandler.getMessageSide() == HMessage.Side.TOSERVER) rc4Tryout.undoRc4(encBuffer); if (packetHandler.getMessageSide() == HMessage.Direction.TOSERVER) rc4Tryout.undoRc4(encBuffer);
if (rc4Tryout.couldBeFresh()) { if (rc4Tryout.couldBeFresh()) {
byte[] encDataCopy = Arrays.copyOf(encBuffer, encBuffer.length); byte[] encDataCopy = Arrays.copyOf(encBuffer, encBuffer.length);
RC4 rc4TryCopy = rc4Tryout.deepCopy(); RC4 rc4TryCopy = rc4Tryout.deepCopy();

View File

@ -23,7 +23,7 @@ public class MacOsHabboClient extends HabboClient {
super(connection); super(connection);
connection.addTrafficListener(0, message -> { connection.addTrafficListener(0, message -> {
if (message.getDestination() == HMessage.Side.TOSERVER && message.getPacket().headerId() == PRODUCTION_ID) { if (message.getDestination() == HMessage.Direction.TOSERVER && message.getPacket().headerId() == PRODUCTION_ID) {
production = message.getPacket().readString(); production = message.getPacket().readString();
} }
}); });
@ -81,9 +81,9 @@ public class MacOsHabboClient extends HabboClient {
String g_mem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "/G-Mem"; String g_mem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "/G-Mem";
if (!useCache) if (!useCache)
pb = new ProcessBuilder(g_mem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort())); pb = new ProcessBuilder(g_mem, hConnection.getClientHost() , Integer.toString(hConnection.getClientPort()));
else else
pb = new ProcessBuilder(g_mem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort()), "-c" + joiner.toString()); pb = new ProcessBuilder(g_mem, hConnection.getClientHost() , Integer.toString(hConnection.getClientPort()), "-c" + joiner.toString());
Process p = pb.start(); Process p = pb.start();

View File

@ -26,7 +26,7 @@ public class RustHabboClient extends HabboClient {
try { try {
String g_mem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "/G-Mem"; String g_mem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "/G-Mem";
ProcessBuilder pb = new ProcessBuilder(g_mem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort())); ProcessBuilder pb = new ProcessBuilder(g_mem, hConnection.getClientHost() , Integer.toString(hConnection.getClientPort()));
Process p = pb.start(); Process p = pb.start();

View File

@ -23,7 +23,7 @@ public class WindowsHabboClient extends HabboClient {
super(connection); super(connection);
connection.addTrafficListener(0, message -> { connection.addTrafficListener(0, message -> {
if (message.getDestination() == HMessage.Side.TOSERVER && message.getPacket().headerId() == PRODUCTION_ID) { if (message.getDestination() == HMessage.Direction.TOSERVER && message.getPacket().headerId() == PRODUCTION_ID) {
production = message.getPacket().readString(); production = message.getPacket().readString();
} }
}); });
@ -81,9 +81,9 @@ public class WindowsHabboClient extends HabboClient {
String g_winmem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "\\G-Mem.exe"; String g_winmem = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParent() + "\\G-Mem.exe";
if (!useCache) if (!useCache)
pb = new ProcessBuilder(g_winmem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort())); pb = new ProcessBuilder(g_winmem, hConnection.getClientHost() , Integer.toString(hConnection.getClientPort()));
else else
pb = new ProcessBuilder(g_winmem, hConnection.getClientHostAndPort().substring(0, hConnection.getClientHostAndPort().indexOf(':')) , Integer.toString(hConnection.getPort()), "-c" + joiner.toString()); pb = new ProcessBuilder(g_winmem, hConnection.getClientHost() , Integer.toString(hConnection.getClientPort()), "-c" + joiner.toString());
Process p = pb.start(); Process p = pb.start();

View File

@ -42,8 +42,8 @@ public class IncomingPacketHandler extends PacketHandler {
} }
@Override @Override
public HMessage.Side getMessageSide() { public HMessage.Direction getMessageSide() {
return HMessage.Side.TOCLIENT; return HMessage.Direction.TOCLIENT;
} }
@Override @Override

View File

@ -52,8 +52,8 @@ public class OutgoingPacketHandler extends PacketHandler {
} }
@Override @Override
public HMessage.Side getMessageSide() { public HMessage.Direction getMessageSide() {
return HMessage.Side.TOSERVER; return HMessage.Direction.TOSERVER;
} }

View File

@ -156,7 +156,7 @@ public abstract class PacketHandler {
} }
} }
public abstract HMessage.Side getMessageSide(); public abstract HMessage.Direction getMessageSide();
public List<Byte> getEncryptedBuffer() { public List<Byte> getEncryptedBuffer() {
return tempEncryptedBuffer; return tempEncryptedBuffer;

View File

@ -91,7 +91,7 @@ public class Connection extends SubForm {
if (newState == HConnection.State.CONNECTED) { if (newState == HConnection.State.CONNECTED) {
lblState.setText("Connected"); lblState.setText("Connected");
outHost.setText(getHConnection().getDomain()); outHost.setText(getHConnection().getDomain());
outPort.setText(getHConnection().getPort()+""); outPort.setText(getHConnection().getServerPort()+"");
} }
if (newState == HConnection.State.WAITING_FOR_CLIENT) { if (newState == HConnection.State.WAITING_FOR_CLIENT) {
lblState.setText("Waiting for connection"); lblState.setText("Waiting for connection");

View File

@ -156,7 +156,7 @@ public class Extensions extends SubForm {
extension.sendMessage( extension.sendMessage(
new HPacket(OUTGOING_MESSAGES_IDS.CONNECTIONSTART) new HPacket(OUTGOING_MESSAGES_IDS.CONNECTIONSTART)
.appendString(getHConnection().getDomain()) .appendString(getHConnection().getDomain())
.appendInt(getHConnection().getPort()) .appendInt(getHConnection().getServerPort())
.appendString(getHConnection().getHotelVersion()) .appendString(getHConnection().getHotelVersion())
.appendString(HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath()) .appendString(HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath())
); );
@ -293,7 +293,7 @@ public class Extensions extends SubForm {
extension.sendMessage( extension.sendMessage(
new HPacket(OUTGOING_MESSAGES_IDS.CONNECTIONSTART) new HPacket(OUTGOING_MESSAGES_IDS.CONNECTIONSTART)
.appendString(getHConnection().getDomain()) .appendString(getHConnection().getDomain())
.appendInt(getHConnection().getPort()) .appendInt(getHConnection().getServerPort())
.appendString(getHConnection().getHotelVersion()) .appendString(getHConnection().getHotelVersion())
.appendString(HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath()) .appendString(HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath())
); );

View File

@ -37,10 +37,10 @@ public class Logger extends SubForm {
public void onParentSet(){ public void onParentSet(){
getHConnection().addStateChangeListener((oldState, newState) -> Platform.runLater(() -> { getHConnection().addStateChangeListener((oldState, newState) -> Platform.runLater(() -> {
if (newState == HConnection.State.PREPARING) { if (newState == HConnection.State.PREPARING) {
miniLogText(Color.ORANGE, "Connecting to "+getHConnection().getDomain() + ":" + getHConnection().getPort()); miniLogText(Color.ORANGE, "Connecting to "+getHConnection().getDomain() + ":" + getHConnection().getServerPort());
} }
if (newState == HConnection.State.CONNECTED) { if (newState == HConnection.State.CONNECTED) {
miniLogText(Color.GREEN, "Connected to "+getHConnection().getDomain() + ":" + getHConnection().getPort()); miniLogText(Color.GREEN, "Connected to "+getHConnection().getDomain() + ":" + getHConnection().getServerPort());
packetLogger.start(); packetLogger.start();
} }
if (newState == HConnection.State.NOT_CONNECTED) { if (newState == HConnection.State.NOT_CONNECTED) {
@ -50,16 +50,16 @@ public class Logger extends SubForm {
})); }));
getHConnection().addTrafficListener(2, message -> { Platform.runLater(() -> { getHConnection().addTrafficListener(2, message -> { Platform.runLater(() -> {
if (message.getDestination() == HMessage.Side.TOCLIENT && cbx_blockIn.isSelected() || if (message.getDestination() == HMessage.Direction.TOCLIENT && cbx_blockIn.isSelected() ||
message.getDestination() == HMessage.Side.TOSERVER && cbx_blockOut.isSelected()) return; message.getDestination() == HMessage.Direction.TOSERVER && cbx_blockOut.isSelected()) return;
if (cbx_splitPackets.isSelected()) { if (cbx_splitPackets.isSelected()) {
packetLogger.appendSplitLine(); packetLogger.appendSplitLine();
} }
int types = 0; int types = 0;
if (message.getDestination() == HMessage.Side.TOCLIENT) types |= PacketLogger.MESSAGE_TYPE.INCOMING.getValue(); if (message.getDestination() == HMessage.Direction.TOCLIENT) types |= PacketLogger.MESSAGE_TYPE.INCOMING.getValue();
else if (message.getDestination() == HMessage.Side.TOSERVER) types |= PacketLogger.MESSAGE_TYPE.OUTGOING.getValue(); else if (message.getDestination() == HMessage.Direction.TOSERVER) types |= PacketLogger.MESSAGE_TYPE.OUTGOING.getValue();
if (message.getPacket().length() >= packetLimit) types |= PacketLogger.MESSAGE_TYPE.SKIPPED.getValue(); if (message.getPacket().length() >= packetLimit) types |= PacketLogger.MESSAGE_TYPE.SKIPPED.getValue();
if (message.isBlocked()) types |= PacketLogger.MESSAGE_TYPE.BLOCKED.getValue(); if (message.isBlocked()) types |= PacketLogger.MESSAGE_TYPE.BLOCKED.getValue();
if (message.getPacket().isReplaced()) types |= PacketLogger.MESSAGE_TYPE.REPLACED.getValue(); if (message.getPacket().isReplaced()) types |= PacketLogger.MESSAGE_TYPE.REPLACED.getValue();

View File

@ -95,13 +95,13 @@ public class UiLoggerController implements Initializable {
ArrayList<Element> elements = new ArrayList<>(); ArrayList<Element> elements = new ArrayList<>();
String expr = packet.toExpression(isIncoming ? HMessage.Side.TOCLIENT : HMessage.Side.TOSERVER); String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
lblHarbleAPI.setText("HarbleAPI: " + (HarbleAPIFetcher.HARBLEAPI == null ? "False" : "True")); lblHarbleAPI.setText("HarbleAPI: " + (HarbleAPIFetcher.HARBLEAPI == null ? "False" : "True"));
if ((viewMessageName || viewMessageHash) && HarbleAPIFetcher.HARBLEAPI != null) { if ((viewMessageName || viewMessageHash) && HarbleAPIFetcher.HARBLEAPI != null) {
HarbleAPI api = HarbleAPIFetcher.HARBLEAPI; HarbleAPI api = HarbleAPIFetcher.HARBLEAPI;
HarbleAPI.HarbleMessage message = api.getHarbleMessageFromHeaderId( HarbleAPI.HarbleMessage message = api.getHarbleMessageFromHeaderId(
(isIncoming ? HMessage.Side.TOCLIENT : HMessage.Side.TOSERVER), (isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
packet.headerId() packet.headerId()
); );

View File

@ -1,7 +1,6 @@
package gearth.ui.scheduler; package gearth.ui.scheduler;
import javafx.beans.InvalidationListener; import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
@ -21,13 +20,13 @@ public class ScheduleItem implements StringifyAble {
private SimpleBooleanProperty pausedProperty = null; private SimpleBooleanProperty pausedProperty = null;
private SimpleObjectProperty<Interval> delayProperty = null; private SimpleObjectProperty<Interval> delayProperty = null;
private SimpleObjectProperty<HPacket> packetProperty = null; private SimpleObjectProperty<HPacket> packetProperty = null;
private SimpleObjectProperty<HMessage.Side> destinationProperty = null; private SimpleObjectProperty<HMessage.Direction> destinationProperty = null;
ScheduleItem (int index, boolean paused, Interval delay, HPacket packet, HMessage.Side destination) { ScheduleItem (int index, boolean paused, Interval delay, HPacket packet, HMessage.Direction destination) {
construct(index, paused, delay, packet, destination); construct(index, paused, delay, packet, destination);
} }
private void construct(int index, boolean paused, Interval delay, HPacket packet, HMessage.Side destination) { private void construct(int index, boolean paused, Interval delay, HPacket packet, HMessage.Direction destination) {
this.indexProperty = new SimpleIntegerProperty(index); this.indexProperty = new SimpleIntegerProperty(index);
this.pausedProperty = new SimpleBooleanProperty(paused); this.pausedProperty = new SimpleBooleanProperty(paused);
this.delayProperty = new SimpleObjectProperty<>(delay); this.delayProperty = new SimpleObjectProperty<>(delay);
@ -55,7 +54,7 @@ public class ScheduleItem implements StringifyAble {
return packetProperty; return packetProperty;
} }
public SimpleObjectProperty<HMessage.Side> getDestinationProperty() { public SimpleObjectProperty<HMessage.Direction> getDestinationProperty() {
return destinationProperty; return destinationProperty;
} }
@ -123,9 +122,9 @@ public class ScheduleItem implements StringifyAble {
boolean paused = parts[1].equals("true"); boolean paused = parts[1].equals("true");
Interval delay = new Interval(parts[2]); Interval delay = new Interval(parts[2]);
HPacket packet = new HPacket(parts[3]); HPacket packet = new HPacket(parts[3]);
HMessage.Side side = parts[4].equals(HMessage.Side.TOSERVER.name()) ? HMessage.Side.TOSERVER : HMessage.Side.TOCLIENT; HMessage.Direction direction = parts[4].equals(HMessage.Direction.TOSERVER.name()) ? HMessage.Direction.TOSERVER : HMessage.Direction.TOCLIENT;
construct(index, paused, delay, packet, side); construct(index, paused, delay, packet, direction);
} }
} }

View File

@ -12,7 +12,6 @@ import gearth.protocol.HPacket;
import gearth.ui.SubForm; import gearth.ui.SubForm;
import javax.swing.*; import javax.swing.*;
import java.awt.event.KeyEvent;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -86,7 +85,7 @@ public class Scheduler extends SubForm {
Interval cur = item.getDelayProperty().get(); Interval cur = item.getDelayProperty().get();
for (int i = 0; i < changed; i++) { for (int i = 0; i < changed; i++) {
if ((t - i) % cur.getDelay() == cur.getOffset()) { if ((t - i) % cur.getDelay() == cur.getOffset()) {
if (item.getDestinationProperty().get() == HMessage.Side.TOSERVER) { if (item.getDestinationProperty().get() == HMessage.Direction.TOSERVER) {
getHConnection().sendToServerAsync(item.getPacketProperty().get()); getHConnection().sendToServerAsync(item.getPacketProperty().get());
} }
else { else {
@ -153,7 +152,7 @@ public class Scheduler extends SubForm {
false, false,
new Interval(txt_delay.getText()), new Interval(txt_delay.getText()),
new HPacket(txt_packet.getText()), new HPacket(txt_packet.getText()),
rb_incoming.isSelected() ? HMessage.Side.TOCLIENT : HMessage.Side.TOSERVER); rb_incoming.isSelected() ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
addItem(newItem); addItem(newItem);
} }
@ -161,7 +160,7 @@ public class Scheduler extends SubForm {
isBeingEdited.getPacketProperty().set(new HPacket(txt_packet.getText())); isBeingEdited.getPacketProperty().set(new HPacket(txt_packet.getText()));
isBeingEdited.getDelayProperty().set(new Interval(txt_delay.getText())); isBeingEdited.getDelayProperty().set(new Interval(txt_delay.getText()));
isBeingEdited.getDestinationProperty().set(rb_incoming.isSelected() ? HMessage.Side.TOCLIENT : HMessage.Side.TOSERVER); isBeingEdited.getDestinationProperty().set(rb_incoming.isSelected() ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
isBeingEdited.isUpdatedTrigger(); isBeingEdited.isUpdatedTrigger();
isBeingEdited = null; isBeingEdited = null;
@ -193,8 +192,8 @@ public class Scheduler extends SubForm {
if (isBeingEdited != newItem) { if (isBeingEdited != newItem) {
txt_packet.setText(newItem.getPacketProperty().get().toString()); txt_packet.setText(newItem.getPacketProperty().get().toString());
txt_delay.setText(newItem.getDelayProperty().get().toString()); txt_delay.setText(newItem.getDelayProperty().get().toString());
rb_incoming.setSelected(newItem.getDestinationProperty().get() == HMessage.Side.TOCLIENT); rb_incoming.setSelected(newItem.getDestinationProperty().get() == HMessage.Direction.TOCLIENT);
rb_outgoing.setSelected(newItem.getDestinationProperty().get() == HMessage.Side.TOSERVER); rb_outgoing.setSelected(newItem.getDestinationProperty().get() == HMessage.Direction.TOSERVER);
isBeingEdited = newItem; isBeingEdited = newItem;
btn_addoredit.setText("Edit schedule item"); //Add to scheduler btn_addoredit.setText("Edit schedule item"); //Add to scheduler