Ghaz-ranka

Untitled

May 23rd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. Objective obj = Objective.builder()
  2. .criterion(Criteria.DUMMY)
  3. .name("timer")
  4. .displayName(Text.of(TextColors.DARK_BLUE, "[ ]"))
  5. .build();
  6. Scoreboard board = Scoreboard.builder()
  7. .objectives(ImmutableList.of(obj))
  8. .build();
  9. obj.getOrCreateScore(Text.of(player.getName())).setScore(0);
  10. player.setScoreboard(board);
  11. board.updateDisplaySlot(obj, DisplaySlots.SIDEBAR);
  12. boards.put(player.getUniqueId(), board);
  13. AtomicInteger integer = new AtomicInteger(10);
  14. tasks.put(id, Task.builder()
  15. .delay(1, TimeUnit.SECONDS)
  16. .interval(1, TimeUnit.SECONDS)
  17. .execute(() -> {
  18.  
  19. player.setScoreboard(board);
  20. /// Duration dur = Duration.of(integer.get(), ChronoUnit.SECONDS);
  21. char[] arr = new char[10];
  22. Arrays.fill(arr, 0, 11 - integer.decrementAndGet(), '|');
  23. obj.setDisplayName(Text.of(TextColors.DARK_BLUE, "[", String.valueOf(arr), "]"));
  24.  
  25. if (integer.get() == 0) {
  26.  
  27. obj.setDisplayName(Text.of(TextColors.DARK_BLUE, "[||||||||||]"));
  28. for (Inventory slot : player.getInventory().query(shovelHead).slots()) {
  29. ItemStack stack = slot.peek().get();
  30. if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Stone Shovelhead")){
  31. if (stack.getQuantity() >= 1) {
  32. slot.poll(1);
  33. break;
  34. }
  35. }
  36. }
  37.  
  38. for (Inventory slot : player.getInventory().query(ItemTypes.STICK).slots()) {
  39. ItemStack stack = slot.peek().get();
  40. if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Tool Handle")){
  41. if (stack.getQuantity() >= 1) {
  42. slot.poll(1);
  43. break;
  44. }
  45. }
  46. }
  47.  
  48. Optional<ItemType> Stoneshovel_ = Sponge.getGame().getRegistry().getType(ItemType.class, "forgecraft:wootzshovel");
  49. ItemType StoneShovelType = Stoneshovel_.get();
  50. ItemStack stoneshovel = ItemStack.of(StoneShovelType, 1);
  51. stoneshovel.offer(Keys.DISPLAY_NAME, Text.of("Stone Shovel"));
  52. //List<Text> itemShovelLore = new ArrayList<Text>();
  53. //itemShovelLore.add(Text.of(TextColors.GOLD, "Crafting Requirements:"));
  54. //itemShovelLore.add(Text.of(TextColors.GOLD, "1 Flat Stone"));
  55. //itemShovelLore.add(Text.of(TextColors.GOLD, "1 Tool Handle"));
  56. //stoneshovel.offer(Keys.ITEM_LORE, itemShovelLore);
  57. //giving player the itemstack stoneshovel
  58. player.getInventory().offer(stoneshovel);
  59. //game.getServer().getPlayer(id).ifPresent(pl -> {
  60. //pl.setLocationSafely(pl.getWorld().getSpawnLocation());
  61. //});
  62. tasks.remove(id).cancel();
  63. boards.remove(id);
  64. }
  65. })
  66. .submit(this));
Advertisement
Add Comment
Please, Sign In to add comment