How to Create Command Expansions
-
This page is going to teach you how to create command expansions for Minecord, which directly handling command "minecord" will not work. Currently Minecord only supports 1 command expansion at the same time, but multiple command expansions support will be added in the future.
First, create a class that implements com.rcextract.minecord.CommandExpansion:
Code (Java):package me.rcextract;
import com.rcextract.minecord.CommandExpansion;
public class Example implements CommandExpansion {
}
Then, create a method of any name with return type as boolean, which lets Bukkit determine the completion of command, and argument types are CommandSender and String[], which CommandSender is the command sender, and String[] is an array of arguments:
Code (Java):package me.rcextract;
import com.rcextract.minecord.CommandExpansion;
import org.bukkit.command.CommandSender;
public class Example implements CommandExpansion {
public boolean onDisable(CommandSender sender, String[] args) {
return true;
}
}
Code (Java):package me.rcextract;
import com.rcextract.minecord.CommandExpansion;
import com.rcextract.minecord.CommandHandler;
import org.bukkit.command.CommandSender;
public class Example implements CommandExpansion {
@CommandHandler("disable")
public boolean onDisable(CommandSender sender, String[] args) {
return true;
}
}
Code (Java):package me.rcextract;
import com.rcextract.minecord.CommandExpansion;
import com.rcextract.minecord.CommandHandler;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginManager;
import org.bukkit.ChatColor;
public class Example implements CommandExpansion {
@CommandHandler("disable")
public boolean onDisable(CommandSender sender, String[] args) {
if (!(sender.hasPermission("minecord.disable"))) {
sender.sendMessage(ChatColor.RED + "You are not permitted to disable Minecord with command!");
return true;
}
PluginManager pm = Bukkit.getPluginManager();
pm.disablePlugin(pm.getPlugin("Minecord"));
sender.sendMessage(ChatColor.GREEN + "Minecord is disabling!");
return true;
}
}
Code (Java):Minecord.getPlugin().setCommandExpansion(new Example()); - Loading...
- Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM