-
Notifications
You must be signed in to change notification settings - Fork 6
Update to V4 #41
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
Merged
Merged
Update to V4 #41
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c728ce6
Update to v4
Veyronity b2c8f9a
spotlessApply
Veyronity c94da03
Use consistent Nullable annotation
Veyronity eefffa3
Last one
Veyronity d8a17ac
Fix edge case NPE
Veyronity b49e026
Use 12 digit SecureRandom longs rather than UUIDs as API keys
Veyronity b94a043
Use longer api key
Veyronity 180b1f7
Add database support for opt out/api keys
Warriorrrr 2f29a87
Fix sse clients not being shutdown properly
Warriorrrr abd1158
Require explicit listing of each desired event
Warriorrrr 051d96e
Store clients by owner uuid
Warriorrrr c25e011
Future error proofing
Warriorrrr 8844bfa
Lower max key size in the db
Warriorrrr 0e25cd2
Add keepalives to sse clients
Warriorrrr cc3a43e
fix build
Warriorrrr 64ba725
Add structured sse error responses
Warriorrrr bb17e5e
Add command cooldown
Warriorrrr 98f54dd
Remove api command from plugin.yml
Warriorrrr df5b80f
Add docs
Veyronity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/net/earthmc/emcapi/endpoint/ShopEndpoint.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package net.earthmc.emcapi.endpoint; | ||
|
|
||
| import com.google.gson.JsonElement; | ||
| import com.google.gson.JsonObject; | ||
| import io.javalin.http.BadRequestResponse; | ||
| import net.earthmc.emcapi.EMCAPI; | ||
| import net.earthmc.emcapi.integration.QuickShopIntegration; | ||
| import net.earthmc.emcapi.object.endpoint.PostEndpoint; | ||
| import net.earthmc.emcapi.util.EndpointUtils; | ||
| import net.earthmc.emcapi.util.JSONUtil; | ||
| import org.jspecify.annotations.Nullable; | ||
|
Veyronity marked this conversation as resolved.
Outdated
|
||
| import org.maxgamer.quickshop.api.shop.Shop; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| public class ShopEndpoint extends PostEndpoint<List<Shop>> { | ||
| private final QuickShopIntegration integration; | ||
|
|
||
| public ShopEndpoint(EMCAPI plugin) { | ||
| this.integration = plugin.integrations().quickShopIntegration(); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Shop> getObjectOrNull(JsonElement element, @Nullable UUID key) { | ||
| String string = JSONUtil.getJsonElementAsStringOrNull(element); | ||
| if (string == null) throw new BadRequestResponse("Your query contains a value that is not a string"); | ||
|
|
||
| UUID player; | ||
| try { | ||
| player = UUID.fromString(string); | ||
| } catch (IllegalArgumentException ignored) { | ||
| return null; | ||
| } | ||
|
|
||
| integration.throwIfDisabled(); | ||
| return integration.getPlayerShops(player, key); | ||
| } | ||
|
|
||
| @Override | ||
| public JsonElement getJsonElement(List<Shop> object, @Nullable UUID key) { | ||
| JsonObject shopsObject = new JsonObject(); | ||
| int counter = 1; | ||
| UUID keyOwner = EndpointUtils.getKeyOwner(key); | ||
| for (Shop shop : object) { | ||
| if (!shop.getOwner().equals(keyOwner)) continue; | ||
| shopsObject.add(String.valueOf(counter++), EndpointUtils.getShopObject(shop)); | ||
| } | ||
|
|
||
| return shopsObject; | ||
| } | ||
| } | ||
2 changes: 1 addition & 1 deletion
2
...mcapi/endpoint/DocumentationEndpoint.java → ...ndpoint/legacy/DocumentationEndpoint.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rthmc/emcapi/endpoint/MudkipEndpoint.java → ...mcapi/endpoint/legacy/MudkipEndpoint.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package net.earthmc.emcapi.endpoint; | ||
| package net.earthmc.emcapi.endpoint.legacy; | ||
|
|
||
| public class MudkipEndpoint { | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/net/earthmc/emcapi/integration/QuickShopIntegration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package net.earthmc.emcapi.integration; | ||
|
|
||
| import net.earthmc.emcapi.util.EndpointUtils; | ||
| import org.maxgamer.quickshop.QuickShop; | ||
| import org.maxgamer.quickshop.api.shop.Shop; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| public class QuickShopIntegration extends Integration { | ||
|
|
||
| public QuickShopIntegration() { | ||
| super("QuickShop"); | ||
| } | ||
|
|
||
| public List<Shop> getPlayerShops(UUID player, UUID key) { | ||
| if (!isEnabled()) { | ||
| return List.of(); | ||
| } | ||
| if (!player.equals(EndpointUtils.getKeyOwner(key))) { | ||
| return List.of(); | ||
| } | ||
| return QuickShop.getInstance().getShopManager().getPlayerAllShops(player); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.