kangarko / Foundation

Foundation™ helps you create highly customized Minecraft plugins (based on Spigot/Paper API) that support multiple MC versions.
https://mineacademy.org
329 stars 63 forks source link

1.20.6: Plugin not registering on startup/reload. #304

Closed CaptnLucid closed 2 months ago

CaptnLucid commented 2 months ago

To report a problem or a bug with this library, please follow the three steps below:

1) 1.20.6: Plugin not registering on startup/reload.

2) Plugin not loading on server start/reload.

3) https://pastebin.com/2acd1RuH

Converted my barebones plugin with only one command over to Foundation. Changed JavaPlugin to SimplePlugin, onEnable to onPluginStart, onDisable to onPluginStop, and updated my singular command to extend SimpleCommand. Everything was working fine creating the plugin the default way. I have followed the proper implementation listed for the Repository and Dependency, as well as the Shading.

CaptnLucid commented 2 months ago

After some further investigation, it seems as though the shading you have in the README.md is incorrect, as following the video guide from 2 months partially solved the issue.

It should be com.github.kangarko:Foundation* instead of com.kangarko.github:Foundation*

Atlease, to get it to work for me that is. However, I have noticed something new. It's now placing a lib folder inside my plugin folder. Is that intended? And the lib folder has both a /com and /org folder inside of it, which makes this seem a little counterproductive, unless it's intended to operate that way.

Now, something else I was wanting to achieve, since I am currently able to get it to function, is to be able to use custom permission handling. I have noticed ingame that there's a custom check given by SimpleCommand. Is there any way to use my own?

Thank you for your assistance with these inquires.

Edit: Accidentally clicked "Close with Comment". Disregard that 😄

broken1arrow commented 2 months ago

After some further investigation, it seems as though the shading you have in the README.md is incorrect, as following the video guide from 2 months partially solved the issue.

It should be com.github.kangarko:Foundation* instead of com.kangarko.github:Foundation*

Atlease, to get it to work for me that is. However, I have noticed something new. It's now placing a lib folder inside my plugin folder. Is that intended? And the lib folder has both a /com and /org folder inside of it, which makes this seem a little counterproductive, unless it's intended to operate that way.

Now, something else I was wanting to achieve, since I am currently able to get it to function, is to be able to use custom permission handling. I have noticed ingame that there's a custom check given by SimpleCommand. Is there any way to use my own?

Thank you for your assistance with these inquires.

Edit: Accidentally clicked "Close with Comment". Disregard that 😄

I think you have setPermission option or should have.

CaptnLucid commented 2 months ago

After some further investigation, it seems as though the shading you have in the README.md is incorrect, as following the video guide from 2 months partially solved the issue. It should be com.github.kangarko:Foundation* instead of com.kangarko.github:Foundation* Atlease, to get it to work for me that is. However, I have noticed something new. It's now placing a lib folder inside my plugin folder. Is that intended? And the lib folder has both a /com and /org folder inside of it, which makes this seem a little counterproductive, unless it's intended to operate that way. Now, something else I was wanting to achieve, since I am currently able to get it to function, is to be able to use custom permission handling. I have noticed ingame that there's a custom check given by SimpleCommand. Is there any way to use my own? Thank you for your assistance with these inquires. Edit: Accidentally clicked "Close with Comment". Disregard that 😄

I think you have setPermission option or should have.

Correct, I do, and from looking into the Source for Foundation, it seems as though a localization/messages_LOCALEPREFIX.yml file is supposed to be created for this, according to src/main/java/org/mineacademy/fo/settings/SimpleLocalization.java, however that is not the case. Instead, like I mentioned above, the only thing being created is a lib subfolder, with two other subfolders, that have their own subfolders.

broken1arrow commented 2 months ago

Yeah but in the command class you created yourself should you have that option.

But did he remove that option?

CaptnLucid commented 2 months ago

Yeah but in the command class you created yourself should you have that option.

But did he remove that option?

public ClearChatCommand() {
        super("clearchat|cc");
        setPermission("command.clearchat");
        setMinArguments(0);
        setUsage("[-silent]");

    }

this is what I have where it'd be placed, however, if I have setPermission empty or deleted, it gives a custom Insufficient Permission line ingame. If I set it to null, it doesn't use my custom coded permission checking.

broken1arrow commented 2 months ago

What custom permission check do you using?

CaptnLucid commented 2 months ago

What custom permission check do you using?

if (!sender.hasPermission("plugin.clearchat")) {
            tell("<b><gradient:dark_red:red>plugin</b> <dark_gray>» <red>You don't have permission to use this command.</red>");
            return;
        }

        boolean silent = args.length > 0 && args[0].equalsIgnoreCase("-silent");

        if (silent && !sender.hasPermission("plugin.clearchat.silent")) {
            tell("<b><gradient:dark_red:red>plugin</b> <dark_gray>» <red>You don't have permission to use the <yellow>-silent</yellow> option.</red>");
            return;
        }

I just tested this again by setting setPermission to null and also by removing it entirely from the super, and I get [✕] Insufficient permission (plugin.command.clearchat). as a response ingame.

broken1arrow commented 2 months ago

You don't need do #haspermission() I think it had before some bypass for this. But you could try empty string or " " to see if that could be a bypass.

Other way is give all player a base permission and then do your own permission check and that includes the tab complete. That can you set up in plugin.yml and set that to true.

CaptnLucid commented 2 months ago

You don't need do #haspermission() I think it had before some bypass for this. But you could try empty string or " " to see if that could be a bypass.

Other way is give all player a base permission and then do your own permission check and that includes the tab complete. That can you set up in plugin.yml and set that to true.

if I do " ", it instead gives the same error, with the permission plugin.command.clearchat.

I'm trying to use my own permission check, that's the thing, I'm just struggling trying to figure out how to do it with SimpleCommand.

I'm also still running into the issue where there's a lib folder in my plugin folder, unsure still if that's intentional or not.

broken1arrow commented 2 months ago

You don't need do #haspermission() I think it had before some bypass for this. But you could try empty string or " " to see if that could be a bypass. Other way is give all player a base permission and then do your own permission check and that includes the tab complete. That can you set up in plugin.yml and set that to true.

if I do " ", it instead gives the same error, with the permission plugin.command.clearchat.

I'm trying to use my own permission check, that's the thing, I'm just struggling trying to figure out how to do it with SimpleCommand.

I'm also still running into the issue where there's a lib folder in my plugin folder, unsure still if that's intentional or not.

Just do in plugin.yml and setPermission("plugin.base.clearchat"); all players will have the base permission and you can do your own check.

permissions:
  plugin.base.clearchat:
    description: Allow players to use base things in the plugin.
    default: true
CaptnLucid commented 2 months ago

I'm still trying to achieve my own custom formatting as well though. I can absolutely achieve what you're recommending, but I would like if possible to be able to format my own Insufficient Permissions response

broken1arrow commented 2 months ago

I'm still trying to achieve my own custom formatting as well though. I can absolutely achieve what you're recommending, but I would like if possible to be able to format my own Insufficient Permissions response

Just copy what foundation has as error message too your own logic. If you only want to change the message I think have something like setPermissionMessage or something similar.

broken1arrow commented 2 months ago

I personally just don't use that function in foundation when it don't offer what I need in customization.

kangarko commented 2 months ago

Hello!

It should be com.github.kangarko:Foundation* instead of com.kangarko.github:Foundation*

Thank you for pointing out to my oversight. I have updated the docs!

The libs folder is a temporary thing for loading some of the libraries we need, similarly to LuckPerms. It will be deleted in Foundation 7 as we since moved away to storing libraries in the root libraries/ folder.

Regarding the SimpleCommand#setPermission() function, I recommend you keep using it. To customize the no permissions message, you need to make a "localization" folder with a file messages_en.yml in it in your src/main/resources folder in the source code of your plugin. We'll take care of the rest and move it to your plugin folder for you.

Thanks to Michael for answering, but I prefer adjusting Foundation to fit users need instead of you needing to use your own function, so just let me know how you'd like to use it and we'll see what we can do.

Thanks Matej

broken1arrow commented 2 months ago

Hello!

It should be com.github.kangarko:Foundation* instead of com.kangarko.github:Foundation*

Thank you for pointing out to my oversight. I have updated the docs!

The libs folder is a temporary thing for loading some of the libraries we need, similarly to LuckPerms. It will be deleted in Foundation 7 as we since moved away to storing libraries in the root libraries/ folder.

Regarding the SimpleCommand#setPermission() function, I recommend you keep using it. To customize the no permissions message, you need to make a "localization" folder with a file messages_en.yml in it in your src/main/resources folder in the source code of your plugin. We'll take care of the rest and move it to your plugin folder for you.

Thanks to Michael for answering, but I prefer adjusting Foundation to fit users need instead of you needing to use your own function, so just let me know how you'd like to use it and we'll see what we can do.

Thanks Matej

Did not foundation had before so you could alter the permission message in the code (I'm pretty sure that existed)?

CaptnLucid commented 2 months ago

Regarding the SimpleCommand#setPermission() function, I recommend you keep using it. To customize the no permissions message, you need to make a "localization" folder with a file messages_en.yml in it in your src/main/resources folder in the source code of your plugin. We'll take care of the rest and move it to your plugin folder for you.

Okay, I'll give that a try. As for the entire formatting you have implemented by Default, from looking at the SimpleLocalization.java, it seems as though the only portion that gets any formatting is public static String NO_PERMISSION = "&cInsufficient permission ({permission}).";

As I've shown above, there is a [✕] at the beginning. Is there a way to change that, or is that hardcoded? If hardcoded, that's fine, I can work with it!

kangarko commented 2 months ago

The X at the beginning is coming from Prefix.Error part of the localization. You can set that to "" or "none" to completely get rid of that and then manually write it where you feel it's appropriate. It's shown in all error-related messages like the no permission's one.

As Michael says, I believe you can use setPermissionMessage() to make a custom no perm message per command that will take priority over the locale.

CaptnLucid commented 2 months ago

The X at the beginning is coming from Prefix.Error part of the localization. You can set that to "" or "none" to completely get rid of that and then manually write it where you feel it's appropriate. It's shown in all error-related messages like the no permission's one.

As Michael says, I believe you can use setPermissionMessage() to make a custom no perm message per command that will take priority over the locale.

Sorry for the late reply, but upon checking the SimpleLocalization.java and also attempting 3 different variations for the prefix in messages_en.yml, it's still there.

I did however get the custom No_Permission: to work, I just mistyped it originally, but now that prefix is messing with me a bit.

kangarko commented 2 months ago

Happy to hear it got solved! I will double check your report in the next foundation update.