SHARE
TWEET

Commands

a guest Apr 10th, 2011 1,591 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ~package com.SySammy.sdRankingSys;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandExecutor;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8.  
  9. /**
  10.  *
  11.  * @author Sammy
  12.  */
  13. public class sdRankCmds implements CommandExecutor {
  14.  
  15.     private sdRS plugin;
  16.  
  17.     public sdRankCmds(sdRS aThis) {
  18.         this.plugin = aThis;
  19.     }
  20.  
  21.     public boolean onCommand(CommandSender cs, Command cmnd, String string, String[] strings) {
  22.         String[] Nargs = strings;
  23.         String cmd = cmnd.getName().toLowerCase();
  24.         if (cmd.equals("rank")) {
  25.             return RankMethod(cs, Nargs);
  26.         }
  27.         return true;
  28.     }
  29.  
  30.     private boolean RankMethod(CommandSender cs, String[] args) {
  31.         Player ply = (Player) cs;
  32.         if (args[0].equalsIgnoreCase("reg")) {
  33.             String name = args[1];
  34.             String valueToreg = args[2];
  35.             Ranks rankClass = plugin.getDatabase().find(Ranks.class).where().ieq("name", name).ieq("playerName", ply.getName()).findUnique();
  36.             if (rankClass == null) {
  37.                 rankClass = new Ranks();
  38.                 rankClass.setPlayer(ply);
  39.                 rankClass.setName(name);
  40.             }
  41.             rankClass.setTest(valueToreg);
  42.             plugin.getDatabase().save(rankClass);
  43.         } else if (args[0].equalsIgnoreCase("view")) {
  44.             String name = args[1];
  45.             Ranks rankClass = plugin.getDatabase().find(Ranks.class).where().ieq("name", name).ieq("playerName", ply.getName()).findUnique();
  46.             if (rankClass == null) {
  47.                 ply.sendMessage(ChatColor.RED + "That entry doesn't exist.");
  48.                 return true;
  49.             }
  50.             ply.sendMessage(ChatColor.GREEN + "name: " + rankClass.getName());
  51.             ply.sendMessage(ChatColor.GREEN + "PlayerName: " + rankClass.getPlayerName());
  52.             ply.sendMessage(ChatColor.GREEN + "Treta: " + rankClass.getTest());
  53.         }
  54.         return true;
  55.     }
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top