Initial version

This commit is contained in:
Michel Roux 2012-05-11 20:49:03 +02:00
parent 117d88655f
commit 2e6c7efc70
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package net.crystalyx.bukkit.simplyperms.rank;
import java.util.Arrays;
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class SimplyRank extends JavaPlugin implements CommandExecutor {
private SimplyAPI api;
public void onEnable() {
api = ((SimplyPlugin) getServer().getPluginManager().getPlugin("SimplyPerms")).getAPI();
getCommand("setrank").setExecutor(this);
}
public boolean onCommand(CommandSender sender, Command cmd, String cmdLine, String[] split) {
try {
if (sender.hasPermission("permissions.rank." + split[1])) {
String player = split[0].toLowerCase();
Player target = getServer().getPlayer(split[0]);
String PlayerName = sender.getName();
String carget = getServer().getPlayer(split[0]).getDisplayName();
String[] groups = split[1].split(",");
api.removePlayerGroups(player);
for (String group : Arrays.asList(groups)) {
api.addPlayerGroup(player, group);
}
api.refreshPermissions();
sender.sendMessage(ChatColor.GREEN + "You've changed " + carget + "'s rank to " + split[1] + ".");
target.sendMessage(ChatColor.AQUA + getServer().getPlayer(PlayerName).getDisplayName() + " changed your rank to " + split[1] + "!");
getLogger().info(getServer().getPlayer(PlayerName).getDisplayName() + " changed " + carget + "'s rank to " + split[1] + ".");
return true;
} else {
sender.sendMessage(ChatColor.RED + "You don't have permission to use this!");
return true;
}
} catch (ArrayIndexOutOfBoundsException e) {
sender.sendMessage(ChatColor.RED + "Wrong syntax! Usage: /rank [Player] [Rank]");
return true;
} catch (NullPointerException e) {
sender.sendMessage(ChatColor.RED + "That player is not online!");
return true;
}
}
}

6
src/plugin.yml Normal file
View File

@ -0,0 +1,6 @@
name: SimplyRank
main: net.crystalyx.bukkit.simplyperms.rank.SimplyRank
author: Xefir Destiny
website: http://dev.bukkit.org/server-mods/simplyperms/
version: 1.0
depend: [ SimplyPerms ]