-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REFERENCE ONLY DO NOT REVIEW!!!] Implement Mojang WebAPI, common user root class, and playerheads #56
base: master
Are you sure you want to change the base?
Conversation
Still todo: figure out tests |
Bumps [classgraph](https://github.com/classgraph/classgraph) from 4.8.92 to 4.8.98. - [Release notes](https://github.com/classgraph/classgraph/releases) - [Commits](classgraph/classgraph@classgraph-4.8.92...classgraph-4.8.98) Signed-off-by: dependabot-preview[bot] <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #56 +/- ##
============================================
+ Coverage 20.39% 26.61% +6.22%
- Complexity 111 196 +85
============================================
Files 63 76 +13
Lines 2859 3179 +320
Branches 381 409 +28
============================================
+ Hits 583 846 +263
- Misses 2261 2278 +17
- Partials 15 55 +40
Continue to review full report at Codecov.
|
|
||
import java.util.UUID; | ||
|
||
public class StickyUserBukkit extends StickyUser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we decided not to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely decided not to do this.
|
||
import java.util.UUID; | ||
|
||
public class StickyUserBungee extends StickyUser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above again
|
||
import java.util.UUID; | ||
|
||
public class StickyUser implements Cacheable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
@@ -0,0 +1,173 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my... Is this used for heads?
Move to resources please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is moved to resources please remove this class.
* Copyright (c) 2020 DumbDogDiner <dumbdogdiner.com>. All rights reserved. | ||
* Licensed under the MIT license, see LICENSE for more information... | ||
*/ | ||
package com.dumbdogdiner.stickyapi.common.webapis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
com.dumbdogdiner.stickyapi.common.webapis
to com.dumbdogdiner.stickyapi.common.mojang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thought was other apis, such as optifine capes or labymod capes, or any other web apis, can be put in here. I will make it com.dumbdogdiner.stickyapi.common.webapi.mojang
unless thats too long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
com.dumbdogdiner.stickyapi.common.web.mojang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add empty files please.
src/main/java/com/dumbdogdiner/stickyapi/common/util/StringUtil.java
Outdated
Show resolved
Hide resolved
|
||
import lombok.Getter; | ||
|
||
public enum DefaultSkins { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to resources please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What format should these be in in resources? SQLite DB??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON.
import com.dumbdogdiner.stickyapi.common.util.StringUtil; | ||
import lombok.Getter; | ||
|
||
public enum MobHead { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to resources.
import java.time.Instant; | ||
import java.util.*; | ||
|
||
public class MojangUser extends StickyUser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using StickyUser, just make this its own object with the basic user information we'd need, such as username, uuid, skin textures, etc. Pretty much an object for the response from Mojang's API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
|
||
import java.util.UUID; | ||
|
||
public class MobHeadGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MobHeadBuilder?
src/main/java/com/dumbdogdiner/stickyapi/bukkit/item/generator/PlayerHeadGenerator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/dumbdogdiner/stickyapi/common/util/textures/DefaultSkins.java
Outdated
Show resolved
Hide resolved
* API URLs | ||
*/ | ||
|
||
public enum APIStatus{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inb4 vlad complains about the lack of a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inb4 vlad complains about the lack of a space.
you know me too well <3
|
||
public Map<String, List<Instant>> getUsernameHistory(){ | ||
HashMap<String, List<Instant>> usernameHistory = new HashMap<>(); | ||
for (AshconResponse.Username u : apiResponse.username_history) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider calling this variable previous
or prev
?
if(usernameHistory.containsKey(u.username) && u.changed_at != null){ | ||
usernameHistory.get(u.username).add(Instant.parse(u.changed_at)); | ||
} else { | ||
ArrayList<Instant> hist = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArrayList<Instant> hist = new ArrayList<>(); | |
ArrayList<Instant> history = new ArrayList<>(); |
/** | ||
* This package contains code that is used for obtaining information from Mojang's web API or cached versions. Other APIs may be supported in the future. | ||
*/ | ||
package com.dumbdogdiner.stickyapi.common.webapis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package com.dumbdogdiner.stickyapi.common.webapis; | |
package com.dumbdogdiner.stickyapi.common.webapis; | |
src/test/java/com/dumbdogdiner/stickyapi/bukkit/item/generator/MobHeadGeneratorTest.java
Outdated
Show resolved
Hide resolved
void getUsername() { | ||
assertEquals(new CachedMojangAPI(UUID.fromString("9b6d27b3-f53b-49d1-b8c4-fa807f7575e9")).getUsername(), "Rodwuff"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
5cb2f06
to
9722bf7
Compare
9722bf7
to
b014f6b
Compare
17dfcfc
to
329515f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dun worry about the formatting comments - I'm just nitpicking. Those will be fixed by themselves once we merge in #58.
implementation 'org.jetbrains:annotations:20.1.0' | ||
implementation 'com.google.code.gson:gson:2.8.6' | ||
implementation 'io.github.classgraph:classgraph:4.8.92' | ||
implementation 'com.github.seancfoley:ipaddress:5.3.3' | ||
implementation 'com.squareup.okhttp3:okhttp:4.9.0' | ||
implementation 'commons-validator:commons-validator:1.7' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Guava's preconditions rather than shading in deps to StickyAPI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the JavaDocs for preconditions. This is included in both bukkit and bungee so will work at runtime. No need to shade in extra dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you're intending to use this for a completely different reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validator is used primarily to check url formatting for validity, and determine if a URL is validly formatted (and I think it also checks if it's resolvable). There are a couple other ways I plan to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also theoretically call the minimize() function to reduce jar size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validator is used primarily to check url formatting for validity, and determine if a URL is validly formatted (and I think it also checks if it's resolvable). There are a couple other ways I plan to use it.
Google preconditions does thissssss - just include a URL regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also theoretically call the minimize() function to reduce jar size
This has side effects, we've already tried it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need to validate the URL ourselves? OkHttp should throw an exception when unable to parse a URL, and if we don't want to use OkHttp, a regular expression will do for URL validity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also probably test URL validity by attempting to construct a URL object using the string and seeing if a MalformedURLException is thrown
@@ -0,0 +1 @@ | |||
systemProp.file.encoding=utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
systemProp.file.encoding=utf-8 | |
systemProp.file.encoding=utf-8 | |
TestsCommon.superficialEnumCodeCoverage(DefaultSkins.class); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
void testEnum(){ | ||
TestsCommon.superficialEnumCodeCoverage(MiniBlock.class); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
public void testHead(){ | ||
TestsCommon.superficialEnumCodeCoverage(MobHead.class); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
I believe it's used in a couple other places too. I can try looking for
another HTTP client, but I really like the way this one works.
…On Sat, Dec 26, 2020, 9:16 AM skyezer ✨ ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In build.gradle
<#56 (comment)>:
> implementation 'org.jetbrains:annotations:20.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'io.github.classgraph:classgraph:4.8.92'
implementation 'com.github.seancfoley:ipaddress:5.3.3'
+ implementation 'com.squareup.okhttp3:okhttp:4.9.0'
+ implementation 'commons-validator:commons-validator:1.7'
Unless you're intending to use this for a completely different reason.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#56 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFUCWTJDUQ3O62O46FUB5TSWYD6XANCNFSM4VDLY7BQ>
.
|
src/test/java/com/dumbdogdiner/stickyapi/common/webapis/CachedMojangAPITest.java
Show resolved
Hide resolved
…sgraph-classgraph-4.8.98' into feat/heads-mojangapi-users
build.gradle
Outdated
testImplementation("org.mockito:mockito-core:3.7.0") | ||
testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.5.0' | ||
testImplementation 'it.unimi.dsi:fastutil:8.4.4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we start adding comments for depends so we know why they're added so I don't have to ask like this later...
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
// Show System.out for code ran by tests | ||
showStandardStreams = true | ||
} | ||
//ignoreFailures = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line if it's commented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its there for testing. I will try to fold into a new task
public static InputStream getResourceAsStream(String resourceName){ | ||
return StickyAPI.class.getResourceAsStream(resourceName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Also, where are the annotations?
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class PlayerHeadBuilder extends SkullBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JAVADOC!!!!
|
||
} | ||
|
||
public @NotNull SkullBuilder filter(@NotNull String group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -64,7 +64,7 @@ public static TextComponent convertURLs(@NotNull String text) { | |||
|
|||
TextComponent urlComponent = new TextComponent(url.getShortened() + " "); | |||
urlComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url.getFullPath())); | |||
urlComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§7Click to open URL"), new Text("\n§8" + url.getFullPath()))); | |||
urlComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.COLOR_CHAR + "" + ChatColor.GRAY + "Click to open URL"), new Text("\n§8" + url.getFullPath()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChatColor.COLOR_CHAR + ""
is unnecessary if you have ChatColor.GRAY
ahead of it.
* Copyright (c) 2020 DumbDogDiner <dumbdogdiner.com>. All rights reserved. | ||
* Licensed under the MIT license, see LICENSE for more information... | ||
*/ | ||
package com.dumbdogdiner.stickyapi.common.webapis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
|
||
//TODO: Better error handeling in case of 404 | ||
|
||
public class MojangAPI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
import java.time.Instant; | ||
import java.util.*; | ||
|
||
public class MojangUser extends StickyUser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
import java.time.Instant; | ||
import java.util.*; | ||
|
||
public class MojangUser extends StickyUser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and bump
Note i did that review on no sleep, i'll do another one later. |
Resolves #62 |
tasks.delombok.shouldRunAfter(sources) | ||
tasks.publish.dependsOn build | ||
tasks.build.shouldRunAfter(clean) | ||
tasks.javadoc.shouldRunAfter(clean) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little hesitant to have javadoc and build run after clean...
@NotZachery thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this could become an issue so I'm fine by it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are set to run after as should, not forced. This prevents (if you did, say, ./gradlew build clean javadoc
it from building then deleting the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay - thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR
No wildcard imports, new line at end of files, and formatting.
* Do not call a method annotated with this, it will do bad things | ||
*/ | ||
@Documented | ||
public @interface DoNotCall { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of this exactly? If a method shouldn't be called why does it exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer it if we can write things in a way where methods that are strictly internal can't be called externally.
import org.bukkit.command.CommandMap; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.bukkit.command.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No wild card imports.
public @NotNull SkullBuilder category(@NotNull String str) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
category(qn[0]); | ||
return head(qn[1]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no wildcard imports
import lombok.Getter; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.sql.Timestamp; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no wildcard imports
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.io.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no wildcard imports
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no wildcard imports
import java.io.InputStreamReader; | ||
import java.lang.reflect.Type; | ||
import java.net.URL; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no wildcard imports
if (splits[0].equals("*")) { | ||
@Nullable String texture = null; | ||
for (@NotNull String cat : getCategories()) { | ||
try { | ||
texture = getTexture(cat, qualifiedName); | ||
} catch (NoSuchElementException e) { | ||
continue; | ||
} | ||
return texture; | ||
} | ||
return texture; | ||
} else { | ||
return getTexture(splits[0], splits[1]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (splits[0].equals("*")) { | |
@Nullable String texture = null; | |
for (@NotNull String cat : getCategories()) { | |
try { | |
texture = getTexture(cat, qualifiedName); | |
} catch (NoSuchElementException e) { | |
continue; | |
} | |
return texture; | |
} | |
return texture; | |
} else { | |
return getTexture(splits[0], splits[1]); | |
} | |
if (!splits[0].equals("*")) | |
return getTexture(splits[0], splits[1]); | |
@Nullable String texture = null; | |
for (@NotNull String cat : getCategories()) { | |
try { | |
texture = getTexture(cat, qualifiedName); | |
} catch (NoSuchElementException e) { | |
continue; | |
} | |
return texture; | |
} | |
return texture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things:
- Formatting, but we can fix that with spotless so don't worry.
- No need to worry about
@Nullable
and@NotNull
annotations in actual method bodies - they're only needed on method signatures so the KLS can work out what is going on. - Need to discuss splitting this into 3 PRs, one for the Web API, the user class, and player heads.
- Pls see comments for a couple of specific things.
- thx for working so hard <3
- friendly neighborhood floofball
@@ -1,6 +1,5 @@ | |||
distributionBase=GRADLE_USER_HOME | |||
distributionPath=wrapper/dists | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference: please don't change Gradle versions without asking one of us!
* Do not call a method annotated with this, it will do bad things | ||
*/ | ||
@Documented | ||
public @interface DoNotCall { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer it if we can write things in a way where methods that are strictly internal can't be called externally.
@@ -43,7 +43,7 @@ | |||
* @param commandName The name of the command the user will execute | |||
* @param owner The plugin that owns this command. | |||
*/ | |||
public AsyncCommand(String commandName, Plugin owner) { | |||
public AsyncCommand(@NotNull String commandName, Plugin owner) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference: please keep changes unrelated to the branch somewhere else!
if (args == null) | ||
throw new NullPointerException("arguments to tabComplete cannot be null"); | ||
|
||
List<String> completions = null; | ||
@org.jetbrains.annotations.Nullable List<String> completions = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these annotations are for the KLS to help infer things properly - don't think we need them in internal Java code.
@@ -181,16 +181,16 @@ public void setTabCompleter(TabCompleter completer) { | |||
*/ | |||
@Override | |||
public java.util.@NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, | |||
String[] args) throws CommandException, IllegalArgumentException { | |||
String @org.jetbrains.annotations.Nullable [] args) throws CommandException, IllegalArgumentException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wacky import? If this can be imported as normal, would be appreciated.
static final OkHttpClient httpClient = new OkHttpClient(); | ||
private static final Gson GSON = new Gson(); | ||
private static final Yaml YAML = new Yaml(); | ||
private static Map<String, Map<String, String>> TextureMap = generateTextureMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skeeball really doesn't like C-style variable names - do you use this to identify static vars?
private static Map<String, Map<String, String>> TextureMap = generateTextureMap(); | |
private static Map<String, Map<String, String>> textureMap = generateTextureMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variables are in C-style (title case), caml case is local, all caps is constant - CS106a code style
Also trying to avoid this: https://youtu.be/GPWah4wbwYs?t=1264
|
||
import java.net.URL; | ||
|
||
public class HttpException extends RuntimeException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Believe I've commented on this before - why the need for two layers of wrapping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's one layer of wrapping in most cases, but its using inheritance to subclass different types of exception so you can do different behaviors
|
||
//TODO: Better error handeling in case of 404 | ||
|
||
public class OldAPI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcard import!
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class MojangAPITest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test for this would be lovely <3
Closes #51