Skip to content
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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

Olzie-12
Copy link

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.

@Antbrix
Copy link

Antbrix commented May 15, 2024

I would like to see this merged, it would be a very nice feature to have.

@Agaloth
Copy link

Agaloth commented May 15, 2024

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

@OakLoaf OakLoaf self-requested a review May 16, 2024 09:58
Copy link
Contributor

@OakLoaf OakLoaf left a 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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (GeyserChecker.isGeyserPlayer(player) && !textData.getBedrockText().isEmpty()) text = textData.getBedrockText();
if (GeyserChecker.isGeyserPlayer(player) && !textData.getBedrockText().isEmpty()) {
text = textData.getBedrockText();
}

@@ -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")}")
Copy link
Contributor

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.

Copy link

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.

Copy link
Contributor

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

Copy link
Contributor

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;
Copy link
Contributor

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:

Suggested change
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.
@Olzie-12
Copy link
Author

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

@OakLoaf
Copy link
Contributor

OakLoaf commented May 16, 2024

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.

@Olzie-12
Copy link
Author

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

Copy link
Contributor

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?

Copy link
Author

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

@@ -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")}")
Copy link
Contributor

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());
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its back now.

@OakLoaf
Copy link
Contributor

OakLoaf commented May 16, 2024

I'll have another look at this in the morning :)

Copy link
Contributor

@OakLoaf OakLoaf left a 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

Comment on lines +8 to +18
public static boolean isBedrockPlayer(Player player) {
if (player == null) {
return false;
}

try {
return FloodgateApi.getInstance().isFloodgateId(player.getUniqueId());
} catch (Throwable ignored) {
return false;
}
}
Copy link
Contributor

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());
}

Copy link
Author

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()) {
Copy link
Contributor

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

Copy link
Author

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

@OakLoaf
Copy link
Contributor

OakLoaf commented May 17, 2024

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?

@Olzie-12
Copy link
Author

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.

@OakLoaf
Copy link
Contributor

OakLoaf commented May 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants