Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.02 KB | None | 0 0
  1. package fr.tinwynn;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import java.util.Timer;
  6. import java.util.TimerTask;
  7.  
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.Location;
  10. import org.bukkit.Material;
  11. import org.bukkit.World;
  12. import org.bukkit.block.Block;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.event.EventHandler;
  15. import org.bukkit.event.Listener;
  16. import org.bukkit.event.block.Action;
  17. import org.bukkit.event.player.PlayerInteractEvent;
  18. import org.bukkit.plugin.Plugin;
  19. import org.bukkit.scheduler.BukkitRunnable;
  20. import org.bukkit.util.Vector;
  21.  
  22.  
  23.  
  24. public class DotonMurDeBou implements Listener{
  25.    
  26.     private Map<String, Long> cooldowns = new HashMap<>();
  27.    
  28.     private SqlConnection sql;
  29.        
  30.     public DotonMurDeBou(SqlConnection sql) {
  31.         this.sql = sql;
  32.     }
  33.    
  34.     @SuppressWarnings("deprecation")
  35.     @EventHandler
  36.     public String interact(PlayerInteractEvent e) {
  37.        
  38.    
  39.         Player p = e.getPlayer();
  40.         Action action = e.getAction();
  41.         Block block = e.getClickedBlock();
  42.         final World world = p.getWorld();
  43.        
  44.  
  45.        
  46.         if(action.equals(Action.RIGHT_CLICK_BLOCK)) {
  47.            
  48.             if(p.getItemInHand().getType().equals(Material.DIRT)) {
  49.                
  50.                
  51.                
  52.                 if(cooldowns.containsKey(p.getName())){
  53.                        
  54.                     int seconds = 2;
  55.                     long timeleft = ((cooldowns.get(p.getName()) / 1000) + seconds) - (System.currentTimeMillis() / 1000);
  56.                     if(timeleft > 0){
  57.                         p.sendMessage("§cVous devez encore attendre (§c§o" + timeleft + "s§c) pour utiliser cette technique");
  58.                         e.setCancelled(true);
  59.                         return null;
  60.                     }
  61.                    
  62.                 }
  63.                
  64.                
  65.                 p.sendMessage("§cDoton, Mur de boue !");
  66.                 cooldowns.put(p.getName(), System.currentTimeMillis());
  67.                 ParticleEffect.SMOKE_LARGE.display(5, 5, 5, 0, 250, p.getLocation().add(0, 1, 0), 20);
  68.                
  69.                
  70.                
  71.                 ParticleEffect.SMOKE_LARGE.display(5, 5, 5, 0, 300, p.getLocation().add(0, 11, 0), 20);
  72.                
  73.                 final int x = block.getX();
  74.                 int y = block.getY();
  75.                 final int z = block.getZ();
  76.                
  77.                
  78.                
  79.                     double rotation = (p.getLocation().getYaw() - 90) % 360;
  80.                     if (rotation < 0) {
  81.                         rotation += 360.0;
  82.                     }
  83.                     if (0 <= rotation && rotation < 22.5) {
  84.                         //p.sendMessage("N");
  85.                        
  86.                        
  87.                         for(y = block.getY(); y != block.getY() + 10; y++){
  88.  
  89.                            
  90.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  91.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  92.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  93.                            
  94.                             world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
  95.                             world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
  96.                            
  97.                            
  98.                            
  99.                            
  100.                            
  101.                            
  102.  
  103.                     }
  104.                        
  105.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  106.                         p.sendMessage("§c-880 de chakra");
  107.                         return "N";
  108.                     } else if (22.5 <= rotation && rotation < 67.5) {
  109.                        
  110.                             for(y = block.getY(); y != block.getY() + 10; y++){
  111.  
  112.                            
  113.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  114.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  115.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  116.                            
  117.                             world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
  118.                             world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
  119.                            
  120.                            
  121.  
  122.                     }
  123.                            
  124.                            
  125.                             sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  126.                             p.sendMessage("§c-880 de chakra");
  127.                         //p.sendMessage("N");
  128.                         return "N";
  129.                     } else if (67.5 <= rotation && rotation < 112.5) {
  130.                        
  131.                         for(y = block.getY(); y != block.getY() + 10; y++){
  132.  
  133.                            
  134.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  135.                             world.getBlockAt(block.getX() + 1, y, block.getZ()).setTypeId(3);
  136.                             world.getBlockAt(block.getX() - 1, y, block.getZ()).setTypeId(3);
  137.                            
  138.                             world.getBlockAt(block.getX() + 2 , y, block.getZ() + 1).setTypeId(3);
  139.                             world.getBlockAt(block.getX() - 2, y, block.getZ() + 1).setTypeId(3);
  140.                            
  141.                            
  142.                            
  143.  
  144.                     }
  145.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  146.                         p.sendMessage("§c-880 de chakra");
  147.                         //p.sendMessage("E");
  148.                         return "E";
  149.                     } else if (112.5 <= rotation && rotation < 157.5) {
  150.                        
  151.                         for(y = block.getY(); y != block.getY() + 10; y++){
  152.  
  153.                            
  154.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  155.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  156.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  157.                            
  158.                             world.getBlockAt(block.getX() - 1, y, block.getZ()+ 2).setTypeId(3);
  159.                             world.getBlockAt(block.getX() - 1, y, block.getZ()- 2).setTypeId(3);
  160.                            
  161.                            
  162.                            
  163.  
  164.                     }
  165.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  166.                         p.sendMessage("§c-880 de chakra");
  167.                         //p.sendMessage("S");
  168.                         return "S";
  169.                     } else if (157.5 <= rotation && rotation < 202.5) {
  170.                        
  171.                         for(y = block.getY(); y != block.getY() + 10; y++){
  172.  
  173.                            
  174.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  175.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  176.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  177.                            
  178.                             world.getBlockAt(block.getX() - 1, y, block.getZ()+ 2).setTypeId(3);
  179.                             world.getBlockAt(block.getX() - 1, y, block.getZ()- 2).setTypeId(3);
  180.                            
  181.                            
  182.                            
  183.  
  184.                     }
  185.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  186.                         p.sendMessage("§c-880 de chakra");
  187.                         return "S";
  188.                     } else if (202.5 <= rotation && rotation < 247.5) {
  189.                        
  190.                         for(y = block.getY(); y != block.getY() + 10; y++){
  191.  
  192.                            
  193.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  194.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  195.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  196.                            
  197.                             world.getBlockAt(block.getX() - 1, y, block.getZ()+ 2).setTypeId(3);
  198.                             world.getBlockAt(block.getX() - 1, y, block.getZ()- 2).setTypeId(3);
  199.                            
  200.                            
  201.                            
  202.  
  203.                     }
  204.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  205.                         p.sendMessage("§c-880 de chakra");
  206.                         //p.sendMessage("S");
  207.                         return "S";
  208.                     } else if (247.5 <= rotation && rotation < 292.5) {
  209.                        
  210.                         for(y = block.getY(); y != block.getY() + 10; y++){
  211.  
  212.                            
  213.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  214.                             world.getBlockAt(block.getX() + 1, y, block.getZ()).setTypeId(3);
  215.                             world.getBlockAt(block.getX() - 1, y, block.getZ()).setTypeId(3);
  216.                            
  217.                             world.getBlockAt(block.getX() - 2, y, block.getZ() - 1).setTypeId(3);
  218.                             world.getBlockAt(block.getX() + 2, y, block.getZ() - 1).setTypeId(3);
  219.                            
  220.                            
  221.                            
  222.  
  223.                     }
  224.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  225.                         p.sendMessage("§c-880 de chakra");
  226.                         //p.sendMessage("W");
  227.                         return "W";
  228.                     } else if (292.5 <= rotation && rotation < 337.5) {
  229.                         //p.sendMessage("N");
  230.                        
  231.                         for(y = block.getY(); y != block.getY() + 10; y++){
  232.  
  233.                            
  234.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  235.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  236.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  237.                            
  238.                             world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
  239.                             world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
  240.                            
  241.                            
  242.                            
  243.  
  244.                     }
  245.                        
  246.                         sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  247.                         p.sendMessage("§c-880 de chakra");
  248.                         return "N";
  249.                     } else if (337.5 <= rotation && rotation < 360.0) {
  250.                         //p.sendMessage("N");
  251.                        
  252.                             for(y = block.getY(); y != block.getY() + 10; y++){
  253.  
  254.                            
  255.                             world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
  256.                             world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
  257.                             world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
  258.                            
  259.                             world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
  260.                             world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
  261.                            
  262.                            
  263.  
  264.                     }
  265.                            
  266.                             sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
  267.                             p.sendMessage("§c-880 de chakra");
  268.                         return "N";
  269.                     } else {
  270.                         return null;
  271.                     }
  272.                 }
  273.                
  274.                
  275.                
  276.        
  277.                    
  278.             }
  279.         return null;
  280.    
  281.        
  282.         }
  283.    
  284.    
  285.        
  286.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement