Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlace(BlockPlaceEvent e) {
- if(e.getPlayer().getGameMode() == GameMode.CREATIVE) {
- File Blocks = new File(plugin.getDataFolder() + File.separator + "Blocks" + File.separator + "Blocks.yml");
- FileConfiguration data = YamlConfiguration.loadConfiguration(Blocks);
- List<String> currentlist = data.getStringList("Blocks");
- String blocklocations = e.getBlock().getWorld() + ":" + e.getBlock().getLocation().getX() + ":" + e.getBlock().getLocation().getY() + ":" + e.getBlock().getLocation().getZ();
- currentlist.add(blocklocations);
- plugin.getConfig().set("Blocks", currentlist);
- try {
- data.save(Blocks);
- } catch (IOException e2) {
- e2.printStackTrace();
- }
- }
- }
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlace(BlockBreakEvent e) {
- File Blocks = new File(plugin.getDataFolder() + File.separator + "Blocks" + File.separator + "Blocks.yml");
- FileConfiguration data = YamlConfiguration.loadConfiguration(Blocks);
- List<String> currentlist = data.getStringList("Blocks");
- String blocklocations = e.getBlock().getWorld() + ":" + e.getBlock().getLocation().getX() + ":" + e.getBlock().getLocation().getY() + ":" + e.getBlock().getLocation().getZ();
- if(currentlist.contains(blocklocations)) {
- e.setCancelled(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement