Hey! I just wrote a plugin and I can't for the life of me find anywhere that tells me how to compile it (in simple terms) Can anyone link a place, or compile it for me? thanks! Code: import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJumpEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import java.util.HashSet; import java.util.Random; import java.util.Set; public class JumpRandomItem extends JavaPlugin implements Listener { private final Set<Material> excludedItems = new HashSet<>(); private double stackChance = 0.1; @Override public void onEnable() { // Register the plugin's listener getServer().getPluginManager().registerEvents(this, this); } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (command.getName().equalsIgnoreCase("excludeitem") && sender instanceof Player && sender.isOp()) { if (args.length != 1) { sender.sendMessage("Usage: /excludeitem <material>"); return true; } Material material = Material.getMaterial(args[0].toUpperCase()); if (material == null) { sender.sendMessage("Invalid material: " + args[0]); return true; } excludedItems.add(material); sender.sendMessage("Excluded item: " + material.toString()); return true; } if (command.getName().equalsIgnoreCase("changestackchance") && sender instanceof Player && sender.isOp()) { if (args.length != 1) { sender.sendMessage("Usage: /changestackchance <chance>"); return true; } try { double chance = Double.parseDouble(args[0]); if (chance < 0 || chance > 1) { sender.sendMessage("Chance must be between 0 and 1"); return true; } stackChance = chance; sender.sendMessage("Stack chance set to: " + chance); } catch (NumberFormatException e) { sender.sendMessage("Invalid chance: " + args[0]); } return true; } return false; } @EventHandler public void onPlayerJump(PlayerJumpEvent event) { // Get the player who jumped Player player = event.getPlayer(); // Create a new random instance Random random = new Random(); // Get a random material for the item Material material; do { material = Material.values()[random.nextInt(Material.values().length)]; } while (excludedItems.contains(material)); // Determine the quantity of the item to give int quantity = random.nextInt(64) + 1; // Roll for a second stack with the configured chance if (random.nextDouble() < stackChance) { quantity += 64; } // Create a new ItemStack with the random material and quantity ItemStack item = new ItemStack(material, quantity); // Give the item to the player player.getInventory().addItem(item); } }
Then I am impressed by the flawless code you have going on there. https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
nothing worked everything broke, i had 3 constant errors i couldnt get rid of and i couldnt make a damn class anywhere
I wish ChatGPT would learn that ThreadLocalRandom exists. It keeps telling people to make new Random instances, when you don't need to.