-
Notifications
You must be signed in to change notification settings - Fork 25
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
Bedrock Text + Paperweight clean setup #87
base: main
Are you sure you want to change the base?
Conversation
I would like to see this merged, it would be a very nice feature to have. |
This is still being tested by me as right now it's having some trouble figuring out if a player is on bedrock or not, once fixed we'll update the PR |
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.
Due to the nature of this PR I think this should be behind a feature flag, we don't currently have feature flags in FancyHolograms currently so it's likely that it would be pulled following the addition of them.
@@ -185,10 +186,10 @@ public final Component getShownText(@Nullable final Player player) { | |||
if (!(getData().getTypeData() instanceof TextHologramData textData)) { | |||
return null; | |||
} | |||
var text = textData.getText(); | |||
if (GeyserChecker.isGeyserPlayer(player) && !textData.getBedrockText().isEmpty()) text = textData.getBedrockText(); |
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 (GeyserChecker.isGeyserPlayer(player) && !textData.getBedrockText().isEmpty()) text = textData.getBedrockText(); | |
if (GeyserChecker.isGeyserPlayer(player) && !textData.getBedrockText().isEmpty()) { | |
text = textData.getBedrockText(); | |
} |
api/build.gradle.kts
Outdated
@@ -8,6 +8,7 @@ dependencies { | |||
compileOnly("io.papermc.paper:paper-api:${findProperty("minecraftVersion")}-R0.1-SNAPSHOT") | |||
|
|||
compileOnly("de.oliver:FancyLib:${findProperty("fancyLibVersion")}") | |||
compileOnly("org.geysermc.geyser:api:${findProperty("geyserVersion")}") |
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 am unsure if this will support all Geyser distributions - as far as I am aware this api would only work for Geyser Spigot/Paper, I would suggest depending on Floodgate instead.
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're completely dropping this detection system, instead we'll modify the config.yml and ask for bedrock player's prefixes, this is the easiest solution for everyone.
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 personally think that's a good solution, all Geyser servers should have Floodgate installed anyway so hooking into the FloodgateApi should be preferred
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 old geyser dependency can be removed now
if (player == null) return false; | ||
|
||
try { | ||
return GeyserApi.api().connectionByUuid(player.getUniqueId()) != 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.
As mentioned above, I recommend using Floodgate instead:
return GeyserApi.api().connectionByUuid(player.getUniqueId()) != null; | |
return FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId()); |
Added workflows, added geyser prefix instead of hooking because of velocity + standalone.
Unfortunately yeah some servers have floodgate installed on velocity, and then using geyser standalone so then the server would not even know if the player is a bedrock player. I don't know much about geyser so please suggest a better idea for this kinda setup |
The only solution I can think of for this PR is to use floodgate. Floodgate can (and should) be put on all backend servers, the majority of plugins that offer bedrock support will do this through floodgate, if a server owner doesn't want floodgate on their backend servers that is on them and will cause them to lose features in a handful of bedrock compatible plugins. |
I completely agree, the way of checking of the players name is not nice whatsoever. I'll make sure to revert back to floodgate and make sure that people use floodgate if they want this implementation |
ok added floodgate support
.github/workflows/maven.yml
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.
Unsure what the purpose of this action is?
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 was just a quick little thing as my Gradle crashed on my computer and I couldn't compile so I used a maven template. you can easily remove this if you'd like from this PR
api/build.gradle.kts
Outdated
@@ -8,6 +8,7 @@ dependencies { | |||
compileOnly("io.papermc.paper:paper-api:${findProperty("minecraftVersion")}-R0.1-SNAPSHOT") | |||
|
|||
compileOnly("de.oliver:FancyLib:${findProperty("fancyLibVersion")}") | |||
compileOnly("org.geysermc.geyser:api:${findProperty("geyserVersion")}") |
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 old geyser dependency can be removed now
} | ||
|
||
try { | ||
boolean b = FloodgateApi.getInstance().isFloodgateId(player.getUniqueId()); |
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.
Maybe give this parameter a more descriptive name than b
I'd suggest something like isBedrockPlayer
or even just bedrockPlayer
gradle/wrapper/gradle-wrapper.jar
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.
Any reason for removing 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.
no, I think my IDE automatically removed it from git
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 back now.
I'll have another look at this in the morning :) |
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.
Make sure to add floodgate as a dependency in the paper-plugin.yml
public static boolean isBedrockPlayer(Player player) { | ||
if (player == null) { | ||
return false; | ||
} | ||
|
||
try { | ||
return FloodgateApi.getInstance().isFloodgateId(player.getUniqueId()); | ||
} catch (Throwable ignored) { | ||
return false; | ||
} | ||
} |
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.
As we only need this for online players it would be better to use isFloodgatePlayer
there is potential that this current code wouldn't work with linked accounts.
public static boolean isBedrockPlayer(Player player) { | |
if (player == null) { | |
return false; | |
} | |
try { | |
return FloodgateApi.getInstance().isFloodgateId(player.getUniqueId()); | |
} catch (Throwable ignored) { | |
return false; | |
} | |
} | |
public static boolean isBedrockPlayer(@NotNull Player player) { | |
return FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId()); | |
} |
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.
As we only need this for online players it would be better to use
isFloodgatePlayer
there is potential that this current code wouldn't work with linked accounts.Suggested change
public static boolean isBedrockPlayer(Player player) { if (player == null) { return false; } try { return FloodgateApi.getInstance().isFloodgateId(player.getUniqueId()); } catch (Throwable ignored) { return false; } } public static boolean isBedrockPlayer(@NotNull Player player) { return FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId()); }
for some reason on testing, with a velocity server and geyser standalone with floodgate on the backend server. this was returning false when indeed the player was joined through geyser on standalone and their uuid became floodgate uuid. not sure why it was returning false.
|
||
return ModernChatColorHandler.translate(text, player); | ||
var text = textData.getText(); | ||
if (FloodgateChecker.isBedrockPlayer(player) && !textData.getBedrockText().isEmpty()) { |
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 code would currently break for servers that do not have floodgate installed, it could be worth implementing FloodgateChecker as an object that is enabled onEnable and then accessed through a getFloodgateChecker
method
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 code would currently break for servers that do not have floodgate installed, it could be worth implementing FloodgateChecker as an object that is enabled onEnable and then accessed through a
getFloodgateChecker
method
i believe this won't break, as the floodgate checker class is our own. then we use a dirty try/catch to check if the class exists in the class loader. if it errors then they don't have floodgate. this is a very dirty way and your suggestion is definitely better
This pr got me inspired to work on my placeholder plugin, it's just a basic PlaceholderAPI add-on that adds a config file for defining text that bedrock players and java players will see. I was wondering if this would be more suitable for you guys? |
i don't know why i didn't think of this from the start, in fact i think a lot of servers would benefit from this as its not just limited to the fancy holograms plugin. |
I did mention this to someone before the pr was made but I guess it didn't make it to you. Nonetheless I do believe that people would still appreciate and use this PR. |
Hello, this pull request fixes the paperweight issue of setting up the versions in multiple modules. instead setup the version once with apply false. Updated paper weight to 1.7.1
Bedrock text, server owners now may specify bedrock_text in holograms.yml, and if a player is a geyser user. it'll show this text. Please note I haven't created any command implementations, and adding, removing and inserting is still changing the base text. Maybe something like this should make it implemented to make it more completed.