Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- public class GiveAllListener extends PluginListener {
- static PropertiesFile settings = new PropertiesFile("GiveAllProperties.properties"); //this defines the static properties file. BX
- {
- try{
- settings.load(); //loads the file I guess o.O BX
- 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
- if (!settings.containsKey("Glass-Drop-Chance")){settings.setDouble("Glass-Drop-Chance",1.0);}
- if (!settings.containsKey("Spawner-Drop-Chance")){settings.setDouble("Spawner-Drop-Chance",0.5);}
- if (!settings.containsKey("Bookshelf-Drop-Chance")){settings.setDouble("Bookshelf-Drop-Chance",1.0);}
- if (!settings.containsKey("Grass-Drop-Chance")){settings.setDouble("Grass-Drop-Chance", 0.3);}
- if (!settings.containsKey("Pie-Drop-Chance")){settings.setDouble("Pie-Drop-Chance", 0.2);}
- if (!settings.containsKey("Woodstairs-Drop-Chance")){settings.setDouble("Woodstairs-Drop-Chance",0.8);}
- if (!settings.containsKey("Stonestairs-Drop-Chance")){settings.setDouble("Stonestairs-Drop-Chance", 0.6);}
- if (!settings.containsKey("Cobblestairs-Drop-Chance")){settings.setDouble("Cobblestairs-Drop-Chance", 0.7);}
- if (!settings.containsKey("Brickstairs-Drop-Chance")){settings.setDouble("Brickstairs-Drop-Chance",1.0);}
- if (!settings.containsKey("SBrickstairs-Drop-Chance")){settings.setDouble("SBrickstairs-Drop-Chance", 0.3);}
- //if (!settings.containsKey("NBrickstairs-Drop-Chance")){settings.setDouble("NBrickstairs-Drop-Chance", 0.7);}
- //if (!settings.containsKey("Mycelium-Drop-Chance")){settings.setDouble("Mycelium-Drop-Chance",0.3);}
- settings.save(); //saves the file I guess o.O lol BX
- }catch (IOException e){System.out.println("[GiveAll] Error loading properties file.");} //prints an error if the file is malformed. BX
- }
- static double firechance = settings.getDouble("Fire-Drop-Chance"); //this obtains your firedrop chance from the settings. BX
- static double glasschance = settings.getDouble("glass-drop-chance");
- static double spawnerchance = settings.getDouble("Spawner-drop-chance");
- static double Bookshelfchance = settings.getDouble("Bookshelf-Drop-Chance");
- static double grasschance = settings.getDouble("Grass-Drop-Chance");
- static double piechance = settings.getDouble("Pie-Drop-Chance");
- static double woodschance = settings.getDouble("Woodstairs-Drop-Chance");
- static double cobbleschance = settings.getDouble("Cobblestairs-Drop-Chance");
- static double brickschance = settings.getDouble("Brickstairs-Drop-Chance");
- static double sbrickschance = settings.getDouble("SBrickstairs-Drop-Chance");
- //static double myceliumchance = settings.getDouble("Mycelium-Drop-Chance");
- //static double nbrickschance = settings.getDouble("NBrickstairs-Drop-Chance");
- //public GiveAllListener() {
- //}
- //I don't know why you had this bit. It's not necessary at all, so I commented them out. BX
- // random blocks
- public boolean onBlockDestroy(Player player, Block block) {
- World world = block.getWorld(); //World world. You don't need to use it as an integer.BX
- //Integer world = Integer.valueOf(block.getWorld().getType().getId()); //This is over complicated. Just use "World" types. BX
- if ((block.getStatus() == 2) && (block.getType() == 52)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 52, 1);
- 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
- }
- else if ((block.getStatus() == 2) && (block.getType() == 20)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 20, 1);
- if (Math.random() < glasschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 20, 1); //Again. BX
- }
- else if ((block.getStatus() == 2) && (block.getType() == 47)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 47, 1);
- if (Math.random() < Bookshelfchance){world.dropItem(block.getX(), block.getY(), block.getZ(), 47, 1); //Again. BX
- }
- else if ((block.getStatus() == 2) && (block.getType() == 02)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 02, 1);
- if (Math.random() < grasschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 02, 1); //Again. BX
- }
- //else if ((block.getStatus() == 2) && (block.getType() == 110)) {
- //block.setType(0);
- //block.update();
- //if (Math.random() < myceliumchance)etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 110, 1);
- //return true;
- //}
- //pie
- // else if ((block.getStatus() == 1) && (block.getType() == 92)) {
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 92, 1);
- // if (Math.random() < piechance){world.dropItem(block.getX(), block.getY(), block.getZ(), 92, 1); //Again. BX
- //}
- //stairs
- else if ((block.getStatus() == 2) && (block.getType() == 53)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 53, 1);
- if (Math.random() < woodschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 53, 1); //Again. BX
- }
- else if ((block.getStatus() == 2) && (block.getType() == 108)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 108, 1);
- if (Math.random() < brickschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 108, 1); //Again. BX
- }
- else if ((block.getStatus() == 2) && (block.getType() == 109)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 109, 1);
- if (Math.random() < sbrickschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 109, 1); //Again. BX
- }
- else if ((block.getStatus() == 2) && (block.getType() == 67)) {
- block.setType(0);
- block.update();
- //etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 67, 1);
- if (Math.random() < cobbleschance){world.dropItem(block.getX(), block.getY(), block.getZ(), 67, 1); //Again. BX
- }
- //else if ((block.getStatus() == 2) && (block.getType() == 114)) {
- //block.setType(0);
- //block.update();
- //if (Math.random() < nbrickschance)etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 114, 1);
- //}
- //fire and ice
- else if
- (block.getWorld().getBlockIdAt(block.getX(),block.getY()+1,block.getZ()) == 51){
- //if (Math.random() < settings.getfirechance()){etc.getServer().getWorld(world.intValue()).dropItem(block.getX(), block.getY(), block.getZ(), 51);
- if (Math.random() < firechance){world.dropItem(block.getX(), block.getY(), block.getZ(), 51); //"firechance" static double, and world drop again. BX
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return true;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment