Guest User

Untitled

a guest
Apr 24th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. public class DropList implements CommandExecutor {
  2.  
  3. FileConfiguration config = Main.plugin.getConfig();
  4.  
  5. @Override
  6. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  7.  
  8. if(args.length == 0) {
  9.  
  10. List<Material> blocksPlaced = Arrays.stream(Material.values())
  11. .filter(Material::isBlock)
  12. .collect(Collectors.toList());
  13.  
  14. List<Material> shuffledBlocks = Arrays.stream(Material.values())
  15. .collect(Collectors.toList());
  16. Collections.shuffle(shuffledBlocks);
  17.  
  18. Map<Material, Material> blockTypeMappings = Streams.zip(blocksPlaced.stream(), shuffledBlocks.stream(), AbstractMap.SimpleEntry::new)
  19. .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  20.  
  21. File configFile = new File("plugins/Randomizer/dictionary.yml");
  22. if (configFile.exists())
  23. configFile.delete();
  24. try {
  25. configFile.createNewFile();
  26. } catch (IOException e) {
  27. e.printStackTrace();
  28. }
  29. FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
  30. for (Map.Entry<Material, Material> entry : blockTypeMappings.entrySet())
  31. config.set(entry.getKey().toString(), entry.getValue().toString());
  32.  
  33.  
  34. }else{
  35. sender.sendMessage("§cBitte benutze nur §6/randomize§c!");
  36. }
  37.  
  38. return false;
  39. }
  40.  
  41. ---------------------------------------------------------------------------------------------------------------------------------------
  42.  
  43.  
  44. public class BlockDestroyedListener implements Listener{
  45.  
  46. FileConfiguration config = Main.plugin.getConfig();
  47.  
  48. @EventHandler
  49. public void onBreak(BlockBreakEvent e){
  50. Block block = e.getBlock();
  51. e.setCancelled(true);
  52. block.setType(Material.AIR);
  53.  
  54.  
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment