Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
1,873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.56 KB | None | 0 0
  1. public boolean inputErrors(){
  2.     JTextField[] tinyint = {G_level,M_slots,A_holy,A_shadow,A_arcane,A_nature,A_fire,A_frost};
  3.     JTextField[] smallint = {M_carry,M_stack,A_armor,W_speed,G_durability,S_0value,S_1value,S_2value,S_3value,S_4value,S_5value,S_6value,S_7value,S_8value,S_9value};
  4.     JTextField[] mediumint = {NEWENTRYFIELD,A_block};
  5.     JTextField[] regularint = {M_buy,M_sell};
  6.     String[] tinynames = {"Level","Slots","Holy res","Shadow res","Arcane res","Nature res","Fire res","Frost res"};
  7.     String[] smallnames = {"Max carry","Max stack","Armor","Speed","Durability","Stat values","Stat values","Stat values","Stat values","Stat values","Stat values","Stat values","Stat values","Stat values","Stat values"};
  8.     String[] mediumnames = {"Entry","Block"};
  9.     String[] regularnames = {"Buy price","Sell price"};
  10.     boolean errors = false;
  11.     int i=0,j=0,k=0,l=0;
  12.     String errorz = "The following errors ocurred during export:\n";
  13.     for (JTextField next : tinyint){if (next.getText().length() == 0){next.setText("0");}
  14.         try{if(Float.parseFloat(next.getText()) > 127){next.setText("127");}i++;
  15.         } catch (Exception e){errorz+=tinynames[i] + " must contain only numbers\n";errors = true;}}
  16.     for (JTextField next : smallint){if (next.getText().length() == 0){next.setText("0");}
  17.         try{if(Float.parseFloat(next.getText()) > 32767){next.setText("32767");}j++;
  18.         } catch (Exception e){errorz+=smallnames[j] + " must contain only numbers\n";errors = true;}}
  19.     for (JTextField next : mediumint){if (next.getText().length() == 0){next.setText("0");}
  20.         try{if(Float.parseFloat(next.getText()) > 8388607){next.setText("8388607");}k++;
  21.         } catch (Exception e){errorz+=mediumnames[k] + " must contain only numbers\n";errors = true;}}
  22.     for (JTextField next : regularint){if (next.getText().length() == 0){next.setText("0");}
  23.         try{if(Float.parseFloat(next.getText()) > 2147483647){next.setText("2147483647");}l++;
  24.         } catch (Exception e){errorz+=regularnames[l] + " must contain only numbers\n";errors = true;}}
  25.     if (G_name.getText().indexOf("\"") != -1){errorz+="Name must not contain quotation marks, apostrophes, or asterisks\n";errors = true;}
  26.     if (G_name.getText().indexOf("\'") != -1){errorz+="Name must not contain quotation marks, apostrophes, or asterisks\n";errors = true;}
  27.     if (G_description.getText().indexOf("\"") != -1){errorz+="Description must not contain quotation marks, apostrophes, or asterisks\n";errors = true;}
  28.     if (G_description.getText().indexOf("\'") != -1){errorz+="Description must not contain quotation marks, apostrophes, or asterisks\n";errors = true;}
  29.     ereport = errorz;
  30.     return errors;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement