i’m starting in java programming and i want to make a plugin to create my own items.
I have the code but i want to import a file of java that’s in the same directory,
This is the directory:
D:.
└───com
└───src
└───me
└───frsvn
└───askyblock_boss_drops
└───commands
└───spigot.jar
└───CustomItem.java
└───CustomItemListener.java
This is the code of CustomItem.java:
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class CustomItem {
public static ItemStack createCustomItem() {
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "Custom Item");
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "This is a custom item.");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
}
This is the code of CustomItemListener.java:
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import CustomItem;
public class CustomItemListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getItem() != null && event.getItem().equals(new CustomItem().createCustomItem())) {
player.sendMessage("You interacted with the custom item!");
}
}
}
I don’t have errors compiling CustomItems.java but compiling CustomItemListener.java give me this error:
CustomItemListener.java:5: error: ‘.’ expected
import CustomItem;
^
1 error
I tried with
import com.src.me.frsvn.askyblock_boss_drops.CustomItems
But it says the package doesn’t exist
Also, I saw that the plugin needs a plugin.yml file, How’s the structure on this file and where do I create it?
I’m using spigot 1.8.8