Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.pudgecraft.StaffMail.commands;
- import java.util.List;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import com.pudgecraft.StaffMail.StaffMail;
- public class Commands implements CommandExecutor{
- private StaffMail plugin;
- public Commands(StaffMail plugin) {
- this.plugin = plugin;
- plugin.getCommand("staffmail").setExecutor(this);
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- Player player = (Player) sender;
- if (player.hasPermission("staffmail.allow")) {
- if(label.equalsIgnoreCase("staffmail") || label.equalsIgnoreCase("sm")) {
- if(args.length==0) {
- plugin.HelpMessage(player);
- }
- else {
- if(args[0].equalsIgnoreCase("read")) {
- List<String> list = plugin.getConfig().getStringList("staffmail");
- for(String s : list){
- plugin.sendMessage(player, s + "");
- }
- }
- else if(args[0].equalsIgnoreCase("send")) {
- if(args.length == 1) {
- plugin.sendMessage(player, "&3Correct Usage: /staffmail send <message>.");
- }
- else {
- String word = "";
- for (int i = 1; i <= (args.length - 1); i++) {
- word = word + " " + args[i];
- }
- List<String> list = plugin.getConfig().getStringList("staffmail");
- list.add(word);
- plugin.getConfig().set("staffmail", list);
- plugin.saveConfig();
- plugin.sendMessage(player, "&3Mail sent.");
- }
- }
- else if(args[0].equalsIgnoreCase("clear")) {
- if(!(player.hasPermission("staffmail.admin"))) {
- plugin.sendMessage(player, "&4You have to be an Admin to use this.");
- }
- else {
- List<String> list = plugin.getConfig().getStringList("staffmail");
- list.clear();
- plugin.getConfig().set("staffmail", list);
- plugin.saveConfig();
- plugin.sendMessage(player, "&3You have successfully cleared staff mail.");
- }
- }
- else {
- plugin.HelpMessage(player);
- }
- }
- }
- return false;
- }
- plugin.sendMessage(player,"&4You don't have permission");
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement