[FREE] F-TOP Payout Plugin

Status
This thread has been locked.

Connectify

Supreme
Feedback score
5
Posts
86
Reactions
19
Resources
0
Greetings, I was asked today to make this plugin for the VailMC Network, It's fairly simple so I decided to release it, Also I'm new to java so don't bash me please :p Although if you have any notes that I could use I would greatly appreciate it, Feel free to use this however you want also it would help a lot if you credit me.

Compiled: https://mega.nz/#!bphjXSIB!treGhg6FERV48oA9mVZyV6B7WUqDcyvsTx236Ih8QkU

Source-Code: https://github.com/MEConnectify/F-Top-Payout

Features:
  • Ability to set the code by doing /payout <player> <store-code>
  • The player can check the code by doing /claimpayout (GUI Based)
  • When the player has a code assigned to their account, It would notify them on join.
  • All the messages are configurable
Pictures:
87344e48f601e50aaa902487ac37e7f0.png
b0bca142065c710ff58adfc85f59ae6a.png
5220c05ffaf199765c5000afb11777e5.png
 
Last edited:
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Connectify

Supreme
Feedback score
5
Posts
86
Reactions
19
Resources
0
Not bashing you, but want to give you some constructive criticism or recommendations.

1. Change your main class name to your plugin's name. Other plugins may need to access your main class at times and it's useful for it to not just be "Main"

2. I see you construct each class with an instance of your main class. Just create a static instance of your main class and implement a static getInstance method. Some people may cry static abuse but that's just because it's what they were told over and over on Spigot. Usage of static can be very useful in certain cases. A static instance of your main class which there should only ever be one instance of is not static abuse.
Doesn't make a difference, just makes your code a bit more readable and helps people who want to hook into your plugins.

3. A constant isn't really needed for your permission beginning. But once again, personal preference.

4. Make use of ! to increase code readability and stop from having so many nested if statements.
Code:
        if (sender instanceof Player) {
            Player player = (Player) sender;

            if (player.hasPermission(Constants.GLOBAL_PERM + "payout")) {
                if (args.length == 2) {
                    Player target = Bukkit.getPlayer(args[0]);
                    if (target != null) {

                        main.getConfig().set("players." + target.getName(), args[1]);
                        main.saveConfig();
                        player.sendMessage(Constants.translate("&7You have successfully set &c" + target.getName() + " &7Store code to " + args[1]));
                    } else {
                        player.sendMessage(Constants.translate("&cTarget is currently offline."));
                    }
                } else {
                    player.sendMessage(Constants.translate("&cUsage: /Payout <name> <Store-Code>"));
                }
            } else {
                player.sendMessage(Constants.NO_PERMS);
            }
        } else {
            sender.sendMessage(Constants.PLAYER_ONLY);
        }
        return true;


Code:
        if (!(sender instanceof Player)) {
            sender.sendMessage(Constants.PLAYER_ONLY);
            return true;
        }
        Player player = (Player) sender;

        if (!player.hasPermission("ftop.payout")) {
            player.sendMessage(Constants.NO_PERMS);
            return true;
        }
          
        if (args.length < 2) {
            player.sendMessage(Constants.translate("&cUsage: /Payout <name> <Store-Code>"));
            return true;
        }
        Player target = Bukkit.getPlayer(args[0]);
      
        if (target == null) {
            player.sendMessage(Constants.translate("&cTarget is currently offline."));
        }

        main.getConfig().set("players." + target.getName(), args[1]);
        main.saveConfig();
        player.sendMessage(Constants.translate("&7You have successfully set &c" + target.getName() + " &7Store code to " + args[1]));

5. Make use of caching. You can store a list of player uuids, load them from config on startup, save them to config on disable, and some scheduled saving in between to be safe in the event of a crash occurs. And your plugin will be so much quicker.
I know it's not really needed in this case, but it's useful in the future for larger projects.

6. User configuration is key. Make those messages editable in the config. Load strings from the config and send them to the player. Your plugins will appear higher quality and appeal to more users.

Also if you're not using Maven, you should be
Thank you, I really appreciate your notes and I’ll try to consider them in my future projects.
 

Connectify

Supreme
Feedback score
5
Posts
86
Reactions
19
Resources
0
Will this be updated to add a config with messages?
Great plugin btw!
I’ll probably update it today, and Thanks :)

EDIT: All the messages are configurable now
 
Last edited:

CureMe

Java Developer
Deactivated
Feedback score
7
Posts
248
Reactions
97
Resources
0
Connectify you can click on the book and drag it out of the GUI...
upload_2019-7-15_1-10-21-png.439839
If this is true, it could be because of this line:
Code:
if (e.getInventory().getTitle().equalsIgnoreCase("Payout")) {
Instead he could check if the title contains Payout instead of equals Payout. Could be to do with bukkit's colour coding? idk don't do as much mc developemnt anymore.
 

Connectify

Supreme
Feedback score
5
Posts
86
Reactions
19
Resources
0
Connectify you can click on the book and drag it out of the GUI...
upload_2019-7-15_1-10-21-png.439839
Oh sorry about that :( I didn’t really notice, it’s currently 2am for me I’ll fix it when I get on tomorrow :D

If this is true, it could be because of this line:
Code:
if (e.getInventory().getTitle().equalsIgnoreCase("Payout")) {
Instead he could check if the title contains Payout instead of equals Payout. Could be to do with bukkit's colour coding? idk don't do as much mc developemnt anymore.
Thanks for the note, I’ll look into it.
 
Status
This thread has been locked.
Top