Skip to content

Commit

Permalink
Merge for release v0.1.5 (#503)
Browse files Browse the repository at this point in the history
* v0.1.5 develop preparation

* Better unicode IV numbers (#476)

* Fix for select Pokemon with less than IV input (#482)

* Fix for select Pokemon with less than IV input

* Use PokeColumn enum to retrieve column index for IV rating

* Outmost exception handler not closing automatically now (#483)

* Remove outdated message

* Fix CP Evolved column (sorting) (#488)

* Checking null values in all CellRenderers (#487)

* Updated base stats + New API (#491)

* Fix Ditto (#492)

* New API version + codestyle of Utilities class (#495)

* Fix cp evolved eevee (#499)

* Fix Eevee CP calculation (partly)

* Fix resource folder

* Fix colored background when selected (#500)

* Fix colored background when selected

* Remove unused imports

* Changed version to v0.1.5 (#502)
  • Loading branch information
Wolfsblvt committed Nov 24, 2016
1 parent f1c64d7 commit 00f4d9e
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 110 deletions.
18 changes: 9 additions & 9 deletions .idea/artifacts/BlossomsPogoManager_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions BlossomsPokemonGoManager.iml
Expand Up @@ -12,10 +12,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.7" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.7" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.7" level="project" />
<orderEntry type="library" name="Maven: com.pokegoapi:PokeGOAPI-library:0.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.Wolfsblvt:PokeGOAPI-Java:f75f306df7b399adb3a3d258551f0cb3e5d2a377" level="project" />
<orderEntry type="library" name="Maven: svarzee.gps:gpsoauth:0.3" level="project" />
<orderEntry type="library" name="Maven: net.iharder:base64:2.3.9" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.9.0" level="project" />
Expand Down
12 changes: 0 additions & 12 deletions README.md
@@ -1,15 +1,3 @@
# Important Note on Using this Tool
Niantic forced the apps to update to latest 0.39 version. All old official apps will not start anymore. That means they will only have new API calls from smartphones, making it very likely to get flagged if you use the old API with unofficial tool, like ours too.

**IMPORTANT: Chances are high for getting flagged and banned if you continue using this tool at the moment!**

Devs are already working on a new API version so that tools can continue to exist, we hope.
Use BlossomsPokemonGoManager at your own risk. It's more likely than ever to get banned for it.
(No reported bans so far though)

<hr />


[![Travis Build Badge](https://img.shields.io/travis/Wolfsblvt/BlossomsPokemonGoManager.svg)](https://travis-ci.org/Wolfsblvt/BlossomsPokemonGoManager)
[![Codacy](https://img.shields.io/codacy/grade/14b05062286f448fb5b59708c4936e42.svg)](https://www.codacy.com/app/wolfsblvt/BlossomsPokemonGoManager?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Wolfsblvt/BlossomsPokemonGoManager&amp;utm_campaign=Badge_Grade)
[![Codacy Coverage](https://img.shields.io/codacy/coverage/14b05062286f448fb5b59708c4936e42.svg)](https://www.codacy.com/app/wolfsblvt/BlossomsPokemonGoManager?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Wolfsblvt/BlossomsPokemonGoManager&amp;utm_campaign=Badge_Grade)
Expand Down
2 changes: 1 addition & 1 deletion checkstyle.xml
Expand Up @@ -274,7 +274,7 @@
<property name="format" value="^((\s*)|(\s*case(.*?):\s*))$"/>
</module>
<module name="UncommentedMain">
<property name="excludedClasses" value="\.Main$"/>
<property name="excludedClasses" value="\.BlossomsPoGoManager$"/>
</module>
<module name="UpperEll"/>

Expand Down
15 changes: 12 additions & 3 deletions pom.xml
Expand Up @@ -93,12 +93,21 @@
<id>bintray</id>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!--<dependency>-->
<!--<groupId>com.pokegoapi</groupId>-->
<!--<artifactId>PokeGOAPI-library</artifactId>-->
<!--<version>0.4.1</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.pokegoapi</groupId>
<artifactId>PokeGOAPI-library</artifactId>
<version>0.4.1</version>
<groupId>com.github.Wolfsblvt</groupId>
<artifactId>PokeGOAPI-Java</artifactId>
<version>f75f306df7b399adb3a3d258551f0cb3e5d2a377</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
@@ -1 +1 @@
v0.1.4
v0.1.5
22 changes: 17 additions & 5 deletions src/me/corriekay/pokegoutil/BlossomsPoGoManager.java
Expand Up @@ -18,6 +18,9 @@
import javafx.application.Application;
import javafx.stage.Stage;

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

private static Stage sPrimaryStage;
Expand Down Expand Up @@ -80,15 +83,24 @@ private static void setupGlobalExceptionHandling() {
current = current.getCause();
}

JOptionPane.showMessageDialog(
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 shuts down now."
+ StringLiterals.NEWLINE + "You can report the error on GitHub or Discord.",
+ 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.ERROR_MESSAGE);
System.exit(-1);
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, options, options[0]);
if (continueChoice == 1) {
// If exit is chosen, we exit here.
System.exit(-1);
}
});
}

Expand Down
7 changes: 6 additions & 1 deletion src/me/corriekay/pokegoutil/data/enums/PokeColumn.java
Expand Up @@ -202,7 +202,12 @@ public Object get(final Pokemon p) {
CP_EVOLVED("CP Evolved", ColumnType.NULLABLE_INT) {
@Override
public Object get(final Pokemon p) {
return p.getCpAfterFullEvolve();
final int cpAfterFullyEvolve = p.getCpAfterFullEvolve();
if (cpAfterFullyEvolve != p.getCp()) {
return String.valueOf(cpAfterFullyEvolve);
} else {
return StringLiterals.NO_VALUE_SIGN;
}
}
},
CAUGHT_WITH("Caught With", ColumnType.STRING) {
Expand Down
112 changes: 84 additions & 28 deletions src/me/corriekay/pokegoutil/utils/Utilities.java
@@ -1,26 +1,40 @@
package me.corriekay.pokegoutil.utils;

import java.awt.Color;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.StringUtils;

import com.google.protobuf.InvalidProtocolBufferException;

/**
* The main Utilities class.
* Inside are utility global constants and basic utility functions that aren't enough to get extracted to its own file.
* <p>
* Dear DEVELOPER, if you decide to add another utility function here, please take a look if there are enough similar
* ones so that they can be extracted in their own class. Also do take a look if there isn't already a specialized
* utility class for what you want to add.
*/
public final class Utilities {


public static final int PERCENTAGE_FACTOR = 100;
public static final int CALCULATION_FACTOR_1000 = 1000;

public static final Random RANDOM = new Random(System.currentTimeMillis());

/** Prevent initializing this class. */
private Utilities() {
}

private static final Random random = new Random(System.currentTimeMillis());

public static boolean isEven(long i) {
return i % 2 == 0;
/**
* Checks is a number is even.
*
* @param number The number.
* @return True if Even, else false.
*/
public static boolean isEven(final long number) {
return number % 2 == 0;
}

/**
Expand All @@ -44,14 +58,15 @@ public static <T extends Comparable> T limit(final T min, final T value, final T
}

/**
* Takes to numbers and creates a decimal percentage of it (like 0.7542).
* Takes two numbers and creates a decimal percentage of it (like 0.7542).
* If the maximum is zero, then the percentage returned is 1.0, so highest possible.
*
* @param number The real part.
* @param maximum The maximum of the number.
* @return The percentage value
* @return The percentage value.
*/
public static double percentage(final double number, final double maximum) {
return number / maximum;
return (maximum != 0.0) ? number / maximum : 1.0;
}

/**
Expand All @@ -67,54 +82,95 @@ public static String percentageWithTwoCharacters(final double decimalNumber) {
return (percentage < PERCENTAGE_FACTOR) ? StringUtils.leftPad(String.valueOf(percentage), 2, '0') : "XX";
}

public static Color randomColor() {
Color c = new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255), 255);
return c;
}

public static void sleep(int milliseconds) {
/**
* Let the thread sleep for a given amount of milliseconds.
* IMPORTANT: Don't call from main thread of the UI, otherwise the UI will freeze.
*
* @param milliseconds The milliseconds to sleep.
*/
public static void sleep(final int milliseconds) {
try {
TimeUnit.MILLISECONDS.sleep(milliseconds);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

public static void sleepRandom(int minMilliseconds, int maxMilliseconds) {
/**
* Let the thread sleep for a random amount between two given millisecond numbers.
* IMPORTANT: Don't call from main thread of the UI, otherwise the UI will freeze.
*
* @param minMilliseconds The minimum amount of milliseconds.
* @param maxMilliseconds The maximum amount of milliseconds
*/
public static void sleepRandom(final int minMilliseconds, final int maxMilliseconds) {
try {
int randomInt = getRandom(minMilliseconds, maxMilliseconds);
System.out.println("Waiting " + (randomInt / 1000.0F) + " seconds.");
final int randomInt = getRandom(minMilliseconds, maxMilliseconds);
System.out.println("Waiting " + ((double) randomInt / CALCULATION_FACTOR_1000) + " seconds.");
TimeUnit.MILLISECONDS.sleep(randomInt);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

public static int getRandom(int minMilliseconds, int maxMilliseconds) {
int from = Math.max(minMilliseconds, maxMilliseconds);
int to = Math.min(minMilliseconds, maxMilliseconds);
return random.nextInt((from - to) + 1) + to;
/**
* Returns a random number between two numbers.
*
* @param minimum The minimum number, inclusive.
* @param maximum The maximum number, inclusive.
* @return The random number.
*/
public static int getRandom(final int minimum, final int maximum) {
final int from = Math.min(minimum, maximum);
final int to = Math.max(minimum, maximum);
return RANDOM.nextInt((to - from) + 1) + from;
}

/**
* Returns a random number between two numbers.
*
* @param minimum The minimum number, inclusive.
* @param maximum The maximum number, inclusive.
* @return The random number.
*/
public static double getRandom(final double minimum, final double maximum) {
final double from = Math.min(minimum, maximum);
final double to = Math.max(minimum, maximum);
return RANDOM.nextDouble() * (to - from) + from;
}

public static String getRealExceptionMessage(Exception e) {
String message = e.getMessage();
if (e instanceof InvalidProtocolBufferException || "Contents of buffer are null".equals(message)) {
/**
* Abstracts the exception message and makes a more readable exception out of it for edge cases.
*
* @param exception The exception.
* @return The real exception message.
*/
public static String getRealExceptionMessage(final Exception exception) {
String message = exception.getMessage();
if (exception instanceof InvalidProtocolBufferException || "Contents of buffer are null".equals(message)) {
message = "Server hasn't responded in time. "
+ "Seems to be busy. "
+ "The action may have been successful though. (" + message + ")";
}
return message;
}

public static String concatString(char delimeter, String... strings) {
/**
* Concat a given count of string with given delimiter.
*
* @param delimiter The delimiter to put between the strings.
* @param strings The strings that should be combined.
* @return The combined string.
*/
public static String concatString(final char delimiter, final String... strings) {
if (strings.length == 0) {
return "";
}

String s = strings[0];
String combined = strings[0];
for (int i = 1; i < strings.length; i++) {
s += delimeter + strings[i];
combined += delimiter + strings[i];
}
return s;
return combined;
}
}
29 changes: 29 additions & 0 deletions src/me/corriekay/pokegoutil/utils/helpers/ColorHelper.java
@@ -0,0 +1,29 @@
package me.corriekay.pokegoutil.utils.helpers;

import java.awt.Color;

import me.corriekay.pokegoutil.utils.Utilities;

/**
* Helper class for managing colors.
*/
public final class ColorHelper {

public static final int MAX_COLOR = 255;

/** Prevent initializing this class. */
private ColorHelper() {
}

/**
* Gets a random color.
* Notes to Developers: If there will be more color functions in the future, please extract them to a ColorHelper.
*
* @return A random color.
*/
public static Color randomColor() {
final Color color = new Color(Utilities.RANDOM.nextInt(MAX_COLOR), Utilities.RANDOM.nextInt(MAX_COLOR), Utilities.RANDOM.nextInt(MAX_COLOR), MAX_COLOR);
return color;
}

}
22 changes: 11 additions & 11 deletions src/me/corriekay/pokegoutil/utils/helpers/UnicodeHelper.java
Expand Up @@ -5,17 +5,17 @@
/** Class to Help get the Unicode character.
* @author Fernando */
public enum UnicodeHelper {
NUMBER_0(0x24FF, "0"),
NUMBER_1(0x278A, "1"),
NUMBER_2(0x278B, "2"),
NUMBER_3(0x278C, "3"),
NUMBER_4(0x278D, "4"),
NUMBER_5(0x278E, "5"),
NUMBER_6(0x278F, "6"),
NUMBER_7(0x2790, "7"),
NUMBER_8(0x2791, "8"),
NUMBER_9(0x2792, "9"),
NUMBER_10(0x2793, "10"),
NUMBER_0(0x24EA, "0"),
NUMBER_1(0x2460, "1"),
NUMBER_2(0x2461, "2"),
NUMBER_3(0x2462, "3"),
NUMBER_4(0x2463, "4"),
NUMBER_5(0x2464, "5"),
NUMBER_6(0x2465, "6"),
NUMBER_7(0x2466, "7"),
NUMBER_8(0x2467, "8"),
NUMBER_9(0x2468, "9"),
NUMBER_10(0x2469, "10"),
NUMBER_11(0x24EB, "11"),
NUMBER_12(0x24EC, "12"),
NUMBER_13(0x24ED, "13"),
Expand Down

0 comments on commit 00f4d9e

Please sign in to comment.