Skip to content

Commit

Permalink
Merge pull request #552 from Wolfsblvt/develop
Browse files Browse the repository at this point in the history
Merge for release v0.1.7
  • Loading branch information
Wolfsblvt authored Feb 23, 2017
2 parents 07d11bf + 0e7a7a1 commit b9a1673
Show file tree
Hide file tree
Showing 27 changed files with 781 additions and 369 deletions.
4 changes: 2 additions & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@
<property name="max" value="20"/>
<!-- Default classes are also listed-->
<property name="excludedClasses"
value="boolean, byte, char, double, float, int, long, short, void, Boolean, Byte, Character, Double, Float, Integer, Long, Short, Void, Object, Class, String, StringBuffer, StringBuilder, ArrayIndexOutOfBoundsException, Exception, RuntimeException, IllegalArgumentException, IllegalStateException, IndexOutOfBoundsException, NullPointerException, Throwable, SecurityException, UnsupportedOperationException, List, ArrayList, Deque, Queue, LinkedList, Set, HashSet, SortedSet, TreeSet, Map, HashMap, SortedMap, TreeMap, DetailsAST, CheckstyleException, UnsupportedEncodingException, BuildException, ConversionException, FileNotFoundException, TestException, Log, Sets, Multimap, TokenStreamRecognitionException, RecognitionException, TokenStreamException, IOException"/>
value="boolean, byte, char, double, float, int, long, short, void, Boolean, Byte, Character, Double, Float, Integer, Long, Short, Void, Object, Class, String, StringBuffer, StringBuilder, ArrayIndexOutOfBoundsException, Exception, RuntimeException, IllegalArgumentException, IllegalStateException, IndexOutOfBoundsException, NullPointerException, Throwable, SecurityException, UnsupportedOperationException, List, ArrayList, Deque, Queue, LinkedList, Set, HashSet, SortedSet, TreeSet, Map, HashMap, SortedMap, TreeMap, DetailsAST, CheckstyleException, UnsupportedEncodingException, BuildException, ConversionException, FileNotFoundException, TestException, Log, Sets, Multimap, TokenStreamRecognitionException, RecognitionException, TokenStreamException, IOException, AsyncPokemonGoException"/>
</module>
<module name="ClassFanOutComplexity">
<property name="severity" value="warning"/>
<property name="max" value="25"/>
<!-- Default classes are also listed-->
<property name="excludedClasses"
value="boolean, byte, char, double, float, int, long, short, void, Boolean, Byte, Character, Double, Float, Integer, Long, Short, Void, Object, Class, String, StringBuffer, StringBuilder, ArrayIndexOutOfBoundsException, Exception, RuntimeException, IllegalArgumentException, IllegalStateException, IndexOutOfBoundsException, NullPointerException, Throwable, SecurityException, UnsupportedOperationException, List, ArrayList, Deque, Queue, LinkedList, Set, HashSet, SortedSet, TreeSet, Map, HashMap, SortedMap, TreeMap, DetailsAST, CheckstyleException, UnsupportedEncodingException, BuildException, ConversionException, FileNotFoundException, TestException, Log, Sets, Multimap, TokenStreamRecognitionException, RecognitionException, TokenStreamException, IOException"/>
value="boolean, byte, char, double, float, int, long, short, void, Boolean, Byte, Character, Double, Float, Integer, Long, Short, Void, Object, Class, String, StringBuffer, StringBuilder, ArrayIndexOutOfBoundsException, Exception, RuntimeException, IllegalArgumentException, IllegalStateException, IndexOutOfBoundsException, NullPointerException, Throwable, SecurityException, UnsupportedOperationException, List, ArrayList, Deque, Queue, LinkedList, Set, HashSet, SortedSet, TreeSet, Map, HashMap, SortedMap, TreeMap, DetailsAST, CheckstyleException, UnsupportedEncodingException, BuildException, ConversionException, FileNotFoundException, TestException, Log, Sets, Multimap, TokenStreamRecognitionException, RecognitionException, TokenStreamException, IOException, AsyncPokemonGoException"/>
</module>
<module name="CyclomaticComplexity">
<property name="severity" value="info"/>
Expand Down
21 changes: 7 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>PokeGoBot</groupId>
<artifactId>PokeGoBot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>BPGM</groupId>
<artifactId>BPGM</artifactId>
<version>0.1.7-beta572-3</version>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
Expand Down Expand Up @@ -67,6 +67,8 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.name}_v${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
Expand Down Expand Up @@ -99,20 +101,11 @@
</repository>
</repositories>
<dependencies>
<!--<dependency>-->
<!--<groupId>com.pokegoapi</groupId>-->
<!--<artifactId>PokeGOAPI-library</artifactId>-->
<!--<version>0.4.1</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.github.Grover-c13</groupId>
<groupId>com.github.gegy1000</groupId>
<artifactId>PokeGOAPI-Java</artifactId>
<version>7317a049fe3cbb38e219e0056c21b29505133db4</version>
<version>fb759f0b51461d0e047ecf04bb33b12829b3e8fe</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.github.Wolfsblvt</groupId> -->
<!-- <artifactId>PokeGOAPI-Java</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.6
v0.2.0-develop
64 changes: 34 additions & 30 deletions src/me/corriekay/pokegoutil/BlossomsPoGoManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import javafx.stage.Stage;
import me.corriekay.pokegoutil.data.managers.AccountController;
import me.corriekay.pokegoutil.data.managers.GlobalSettingsController;
import me.corriekay.pokegoutil.gui.controller.ChooseGuiWindowController;
Expand All @@ -15,13 +16,10 @@
import me.corriekay.pokegoutil.utils.helpers.UIHelper;
import me.corriekay.pokegoutil.utils.windows.WindowStuffHelper;

import javafx.application.Application;
import javafx.stage.Stage;

/**
* The main project class. Contains the runtime stuff.
*/
public class BlossomsPoGoManager extends Application {
public class BlossomsPoGoManager {

private static Stage sPrimaryStage;

Expand All @@ -32,7 +30,8 @@ public class BlossomsPoGoManager extends Application {
*/
public static void main(final String[] args) {
GlobalSettingsController.setup();
launch(args);
// launch(args);
new BlossomsPoGoManager().start(null);
}

/**
Expand All @@ -56,7 +55,11 @@ public static void setNewPrimaryStage(final Stage stage) {
sPrimaryStage = stage;
}

@Override
// @Override
/**
* Legacy start method from JavaFX nature.
* @param primaryStage Received when have JavaFX nature
*/
public void start(final Stage primaryStage) {
setupGlobalExceptionHandling();

Expand All @@ -82,36 +85,37 @@ private static void setupGlobalExceptionHandling() {
result.add(current.getClass().getSimpleName() + StringLiterals.COLON_SEPARATOR + current.getLocalizedMessage());
current = current.getCause();
}

final String[] options = new String[] {"Continue anyway", "Exit"};
final int continueChoice = JOptionPane.showOptionDialog(
WindowStuffHelper.ALWAYS_ON_TOP_PARENT,
String.join(StringLiterals.NEWLINE, result)
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "Application got a critical error."
+ StringLiterals.NEWLINE + "You can report the error on GitHub or Discord."
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "It is possible to continue here, but do note that the application might not work as expected."
+ StringLiterals.NEWLINE + "Close and restart if that's the case.",
"General Unhandled Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, options, options[0]);
if (continueChoice == 1) {
// If exit is chosen, we exit here.
System.exit(-1);
}
SwingUtilities.invokeLater(() -> {
final String[] options = new String[] {"Continue anyway", "Exit"};
final int continueChoice = JOptionPane.showOptionDialog(
WindowStuffHelper.ALWAYS_ON_TOP_PARENT,
String.join(StringLiterals.NEWLINE, result)
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "Application got a critical error."
+ StringLiterals.NEWLINE + "You can report the error on GitHub or Discord."
+ StringLiterals.NEWLINE
+ StringLiterals.NEWLINE + "It is possible to continue here, but do note that the application might not work as expected."
+ StringLiterals.NEWLINE + "Close and restart if that's the case.",
"General Unhandled Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, options, options[0]);
if (continueChoice == 1) {
// If exit is chosen, we exit here.
System.exit(-1);
}
});
});
}

/**
* Opens the old GUI.
*/
private void openOldGui() {
SwingUtilities.invokeLater(() -> {
UIHelper.setNativeLookAndFeel();
AccountController.initialize();
AccountController.logOn();
});
// SwingUtilities.invokeLater(() -> {
UIHelper.setNativeLookAndFeel();
AccountController.initialize();
AccountController.logOn();
// });
}
}
10 changes: 10 additions & 0 deletions src/me/corriekay/pokegoutil/data/enums/ColumnType.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public enum ColumnType {
Comparators.DOUBLE,
CellRendererHelper.PERCENTAGE
),
DPS1VALUE(
Double.class,
Comparators.DOUBLE,
CellRendererHelper.DPS1VALUE
),
DPS2VALUE(
Double.class,
Comparators.DOUBLE,
CellRendererHelper.DPS2VALUE
),
STRING(
String.class,
Comparators.STRING
Expand Down
100 changes: 88 additions & 12 deletions src/me/corriekay/pokegoutil/data/enums/PokeColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
import com.pokegoapi.api.pokemon.Pokemon;
import com.pokegoapi.exceptions.NoSuchItemException;
import com.pokegoapi.google.common.geometry.S2CellId;
import com.pokegoapi.main.PokemonMeta;

import POGOProtos.Enums.PokemonIdOuterClass;
import POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove;
import POGOProtos.Enums.PokemonTypeOuterClass.PokemonType;
import POGOProtos.Settings.Master.MoveSettingsOuterClass.MoveSettings;
import me.corriekay.pokegoutil.utils.AutoIncrementer;
import me.corriekay.pokegoutil.utils.ConfigKey;
import me.corriekay.pokegoutil.utils.ConfigNew;
Expand All @@ -28,6 +32,8 @@

/**
* A class that holds data relevant for each column.
* Cleka 19.2.2017: renamed "name" to "heading",
* otherwise .name returns something different than .name()!
*/
public enum PokeColumn {
AUTO_INCREMENT("Row", ColumnType.AUTO_INCREMENT) {
Expand Down Expand Up @@ -93,13 +99,13 @@ public Object get(final Pokemon p) {
TYPE_1("Type 1", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return PokemonUtils.formatType(p.getMeta().getType1());
return PokemonUtils.formatType(p.getSettings().getType());
}
},
TYPE_2("Type 2", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return PokemonUtils.formatType(p.getMeta().getType2());
return PokemonUtils.formatType(p.getSettings().getType2());
}
},
MOVE_1("Move 1", ColumnType.STRING) {
Expand All @@ -116,6 +122,34 @@ public Object get(final Pokemon p) {
+ PokemonUtils.formatDps(PokemonCalculationUtils.dpsForMove(p, false));
}
},
DPS_1("DPS 1", ColumnType.DPS1VALUE) {
@Override
public Object get(final Pokemon p) {
return Math.round(10.0 * PokemonCalculationUtils.dpsForMove(p, true)) / 10.0;
}
},
DPS_2("DPS 2", ColumnType.DPS2VALUE) {
@Override
public Object get(final Pokemon p) {
return Math.round(10.0 * PokemonCalculationUtils.dpsForMove(p, false)) / 10.0;
}
},
MOVETYPE_1("Movetype 1", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
final PokemonMove move = p.getMove1();
PokemonType type = PokemonMeta.getMoveSettings(move).getPokemonType();
return PokemonUtils.formatType(type);
}
},
MOVETYPE_2("Movetype 2", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
final PokemonMove move = p.getMove2();
PokemonType type = PokemonMeta.getMoveSettings(move).getPokemonType();
return PokemonUtils.formatType(type);
}
},
HP("HP", ColumnType.INT) {
@Override
public Object get(final Pokemon p) {
Expand All @@ -125,7 +159,7 @@ public Object get(final Pokemon p) {
EVOLVABLE_COUNT("Evolvable", ColumnType.NULLABLE_INT) {
@Override
public Object get(final Pokemon p) {
if (p.getCandiesToEvolve() != 0) {
if (p.getCandiesToEvolve() > 1) {
final int candies = p.getCandy();
final int candiesToEvolve = p.getCandiesToEvolve();

Expand Down Expand Up @@ -240,7 +274,13 @@ public Object get(final Pokemon p) {
FAVORITE("Favorite", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return (p.isFavorite()) ? "Yes" : "";
return (p.isFavorite()) ? YES : "";
}
},
GYM("Gym", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return (p.isDeployed()) ? YES : "";
}
},
DUEL_ABILITY_RATING("Duel Ability Rating", ColumnType.PERCENTAGE) {
Expand Down Expand Up @@ -313,15 +353,35 @@ public Object get(final Pokemon p) {
return LocationHelper.getLocation(cell).thenApply(location -> location.formattedLocation);
}
},
COSTUME("Costume", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return p.getPokemonDisplay() != null ? p.getPokemonDisplay().getCostume().toString() : "";
}
},
GENDER("Gender", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return p.getPokemonDisplay() != null ? p.getPokemonDisplay().getGender().toString() : "";
}
},
SHINY("Shiny", ColumnType.STRING) {
@Override
public Object get(final Pokemon p) {
return p.getPokemonDisplay() != null ? (p.getPokemonDisplay().getShiny() ? YES : "")
: "";
}
},
PID("PID", ColumnType.LONG) {
@Override
public Object get(final Pokemon p) {
return p.getId();
}
};

private static final String YES = "Yes";
public final int id;
public final String name;
public final String heading;
public final ColumnType columnType;
public final ArrayList data;

Expand All @@ -330,30 +390,30 @@ public Object get(final Pokemon p) {
/**
* Constructor to create the enum entries.
*
* @param name The name of the column.
* @param heading The name of the column.
* @param columnType The type of the column.
*/
PokeColumn(final String name, final ColumnType columnType) {
PokeColumn(final String heading, final ColumnType columnType) {
this.id = Internal.AUTO_INCREMENTER.get();
this.name = name;
this.heading = heading;
this.columnType = columnType;
this.data = CollectionHelper.provideArrayList(columnType.clazz);
}

/**
* Constructor to create an enum entry with a custom cell renderer.
*
* @param name The name of the column.
* @param heading The name of the column.
* @param columnType The type of the column.
* @param customCellRenderer The custom cell renderer.
*/
PokeColumn(final String name, final ColumnType columnType, final TableCellRenderer customCellRenderer) {
this(name, columnType);
PokeColumn(final String heading, final ColumnType columnType, final TableCellRenderer customCellRenderer) {
this(heading, columnType);
this.customCellRenderer = customCellRenderer;
}

/**
* Gets the column for given id.
* Gets the PokeColumn enum for given id.
*
* @param id The id.
* @return The column.
Expand All @@ -368,6 +428,22 @@ public static PokeColumn getForId(final int id) {
throw new NoSuchElementException("There is no column with id " + id);
}

/**
* Gets the PokeColumn enum for given heading.
*
* @param heading The heading.
* @return The column.
*/
public static PokeColumn getForHeading(final String heading) {
for (final PokeColumn column : PokeColumn.values()) {
if (column.heading.equals(heading)) {
return column;
}
}
// If not found, we throw an exception
throw new NoSuchElementException("There is no column with heading " + heading);
}

/**
* Returns the comparator for the given column, based on the column type.
*
Expand Down
Loading

0 comments on commit b9a1673

Please sign in to comment.