-
Notifications
You must be signed in to change notification settings - Fork 5
[REFERENCE ONLY DO NOT REVIEW!!!] Implement Mojang WebAPI, common user root class, and playerheads #56
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
base: master
Are you sure you want to change the base?
[REFERENCE ONLY DO NOT REVIEW!!!] Implement Mojang WebAPI, common user root class, and playerheads #56
Changes from 14 commits
5972a00
b8a5bf6
8dae48a
7d74d10
3db73ff
004fbf0
b014f6b
329515f
ab69d97
67a9c4b
680655b
8c113ec
ac010e4
0b15f04
b6f0496
6d4bcec
c4a023e
0fb226b
c44992f
b278a81
8c6b7b5
786590d
cacaefb
ade9f94
223a6f9
84c0b3b
6b4316f
42b1739
d16c439
3aaa25b
6fc4385
263164b
26c8415
614816b
e6a97e1
94683c6
aa23150
7f2cab7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ plugins { | |
| id "com.github.hierynomus.license" version "0.15.0" | ||
| } | ||
|
|
||
|
|
||
|
|
||
| jacoco { | ||
| // Use JaCoCo 0.8.6 for (experimental) support for Java 15 class files. | ||
| toolVersion = "0.8.6" | ||
|
|
@@ -25,6 +27,10 @@ license { | |
| tasks.withType(JavaCompile) { | ||
| options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XDignore.symbol.file" | ||
| } | ||
|
|
||
| javadoc{ | ||
| options.addBooleanOption("-frames", true) | ||
| } | ||
| // Run the license formatter before compiling the source code. | ||
| tasks.compileJava.dependsOn licenseFormatMain, licenseFormatTest | ||
|
|
||
|
|
@@ -48,30 +54,37 @@ dependencies { | |
|
|
||
| compileOnly 'com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT' | ||
| compileOnly 'net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT' | ||
|
|
||
| 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' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use Guava's preconditions rather than shading in deps to StickyAPI.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please explain
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless you're intending to use this for a completely different reason.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also theoretically call the minimize() function to reduce jar size
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Google preconditions does thissssss - just include a URL regex.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This has side effects, we've already tried it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| // JUnit 5 Testing | ||
| testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") | ||
| testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") | ||
| testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' | ||
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' | ||
|
|
||
| // Mocking | ||
| testImplementation("org.powermock:powermock-module-junit4:2.0.9") | ||
| testImplementation("org.powermock:powermock-api-mockito2:2.0.9") | ||
| testImplementation("org.powermock:powermock-module-junit4-rule:2.0.9") | ||
| testImplementation("org.powermock:powermock-classloading-xstream:2.0.9") | ||
| testImplementation("org.mockito:mockito-core:3.6.28") | ||
| testImplementation 'org.powermock:powermock-module-junit4:2.0.9' | ||
| testImplementation 'org.powermock:powermock-api-mockito2:2.0.9' | ||
| testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.9' | ||
| testImplementation 'org.powermock:powermock-classloading-xstream:2.0.9' | ||
| testImplementation 'org.mockito:mockito-core:3.6.28' | ||
| testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.5.0' | ||
| testImplementation 'it.unimi.dsi:fastutil:8.4.4' | ||
| } | ||
|
|
||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| testLogging { | ||
| events "passed", "skipped", "failed" | ||
| // Show System.out for code ran by tests | ||
| showStandardStreams = true | ||
| } | ||
| //ignoreFailures = true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line if it's commented.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| finalizedBy jacocoTestReport // report is always generated after tests run | ||
| } | ||
|
|
||
|
|
@@ -88,9 +101,22 @@ task sources(type: Jar, dependsOn: classes) { | |
| from sourceSets.main.allSource | ||
| } | ||
|
|
||
| tasks.delombok.shouldRunAfter(sources) | ||
|
|
||
|
|
||
| tasks.publish.dependsOn build, sources | ||
| tasks.publish.dependsOn build | ||
|
|
||
| tasks.javadoc.dependsOn delombok | ||
| javadoc { | ||
| options.addBooleanOption('XDignore.symbol.file', true) | ||
| options.addBooleanOption('-frames', true) | ||
| } | ||
| tasks.build.finalizedBy(sources) | ||
|
|
||
| task rebuild {} | ||
| tasks.rebuild.dependsOn build, clean | ||
| tasks.build.shouldRunAfter(clean) | ||
| tasks.javadoc.shouldRunAfter(clean) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||||
| systemProp.file.encoding=utf-8 | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.7.1-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists | ||
| compileJava.options.encoding=UTF-8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| */ | ||
| package com.dumbdogdiner.stickyapi; | ||
|
|
||
| import java.io.InputStream; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.logging.Logger; | ||
|
|
@@ -25,4 +26,15 @@ public class StickyAPI { | |
| @Getter | ||
| @Setter | ||
| private static ExecutorService pool = Executors.newCachedThreadPool(); | ||
|
|
||
| /** | ||
| * Provides a wrapper for {@link java.lang.Class#getResourceAsStream(String)} (String)} | ||
| * @param resourceName The resource to get | ||
| * @return an {@link InputStream} to that resource | ||
| */ | ||
| public static InputStream getResourceAsStream(String resourceName){ | ||
| return StickyAPI.class.getResourceAsStream(resourceName); | ||
| } | ||
|
||
|
|
||
| private StickyAPI() {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||
| /* | ||||||||||
| * Copyright (c) 2020 DumbDogDiner <dumbdogdiner.com>. All rights reserved. | ||||||||||
| * Licensed under the MIT license, see LICENSE for more information... | ||||||||||
| */ | ||||||||||
| package com.dumbdogdiner.stickyapi.bukkit.item.generator; | ||||||||||
|
|
||||||||||
| import com.destroystokyo.paper.profile.PlayerProfile; | ||||||||||
| import com.destroystokyo.paper.profile.ProfileProperty; | ||||||||||
| import com.dumbdogdiner.stickyapi.bukkit.user.StickyUserBukkit; | ||||||||||
| import org.bukkit.Bukkit; | ||||||||||
| import org.bukkit.Material; | ||||||||||
| import org.bukkit.OfflinePlayer; | ||||||||||
| import org.bukkit.entity.Player; | ||||||||||
| import org.bukkit.inventory.ItemStack; | ||||||||||
| import org.bukkit.inventory.meta.SkullMeta; | ||||||||||
| import com.google.gson.Gson; | ||||||||||
|
|
||||||||||
| import java.net.URL; | ||||||||||
| import java.util.Base64; | ||||||||||
| import java.util.UUID; | ||||||||||
|
|
||||||||||
| public class PlayerHeadGenerator { | ||||||||||
|
||||||||||
| private SkullMeta meta = (SkullMeta) (new ItemStack(Material.PLAYER_HEAD, 1)).getItemMeta(); | ||||||||||
|
|
||||||||||
| PlayerProfile ownerProfile; | ||||||||||
kaylendog marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| public PlayerHeadGenerator(UUID playerId){ | ||||||||||
|
||||||||||
| public PlayerHeadGenerator(UUID playerId){ | |
| public PlayerHeadGenerator(@NotNull UUID playerId) { |
Use annotations please, this is for Kotlin support.
Outdated
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 PlayerHeadGenerator(Player player){ | |
| public PlayerHeadGenerator(@NotNull Player player) { |
Outdated
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.
There must be a better way to do this aside from implementing an API-specific user.
Outdated
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 PlayerHeadGenerator(OfflinePlayer player){ | |
| public PlayerHeadGenerator(@NotNull OfflinePlayer player) { |
Outdated
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 PlayerHeadGenerator(ItemStack head){ | |
| public PlayerHeadGenerator(@NotNull ItemStack head) { |
Outdated
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 setTexture(URL textureURL){ | |
| public void setTexture(@NotNull URL textureURL) { |
Outdated
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 textures(String url){ | |
| public textures(@NotNull String url) { |
Outdated
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.
| class SKIN{ | |
| class SKIN { |
Outdated
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 SKIN(String s){ | |
| public SKIN(String s) { |
Outdated
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 SKIN(String s){ | |
| public SKIN(@NotNull String s) { |
Outdated
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 setTexture(String texture){ | |
| public void setTexture(String 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.
| public void setTexture(String texture){ | |
| public void setTexture(@NotNull String texture) { |
Outdated
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 ItemStack getHead(){ | |
| public ItemStack getHead() { |
Outdated
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 ItemStack getHead(int amount){ | |
| public ItemStack getHead(int amount) { |
Outdated
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 ItemStack getHead(int amount){ | |
| public ItemStack getHead(@NotNull int amount) { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2020 DumbDogDiner <dumbdogdiner.com>. All rights reserved. | ||||||
| * Licensed under the MIT license, see LICENSE for more information... | ||||||
| */ | ||||||
| package com.dumbdogdiner.stickyapi.bukkit.item.generator; | ||||||
|
|
||||||
| import com.destroystokyo.paper.profile.PlayerProfile; | ||||||
| import com.destroystokyo.paper.profile.ProfileProperty; | ||||||
| import com.dumbdogdiner.stickyapi.common.util.textures.TextureHelper; | ||||||
| import lombok.Getter; | ||||||
| import lombok.Setter; | ||||||
| import lombok.experimental.Accessors; | ||||||
| import org.apache.commons.lang.StringUtils; | ||||||
| import org.bukkit.Bukkit; | ||||||
| import org.bukkit.Material; | ||||||
| import org.bukkit.inventory.ItemStack; | ||||||
| import org.bukkit.inventory.meta.SkullMeta; | ||||||
|
|
||||||
| import java.util.UUID; | ||||||
|
|
||||||
|
|
||||||
| public class SkullBuilder { | ||||||
| @Getter | ||||||
| private String filter = "*"; | ||||||
| @Getter | ||||||
| private int quantity = 1; | ||||||
| @Getter | ||||||
| private String head; | ||||||
| @Accessors(fluent = true, chain = true) | ||||||
| @Setter @Getter | ||||||
| private String name; | ||||||
|
|
||||||
|
|
||||||
| public SkullBuilder() { | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| public SkullBuilder filter(String group) { | ||||||
|
||||||
| public SkullBuilder filter(String group) { | |
| public SkullBuilder filter(@NotNull String group) { |
Outdated
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 SkullBuilder head(String head) { | |
| public SkullBuilder head(@NotNull String head) { |
Outdated
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 SkullBuilder quantity(int i) { | |
| public SkullBuilder quantity(@NotNull int i) { |
Outdated
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.
Throw error if stack is over 64 or under 0?
Outdated
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.
Avoid using Apache's StringUtils as we have our own, just for consistency.
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 that was ours, oops. I'll use that, and if it doesnt have what I need I'll use inheritance
Uh oh!
There was an error while loading. Please reload this page.