First off I'd like to apologize in advance because I am most likely going to upset a lot of coders here considering my skill-level on coding..
I love to code! It really makes me happy in all honesty and I want to be able to progress and become better but I can't do it alone, at least so I think.
So here's my problem on Eclipse, it keeps telling me that there's plenty of errors all over my lines but whenever I try to fix them (in a way according to a lot of tutorials) it doesn't want to get fixed. I'm thinking that it might be the eclispe program bugging out or something like that! (Or it might just be that I am an idiot and don't know how to code, either of those two.)
So here's my coding, I'm trying to make a Plugin that welcomes a player and gives them a warm message along with some free experience points and a free item.
It has a Listener obviously and here's my coding. Please tell me what's wrong!
Main:
package me.noobpowah;
import.org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class ServerFunctions extends JavaPlugin {
@Override
public void onEnable() {
new JoinListener(this);
}
@Override
public void onDisable() {
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[ args]) {
if (cmd.getName().equalsIgnoreCase("totalexp") && sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage(ChatColor.GOLD + "Total EXP: " + player.gettotalExperience());
return true;
} else if (cmd.getName().equalsIgnoreCase("exp") && sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage(ChatColor.GOLD + "EXP to next level: " + player.getExpToLevel());
return true;
}
return false;
}
}
Listener:
package me.noobpowah;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.ChatColor;
import org.bukkit.inventory;
public class JoinListener {
public JoinListener(ServerFunctions plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onEvent(BlockPlaceEvent e) {
Player player = e.getPlayer();
e.setJoinMessage(ChatColor.AQUA + "Welcome, " + player.getName() + ", to
the server!");
//If new player
if (player.hasPlayedBefore() == false) {
player.sendMessage(ChatColor.Green + "You seem to be new here aren't
you? Here! Have a free apple as a welcome gift.");
//Adds 1 apple to the player's inventory
player.getInventory().addItem(new ItemStack(Material.APPLE, 1));
}
}
}
`