-
Notifications
You must be signed in to change notification settings - Fork 73
Add Velocity Support #766
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
Add Velocity Support #766
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
12e5227
Velocity somewhat working (ALPHA) release
proferabg 22fc3a9
Remove Un-ported Example
proferabg 7aa6e6b
Remove Waterfall-Compat dependency
proferabg 501394d
Move ChatUtil and add in unicode.txt
proferabg 8b6be73
Fix some formatting and refactoring
proferabg 404e0f9
Fix Redis Server ID
proferabg 62590b4
Fix Packet Listener and target java 11 like Velocity
proferabg 0f1839c
Remove SortingRuleAliasProcessor + Add Team Packet Registration
proferabg 3bbc797
Remove deprecated API functions
proferabg f52e89b
Fix Compile Errors
proferabg 5258dad
Merge remote-tracking branch 'origin-original/dev' into dev
proferabg 1833ee5
Update Velocity to 1.20.1
proferabg d117a13
Update minecraft-data-api version
proferabg f1ba70d
Update Submodules
proferabg 74f91a0
Merge remote-tracking branch 'upstream/master' into dev
proferabg 326b399
Updated but not tested
proferabg d1b686d
Working? Seriously?
proferabg 5d8e941
Fix github workflow
proferabg 10d61aa
Make all projects build with JDK 8, make Bungee build with JDK 16, an…
proferabg 52618b0
Make Velocity build without jar library
proferabg f8e469b
Update submodule
proferabg 766a309
Update Submodules
proferabg 17d6326
Remove check for plugin.
proferabg 0486694
Copyrights, Velocity Metrics, and Team Packet Mode Enum
proferabg 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
Submodule TabOverlayCommon
updated
3 files
| +3 −2 | build.gradle | |
| +5 −1 | config/build.gradle | |
| +1 −1 | gradle/wrapper/gradle-wrapper.properties |
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 @@ | ||
|
|
||
| dependencies { | ||
| compileOnly "com.velocitypowered:velocity-api:${rootProject.ext.velocityVersion}" | ||
| annotationProcessor "com.velocitypowered:velocity-api:${rootProject.ext.velocityVersion}" | ||
| api "de.codecrafter47.taboverlay:taboverlaycommon-api:1.0-SNAPSHOT" | ||
| } | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion.set(JavaLanguageVersion.of(17)) | ||
| } | ||
| } | ||
|
|
||
| java { | ||
| withJavadocJar() | ||
| withSourcesJar() | ||
| } | ||
|
|
||
| publishing { | ||
| publications { | ||
| maven(MavenPublication) { | ||
| from(components.java) | ||
| } | ||
| } | ||
| } |
144 changes: 144 additions & 0 deletions
144
...city/src/main/java/codecrafter47/bungeetablistplus/api/velocity/BungeeTabListPlusAPI.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,144 @@ | ||
| /* | ||
| * Copyright (C) 2025 proferabg | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package codecrafter47.bungeetablistplus.api.velocity; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.velocitypowered.api.proxy.Player; | ||
| import de.codecrafter47.taboverlay.TabView; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
| import java.awt.image.BufferedImage; | ||
| import java.util.concurrent.CompletableFuture; | ||
|
|
||
| public abstract class BungeeTabListPlusAPI { | ||
| private static BungeeTabListPlusAPI instance = null; | ||
|
|
||
| /** | ||
| * Registers a custom variable | ||
| * <p> | ||
| * You cannot use this to replace existing variables. If registering a variable which already | ||
| * exists there may be an exception thrown but there is no guarantee that an exception | ||
| * is thrown in that case. | ||
| * | ||
| * @param plugin your plugin | ||
| * @param variable your variable | ||
| */ | ||
| public static void registerVariable(Object plugin, Variable variable) { | ||
| Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); | ||
| instance.registerVariable0(plugin, variable); | ||
| } | ||
|
|
||
| protected abstract void registerVariable0(Object plugin, Variable variable); | ||
|
|
||
| /** | ||
| * Registers a custom variable bound to a specific server | ||
| * <p> | ||
| * You cannot use this to replace existing variables. If registering a variable which already | ||
| * exists there may be an exception thrown but there is no guarantee that an exception | ||
| * is thrown in that case. | ||
| * | ||
| * @param plugin your plugin | ||
| * @param variable your variable | ||
| */ | ||
| public static void registerVariable(Object plugin, ServerVariable variable) { | ||
| Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); | ||
| instance.registerVariable0(plugin, variable); | ||
| } | ||
|
|
||
| protected abstract void registerVariable0(Object plugin, ServerVariable variable); | ||
|
|
||
| /** | ||
| * Get the face part of the players skin as an icon for use in the tab list. | ||
| * | ||
| * @param player the player | ||
| * @return the icon | ||
| */ | ||
| @Nonnull | ||
| public static de.codecrafter47.taboverlay.Icon getPlayerIcon(Player player) { | ||
| Preconditions.checkState(instance != null, "BungeeTabListPlus not initialized"); | ||
| return instance.getPlayerIcon0(player); | ||
| } | ||
|
|
||
| @Nonnull | ||
| protected abstract de.codecrafter47.taboverlay.Icon getPlayerIcon0(Player player); | ||
|
|
||
|
|
||
| /** | ||
| * Creates an icon from an 8x8 px image. The creation of the icon can take several | ||
| * minutes. When the icon has been created the callback is invoked. | ||
| * | ||
| * @param image the image | ||
| * @return a completable future providing the icon is ready | ||
| */ | ||
| public static CompletableFuture<de.codecrafter47.taboverlay.Icon> getIconFromImage(BufferedImage image) { | ||
| Preconditions.checkState(instance != null, "BungeeTabListPlus not initialized"); | ||
| return instance.getIconFromImage0(image); | ||
| } | ||
|
|
||
| protected abstract CompletableFuture<de.codecrafter47.taboverlay.Icon> getIconFromImage0(BufferedImage image); | ||
|
|
||
| /** | ||
| * Get the tab view of a player. The tab view object allows registering and unregistering custom tab overlay | ||
| * handlers. | ||
| * | ||
| * @param player the player | ||
| * @return tab view of that player | ||
| * @throws IllegalStateException is the player is not found | ||
| * @see TabView | ||
| * @see de.codecrafter47.taboverlay.TabOverlayProviderSet | ||
| * @see de.codecrafter47.taboverlay.TabOverlayProvider | ||
| * @see de.codecrafter47.taboverlay.AbstractPlayerTabOverlayProvider | ||
| */ | ||
| public static TabView getTabViewForPlayer(Player player) { | ||
| Preconditions.checkState(instance != null, "BungeeTabListPlus not initialized"); | ||
| return instance.getTabViewForPlayer0(player); | ||
| } | ||
|
|
||
| protected abstract TabView getTabViewForPlayer0(Player player); | ||
|
|
||
| /** | ||
| * Get the FakePlayerManager instance | ||
| * | ||
| * @return the FakePlayerManager instance | ||
| */ | ||
| public static FakePlayerManager getFakePlayerManager() { | ||
| Preconditions.checkState(instance != null, "BungeeTabListPlus not initialized"); | ||
| return instance.getFakePlayerManager0(); | ||
| } | ||
|
|
||
| protected abstract FakePlayerManager getFakePlayerManager0(); | ||
|
|
||
| /** | ||
| * Check if a player is hidden from the tab list. | ||
| * <p> | ||
| * A player is regarded as hidden if one of the following conditions is true: | ||
| * - The player is hidden using a vanish plugin(e.g. SuperVanish, Essentials, ...) | ||
| * - The player has been hidden using the /btlp hide command | ||
| * - The player is in the list of hidden players in the configuration | ||
| * - The player is on one of the hidden servers(configuration) | ||
| * | ||
| * @param player the player | ||
| * @return true if hidden, false otherwise | ||
| */ | ||
| public static boolean isHidden(Player player) { | ||
| Preconditions.checkState(instance != null, "BungeeTabListPlus not initialized"); | ||
| return instance.isHidden0(player); | ||
| } | ||
|
|
||
| protected abstract boolean isHidden0(Player player); | ||
| } |
64 changes: 64 additions & 0 deletions
64
...elocity/src/main/java/codecrafter47/bungeetablistplus/api/velocity/FakePlayerManager.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,64 @@ | ||
| /* | ||
| * Copyright (C) 2025 proferabg | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package codecrafter47.bungeetablistplus.api.velocity; | ||
|
|
||
| import codecrafter47.bungeetablistplus.api.velocity.tablist.FakePlayer; | ||
| import com.velocitypowered.api.proxy.server.ServerInfo; | ||
|
|
||
| import java.util.Collection; | ||
|
|
||
| /** | ||
| * Controls fake players | ||
| */ | ||
| public interface FakePlayerManager { | ||
|
|
||
| /** | ||
| * Get all fake players which are currently displayed on the tab list | ||
| * | ||
| * @return collection of all fake players | ||
| */ | ||
| Collection<FakePlayer> getOnlineFakePlayers(); | ||
|
|
||
| /** | ||
| * @return whether the plugin will randomly add fake players it finds in the config, and randomly removes fake players | ||
| */ | ||
| boolean isRandomJoinLeaveEnabled(); | ||
|
|
||
| /** | ||
| * set whether the plugin should randomly add fake players it finds in the config, and randomly removes fake players | ||
| * | ||
| * @param value whether random join/leave events for fake players should be enabled | ||
| */ | ||
| void setRandomJoinLeaveEnabled(boolean value); | ||
|
|
||
| /** | ||
| * Creates a fake player which is immediately visible on the tab list | ||
| * | ||
| * @param name name of the fake player | ||
| * @param server server of the fake player | ||
| * @return the fake player | ||
| */ | ||
| FakePlayer createFakePlayer(String name, ServerInfo server); | ||
|
|
||
| /** | ||
| * remove a fake player | ||
| * | ||
| * @param fakePlayer the fake player to be removed | ||
| */ | ||
| void removeFakePlayer(FakePlayer fakePlayer); | ||
| } |
42 changes: 42 additions & 0 deletions
42
api-velocity/src/main/java/codecrafter47/bungeetablistplus/api/velocity/Icon.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,42 @@ | ||
| /* | ||
| * Copyright (C) 2025 proferabg | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package codecrafter47.bungeetablistplus.api.velocity; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.NonNull; | ||
|
|
||
| import java.io.Serializable; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * An icon shown in the tab list. | ||
| */ | ||
| @Data | ||
| public class Icon implements Serializable { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private final UUID player; | ||
| @NonNull | ||
| private final String[][] properties; | ||
|
|
||
| /** | ||
| * The default icon. The client will show a random Alex/ Steve face when using this. | ||
| */ | ||
| public static final Icon DEFAULT = new Icon(null, new String[0][]); | ||
| } |
65 changes: 65 additions & 0 deletions
65
api-velocity/src/main/java/codecrafter47/bungeetablistplus/api/velocity/ServerVariable.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,65 @@ | ||
| /* | ||
| * Copyright (C) 2025 proferabg | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package codecrafter47.bungeetablistplus.api.velocity; | ||
|
|
||
| /** | ||
| * Base class for creating custom Variables bound to a server. | ||
| * <p> | ||
| * To create a custom (per server) Variable you need to create a subclass of this class | ||
| * and register an instance of it with {@link BungeeTabListPlusAPI#registerVariable} | ||
| * <p> | ||
| * After registration the variable can be used in the config file in several ways: | ||
| * Use {@code ${viewer server <name>}} to resolve the variable for the server of the | ||
| * player looking at the tab list. | ||
| * Use {@code ${player server <name>}} to resolve the variable for the server of a | ||
| * player displayed on the tab list, this one can only be used inside the playerComponent. | ||
| * Use {@code ${server <name>}} to resolve the variable for a particular server inside the | ||
| * serverHeader option of the players by server component. | ||
| * Use {@code ${server:<serverName> <name>}} to resolve the variable for a specific server. | ||
| */ | ||
| public abstract class ServerVariable { | ||
| private final String name; | ||
|
|
||
| /** | ||
| * invoked by the subclass to set the name of the variable | ||
| * | ||
| * @param name name of the variable without { } | ||
| */ | ||
| public ServerVariable(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| /** | ||
| * This method is periodically invoked by BungeeTabListPlus to check whether the replacement for the variable changed. | ||
| * <p> | ||
| * The implementation is expected to be thread safe. | ||
| * | ||
| * @param serverName name of the server for which the variable should be replaced | ||
| * @return the replacement for the variable | ||
| */ | ||
| public abstract String getReplacement(String serverName); | ||
|
|
||
| /** | ||
| * Getter for the variable name. | ||
| * | ||
| * @return the name of the variable | ||
| */ | ||
| public final String getName() { | ||
| return name; | ||
| } | ||
| } |
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.
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.
While probably not necessary, it could be good to update this to v4, because... why should it stay on v2?
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.
This can be changed if we want to use v4. Left it at v2 to minimize changes