Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 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("SpawnerDropChance")){settings.setDouble("SpawnerDropChance",0.5);}
  10. if (!settings.containsKey("FireDropChance")){settings.setDouble("FireDropChance", 0.2);} //if (settings does not contain FireDropChance) THEN {add FireDropChance to settings with 0.2} BX
  11. if (!settings.containsKey("GlassDropChance")){settings.setDouble("GlassDropChance",1.0);}
  12. if (!settings.containsKey("GrassDropChance")){settings.setDouble("GrassDropChance",0.3);}
  13. if (!settings.containsKey("BookshelfDropChance")){settings.setDouble("BookshelfDropChance",1.0);}
  14. if (!settings.containsKey("WoodstairsDropChance")){settings.setDouble("WoodstairsDropChance",0.5);}
  15. if (!settings.containsKey("CobblestairsDropChance")){settings.setDouble("CobblestairsDropChance",0.5);}
  16. if (!settings.containsKey("BrickstairsDropChance")){settings.setDouble("BrickstairsDropChance",0.5);}
  17. if (!settings.containsKey("StoneBrickstairsDropChance")){settings.setDouble("StoneBrickstairsDropChance",0.5);}
  18. settings.save(); //saves the file I guess o.O lol BX
  19. }catch (IOException e){System.out.println("[GiveAll] Error loading properties file.");} //prints an error if the file is malformed. BX
  20. }
  21. static double firechance = settings.getDouble("FireDropChance"); //this obtains your firedrop chance from the settings. BX
  22. static double glasschance = settings.getDouble("GlassDropChance");
  23. static double spawnerchance = settings.getDouble("SpawnerDropChance");
  24. static double grasschance = settings.getDouble("GrassDropChance");
  25. static double bookshelfchance = settings.getDouble("BookshelfDropChance");
  26. static double woodschance = settings.getDouble("WoodstairsDropChance");
  27. static double cobbleschance = settings.getDouble("CobblestairsDropChance");
  28. static double brickchance = settings.getDouble("BrickstairsDropChance");
  29. static double sbrickschance = settings.getDouble("StoneBrickstairsDropChance");
  30. //public GiveAllListener() {
  31. //}
  32. //I don't know why you had this bit. It's not necessary at all, so I commented them out. BX
  33.  
  34.  
  35. // random blocks
  36. public boolean onBlockDestroy(Player player, Block block) {
  37. World world = block.getWorld(); //World world. You don't need to use it as an integer.BX
  38. //Integer world = Integer.valueOf(block.getWorld().getType().getId()); //This is overcomplicated. Just use "World" types. BX
  39. if ((block.getStatus() == 2) && (block.getType() == 52)) {
  40. block.setType(0);
  41. block.update();
  42. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 52, 1);
  43. 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
  44. }
  45. else if ((block.getStatus() == 2) && (block.getType() == 20)) {
  46. block.setType(0);
  47. block.update();
  48. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 20, 1);
  49. if (Math.random() <glasschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 20, 1);}
  50. }
  51. else if ((block.getStatus() == 2) && (block.getType() == 47)) {
  52. block.setType(0);
  53. block.update();
  54. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 47, 1);
  55. if (Math.random() < bookshelfchance){world.dropItem(block.getX(), block.getY(), block.getZ(), 47, 1);}
  56. }
  57. else if ((block.getStatus() == 2) && (block.getType() == 02)) {
  58. block.setType(0);
  59. block.update();
  60. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 02, 1);
  61. if (Math.random() <grasschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 02, 1);}
  62. else{world.dropItem(block.getX(), block.getY(), block.getZ(), 3,1);}
  63. }
  64. //else if ((block.getStatus() == 2) && (block.getType() == 110)) {
  65. //block.setType(0);
  66. //block.update();
  67. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 110, 1);
  68. //return true;
  69. //}
  70. //pie
  71. // else if ((block.getStatus() == 1) && (block.getType() == 92)) {
  72. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 92, 1);
  73. // world.dropItem(block.getX(), block.getY(), block.getZ(), 92, 1); //Again. BX
  74. //}
  75. //stairs
  76. else if ((block.getStatus() == 2) && (block.getType() == 53)) {
  77. block.setType(0);
  78. block.update();
  79. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 53, 1);
  80. if (Math.random() <woodschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 53, 1);} //Again. BX
  81. }
  82. else if ((block.getStatus() == 2) && (block.getType() == 108)) {
  83. block.setType(0);
  84. block.update();
  85. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 108, 1);
  86. if (Math.random() <brickchance){world.dropItem(block.getX(), block.getY(), block.getZ(), 108, 1);} //Again. BX
  87. }
  88. else if ((block.getStatus() == 2) && (block.getType() == 109)) {
  89. block.setType(0);
  90. block.update();
  91. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 109, 1);
  92. if (Math.random() <sbrickschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 109, 1);} //Again. BX
  93. }
  94. else if ((block.getStatus() == 2) && (block.getType() == 67)) {
  95. block.setType(0);
  96. block.update();
  97. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 67, 1);
  98. if (Math.random() <cobbleschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 67, 1);} //Again. BX
  99. }
  100. //else if ((block.getStatus() == 2) && (block.getType() == 114)) {
  101. //block.setType(0);
  102. //block.update();
  103. //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 114, 1);
  104. //}
  105. //fire and ice
  106. else if
  107. (block.getWorld().getBlockIdAt(block.getX(),block.getY()+1,block.getZ()) == 51){
  108. //if (Math.random() < firechance()){etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 51);
  109. if (Math.random() < firechance){world.dropItem(block.getX(), block.getY(), block.getZ(), 51); //"firechance" static double, and world drop again. BX
  110. }
  111. return true;
  112. }
  113. return false;
  114. }
  115. }
Add Comment
Please, Sign In to add comment