I'm still a beginner in programming Minecraft plugins and just trying to make a trash can.
Here are the source codes:
Main:
package de.darius.muell.main;
import org.bukkit.plugin.java.JavaPlugin;
import de.darius.muell.commands.AbfallCommand;
import de.darius.muell.commands.HelpCommand;
public class Main extends JavaPlugin {
public void onEnable () {
getCommand ("waste help") setExecutor (new HelpCommand ());
getCommand ("trash"). SetExecutor (new TrashCommand ());
}
}
Waste Command:
package de.darius.muell.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
public class WasteCommand implements CommandExecutor {
@Override
public boolean onCommand (CommandSender sender, Command cmd, String label, String [] args) {
if (sender instanceof Player) {
Player p = (player) transmitter;
if (p.hasPermission ("muell.open")) {
if (args.length == 0) {
Inventory inventory = Bukkit.createInventory (null, 93, "§4§§Waste");
p.openInventory (inventory);
p.sendMessage ("§7 [§4§lAbfall§7] §3§oThe inventory has been opened!");
}
else
p.sendMessage ("§7 [§4§lAbfall§7] §7Please use §8§l / Abfall §7.");
}
else
p.sendMessage ("§7 [§4§lAbfall§7] §7Do you have §§§§§ine rights");
}
return false;
}
}
HelpCommand:
package de.darius.muell.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class HelpCommand implements CommandExecutor {
@Override
public boolean onCommand (CommandSender sender, Command cmd, String label, String [] args) {
Player p = (player) transmitter;
p.sendMessage ("§7 [§4§lWaste§7] \ n §7 ------------------------------- ---- \ n§e§oYou can get rid of your garbage. \ n§7 ------------------------------- ---- ");
return false;
}
}
Plugin.yml:
name: waste
author: Darius
version: 1.0
main: de.darius.muell.main.Main
commands:
Waste help:
description: Invokes help for this plugin.
waste:
description: Opens the dustbin.
Can you check it once?
A command must not contain a word spacing.
Normal whites are returned with a command, if used correctly true.
Otherwise the code should be executable.
Okay I'll try it out.