Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.11 KB | None | 0 0
  1.  
  2. public ItemStack getBlockPackage(int amount) {
  3. String url = "http://textures.minecraft.net/texture/d5c6dc2bbf51c36cfc7714585a6a5683ef2b14d47d8ff714654a893f5da622";
  4. GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  5. PropertyMap propertyMap = profile.getProperties();
  6. if (propertyMap == null) {
  7. throw new IllegalStateException("Profile doesn't contain a property map");
  8. }
  9. byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  10. propertyMap.put("textures", new Property("textures", new String(encodedData)));
  11. ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
  12. ItemMeta headMeta = head.getItemMeta();
  13. Class<?> headMetaClass = headMeta.getClass();
  14. Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
  15. ArrayList<String> lore = new ArrayList<String>();
  16. for(String line : getConfig().getStringList("Block-Package.Lore")) {
  17. lore.add(ChatColor.translateAlternateColorCodes('&', line));
  18. }
  19. headMeta.setLore(lore);
  20. headMeta.setDisplayName(Strings.format(this.getConfig().getString("Block-Package.Name")));
  21. head.setItemMeta(headMeta);
  22. return head;
  23. }
  24. public ItemStack getUtilityPackage(int amount) {
  25. String url = "http://textures.minecraft.net/texture/b0b068709790d41b8927b8422d21bb52404b55b4ca352cdb7c68e4b36592721";
  26. GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  27. PropertyMap propertyMap = profile.getProperties();
  28. if (propertyMap == null) {
  29. throw new IllegalStateException("Profile doesn't contain a property map");
  30. }
  31. byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  32. propertyMap.put("textures", new Property("textures", new String(encodedData)));
  33. ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
  34. ItemMeta headMeta = head.getItemMeta();
  35. Class<?> headMetaClass = headMeta.getClass();
  36. Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
  37. ArrayList<String> lore = new ArrayList<String>();
  38. for(String line : getConfig().getStringList("Utility-Package.Lore")) {
  39. lore.add(ChatColor.translateAlternateColorCodes('&', line));
  40. }
  41. headMeta.setLore(lore);
  42. headMeta.setDisplayName(Strings.format(this.getConfig().getString("Utility-Package.Name")));
  43. head.setItemMeta(headMeta);
  44. return head;
  45. }
  46. public ItemStack getRankPackage(int amount) {
  47. String url = "http://textures.minecraft.net/texture/9c96be7886eb7df75525a363e5f549626c21388f0fda988a6e8bf487a53";
  48. GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  49. PropertyMap propertyMap = profile.getProperties();
  50. if (propertyMap == null) {
  51. throw new IllegalStateException("Profile doesn't contain a property map");
  52. }
  53. byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  54. propertyMap.put("textures", new Property("textures", new String(encodedData)));
  55. ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
  56. ItemMeta headMeta = head.getItemMeta();
  57. Class<?> headMetaClass = headMeta.getClass();
  58. Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
  59. ArrayList<String> lore = new ArrayList<String>();
  60. for(String line : getConfig().getStringList("Rank-Package.Lore")) {
  61. lore.add(ChatColor.translateAlternateColorCodes('&', line));
  62. }
  63. headMeta.setLore(lore);
  64. headMeta.setDisplayName(Strings.format(this.getConfig().getString("Rank-Package.Name")));
  65. head.setItemMeta(headMeta);
  66. return head;
  67. }
  68. public ItemStack getCosmeticPackage(int amount) {
  69. String url = "http://textures.minecraft.net/texture/cdbca4b69eaf8dcb7ac3728228de8a64440787013342ddaabc1b00eeb8eec1e2";
  70. GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  71. PropertyMap propertyMap = profile.getProperties();
  72. if (propertyMap == null) {
  73. throw new IllegalStateException("Profile doesn't contain a property map");
  74. }
  75. byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  76. propertyMap.put("textures", new Property("textures", new String(encodedData)));
  77. ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
  78. ItemMeta headMeta = head.getItemMeta();
  79. Class<?> headMetaClass = headMeta.getClass();
  80. Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
  81. ArrayList<String> lore = new ArrayList<String>();
  82. for(String line : getConfig().getStringList("Cosmetic-Package.Lore")) {
  83. lore.add(ChatColor.translateAlternateColorCodes('&', line));
  84. }
  85. headMeta.setLore(lore);
  86. headMeta.setDisplayName(Strings.format(this.getConfig().getString("Cosmetic-Package.Name")));
  87. head.setItemMeta(headMeta);
  88. return head;
  89. }
  90. public ItemStack getGearPackage(int amount) {
  91. String url = "http://textures.minecraft.net/texture/f624c927cfea31355427993d8b79712e86f94d5953433f848849a39a6879";
  92. GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  93. PropertyMap propertyMap = profile.getProperties();
  94. if (propertyMap == null) {
  95. throw new IllegalStateException("Profile doesn't contain a property map");
  96. }
  97. byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  98. propertyMap.put("textures", new Property("textures", new String(encodedData)));
  99. ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
  100. ItemMeta headMeta = head.getItemMeta();
  101. Class<?> headMetaClass = headMeta.getClass();
  102. Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
  103. ArrayList<String> lore = new ArrayList<String>();
  104. for(String line : getConfig().getStringList("Gear-Package.Lore")) {
  105. lore.add(ChatColor.translateAlternateColorCodes('&', line));
  106. }
  107. headMeta.setLore(lore);
  108. headMeta.setDisplayName(Strings.format(this.getConfig().getString("Gear-Package.Name")));
  109. head.setItemMeta(headMeta);
  110. return head;
  111. }
  112. public ItemStack getLootPackage(int amount) {
  113.  
  114. String url = "http://textures.minecraft.net/texture/ce22391e35a3e5bcee89db312e874fdc9d9e7a6351314b82bda97fbd2be87eb8";
  115. GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  116. PropertyMap propertyMap = profile.getProperties();
  117. if (propertyMap == null) {
  118. throw new IllegalStateException("Profile doesn't contain a property map");
  119. }
  120. byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  121. propertyMap.put("textures", new Property("textures", new String(encodedData)));
  122. ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
  123. ItemMeta headMeta = head.getItemMeta();
  124. Class<?> headMetaClass = headMeta.getClass();
  125. Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
  126. ArrayList<String> lore = new ArrayList<String>();
  127. for(String line : getConfig().getStringList("Loot-Package.Lore")) {
  128. lore.add(ChatColor.translateAlternateColorCodes('&', line));
  129. }
  130. headMeta.setLore(lore);
  131. headMeta.setDisplayName(Strings.format(this.getConfig().getString("Loot-Package.Name")));
  132. head.setItemMeta(headMeta);
  133. return head;
  134. }
  135.  
  136. static Random rand = new Random();
  137. static <T> T getRandomItem(List<T> list) {
  138. return list.get(rand.nextInt(list.size()));
  139. }
  140.  
  141. public void giveBlockPackageLoot(Player p) {
  142. for(int i = 1; i <= 4;) {
  143.  
  144. int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Block-Package.Items.amount") + 1);
  145. if(this.getConfig().getString("Block-Package.Items." + randomNum + ".type").equals("command")) {
  146. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Block-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
  147. i++;
  148. }
  149. if(this.getConfig().getString("Block-Package.Items." + randomNum + ".type").equals("item")) {
  150. ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Block-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Block-Package.Items." + randomNum + ".amount"));
  151.  
  152. p.getInventory().addItem(random);
  153. i++;
  154. }
  155. }
  156. p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  157. if(p.getInventory().getItemInHand().getAmount() <= 1) {
  158. p.getInventory().remove(p.getItemInHand());
  159. }
  160. else {
  161. p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  162. }
  163. }
  164. public void giveUtilityPackageLoot(Player p) {
  165. for(int i = 1; i <= 4;) {
  166.  
  167. int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Utility-Package.Items.amount") + 1);
  168. if(this.getConfig().getString("Utility-Package.Items." + randomNum + ".type").equals("command")) {
  169. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Utility-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
  170. i++;
  171. }
  172. if(this.getConfig().getString("Utility-Package.Items." + randomNum + ".type").equals("item")) {
  173. ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Utility-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Utility-Package.Items." + randomNum + ".amount"));
  174.  
  175. p.getInventory().addItem(random);
  176. i++;
  177. }
  178. }
  179. p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  180. if(p.getInventory().getItemInHand().getAmount() <= 1) {
  181. p.getInventory().remove(p.getItemInHand());
  182. }
  183. else {
  184. p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  185. }
  186.  
  187. }
  188. public void giveRankPackageLoot(Player p) {
  189. for(int i = 1; i <= 4;) {
  190.  
  191. int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Rank-Package.Items.amount") + 1);
  192. if(this.getConfig().getString("Rank-Package.Items." + randomNum + ".type").equals("command")) {
  193. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Rank-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
  194. i++;
  195. }
  196. if(this.getConfig().getString("Rank-Package.Items." + randomNum + ".type").equals("item")) {
  197. ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Rank-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Rank-Package.Items." + randomNum + ".amount"));
  198.  
  199. p.getInventory().addItem(random);
  200. i++;
  201. }
  202. }
  203. p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  204. if(p.getInventory().getItemInHand().getAmount() <= 1) {
  205. p.getInventory().remove(p.getItemInHand());
  206. }
  207. else {
  208. p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  209. }
  210. }
  211. public void giveGearPackageLoot(Player p) {
  212. for(int i = 1; i <= 4;) {
  213.  
  214. int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Gear-Package.Items.amount") + 1);
  215. if(this.getConfig().getString("Gear-Package.Items." + randomNum + ".type").equals("command")) {
  216. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Gear-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
  217. i++;
  218. }
  219. if(this.getConfig().getString("Gear-Package.Items." + randomNum + ".type").equals("item")) {
  220. ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Gear-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Gear-Package.Items." + randomNum + ".amount"));
  221.  
  222. p.getInventory().addItem(random);
  223. i++;
  224. }
  225. }
  226. p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  227. if(p.getInventory().getItemInHand().getAmount() <= 1) {
  228. p.getInventory().remove(p.getItemInHand());
  229. }
  230. else {
  231. p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  232. }
  233.  
  234. }
  235. public void giveLootPackageLoot(Player p) {
  236. for(int i = 1; i <= 4;) {
  237.  
  238. int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Loot-Package.Items.amount") + 1);
  239. if(this.getConfig().getString("Loot-Package.Items." + randomNum + ".type").equals("command")) {
  240. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Loot-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
  241. i++;
  242. }
  243. if(this.getConfig().getString("Loot-Package.Items." + randomNum + ".type").equals("item")) {
  244. ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Loot-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Loot-Package.Items." + randomNum + ".amount"));
  245.  
  246. p.getInventory().addItem(random);
  247. i++;
  248. }
  249. }
  250. p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  251. if(p.getInventory().getItemInHand().getAmount() <= 1) {
  252. p.getInventory().remove(p.getItemInHand());
  253. }
  254. else {
  255. p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  256. }
  257.  
  258.  
  259. }
  260. public void giveCosmeticPackageLoot(Player p) {
  261. ArrayList<ItemStack> packageloot = new ArrayList<ItemStack>();
  262. for(int i = 1; i <= 4;) {
  263.  
  264. int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Cosmetic-Package.Items.amount") + 1);
  265. if(this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".type").equals("command")) {
  266. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
  267. i++;
  268. }
  269. if(this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".type").equals("item")) {
  270. ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Cosmetic-Package.Items." + randomNum + ".amount"));
  271.  
  272. p.getInventory().addItem(random);
  273. i++;
  274. }
  275. }
  276. p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  277. if(p.getInventory().getItemInHand().getAmount() <= 1) {
  278. p.getInventory().remove(p.getItemInHand());
  279. }
  280. else {
  281. p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  282. }
  283. }
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement