Skip to content

Commit

Permalink
#24 Merged MacOs color fix (thanks to https://github.com/lpalm>.
Browse files Browse the repository at this point in the history
  • Loading branch information
ocraft committed May 7, 2020
1 parent 2ed5c0e commit fb0fdb9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sc2client-api should be valid or similar by analogy in this Java Api. More info
<dependency>
<groupId>com.github.ocraft</groupId>
<artifactId>ocraft-s2client-bot</artifactId>
<version>0.3.15</version>
<version>0.3.16</version>
</dependency>
----

Expand Down
2 changes: 1 addition & 1 deletion docs/building.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For reference, it can be found here: https://github.com/ocraft/ocraft-s2client
<dependency>
<groupId>com.github.ocraft</groupId>
<artifactId>ocraft-s2client-bot</artifactId>
<version>0.3.15</version>
<version>0.3.16</version>
</dependency>
----
. If you want to build your own version (you need maven install on your PATH):
Expand Down
2 changes: 1 addition & 1 deletion ocraft-s2client-api/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ analyze in many different tools.
<dependency>
<groupId>com.github.ocraft</groupId>
<artifactId>ocraft-s2client-api</artifactId>
<version>0.3.15</version>
<version>0.3.16</version>
</dependency>
----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@
*/
public final class OsCheck {

public enum OSType {
Windows,
MacOS,
Linux,
Other
public enum OsType {
WINDOWS,
MAC_OS,
LINUX,
OTHER
}

// Cached result of OS detection
private static OSType detectedOs;
private static OsType detectedOs;

/**
* Detect the operating system from the os.name System property and cache
* the result
*
* @returns - the operating system detected
* @return - the operating system detected
*/
public static OSType getOSType() {
public static OsType getOSType() {
if (detectedOs == null) {
String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if ((OS.contains("mac")) || (OS.contains("darwin"))) {
detectedOs = OSType.MacOS;
} else if (OS.contains("win")) {
detectedOs = OSType.Windows;
} else if (OS.contains("nux")) {
detectedOs = OSType.Linux;
String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if ((os.contains("mac")) || (os.contains("darwin"))) {
detectedOs = OsType.MAC_OS;
} else if (os.contains("win")) {
detectedOs = OsType.WINDOWS;
} else if (os.contains("nux")) {
detectedOs = OsType.LINUX;
} else {
detectedOs = OSType.Other;
detectedOs = OsType.OTHER;
}
}
return detectedOs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import SC2APIProtocol.Debug;
import com.github.ocraft.s2client.protocol.OsCheck;
import com.github.ocraft.s2client.protocol.OsCheck.OSType;
import com.github.ocraft.s2client.protocol.OsCheck.OsType;
import com.github.ocraft.s2client.protocol.Sc2ApiSerializable;
import com.github.ocraft.s2client.protocol.Strings;

Expand Down Expand Up @@ -68,7 +68,7 @@ public static Color of(int r, int g, int b) {

@Override
public Debug.Color toSc2Api() {
if(OsCheck.getOSType() == OSType.MacOS) {
if (OsCheck.getOSType() == OsType.MAC_OS) {
// MacOS has BGR channels instead of RGB.
return Debug.Color.newBuilder().setR(b).setG(g).setB(r).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import SC2APIProtocol.Debug;
import com.github.ocraft.s2client.protocol.OsCheck;
import com.github.ocraft.s2client.protocol.OsCheck.OSType;
import com.github.ocraft.s2client.protocol.OsCheck.OsType;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.jupiter.api.Test;

Expand All @@ -43,7 +43,7 @@ class ColorTest {

@Test
void serializesToSc2ApiColor() {
if(OsCheck.getOSType() == OSType.MacOS) {
if(OsCheck.getOSType() == OsType.MAC_OS) {
assertThatAllFieldsInRequestAreSerialized(Color.of(COLOR_B, COLOR_G, COLOR_R).toSc2Api());
} else {
assertThatAllFieldsInRequestAreSerialized(Color.of(COLOR_R, COLOR_G, COLOR_B).toSc2Api());
Expand Down

0 comments on commit fb0fdb9

Please sign in to comment.