derevandal

Untitled

Jan 2nd, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.53 KB | None | 0 0
  1.     else if (sub[0].equals("banir")) {
  2.             MapleCharacter victim  = cserv.getPlayerStorage().getCharacterByName(sub[1]);
  3.             String time = sub[2];
  4.             int hours = Integer.parseInt(sub[2]);
  5.             String description = joinStringFrom(sub, 2);
  6.             String reason = player.getName() + " baniu "+victim.getName()+" por "+description;
  7.             if(victim == null || description == null || time == null){
  8.                 player.message("!banir [jogador] [tempo] [motivo]");
  9.                 return true;
  10.             }
  11.             if(hours == 0 && player.gmLevel() >= 3){
  12.                 player.message("Somente administradores podem banir permanetemente!");
  13.                 return true;
  14.             }
  15.             if(hours > 0){
  16.                 try {
  17.                     String tempban = "STR_TO_DATE("+sub[2]+" "+sub[3]+",'%Y/%m/%d %H:%i')"; /* pega a data atual e soma o time, depois convert em str */
  18.                     try (PreparedStatement p = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts "
  19.                             + "SET tempban = '"+tempban+"', "
  20.                             + "banreason = '"+description+"' "
  21.                             + "WHERE id = " + victim.getName())) {
  22.                         p.executeUpdate();
  23.                     }
  24.                     victim.getClient().disconnect(false, false);
  25.                     victim.sendPolice("Voce foi banido do FlameStory. Rasao: "+ description +"; Tempo:"+ time +" horas.");
  26.                     player.dropMessage("Voce baniu "+ victim.getName() +". Rasao: "+ description +"; Tempo:"+ time +" horas.");
  27.                     logger logger = new logger(player.getName()+"baniu "+ victim.getName() +". Rasao: "+ description +"; Tempo:"+ time +" horas.");
  28.                 } catch (Exception e) {
  29.                     player.message("Ocorreu algum erro ao tentar banir o jogador "+victim.getName()+".");
  30.                 }
  31.                 return true;
  32.             }else{
  33.                 String ip = victim.getClient().getSession().getRemoteAddress().toString().split(":")[0];
  34.         reason += " (IP: " + ip + ")";
  35.                 victim.ban(reason);
  36.                 victim.sendPolice("Voce foi banido do FlameStory. Rasao: "+ description +".");
  37.                 player.dropMessage("Voce baniu "+ victim.getName() +". Rasao: "+ description +".");
  38.                 logger logger = new logger(player.getName()+"baniu "+ victim.getName() +". Rasao: "+ description +"; Tempo: permanente.");
  39.                 return true;
  40.             }          
  41.         }
Add Comment
Please, Sign In to add comment