Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. package fr.Rbmc.Pintocraft;
  2.  
  3.  
  4. import java.io.File;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.io.ObjectOutputStream;
  8. import java.sql.ResultSet;
  9.  
  10. import org.apache.logging.log4j.core.config.plugins.Plugin;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13.  
  14.  
  15. public class main extends JavaPlugin
  16. {
  17.  
  18. Plugin plugin;
  19.  
  20. public void StructureAPI(Plugin pl)
  21. {
  22. this.plugin = pl;
  23. }
  24. public SqlConnection sql;
  25. public ResultSet ID;
  26.  
  27. public void onEnable()
  28. {
  29. sql = new SqlConnection("jdbc:mysql://","149.202.36.43:3306","TestPluginImpr3D","printschem","schempass");
  30. sql.connection();
  31. }
  32.  
  33. public void onDisable()
  34. {
  35. sql.disconnect();
  36. }
  37.  
  38. public class ITOA
  39. {
  40. public String convert(int value, int base)
  41. {
  42. boolean negative = false;
  43. String s = "";
  44. if (value == 0)
  45. return "0";
  46. negative = (value < 0);
  47. if (negative)
  48. value = -1 * value;
  49. while (value != 0)
  50. {
  51. s = (value % base) + s;
  52. ID = value / base;
  53. }
  54. if (negative)
  55. s = "-" + s;
  56. return s;
  57. }
  58. }
  59. public void save(int ID, int[][][] b)
  60. {
  61. ObjectOutputStream oos = null;
  62. FileOutputStream fout = null;
  63.  
  64. File f = new File(((JavaPlugin) plugin).getDataFolder() + "/schematics/"+ convert(ID, 10) + ".schem");
  65. File dir = new File(((JavaPlugin) plugin).getDataFolder() + "/schematics");
  66.  
  67. try
  68. {
  69. dir.mkdirs();
  70. f.createNewFile();
  71. }
  72. catch (IOException e1)
  73. {
  74. e1.printStackTrace();
  75. }
  76. try
  77. {
  78. fout = new FileOutputStream(f);
  79. oos = new ObjectOutputStream(fout);
  80. oos.writeObject(b);
  81. }
  82. catch (Exception e)
  83. {
  84. e.printStackTrace();
  85. }
  86. finally
  87. {
  88. if(oos != null)
  89. {
  90. try
  91. {
  92. oos.close();
  93. }
  94. catch (IOException e)
  95. {
  96. e.printStackTrace();
  97. }
  98. }
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement