-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a78e00c
commit 95a9a45
Showing
10 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
73 changes: 73 additions & 0 deletions
73
api/src/main/java/com/lunarclient/apollo/stats/ApolloPluginDescription.java
This file contains 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,73 @@ | ||
/* | ||
* This file is part of Apollo, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2023 Moonsworth | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* 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 | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.lunarclient.apollo.stats; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* Represents a single plugin used for stats. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Getter | ||
@Builder | ||
@ToString // TODO: remove | ||
public class ApolloPluginDescription { | ||
|
||
/** | ||
* Returns the plugin {@link String} name. | ||
* | ||
* @return the plugin name | ||
* @since 1.0.0 | ||
*/ | ||
String name; | ||
|
||
/** | ||
* Returns the plugin {@link String} description. | ||
* | ||
* @return the plugin description | ||
* @since 1.0.0 | ||
*/ | ||
String description; | ||
|
||
/** | ||
* Returns the plugin {@link List} of {@link String} authors. | ||
* | ||
* @return the plugin authors | ||
* @since 1.0.0 | ||
*/ | ||
List<String> authors; | ||
|
||
/** | ||
* Returns the plugin {@link String} version. | ||
* | ||
* @return the plugin version | ||
* @since 1.0.0 | ||
*/ | ||
String version; | ||
|
||
} |
85 changes: 85 additions & 0 deletions
85
api/src/main/java/com/lunarclient/apollo/stats/ApolloStats.java
This file contains 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,85 @@ | ||
/* | ||
* This file is part of Apollo, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2023 Moonsworth | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* 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 | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.lunarclient.apollo.stats; | ||
|
||
import java.util.List; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* Represents a player on Apollo. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface ApolloStats { | ||
|
||
/** | ||
* Gets the servers message of the day (MOTD). | ||
* | ||
* @return the servers message of the day | ||
* @since 1.0.0 | ||
*/ | ||
String getMotd(); | ||
|
||
/** | ||
* Gets the servers icon (Base64). | ||
* | ||
* @return the servers icon | ||
* @since 1.0.0 | ||
*/ | ||
String getIcon(); | ||
|
||
/** | ||
* Gets the servers version. | ||
* | ||
* @return the servers version | ||
* @since 1.0.0 | ||
*/ | ||
String getVersion(); | ||
|
||
/** | ||
* Gets the servers plugin list. | ||
* | ||
* @return the servers plugin list | ||
* @since 1.0.0 | ||
*/ | ||
List<ApolloPluginDescription> getPlugins(); | ||
|
||
/** | ||
* Gets the servers platform type (Bukkit, BungeeCord, Velocity...). | ||
* | ||
* @return the servers platform type | ||
* @since 1.0.0 | ||
*/ | ||
String getPlatformType(); | ||
|
||
/** | ||
* Gets the servers platform version. | ||
* | ||
* @return the servers platform version | ||
* @since 1.0.0 | ||
*/ | ||
String getPlatformVersion(); | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
api/src/main/java/com/lunarclient/apollo/stats/ApolloStatsManager.java
This file contains 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,66 @@ | ||
/* | ||
* This file is part of Apollo, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2023 Moonsworth | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* 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 | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.lunarclient.apollo.stats; | ||
|
||
import com.lunarclient.apollo.Apollo; | ||
import com.lunarclient.apollo.option.Option; | ||
import com.lunarclient.apollo.option.SimpleOption; | ||
import io.leangen.geantyref.TypeToken; | ||
|
||
/** | ||
* Manages Apollo statistics. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public final class ApolloStatsManager { | ||
|
||
private static final String CONFIG_PREFIX = "mcstats"; | ||
|
||
public static final SimpleOption<Boolean> SERVER_IP = Option.<Boolean>builder() | ||
.comment("Set to 'true' to send your server IP address to MCStats, otherwise 'false'.") | ||
.node(CONFIG_PREFIX + "server-address").type(TypeToken.get(Boolean.class)) | ||
.defaultValue(true).build(); | ||
|
||
/** | ||
* Constructs the {@link ApolloStatsManager}. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public ApolloStatsManager() { | ||
this.handleServerStartStats(); | ||
} | ||
|
||
private void handleServerStartStats() { | ||
ApolloStats stats = Apollo.getPlatform().getStats(); | ||
|
||
// Request | ||
System.out.println(stats.getMotd()); | ||
System.out.println(stats.getIcon()); | ||
System.out.println(stats.getVersion()); | ||
System.out.println(stats.getPlugins()); | ||
System.out.println(stats.getPlatformType()); | ||
System.out.println(stats.getPlatformVersion()); | ||
} | ||
|
||
} |
This file contains 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
Oops, something went wrong.