Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ItemStack getBlockPackage(int amount) {
- String url = "http://textures.minecraft.net/texture/d5c6dc2bbf51c36cfc7714585a6a5683ef2b14d47d8ff714654a893f5da622";
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- PropertyMap propertyMap = profile.getProperties();
- if (propertyMap == null) {
- throw new IllegalStateException("Profile doesn't contain a property map");
- }
- byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- propertyMap.put("textures", new Property("textures", new String(encodedData)));
- ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- ItemMeta headMeta = head.getItemMeta();
- Class<?> headMetaClass = headMeta.getClass();
- Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
- ArrayList<String> lore = new ArrayList<String>();
- for(String line : getConfig().getStringList("Block-Package.Lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
- headMeta.setLore(lore);
- headMeta.setDisplayName(Strings.format(this.getConfig().getString("Block-Package.Name")));
- head.setItemMeta(headMeta);
- return head;
- }
- public ItemStack getUtilityPackage(int amount) {
- String url = "http://textures.minecraft.net/texture/b0b068709790d41b8927b8422d21bb52404b55b4ca352cdb7c68e4b36592721";
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- PropertyMap propertyMap = profile.getProperties();
- if (propertyMap == null) {
- throw new IllegalStateException("Profile doesn't contain a property map");
- }
- byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- propertyMap.put("textures", new Property("textures", new String(encodedData)));
- ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- ItemMeta headMeta = head.getItemMeta();
- Class<?> headMetaClass = headMeta.getClass();
- Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
- ArrayList<String> lore = new ArrayList<String>();
- for(String line : getConfig().getStringList("Utility-Package.Lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
- headMeta.setLore(lore);
- headMeta.setDisplayName(Strings.format(this.getConfig().getString("Utility-Package.Name")));
- head.setItemMeta(headMeta);
- return head;
- }
- public ItemStack getRankPackage(int amount) {
- String url = "http://textures.minecraft.net/texture/9c96be7886eb7df75525a363e5f549626c21388f0fda988a6e8bf487a53";
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- PropertyMap propertyMap = profile.getProperties();
- if (propertyMap == null) {
- throw new IllegalStateException("Profile doesn't contain a property map");
- }
- byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- propertyMap.put("textures", new Property("textures", new String(encodedData)));
- ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- ItemMeta headMeta = head.getItemMeta();
- Class<?> headMetaClass = headMeta.getClass();
- Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
- ArrayList<String> lore = new ArrayList<String>();
- for(String line : getConfig().getStringList("Rank-Package.Lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
- headMeta.setLore(lore);
- headMeta.setDisplayName(Strings.format(this.getConfig().getString("Rank-Package.Name")));
- head.setItemMeta(headMeta);
- return head;
- }
- public ItemStack getCosmeticPackage(int amount) {
- String url = "http://textures.minecraft.net/texture/cdbca4b69eaf8dcb7ac3728228de8a64440787013342ddaabc1b00eeb8eec1e2";
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- PropertyMap propertyMap = profile.getProperties();
- if (propertyMap == null) {
- throw new IllegalStateException("Profile doesn't contain a property map");
- }
- byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- propertyMap.put("textures", new Property("textures", new String(encodedData)));
- ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- ItemMeta headMeta = head.getItemMeta();
- Class<?> headMetaClass = headMeta.getClass();
- Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
- ArrayList<String> lore = new ArrayList<String>();
- for(String line : getConfig().getStringList("Cosmetic-Package.Lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
- headMeta.setLore(lore);
- headMeta.setDisplayName(Strings.format(this.getConfig().getString("Cosmetic-Package.Name")));
- head.setItemMeta(headMeta);
- return head;
- }
- public ItemStack getGearPackage(int amount) {
- String url = "http://textures.minecraft.net/texture/f624c927cfea31355427993d8b79712e86f94d5953433f848849a39a6879";
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- PropertyMap propertyMap = profile.getProperties();
- if (propertyMap == null) {
- throw new IllegalStateException("Profile doesn't contain a property map");
- }
- byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- propertyMap.put("textures", new Property("textures", new String(encodedData)));
- ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- ItemMeta headMeta = head.getItemMeta();
- Class<?> headMetaClass = headMeta.getClass();
- Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
- ArrayList<String> lore = new ArrayList<String>();
- for(String line : getConfig().getStringList("Gear-Package.Lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
- headMeta.setLore(lore);
- headMeta.setDisplayName(Strings.format(this.getConfig().getString("Gear-Package.Name")));
- head.setItemMeta(headMeta);
- return head;
- }
- public ItemStack getLootPackage(int amount) {
- String url = "http://textures.minecraft.net/texture/ce22391e35a3e5bcee89db312e874fdc9d9e7a6351314b82bda97fbd2be87eb8";
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- PropertyMap propertyMap = profile.getProperties();
- if (propertyMap == null) {
- throw new IllegalStateException("Profile doesn't contain a property map");
- }
- byte[] encodedData = base64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- propertyMap.put("textures", new Property("textures", new String(encodedData)));
- ItemStack head = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- ItemMeta headMeta = head.getItemMeta();
- Class<?> headMetaClass = headMeta.getClass();
- Reflections.getField(headMetaClass, "profile", GameProfile.class).set(headMeta, profile);
- ArrayList<String> lore = new ArrayList<String>();
- for(String line : getConfig().getStringList("Loot-Package.Lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
- headMeta.setLore(lore);
- headMeta.setDisplayName(Strings.format(this.getConfig().getString("Loot-Package.Name")));
- head.setItemMeta(headMeta);
- return head;
- }
- static Random rand = new Random();
- static <T> T getRandomItem(List<T> list) {
- return list.get(rand.nextInt(list.size()));
- }
- public void giveBlockPackageLoot(Player p) {
- for(int i = 1; i <= 4;) {
- int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Block-Package.Items.amount") + 1);
- if(this.getConfig().getString("Block-Package.Items." + randomNum + ".type").equals("command")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Block-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
- i++;
- }
- if(this.getConfig().getString("Block-Package.Items." + randomNum + ".type").equals("item")) {
- ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Block-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Block-Package.Items." + randomNum + ".amount"));
- p.getInventory().addItem(random);
- i++;
- }
- }
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- if(p.getInventory().getItemInHand().getAmount() <= 1) {
- p.getInventory().remove(p.getItemInHand());
- }
- else {
- p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- public void giveUtilityPackageLoot(Player p) {
- for(int i = 1; i <= 4;) {
- int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Utility-Package.Items.amount") + 1);
- if(this.getConfig().getString("Utility-Package.Items." + randomNum + ".type").equals("command")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Utility-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
- i++;
- }
- if(this.getConfig().getString("Utility-Package.Items." + randomNum + ".type").equals("item")) {
- ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Utility-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Utility-Package.Items." + randomNum + ".amount"));
- p.getInventory().addItem(random);
- i++;
- }
- }
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- if(p.getInventory().getItemInHand().getAmount() <= 1) {
- p.getInventory().remove(p.getItemInHand());
- }
- else {
- p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- public void giveRankPackageLoot(Player p) {
- for(int i = 1; i <= 4;) {
- int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Rank-Package.Items.amount") + 1);
- if(this.getConfig().getString("Rank-Package.Items." + randomNum + ".type").equals("command")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Rank-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
- i++;
- }
- if(this.getConfig().getString("Rank-Package.Items." + randomNum + ".type").equals("item")) {
- ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Rank-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Rank-Package.Items." + randomNum + ".amount"));
- p.getInventory().addItem(random);
- i++;
- }
- }
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- if(p.getInventory().getItemInHand().getAmount() <= 1) {
- p.getInventory().remove(p.getItemInHand());
- }
- else {
- p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- public void giveGearPackageLoot(Player p) {
- for(int i = 1; i <= 4;) {
- int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Gear-Package.Items.amount") + 1);
- if(this.getConfig().getString("Gear-Package.Items." + randomNum + ".type").equals("command")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Gear-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
- i++;
- }
- if(this.getConfig().getString("Gear-Package.Items." + randomNum + ".type").equals("item")) {
- ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Gear-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Gear-Package.Items." + randomNum + ".amount"));
- p.getInventory().addItem(random);
- i++;
- }
- }
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- if(p.getInventory().getItemInHand().getAmount() <= 1) {
- p.getInventory().remove(p.getItemInHand());
- }
- else {
- p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- public void giveLootPackageLoot(Player p) {
- for(int i = 1; i <= 4;) {
- int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Loot-Package.Items.amount") + 1);
- if(this.getConfig().getString("Loot-Package.Items." + randomNum + ".type").equals("command")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Loot-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
- i++;
- }
- if(this.getConfig().getString("Loot-Package.Items." + randomNum + ".type").equals("item")) {
- ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Loot-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Loot-Package.Items." + randomNum + ".amount"));
- p.getInventory().addItem(random);
- i++;
- }
- }
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- if(p.getInventory().getItemInHand().getAmount() <= 1) {
- p.getInventory().remove(p.getItemInHand());
- }
- else {
- p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- public void giveCosmeticPackageLoot(Player p) {
- ArrayList<ItemStack> packageloot = new ArrayList<ItemStack>();
- for(int i = 1; i <= 4;) {
- int randomNum = ThreadLocalRandom.current().nextInt(1, this.getConfig().getInt("Cosmetic-Package.Items.amount") + 1);
- if(this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".type").equals("command")) {
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".command").replace("%player%", p.getName()));
- i++;
- }
- if(this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".type").equals("item")) {
- ItemStack random = new ItemStack(Material.getMaterial(this.getConfig().getString("Cosmetic-Package.Items." + randomNum + ".material")) ,this.getConfig().getInt("Cosmetic-Package.Items." + randomNum + ".amount"));
- p.getInventory().addItem(random);
- i++;
- }
- }
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- if(p.getInventory().getItemInHand().getAmount() <= 1) {
- p.getInventory().remove(p.getItemInHand());
- }
- else {
- p.getInventory().getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement