Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.gamingod.BukkitCoding;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.Listener;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener {
- @Override
- public void onEnable() {
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- }
- //The Command
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- //Checking if they are a player
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "Only players can do this!");
- return true;
- }
- //If the command is /tutorial
- if (cmd.getName().equalsIgnoreCase("tutorial")) {
- Player p = (Player) sender;
- p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "IT WORKS!");
- p.setDisplayName(ChatColor.LIGHT_PURPLE + p.getName() + ChatColor.RESET);
- p.setPlayerListName(ChatColor.LIGHT_PURPLE + p.getName() + ChatColor.RESET);
- }
- //If the command is /commandtwo
- if (cmd.getName().equalsIgnoreCase("commandtwo")) {
- Player p = (Player) sender;
- //If there are no args
- if (args.length == 0) {
- p.sendMessage(ChatColor.RED + "Usage: /commandtwo <true|false>");
- //If there is one argument
- } else if (args.length == 1) {
- //If the command is /commandtwo true
- if (args[0].equalsIgnoreCase("true")) {
- p.sendMessage("commandtwo is now a true");
- //If the command is /comandtwo false
- } else if (args[0].equalsIgnoreCase("false")) {
- p.sendMessage("commandtwo is now false");
- } else {
- //If the command is /commandtwo <anything>
- p.sendMessage(ChatColor.RED + "Usage: /commandtwo <true|false>");
- }
- } else {
- //Two or more arguments
- p.sendMessage(ChatColor.RED + "Usage: /commandtwo <true|false>");
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement