Guest User

Untitled

a guest
Oct 9th, 2018
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @EventHandler(priority = EventPriority.HIGHEST)
  2. public void onPlace(BlockPlaceEvent e) {
  3. if(e.getPlayer().getGameMode() == GameMode.CREATIVE) {
  4. File Blocks = new File(plugin.getDataFolder() + File.separator + "Blocks" + File.separator + "Blocks.yml");
  5. FileConfiguration data = YamlConfiguration.loadConfiguration(Blocks);
  6. List<String> currentlist = data.getStringList("Blocks");
  7.  
  8. String blocklocations = e.getBlock().getWorld() + ":" + e.getBlock().getLocation().getX() + ":" + e.getBlock().getLocation().getY() + ":" + e.getBlock().getLocation().getZ();
  9. currentlist.add(blocklocations);
  10.  
  11. plugin.getConfig().set("Blocks", currentlist);
  12. try {
  13. data.save(Blocks);
  14. } catch (IOException e2) {
  15. e2.printStackTrace();
  16. }
  17. }
  18. }
  19.  
  20. @EventHandler(priority = EventPriority.HIGHEST)
  21. public void onPlace(BlockBreakEvent e) {
  22. File Blocks = new File(plugin.getDataFolder() + File.separator + "Blocks" + File.separator + "Blocks.yml");
  23. FileConfiguration data = YamlConfiguration.loadConfiguration(Blocks);
  24. List<String> currentlist = data.getStringList("Blocks");
  25.  
  26. String blocklocations = e.getBlock().getWorld() + ":" + e.getBlock().getLocation().getX() + ":" + e.getBlock().getLocation().getY() + ":" + e.getBlock().getLocation().getZ();
  27. if(currentlist.contains(blocklocations)) {
  28. e.setCancelled(true);
  29. }
  30. }
RAW Paste Data