Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The Package
- package norway.purepk95.HelpMe;
- // All the imports
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.plugin.Plugin;
- import com.nijiko.permissions.PermissionHandler;
- import com.nijikokun.bukkit.Permissions.Permissions;
- /**
- * HelpMe for Bukkit
- *
- * @author purepk95
- */
- //Starts the class
- public class HelpMe extends JavaPlugin{
- public static PermissionHandler Permissions;
- // onDisable
- public void onDisable() {
- PluginDescriptionFile pdfFile = this.getDescription();
- System.out.println( pdfFile.getName() + " is disabled!" );
- }
- // onEnable
- public void onEnable() {
- setupPermissions();
- PluginDescriptionFile pdfFile = this.getDescription();
- System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); }
- // Permission setup
- private void setupPermissions() {
- Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
- if (HelpMe.Permissions == null) {
- if (test != null) {
- HelpMe.Permissions = ((Permissions)test).getHandler();
- } else {
- System.out.println("Permission system not detected, defaulting to OP");
- }
- }
- }
- // Command system
- public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
- if (sender instanceof Player) {
- Player player = (Player) sender;
- if(Permissions.has(player, "HelpMe.use") && command.getName().equalsIgnoreCase("helpme")) {
- player.sendMessage(ChatColor.DARK_GREEN + "A mod or a admin will come and help you soon as possible.");
- player.sendMessage(ChatColor.DARK_GREEN + "If no one come and helps you within 20 minutes, perform the command again.");
- getServer().broadcastMessage(ChatColor.DARK_RED + player.getDisplayName() + ChatColor.DARK_GREEN + " need some help!");
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment