first release

This commit is contained in:
sirjonasxx 2018-07-19 18:35:48 +02:00
parent 1685f350c9
commit dd8b4b0c35
26 changed files with 587 additions and 289 deletions

Binary file not shown.

Binary file not shown.

View File

@ -109,7 +109,7 @@ public abstract class Extension {
// nothing to be done yet
}
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.ONDOUBLECLICK) {
onDoubleClick();
onClick();
}
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.PACKETINTERCEPT) {
String stringifiedMessage = packet.readLongString();
@ -258,7 +258,7 @@ public abstract class Extension {
/**
* The application got doubleclicked from the G-Earth interface. Doing something here is optional
*/
protected void onDoubleClick(){}
protected void onClick(){}
/**
* A connection with Habbo has been started

View File

@ -38,7 +38,11 @@ public class AdminOnConnect extends Extension {
protected void onStartConnection() {
done = false;
}
@Override
protected void onClick() {
System.out.println("clicked");
}
protected String getTitle() {

View File

@ -25,13 +25,14 @@ public class SpeechColorizer extends Extension {
super(args);
}
private static final int SPEECH_ID = 1926;
private static final int SPEECH_ID = 3373;
private static final String[] COLORS = {"red", "blue", "cyan", "green", "purple"};
private static final Random r = new Random();
@Override
protected void init() {
intercept(HMessage.Side.TOSERVER, SPEECH_ID, this::onSendMessage);
System.out.println("test");
}
private void onSendMessage(HMessage message) {

View File

@ -1,13 +1,13 @@
package main.protocol.memory.habboclient.windows;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinBase;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.ptr.IntByReference;
//import com.sun.jna.Memory;
//import com.sun.jna.Native;
//import com.sun.jna.Pointer;
//import com.sun.jna.platform.win32.Kernel32;
//import com.sun.jna.platform.win32.User32;
//import com.sun.jna.platform.win32.WinBase;
//import com.sun.jna.platform.win32.WinNT;
//import com.sun.jna.ptr.IntByReference;
import main.protocol.HConnection;
import main.protocol.memory.habboclient.HabboClient;
@ -23,281 +23,289 @@ import java.util.*;
/*
* all code in this file is here for no actual purpose atm
* not functional class
*/
public class WindowsHabboClient extends HabboClient {
private static final boolean DEBUG = true;
private List<WindowsTask> possibleFlashTasks;
static Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32",Kernel32.class);
static User32 user32 = (User32) Native.loadLibrary("user32", User32.class);
public static int PROCESS_VM_READ= 0x0010;
public static int PROCESS_VM_WRITE = 0x0020;
public static int PROCESS_VM_OPERATION = 0x0008;
public WindowsHabboClient(HConnection connection) {
super(connection);
}
static class WindowsTask {
public String name;
public int PID;
public String session_name;
public int sessionNumber;
public int mem_usage;
public WindowsTask(String name, int PID, String sessions_name, int sessionNumber, int mem_usage) {
this.name = name;
this.PID = PID;
this.session_name = sessions_name;
this.sessionNumber = sessionNumber;
this.mem_usage = mem_usage;
}
@Override
public String toString() {
return "name: " + name + ", PID: " + PID + ", memory: " + mem_usage;
}
}
private static List<String> execute_command(String command) {
List<String> result = new ArrayList<>();
try {
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader=new BufferedReader( new InputStreamReader(process.getInputStream()));
String s;
while ((s = reader.readLine()) != null){
result.add(s);
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
private static List<String> splitStringExtra(String s, String regex ) {
String[] split = s.split(regex);
List<String> realSplit = new ArrayList<>();
for (String spli : split) {
if (!spli.equals("") && !spli.equals(" ")) {
realSplit.add(spli);
}
}
return realSplit;
}
private static List<WindowsTask> parseTaskList(List<String> lines) {
List<WindowsTask> windowsTasks = new ArrayList<>();
final int ARG_COUNT = 5;
boolean listHasStarted = false;
int[] paramLengths = new int[ARG_COUNT];
for (String line : lines) {
if (!listHasStarted && line.startsWith("=")) {
List<String> splitted = splitStringExtra(line, " ");
if (splitted.size() == ARG_COUNT) {
listHasStarted = true;
for (int i = 0; i < ARG_COUNT; i++) {
paramLengths[i] = splitted.get(i).length();
}
}
}
else if (listHasStarted && splitStringExtra(line, " ").size() >= 5) {
int v = 0;
String[] args = new String[ARG_COUNT];
for (int i = 0; i < ARG_COUNT; i++) {
int endindex = v + paramLengths[i];
args[i] = trim(line.substring(v, endindex));
v = endindex + 1;
}
WindowsTask task = new WindowsTask(
args[0],
Integer.parseInt(args[1]),
args[2],
Integer.parseInt(args[3]),
obtainMemorySizeFromCMDString(args[4])
);
windowsTasks.add(task);
}
}
return windowsTasks;
}
private static String trim(String s) {
int start = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ' ') start++;
else break;
}
int end = s.length();
for (int i = s.length() - 1; i >= 0; i--) {
if (s.charAt(i) == ' ') end--;
else break;
}
return s.substring(start, end);
}
private static int obtainMemorySizeFromCMDString(String s) {
s = s.replaceAll("[^0-9A-Z]","")
.replace("K","000")
.replace("M", "000000")
.replace("G", "000000000");
return Integer.parseInt(s);
}
private void obtain_PIDs() {
int headPID = -1;
String command1 = "cmd /C netstat -a -o -n | findstr "+hConnection.getClientHostAndPort()+" | findstr ESTABLISHED";
List<String> connections = execute_command(command1);
for (String s : connections) {
List<String> realSplit = splitStringExtra(s, " ");
if (realSplit.size() > 1 && realSplit.get(1).equals(hConnection.getClientHostAndPort())) {
headPID = Integer.parseInt(realSplit.get(4));
}
}
String command2 = "cmd /C tasklist";
List<String> tasks = execute_command(command2);
List<WindowsTask> taskList = parseTaskList(tasks);
WindowsTask matchWithPID = null;
int i = 0;
while (matchWithPID == null && i < taskList.size()) {
WindowsTask task = taskList.get(i);
if (task.PID == headPID) {
matchWithPID = task;
}
i++;
}
possibleFlashTasks = new ArrayList<>();
if (matchWithPID != null) {
for (WindowsTask task : taskList) {
if (task.name.equals(matchWithPID.name)) {
possibleFlashTasks.add(task);
}
}
}
}
@Override
public List<byte[]> getRC4possibilities() {
obtain_PIDs();
List<byte[]> possibilities = new ArrayList<>();
int[] count = {0};
for (int i = 0; i < possibleFlashTasks.size(); i++) {
WindowsTask task = possibleFlashTasks.get(i);
if (DEBUG) System.out.println("Potential task " + task);
new Thread(() -> {
List<byte[]> sublist = getRC4possibilities(task.PID, task.mem_usage);
synchronized (count) {
possibilities.addAll(sublist);
count[0] ++;
return null;
}
}).start();
}
while (count[0] != possibleFlashTasks.size() + 1) { // the +1 is temporary, to keep this function blocking untill it's functional
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return possibilities;
}
public List<byte[]> getRC4possibilities(int processID, int processMemorySize) {
List<byte[]> result = new ArrayList<>();
// user32.GetWindowThreadProcessId()
WinNT.HANDLE process = kernel32.OpenProcess(PROCESS_VM_READ|PROCESS_VM_OPERATION, true, processID);
IntByReference test = new IntByReference(0);
Memory output = new Memory(100000);
System.out.println(kernel32.ReadProcessMemory(process, new Pointer(0), output, 100000, test));
System.out.println(test.getValue());
int[] counter = new int[256];
int p = 0;
while (p < output.size()) {
counter[(output.getByte(p) + 256) % 256] ++;
p += 4;
}
// for (int i = 0; i < counter.length; i++) {
// System.out.println("counter " + i + " = " + counter[i]);
//
// private static final boolean DEBUG = true;
// private List<WindowsTask> possibleFlashTasks;
//
// static Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32",Kernel32.class);
// static User32 user32 = (User32) Native.loadLibrary("user32", User32.class);
//
// public static int PROCESS_VM_READ= 0x0010;
// public static int PROCESS_VM_WRITE = 0x0020;
// public static int PROCESS_VM_OPERATION = 0x0008;
//
//
// public WindowsHabboClient(HConnection connection) {
// super(connection);
// }
//
// static class WindowsTask {
// public String name;
// public int PID;
// public String session_name;
// public int sessionNumber;
// public int mem_usage;
//
// public WindowsTask(String name, int PID, String sessions_name, int sessionNumber, int mem_usage) {
// this.name = name;
// this.PID = PID;
// this.session_name = sessions_name;
// this.sessionNumber = sessionNumber;
// this.mem_usage = mem_usage;
// }
//
// @Override
// public String toString() {
// return "name: " + name + ", PID: " + PID + ", memory: " + mem_usage;
// }
// }
//
// private static List<String> execute_command(String command) {
// List<String> result = new ArrayList<>();
// try {
// Process process = Runtime.getRuntime().exec(command);
// BufferedReader reader=new BufferedReader( new InputStreamReader(process.getInputStream()));
// String s;
// while ((s = reader.readLine()) != null){
// result.add(s);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// return result;
// }
// private static List<String> splitStringExtra(String s, String regex ) {
// String[] split = s.split(regex);
//
// List<String> realSplit = new ArrayList<>();
// for (String spli : split) {
// if (!spli.equals("") && !spli.equals(" ")) {
// realSplit.add(spli);
// }
// }
//
// return realSplit;
// }
// private static List<WindowsTask> parseTaskList(List<String> lines) {
// List<WindowsTask> windowsTasks = new ArrayList<>();
//
// final int ARG_COUNT = 5;
// boolean listHasStarted = false;
// int[] paramLengths = new int[ARG_COUNT];
// for (String line : lines) {
//
// if (!listHasStarted && line.startsWith("=")) {
// List<String> splitted = splitStringExtra(line, " ");
// if (splitted.size() == ARG_COUNT) {
// listHasStarted = true;
// for (int i = 0; i < ARG_COUNT; i++) {
// paramLengths[i] = splitted.get(i).length();
// }
// }
// }
// else if (listHasStarted && splitStringExtra(line, " ").size() >= 5) {
// int v = 0;
// String[] args = new String[ARG_COUNT];
// for (int i = 0; i < ARG_COUNT; i++) {
// int endindex = v + paramLengths[i];
// args[i] = trim(line.substring(v, endindex));
// v = endindex + 1;
// }
//
// WindowsTask task = new WindowsTask(
// args[0],
// Integer.parseInt(args[1]),
// args[2],
// Integer.parseInt(args[3]),
// obtainMemorySizeFromCMDString(args[4])
// );
//
// windowsTasks.add(task);
// }
//
// }
//
// return windowsTasks;
// }
// private static String trim(String s) {
// int start = 0;
// for (int i = 0; i < s.length(); i++) {
// if (s.charAt(i) == ' ') start++;
// else break;
// }
//
// int end = s.length();
// for (int i = s.length() - 1; i >= 0; i--) {
// if (s.charAt(i) == ' ') end--;
// else break;
// }
//
// return s.substring(start, end);
// }
// private static int obtainMemorySizeFromCMDString(String s) {
// s = s.replaceAll("[^0-9A-Z]","")
// .replace("K","000")
// .replace("M", "000000")
// .replace("G", "000000000");
// return Integer.parseInt(s);
// }
//
// private void obtain_PIDs() {
// int headPID = -1;
//
//
// String command1 = "cmd /C netstat -a -o -n | findstr "+hConnection.getClientHostAndPort()+" | findstr ESTABLISHED";
// List<String> connections = execute_command(command1);
// for (String s : connections) {
// List<String> realSplit = splitStringExtra(s, " ");
//
// if (realSplit.size() > 1 && realSplit.get(1).equals(hConnection.getClientHostAndPort())) {
// headPID = Integer.parseInt(realSplit.get(4));
// }
// }
//
//
//
// String command2 = "cmd /C tasklist";
// List<String> tasks = execute_command(command2);
// List<WindowsTask> taskList = parseTaskList(tasks);
//
// WindowsTask matchWithPID = null;
// int i = 0;
// while (matchWithPID == null && i < taskList.size()) {
// WindowsTask task = taskList.get(i);
// if (task.PID == headPID) {
// matchWithPID = task;
// }
// i++;
// }
//
// possibleFlashTasks = new ArrayList<>();
// if (matchWithPID != null) {
// for (WindowsTask task : taskList) {
// if (task.name.equals(matchWithPID.name)) {
// possibleFlashTasks.add(task);
// }
// }
// }
//
//
//
// }
//
// @Override
// public List<byte[]> getRC4possibilities() {
// obtain_PIDs();
//
// List<byte[]> possibilities = new ArrayList<>();
//
// int[] count = {0};
// for (int i = 0; i < possibleFlashTasks.size(); i++) {
// WindowsTask task = possibleFlashTasks.get(i);
// if (DEBUG) System.out.println("Potential task " + task);
//
// new Thread(() -> {
// List<byte[]> sublist = getRC4possibilities(task.PID, task.mem_usage);
//
// synchronized (count) {
// possibilities.addAll(sublist);
// count[0] ++;
// }
//
// }).start();
// }
//
// while (count[0] != possibleFlashTasks.size() + 1) { // the +1 is temporary, to keep this function blocking untill it's functional
// try {
// Thread.sleep(1);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// return possibilities;
// }
//
// public List<byte[]> getRC4possibilities(int processID, int processMemorySize) {
// List<byte[]> result = new ArrayList<>();
//
//// user32.GetWindowThreadProcessId()
// WinNT.HANDLE process = kernel32.OpenProcess(PROCESS_VM_READ|PROCESS_VM_OPERATION, true, processID);
// Memory out = new Memory(processMemorySize);
// kernel32.ReadProcessMemory(process, new Pointer(0), out, processMemorySize, new IntByReference());
//
// IntByReference test = new IntByReference(0);
// Memory output = new Memory(100000);
// System.out.println(kernel32.ReadProcessMemory(process, new Pointer(0), output, 100000, test));
// System.out.println(test.getValue());
//
// int[] counter = new int[256];
// int p = 0;
// while (p < out.size()) {
// counter[((out.getByte(p)) + 256) % 256] ++;
// while (p < output.size()) {
// counter[(output.getByte(p) + 256) % 256] ++;
// p += 4;
// }
//
// HashMap<Integer, ArrayList<Integer>> mapper = new HashMap<>();
// HashSet<Integer> allvalues = new HashSet<>();
// for (int i = 0; i < counter.length; i++) {
// if (!mapper.containsKey(counter[i])) {
// mapper.put(counter[i], new ArrayList<>());
// }
// mapper.get(counter[i]).add(i);
// allvalues.add(counter[i]);
// }
//// System.out.println(allvalues.size());
// ArrayList<Integer> allvalues2 = new ArrayList<>(allvalues);
// allvalues2.sort(Integer::compareTo);
//// for (int i = 0; i < counter.length; i++) {
//// System.out.println("counter " + i + " = " + counter[i]);
//// }
//
// StringBuilder sttt = new StringBuilder();
// sttt.append("process ").append(processID).append(", ");
// for (int i = 1; i < Math.min(4, allvalues2.size()+1); i++) {
// int occ = allvalues2.get(allvalues2.size() - i);
// sttt .append(i)
// .append(": ")
// .append(mapper.get(occ).get(0))
// .append(" with ")
// .append(occ)
// .append(" occurences, ");
//// WinNT.HANDLE process = kernel32.OpenProcess(PROCESS_VM_READ|PROCESS_VM_OPERATION, true, processID);
//// Memory out = new Memory(processMemorySize);
//// kernel32.ReadProcessMemory(process, new Pointer(0), out, processMemorySize, new IntByReference());
////
//// int[] counter = new int[256];
//// int p = 0;
//// while (p < out.size()) {
//// counter[((out.getByte(p)) + 256) % 256] ++;
//// p += 4;
//// }
////
//// HashMap<Integer, ArrayList<Integer>> mapper = new HashMap<>();
//// HashSet<Integer> allvalues = new HashSet<>();
//// for (int i = 0; i < counter.length; i++) {
//// if (!mapper.containsKey(counter[i])) {
//// mapper.put(counter[i], new ArrayList<>());
//// }
//// mapper.get(counter[i]).add(i);
//// allvalues.add(counter[i]);
//// }
////// System.out.println(allvalues.size());
//// ArrayList<Integer> allvalues2 = new ArrayList<>(allvalues);
//// allvalues2.sort(Integer::compareTo);
////
//// StringBuilder sttt = new StringBuilder();
//// sttt.append("process ").append(processID).append(", ");
//// for (int i = 1; i < Math.min(4, allvalues2.size()+1); i++) {
//// int occ = allvalues2.get(allvalues2.size() - i);
//// sttt .append(i)
//// .append(": ")
//// .append(mapper.get(occ).get(0))
//// .append(" with ")
//// .append(occ)
//// .append(" occurences, ");
//// }
//// System.out.println(sttt);
//
// return result;
// }
//
// public static void main(String[] args) {
// String command2 = "cmd /C tasklist";
// List<String> tasks = execute_command(command2);
// List<WindowsTask> taskList = parseTaskList(tasks);
//
// System.out.println("t");
// }
// System.out.println(sttt);
return result;
}
public static void main(String[] args) {
String command2 = "cmd /C tasklist";
List<String> tasks = execute_command(command2);
List<WindowsTask> taskList = parseTaskList(tasks);
System.out.println("t");
}
}

View File

@ -1,4 +1,4 @@
package main.ui.scheduler.buttons;
package main.ui.buttons;
import javafx.event.EventHandler;
import javafx.scene.Cursor;

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 443 B

View File

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 460 B

View File

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 454 B

View File

Before

Width:  |  Height:  |  Size: 725 B

After

Width:  |  Height:  |  Size: 725 B

View File

Before

Width:  |  Height:  |  Size: 621 B

After

Width:  |  Height:  |  Size: 621 B

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 446 B

View File

@ -1,4 +1,4 @@
package main.ui.scheduler.buttons;
package main.ui.buttons;
public class DeleteButton extends BoxButton {

View File

@ -1,4 +1,4 @@
package main.ui.scheduler.buttons;
package main.ui.buttons;
public class EditButton extends BoxButton {

View File

@ -1,4 +1,4 @@
package main.ui.scheduler.buttons;
package main.ui.buttons;
import javafx.beans.InvalidationListener;
import javafx.event.EventHandler;

View File

@ -0,0 +1,11 @@
package main.ui.buttons;
/**
* Created by Jonas on 19/07/18.
*/
public class SimpleClickButton extends BoxButton{
public SimpleClickButton() {
super("ButtonResume.png", "ButtonResumeHover.png");
}
}

View File

@ -0,0 +1,95 @@
package main.ui.extensions;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import main.ui.buttons.SimpleClickButton;
import main.ui.scheduler.ScheduleItem;
import main.ui.buttons.DeleteButton;
import main.ui.buttons.EditButton;
import main.ui.buttons.PauseResumeButton;
/**
* Created by Jonas on 19/07/18.
*/
public class ExtensionItemContainer extends GridPane {
public static final int[] columnWidths = {22, 34, 18, 13, 11};
GEarthExtension item;
Label titleLabel;
Label descriptionLabel;
Label authorLabel;
Label versionLabel;
VBox parent;
ExtensionItemContainer(GEarthExtension item, VBox parent, ScrollPane scrollPane) {
super();
setGridLinesVisible(true);
VBox.setMargin(this, new Insets(2, -2, -2, -2));
setPrefWidth(scrollPane.getWidth());
setPrefHeight(23);
scrollPane.widthProperty().addListener(observable -> setPrefWidth(scrollPane.getWidth()));
this.parent = parent;
this.item = item;
initialize();
}
private void initialize() {
RowConstraints rowConstraints = new RowConstraints(23);
getRowConstraints().addAll(rowConstraints);
for (int i = 0; i < columnWidths.length; i++) {
ColumnConstraints columnConstraints = new ColumnConstraints(20);
columnConstraints.setPercentWidth(columnWidths[i]);
getColumnConstraints().add(columnConstraints);
}
titleLabel = initNewLabelColumn(item.getTitle());
descriptionLabel = initNewLabelColumn(item.getDescription());
authorLabel = initNewLabelColumn(item.getAuthor());
versionLabel = initNewLabelColumn(item.getVersion());
add(titleLabel, 0, 0);
add(descriptionLabel, 1, 0);
add(authorLabel, 2, 0);
add(versionLabel, 3, 0);
// getChildren().addAll(indexLabel, packetLabel, delayLabel, destinationLabel);
DeleteButton deleteButton = new DeleteButton();
deleteButton.show();
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
SimpleClickButton clickButton = new SimpleClickButton();
clickButton.show();
clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isClickTrigger());
HBox buttonsBox = new HBox(clickButton, deleteButton);
buttonsBox.setSpacing(10);
buttonsBox.setAlignment(Pos.CENTER);
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
add(buttonsBox, 4, 0);
parent.getChildren().add(this);
GridPane this2 = this;
item.onDelete(observable -> parent.getChildren().remove(this2));
}
private Label initNewLabelColumn(String text) {
Label label = new Label();
label.setFont(new Font(12));
GridPane.setMargin(label, new Insets(0, 0, 0, 5));
label.setText(text);
return label;
}
}

View File

@ -1,14 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.ui.extensions.Extensions">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="303.0" minWidth="10.0" prefWidth="277.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="288.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="227.0" minHeight="10.0" prefHeight="222.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="185.0" minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ScrollPane fx:id="scroller" hbarPolicy="NEVER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-border-color: #888888; -fx-background: #FFFFFF; -fx-border-radius: 4px;" vbarPolicy="ALWAYS">
<GridPane.margin>
<Insets bottom="8.0" left="17.0" right="17.0" top="17.0" />
</GridPane.margin>
<content>
<VBox fx:id="extensioncontainer" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<children>
<GridPane fx:id="header_ext" gridLinesVisible="true">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="163.0" minWidth="10.0" percentWidth="22.0" prefWidth="57.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="190.0" minWidth="10.0" percentWidth="34.0" prefWidth="189.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="118.0" minWidth="10.0" percentWidth="18.0" prefWidth="66.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" percentWidth="13.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" percentWidth="11.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Title" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Description" GridPane.columnIndex="1" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Author" GridPane.columnIndex="2" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Version" GridPane.columnIndex="3" />
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-text-fill: #666666; -fx-background-color: #F7F7F7;" text="Edit" GridPane.columnIndex="4" />
</children>
<VBox.margin>
<Insets bottom="-2.0" left="-2.0" right="-2.0" top="-2.0" />
</VBox.margin>
</GridPane>
</children></VBox>
</content>
</ScrollPane>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" vgap="3.0" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="349.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<GridPane.margin>
<Insets bottom="10.0" left="17.0" right="17.0" />
</GridPane.margin>
<children>
<GridPane hgap="7.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="63.0" minWidth="49.0" prefWidth="49.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="114.0" minWidth="10.0" prefWidth="101.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="257.0" minWidth="70.0" prefWidth="247.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="35.0" prefWidth="113.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="ext_port" editable="false" prefHeight="26.0" prefWidth="157.0" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="-7.0" />
</GridPane.margin>
</TextField>
<Label maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Port:" textFill="#000000bb">
<GridPane.margin>
<Insets left="3.0" />
</GridPane.margin>
</Label>
<Button fx:id="btn_install" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#installBtnClicked" text="Install" GridPane.columnIndex="3" />
</children>
</GridPane>
</children>
</GridPane>
</children>
</GridPane>

View File

@ -1,5 +1,14 @@
package main.ui.extensions;
import javafx.application.Platform;
import javafx.beans.*;
import javafx.beans.Observable;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import main.Main;
import main.protocol.*;
import main.ui.SubForm;
@ -91,6 +100,14 @@ import java.util.*;
public class Extensions extends SubForm {
public Button btn_install;
public Button btn_remove;
public TextField ext_port;
public VBox extensioncontainer;
public GridPane header_ext;
public ScrollPane scroller;
public static class OUTGOING_MESSAGES_IDS {
public static final int ONDOUBLECLICK = 1;
public static final int INFOREQUEST = 2; // backend: implemented
@ -117,7 +134,7 @@ public class Extensions extends SubForm {
private final List<GEarthExtension> gEarthExtensions = new ArrayList<>();
public void initialize() {
scroller.widthProperty().addListener(observable -> header_ext.setPrefWidth(scroller.getWidth()));
}
protected void onParentSet() {
@ -242,6 +259,15 @@ public class Extensions extends SubForm {
if (getHConnection().getState() == HConnection.State.CONNECTED) {
extension.sendMessage(new HPacket(OUTGOING_MESSAGES_IDS.CONNECTIONSTART));
}
Platform.runLater(() -> new ExtensionItemContainer(extension, extensioncontainer, scroller));
extension.onRemoveClick(observable -> {
try {
extension.getConnection().close();
} catch (IOException e) {
e.printStackTrace();
}
});
extension.onClick(observable -> extension.sendMessage(new HPacket(OUTGOING_MESSAGES_IDS.ONDOUBLECLICK)));
}
@Override
@ -252,12 +278,18 @@ public class Extensions extends SubForm {
extension.removeOnReceiveMessageListener(messageListeners.get(extension));
messageListeners.remove(extension);
Platform.runLater(extension::delete);
}
});
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Extension server registered on port: " + extensionsRegistrer.getPort());
ext_port.setText(extensionsRegistrer.getPort()+"");
// System.out.println("Extension server registered on port: " + extensionsRegistrer.getPort());
}
public void installBtnClicked(ActionEvent actionEvent) {
}
}

View File

@ -1,5 +1,6 @@
package main.ui.extensions;
import javafx.beans.InvalidationListener;
import main.protocol.HMessage;
import main.protocol.HPacket;
import main.protocol.packethandler.PayloadBuffer;
@ -179,4 +180,34 @@ public class GEarthExtension {
void act(GEarthExtension extension); // returns itself
}
private List<InvalidationListener> onRemoveClickListener = new ArrayList<>();
public void onRemoveClick(InvalidationListener listener) {
onRemoveClickListener.add(listener);
}
public void isRemoveClickTrigger() {
for (int i = onRemoveClickListener.size() - 1; i >= 0; i--) {
onRemoveClickListener.get(i).invalidated(null);
}
}
private List<InvalidationListener> onClickListener = new ArrayList<>();
public void onClick(InvalidationListener listener) {
onClickListener.add(listener);
}
public void isClickTrigger() {
for (int i = onClickListener.size() - 1; i >= 0; i--) {
onClickListener.get(i).invalidated(null);
}
}
private List<InvalidationListener> onDeleteListeners = new ArrayList<>();
public void onDelete(InvalidationListener listener) {
onDeleteListeners.add(listener);
}
public void delete() {
for (int i = onDeleteListeners.size() - 1; i >= 0; i--) {
onDeleteListeners.get(i).invalidated(null);
}
}
}

View File

@ -1,14 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.ui.info.Info">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="303.0" minWidth="10.0" prefWidth="277.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="288.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="367.0" minWidth="10.0" prefWidth="332.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="233.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextArea fx:id="text" editable="false" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<GridPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</GridPane.margin>
</TextArea>
</children>
</GridPane>

View File

@ -1,9 +1,40 @@
package main.ui.info;
import javafx.scene.control.TextArea;
import main.ui.SubForm;
/**
* Created by Jonas on 06/04/18.
*/
public class Info extends SubForm {
public TextArea text;
public void initialize() {
String[] lines = {
"G-Earth",
"Linux Habbo Packet Manipulator",
"",
"Made by:",
"sirjonasxx",
"",
"Special thanks to:",
"LittleJ",
"ArachisH",
"",
"Check out:",
"sngforum.info",
"darkbox.nl"
};
String all = lines[0];
for (int i = 1; i < lines.length; i++) {
all += (System.lineSeparator() + lines[i]);
}
text.setText(
all
);
}
}

View File

@ -1,8 +1,5 @@
package main.ui.scheduler;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
@ -10,9 +7,9 @@ import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import main.ui.scheduler.buttons.DeleteButton;
import main.ui.scheduler.buttons.EditButton;
import main.ui.scheduler.buttons.PauseResumeButton;
import main.ui.buttons.DeleteButton;
import main.ui.buttons.EditButton;
import main.ui.buttons.PauseResumeButton;
/**
* Created by Jonas on 07/04/18.