Guest User

Untitled

a guest
Feb 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1. import java.io.IOException;
  2.  
  3. public class GiveAllListener extends PluginListener {
  4.  
  5. static PropertiesFile settings = new PropertiesFile("GiveAllProperties.properties"); //this defines the static properties file. BX
  6. {
  7. try{
  8. settings.load(); //loads the file I guess o.O BX
  9. if (!settings.containsKey("Fire-Drop-Chance")){settings.setDouble("Fire-Drop-Chance", 0.2);} //if (settings does not contain FireDropChance) THEN {add FireDropChance to settings with 0.2} BX
  10. if (!settings.containsKey("Glass-Drop-Chance")){settings.setDouble("Glass-Drop-Chance",1.0);}
  11. if (!settings.containsKey("Spawner-Drop-Chance")){settings.setDouble("Spawner-Drop-Chance",0.5);}
  12. if (!settings.containsKey("Bookshelf-Drop-Chance")){settings.setDouble("Bookshelf-Drop-Chance",1.0);}
  13. if (!settings.containsKey("Grass-Drop-Chance")){settings.setDouble("Grass-Drop-Chance", 0.3);}
  14. if (!settings.containsKey("Pie-Drop-Chance")){settings.setDouble("Pie-Drop-Chance", 0.2);}
  15. if (!settings.containsKey("Woodstairs-Drop-Chance")){settings.setDouble("Woodstairs-Drop-Chance",0.8);}
  16. if (!settings.containsKey("Stonestairs-Drop-Chance")){settings.setDouble("Stonestairs-Drop-Chance", 0.6);}
  17. if (!settings.containsKey("Cobblestairs-Drop-Chance")){settings.setDouble("Cobblestairs-Drop-Chance", 0.7);}
  18. if (!settings.containsKey("Brickstairs-Drop-Chance")){settings.setDouble("Brickstairs-Drop-Chance",1.0);}
  19. if (!settings.containsKey("SBrickstairs-Drop-Chance")){settings.setDouble("SBrickstairs-Drop-Chance", 0.3);}
  20. //if (!settings.containsKey("NBrickstairs-Drop-Chance")){settings.setDouble("NBrickstairs-Drop-Chance", 0.7);}
  21. //if (!settings.containsKey("Mycelium-Drop-Chance")){settings.setDouble("Mycelium-Drop-Chance",0.3);}
  22. settings.save(); //saves the file I guess o.O lol BX
  23. }catch (IOException e){System.out.println("[GiveAll] Error loading properties file.");} //prints an error if the file is malformed. BX
  24. }
  25. static double firechance = settings.getDouble("Fire-Drop-Chance"); //this obtains your firedrop chance from the settings. BX
  26. static double glasschance = settings.getDouble("glass-drop-chance");
  27. static double spawnerchance = settings.getDouble("Spawner-drop-chance");
  28. static double Bookshelfchance = settings.getDouble("Bookshelf-Drop-Chance");
  29. static double grasschance = settings.getDouble("Grass-Drop-Chance");
  30. static double piechance = settings.getDouble("Pie-Drop-Chance");
  31. static double woodschance = settings.getDouble("Woodstairs-Drop-Chance");
  32. static double cobbleschance = settings.getDouble("Cobblestairs-Drop-Chance");
  33. static double brickschance = settings.getDouble("Brickstairs-Drop-Chance");
  34. static double sbrickschance = settings.getDouble("SBrickstairs-Drop-Chance");
  35. //static double myceliumchance = settings.getDouble("Mycelium-Drop-Chance");
  36. //static double nbrickschance = settings.getDouble("NBrickstairs-Drop-Chance");
  37. //public GiveAllListener() {
  38. //}
  39. //I don't know why you had this bit. It's not necessary at all, so I commented them out. BX
  40.  
  41.  
  42. // random blocks
  43. public boolean onBlockDestroy(Player player, Block block) {
  44. World world = block.getWorld(); //World world. You don't need to use it as an integer.BX
  45. //Integer world = Integer.valueOf(block.getWorld().getType().getId()); //This is over complicated. Just use "World" types. BX
  46. if ((block.getStatus() == 2) && (block.getType() == 52)) {
  47. block.setType(0);
  48. block.update();
  49. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 52, 1);
  50. if (Math.random() < spawnerchance){world.dropItem(block.getX(), block.getY(), block.getZ(), 52, 1); //here's the proper way to drop an item in World. BX
  51. }
  52. else if ((block.getStatus() == 2) && (block.getType() == 20)) {
  53. block.setType(0);
  54. block.update();
  55. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 20, 1);
  56. if (Math.random() < glasschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 20, 1); //Again. BX
  57. }
  58. else if ((block.getStatus() == 2) && (block.getType() == 47)) {
  59. block.setType(0);
  60. block.update();
  61. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 47, 1);
  62. if (Math.random() < Bookshelfchance){world.dropItem(block.getX(), block.getY(), block.getZ(), 47, 1); //Again. BX
  63. }
  64. else if ((block.getStatus() == 2) && (block.getType() == 02)) {
  65. block.setType(0);
  66. block.update();
  67. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 02, 1);
  68. if (Math.random() < grasschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 02, 1); //Again. BX
  69. }
  70. //else if ((block.getStatus() == 2) && (block.getType() == 110)) {
  71. //block.setType(0);
  72. //block.update();
  73. //if (Math.random() < myceliumchance)etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 110, 1);
  74. //return true;
  75. //}
  76. //pie
  77. // else if ((block.getStatus() == 1) && (block.getType() == 92)) {
  78. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 92, 1);
  79. // if (Math.random() < piechance){world.dropItem(block.getX(), block.getY(), block.getZ(), 92, 1); //Again. BX
  80. //}
  81. //stairs
  82. else if ((block.getStatus() == 2) && (block.getType() == 53)) {
  83. block.setType(0);
  84. block.update();
  85. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 53, 1);
  86. if (Math.random() < woodschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 53, 1); //Again. BX
  87. }
  88. else if ((block.getStatus() == 2) && (block.getType() == 108)) {
  89. block.setType(0);
  90. block.update();
  91. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 108, 1);
  92. if (Math.random() < brickschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 108, 1); //Again. BX
  93. }
  94. else if ((block.getStatus() == 2) && (block.getType() == 109)) {
  95. block.setType(0);
  96. block.update();
  97. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 109, 1);
  98. if (Math.random() < sbrickschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 109, 1); //Again. BX
  99. }
  100. else if ((block.getStatus() == 2) && (block.getType() == 67)) {
  101. block.setType(0);
  102. block.update();
  103. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 67, 1);
  104. if (Math.random() < cobbleschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 67, 1); //Again. BX
  105. }
  106. //else if ((block.getStatus() == 2) && (block.getType() == 114)) {
  107. //block.setType(0);
  108. //block.update();
  109. //if (Math.random() < nbrickschance)etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 114, 1);
  110. //}
  111. //fire and ice
  112. else if
  113. (block.getWorld().getBlockIdAt(block.getX(),block.getY()+1,block.getZ()) == 51){
  114. //if (Math.random() < settings.getfirechance()){etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 51);
  115. if (Math.random() < firechance){world.dropItem(block.getX(), block.getY(), block.getZ(), 51); //"firechance" static double, and world drop again. BX
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. return true;
  126. }
  127. return false;
  128. }
  129. }
Add Comment
Please, Sign In to add comment