Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
stirante committed Nov 21, 2019
1 parent 9929d75 commit e235a76
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 412 deletions.
8 changes: 2 additions & 6 deletions src/main/java/com/stirante/runechanger/RuneChanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,9 @@ public void onClientDisconnected() {

private void onChampionChanged(Champion champion) {
ObservableList<RunePage> pages = FXCollections.observableArrayList();
gui.setRunes(pages, (page) -> {
new Thread(() -> runesModule.setCurrentRunePage(page)).start();
});
gui.setRunes(pages, (page) -> new Thread(() -> runesModule.setCurrentRunePage(page)).start());
log.info("Downloading runes for champion: " + champion.getName());
pages.addListener((InvalidationListener) observable -> {
gui.setRunes(pages);
});
pages.addListener((InvalidationListener) observable -> gui.setRunes(pages));
RuneStore.getRunes(champion, pages);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static void main(String[] args) throws InterruptedException {
// Every second, we take screenshot and check if it matches the specified colors. Used for actually creating the screen points.
// First, I take a screenshot of LoL client and then calculate percentage position of the point of interest.
// After that, I check what color is there, when I want it to be triggered and then replace the values below, to check whether it triggers correctly
//noinspection InfiniteLoopStatement
while (true) {
BufferedImage screenshot = GDI32Util.getScreenshot(hwnd);
float x = 0.1234375f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
import com.jfoenix.controls.JFXAlert;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialogLayout;
import com.stirante.runechanger.util.LangHelper;
import javafx.animation.FadeTransition;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.util.Duration;

import java.util.concurrent.atomic.AtomicBoolean;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/stirante/runechanger/gui/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

public class Settings extends Application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,9 @@ public String toSerializedString() {
runepageList.add(mainStyle);
runepageList.add(subStyle);

runes.forEach(rune -> {
runepageList.add(rune.getId());
});
runes.forEach(rune -> runepageList.add(rune.getId()));

modifiers.forEach(modifier -> {
runepageList.add(modifier.getId());
});
modifiers.forEach(modifier -> runepageList.add(modifier.getId()));

return runepageList.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public class Version {
InputStream stream = Version.class.getResourceAsStream("/version.json");
//Add our own date deserializer, which will return current date in case of parsing error
//It's added, so it won't crash when running from IDE
JsonDeserializer<Date> dateDeserializer = new JsonDeserializer<Date>() {
JsonDeserializer<Date> dateDeserializer = new JsonDeserializer<>() {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

@Override
public Date deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context)
throws JsonParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.stirante.runechanger.model.client.RunePage;
import javafx.collections.ObservableList;

import java.util.List;

public interface RuneSource {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static void getRemoteRunes(Champion champion, ObservableList<RunePage> pa
}
}

@SuppressWarnings("unchecked")
public static <T extends RuneSource> T getSource(Class<T> clz) {
for (RuneSource source : sources) {
if (clz.isAssignableFrom(source.getClass())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.stirante.runechanger.model.client.*;
import com.stirante.runechanger.util.FxUtils;
import com.stirante.runechanger.util.StringUtils;
import generated.Position;
import javafx.collections.ObservableList;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static Configuration getConfiguration() throws IOException {
private static void extractFile(ZipInputStream in, File outdir, String name) throws IOException {
byte[] buffer = new byte[BUFFER_SIZE];
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(outdir, name)));
int count = -1;
int count;
while ((count = in.read(buffer)) != -1) {
out.write(buffer, 0, count);
}
Expand Down
Loading

0 comments on commit e235a76

Please sign in to comment.