Basic Healing Plugin | Looking for vouches!

Status
This thread has been locked.

SmittyINC

Feedback score
0
Posts
62
Reactions
16
Resources
0
Hey whats up guys, I'm back!

It's been a while, and I've realized I need to get more vouches. I have coded a basic healing plugin that allows you to heal yourself, and a target player. There is no permissions but if you guys want some I would gladly change the code for you. I will provide the link for the download and a link to the paste bin so you could create the plugin and add/remove things that you don't like. Please remember, I'm not an experienced coder, but I know this plugin works the way it should. If you have any advice for me on my code then I'm all ears. Also, If you could vouch that would be greatly appreciated! Enjoy.

PasteBin:


DropBox download:
https://www.dropbox.com/s/iwmtwidgwavp2i7/Healing.jar?dl=0
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

TheNewTao

Java Developer
Premium
Feedback score
0
Posts
654
Reactions
274
Resources
0
Looks great :) just two things, you can't assume the sender is a player, you should always check if the sender is a player before casting it. Also, you don't have to log that the plugin is enabled, it is already done for you. Your indentation seems a bit off as well. However, you did a great job!
 

SmittyINC

Feedback score
0
Posts
62
Reactions
16
Resources
0
Looks great :) just two things, you can't assume the sender is a player, you should always check if the sender is a player before casting it. Also, you don't have to log that the plugin is enabled, it is already done for you. Your indentation seems a bit off as well. However, you did a great job!

Thank you! I greatly appreciate your advice, as you are a very renowned Java Developer it seems. I will fix this, and I did it before it was something along the lines of this:

if(!(sender instanceof Player)) {
sender.sendMessage(Only players can execute this command);
}

Corrected!
 
Last edited:

SmittyINC

Feedback score
0
Posts
62
Reactions
16
Resources
0
There really is no reason to instantiate the plugin description and logger twice nor is there a reason to output to console that your plugin has been enabled. Bukkit/Spigot already outputs a message to console so you are basically sending the same message twice. The only reason you should output to console is if you have something important to tell the server owner (i.e. "5 kits loaded!").

You need to check if the target player is null before operating on the variable. With your code right now, there will be a null pointer exception if the player is offline.


No. That is checking if a variable is equal to a variable. If you are trying to see if an object is an instance of a Player you do this:

PHP:
if(!(sender instanceof Player)) //Remember that "Player" is representing the class here.
{
  //sender is not a player
  //be sure to have a return; statement here to prevent the code from going any further
}

Thank you, I have fixed it in my post above. Also, I did not know that bukkit/Spigot already outputs the enable/disable, will fix code in next plugin.
 

SmittyINC

Feedback score
0
Posts
62
Reactions
16
Resources
0
hey dude if you want to help out with a server im working on add me on skype: fazio23

we are making a star wars server, theres a lot to it so if you want to know more add me on skype. Also we need custom plugins and we already have one developer but we need more to help us.
Hey, I would love to help. Please add me: dansmith496. I tried adding you but there are many fazio23's. Sorry for the inconvenience.
 
Status
This thread has been locked.
Top