Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.tinwynn;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Timer;
- import java.util.TimerTask;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.util.Vector;
- public class DotonMurDeBou implements Listener{
- private Map<String, Long> cooldowns = new HashMap<>();
- private SqlConnection sql;
- public DotonMurDeBou(SqlConnection sql) {
- this.sql = sql;
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public String interact(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- Action action = e.getAction();
- Block block = e.getClickedBlock();
- final World world = p.getWorld();
- if(action.equals(Action.RIGHT_CLICK_BLOCK)) {
- if(p.getItemInHand().getType().equals(Material.DIRT)) {
- if(cooldowns.containsKey(p.getName())){
- int seconds = 2;
- long timeleft = ((cooldowns.get(p.getName()) / 1000) + seconds) - (System.currentTimeMillis() / 1000);
- if(timeleft > 0){
- p.sendMessage("§cVous devez encore attendre (§c§o" + timeleft + "s§c) pour utiliser cette technique");
- e.setCancelled(true);
- return null;
- }
- }
- p.sendMessage("§cDoton, Mur de boue !");
- cooldowns.put(p.getName(), System.currentTimeMillis());
- ParticleEffect.SMOKE_LARGE.display(5, 5, 5, 0, 250, p.getLocation().add(0, 1, 0), 20);
- ParticleEffect.SMOKE_LARGE.display(5, 5, 5, 0, 300, p.getLocation().add(0, 11, 0), 20);
- final int x = block.getX();
- int y = block.getY();
- final int z = block.getZ();
- double rotation = (p.getLocation().getYaw() - 90) % 360;
- if (rotation < 0) {
- rotation += 360.0;
- }
- if (0 <= rotation && rotation < 22.5) {
- //p.sendMessage("N");
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- return "N";
- } else if (22.5 <= rotation && rotation < 67.5) {
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- //p.sendMessage("N");
- return "N";
- } else if (67.5 <= rotation && rotation < 112.5) {
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() + 2 , y, block.getZ() + 1).setTypeId(3);
- world.getBlockAt(block.getX() - 2, y, block.getZ() + 1).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- //p.sendMessage("E");
- return "E";
- } else if (112.5 <= rotation && rotation < 157.5) {
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- //p.sendMessage("S");
- return "S";
- } else if (157.5 <= rotation && rotation < 202.5) {
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- return "S";
- } else if (202.5 <= rotation && rotation < 247.5) {
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- //p.sendMessage("S");
- return "S";
- } else if (247.5 <= rotation && rotation < 292.5) {
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() - 1, y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() - 2, y, block.getZ() - 1).setTypeId(3);
- world.getBlockAt(block.getX() + 2, y, block.getZ() - 1).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- //p.sendMessage("W");
- return "W";
- } else if (292.5 <= rotation && rotation < 337.5) {
- //p.sendMessage("N");
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- return "N";
- } else if (337.5 <= rotation && rotation < 360.0) {
- //p.sendMessage("N");
- for(y = block.getY(); y != block.getY() + 10; y++){
- world.getBlockAt(block.getX(), y, block.getZ()).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()+ 1).setTypeId(3);
- world.getBlockAt(block.getX() , y, block.getZ()- 1).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()+ 2).setTypeId(3);
- world.getBlockAt(block.getX() + 1, y, block.getZ()- 2).setTypeId(3);
- }
- sql.removeMoney(p, 880); //RETIRER 880 DE CHAKRA AU JOUEUR
- p.sendMessage("§c-880 de chakra");
- return "N";
- } else {
- return null;
- }
- }
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement