spenk

SignJoin

Mar 16th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.49 KB | None | 0 0
  1. public class SignJoinJoin extends PluginListener
  2. {
  3.       int i;
  4.   public boolean onSignChange(Player player, Sign sign)
  5.   {
  6.     Block b = sign.getBlock();
  7.     World world = player.getWorld();
  8.     if ((sign.getText(0).equals("[Join]")) &&
  9.       (player.canUseCommand("/signadmin"))) {
  10.       sign.setText(0, "[Join]");
  11.       if (sign.getText(1).isEmpty()) sign.setText(1, "§4White List");
  12.       if (sign.getText(2).isEmpty()) sign.setText(2, "§4add to Group:");
  13.       if (sign.getText(3).isEmpty()) sign.setText(3, "default");
  14.       player.sendMessage("§2Sign sucsessfully created.");
  15.       return false;
  16.     }
  17.  
  18.     if (sign.getText(0).equals("[Caste]")) {
  19.       if ((!player.canUseCommand("/signadmin")) ||
  20.         (sign.getText(1).isEmpty())) { player.notify("You have to fill in an group on line 2"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
  21.       if (!etc.getDataSource().doesGroupExist(sign.getText(1))) { player.notify("The group on line 2 does not exist"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
  22.       if (sign.getText(2).isEmpty()) { player.notify("You have to fill in an group on line 3"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
  23.       if (!etc.getDataSource().doesGroupExist(sign.getText(2))) { player.notify("The group on line 3 does not exist"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
  24.       if (sign.getText(3).isEmpty()) { player.notify("You have to fill in an price on line 4"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; } try {
  25.         Double.parseDouble(sign.getText(3)); } catch (NumberFormatException nfe) { player.notify("Line 4 must be an number!"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
  26.       player.sendMessage("§2Sign sucsessfully created.");
  27.       return false;
  28.     }
  29.     return false;
  30.   }
  31.   public boolean onBlockRightClick(Player player, Block bc, Item iih) {
  32.     if ((bc.getType() == 63) || (bc.getType() == 68)) {
  33.       Sign sign = (Sign)bc.getWorld().getComplexBlock(bc.getX(), bc.getY(), bc.getZ());
  34.       if (sign.getText(0).equalsIgnoreCase("[Join]")) {
  35.         if (player.canUseCommand("/signjoin")) {
  36.           if (!etc.getDataSource().isUserOnWhitelist(player.getName())) {
  37.             if ((player.getGroups()[0].equals("default")) || (player.getGroups()[0].equals("guest"))) {
  38.               player.setGroups(new String[] { sign.getText(3) });
  39.               etc.getDataSource().modifyPlayer(player);
  40.               etc.getDataSource().addToWhitelist(player.getName());
  41.               player.sendMessage("§2Your added to the whitelist and modified.");
  42.               return false;
  43.             }
  44.  
  45.             player.notify("You are already modified.");
  46.             return true;
  47.           }
  48.  
  49.           player.notify("You are already on the whitelist");
  50.         }
  51.         else {
  52.           player.notify("You are not allowed to preform this command");
  53.           return true;
  54.         }
  55.       }
  56.       if (sign.getText(0).equals("[Caste]")) {
  57.         if (sign.getText(1).equals(player.getGroups()[0])) {
  58.           double money = ((Double)etc.getLoader().callCustomHook("dCBalance", new Object[] { "Player-Balance", player.getName() })).doubleValue();
  59.           if (money < Double.parseDouble(sign.getText(3))) { player.notify("You dont have enough money to preform this action"); return true; }
  60.           player.setGroups(new String[] { sign.getText(2) });
  61.           etc.getDataSource().modifyPlayer(player);
  62.           etc.getLoader().callCustomHook("dCBalance", new Object[] { "Player-Charge", player.getName(), Double.valueOf(Double.parseDouble(sign.getText(3))) });
  63.           //newcode
  64.           char[] c = sign.getText(2).toCharArray();
  65.           while(!isNumber(c[i])){
  66.               i++;
  67.           }
  68.           player.chat("/teach"+c[i]+" "+player.getName()+" PASS");
  69.           //newcode
  70.           player.sendMessage("§2You Changed from caste");
  71.           return false;
  72.         }
  73.         player.notify("You can not change from your current caste to this caste");
  74.         return true;
  75.       }
  76.  
  77.     }
  78.  
  79.     return false;
  80.   }
  81.   public boolean isNumber(char c){try{Integer.parseInt(c+"");}catch(NumberFormatException nfe){return false;}
  82. return true;}
  83. }
Advertisement
Add Comment
Please, Sign In to add comment