Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.13 KB | None | 0 0
  1. package me.Fyriboo.base;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Location;
  5. import org.bukkit.Material;
  6. import org.bukkit.block.BlockFace;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. public class Build extends JavaPlugin {
  11.     static FileManager settings = FileManager.getInstance();
  12.     static int count;
  13.     static int countdown;
  14.     static int pointer = 0;
  15.     static BlockFace dir;
  16.     public static long time;
  17.  
  18.     @Override
  19.     public void onEnable() {
  20.         settings.setup(this);
  21.     }
  22.  
  23.     public static void CountDown(Player p) {
  24.         countdown = settings.getData().getString("base1").split(";").length;
  25.         String world = p.getWorld().getName();
  26.         Location loc = p.getLocation();
  27.         count = Bukkit.getScheduler().scheduleSyncRepeatingTask(Commands.plugin, new Runnable() {
  28.  
  29.             @SuppressWarnings("deprecation")
  30.             @Override
  31.             public void run() {
  32.                 if (countdown > 0) {
  33.                     int add1 = Integer
  34.                             .parseInt(settings.getData().getString("base1").split(";")[pointer].split(",")[1]);
  35.                     int add2 = Integer
  36.                             .parseInt(settings.getData().getString("base1").split(";")[pointer].split(",")[2]);
  37.                     int add3 = Integer
  38.                             .parseInt(settings.getData().getString("base1").split(";")[pointer].split(",")[3]);
  39.                     loc.add(add1, add2, add3);
  40.                     String item = settings.getData().getString("base1").split(";")[pointer].split(",")[0];
  41.                     if (item.contains(":")) {
  42.                         Bukkit.getWorld(world).getBlockAt(loc)
  43.                                 .setType(Material.getMaterial((int) Double.parseDouble(item.split(":")[0])));
  44.                         Bukkit.getWorld(world).getBlockAt(loc).setData((Byte) Byte.parseByte(item.split(":")[1]));
  45.                     } else if (item.contains("%")) {
  46.                         Bukkit.getWorld(world).getBlockAt(loc)
  47.                                 .setType(Material.getMaterial((int) Double.parseDouble(item.split("%")[0])));
  48.                         if (item.split("%")[1].equalsIgnoreCase("E")) {
  49.                             getStairsData(world, loc, "East");
  50.                         } else if (item.split("%")[1].equalsIgnoreCase("N")) {
  51.                             getStairsData(world, loc, "North");
  52.                         } else if (item.split("%")[1].equalsIgnoreCase("S")) {
  53.                             getStairsData(world, loc, "South");
  54.                         } else if (item.split("%")[1].equalsIgnoreCase("W")) {
  55.                             getStairsData(world, loc, "West");
  56.                         }
  57.                     } else {
  58.                         Bukkit.getWorld(world).getBlockAt(loc)
  59.                                 .setType(Material.getMaterial((int) Double.parseDouble(item)));
  60.                     }
  61.                     countdown--;
  62.                     pointer++;
  63.                     loc.subtract(add1, add2, add3);
  64.                 } else {
  65.                     Finish();
  66.                     Bukkit.getScheduler().cancelTask(count);
  67.                     countdown = settings.getData().getString("base1").split(":").length;
  68.                     pointer = 0;
  69.                 }
  70.             }
  71.         }, 0L, time);
  72.     }
  73.  
  74.     @SuppressWarnings("deprecation")
  75.     public static boolean getStairsData(String world, Location loc, String dir) {
  76.         byte d = 0;
  77.  
  78.         if (dir.equalsIgnoreCase("West")) {
  79.             d = 0x1;
  80.         } else if (dir.equalsIgnoreCase("East")) {
  81.             d = 0x0;
  82.         } else if (dir.equalsIgnoreCase("North")) {
  83.             d = 0x3;
  84.         } else if (dir.equalsIgnoreCase("South")) {
  85.             d = 0x2;
  86.         }
  87.  
  88.         return Bukkit.getWorld(world).getBlockAt(loc).setTypeIdAndData(156, d, false);
  89.     }
  90.  
  91.     public static void Finish() {
  92.         Bukkit.broadcastMessage("Fertig gebaut!");
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement