Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. package com.thoo.bot.cosmetics;
  2.  
  3. import com.thoo.bot.enums.ECosmetic;
  4. import com.thoo.bot.enums.ERarity;
  5.  
  6. public class Skin<T> {
  7.  
  8. private String name;
  9. private String CID;
  10. private ERarity rarity;
  11. private ECosmetic cosmetic;
  12. private String[] exports;
  13. private String[] sources;
  14. private T image;
  15.  
  16. public Skin(String name, String CID, ERarity rarity, ECosmetic cosmetic, String[] exports, String[] sources, T image){
  17. this.name = name;
  18. this.CID = CID;
  19. this.rarity = rarity;
  20. this.cosmetic = cosmetic;
  21. this.exports = exports;
  22. this.sources = sources;
  23. this.image = image;
  24. }
  25.  
  26. public String[] getExports() {
  27. return exports;
  28. }
  29.  
  30. public ECosmetic getCosmetic() {
  31. return cosmetic;
  32. }
  33.  
  34. public ERarity getRarity() {
  35. return rarity;
  36. }
  37.  
  38. public String getName() {
  39. return name;
  40. }
  41.  
  42. public T getImage() {
  43. return image;
  44. }
  45.  
  46. public String[] getSources() {
  47. return sources;
  48. }
  49. }
  50.  
  51. package com.thoo.bot.discord.listeners;
  52.  
  53. import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
  54. import net.dv8tion.jda.core.hooks.ListenerAdapter;
  55.  
  56. public class SkinListener extends ListenerAdapter {
  57.  
  58. public void onGuildMessageReceived(GuildMessageReceivedEvent e){
  59. String[] args = e.getMessage().getContentDisplay().split(" ");
  60. if(e.getAuthor().isBot()) return;
  61. if(args[0].equalsIgnoreCase("!skin")){
  62. e.getChannel().sendMessage("Test").queue();
  63. }
  64. }
  65.  
  66. }
  67.  
  68.  
  69. package com.thoo.bot.discord;
  70.  
  71. import com.thoo.bot.discord.listeners.SkinListener;
  72. import net.dv8tion.jda.core.AccountType;
  73. import net.dv8tion.jda.core.JDA;
  74. import net.dv8tion.jda.core.JDABuilder;
  75.  
  76. public class DiscordListener {
  77.  
  78. private static JDA jda;
  79.  
  80. public static void start(){
  81. try {
  82. jda = new JDABuilder(AccountType.BOT).setToken("").buildBlocking();
  83. addListener(new SkinListener());
  84. } catch(Exception e){
  85. System.err.println("Error while connecting to Discord bot: " + e.getMessage());
  86. }
  87. }
  88.  
  89. private static void addListener(Object listener){
  90. jda.addEventListener(listener);
  91. }
  92.  
  93. }
  94. package com.thoo.bot.enums;
  95.  
  96. public enum ECosmetic {
  97.  
  98. OUTFIT,
  99. BACKPACK,
  100. GLIDER,
  101. WRAP,
  102. SPRAY,
  103. DANCE,
  104. EMOTE,
  105. PICKAXE,
  106. CONTRAIL,
  107. MUSIC,
  108. BANNER,
  109. LOADINGSCREEN;
  110.  
  111. }
  112.  
  113. package com.thoo.bot.enums;
  114.  
  115.  
  116. public enum EEncryptionKey {
  117.  
  118. V9_20("0xE47F0FE3C66BC50D65A92F93609710FEB580BD982017A7D3FC6DE7872197E0CA");
  119.  
  120. private String AES;
  121.  
  122. EEncryptionKey(String AES){
  123. this.AES = AES;
  124. }
  125.  
  126. public String getAES() {
  127. return AES;
  128. }
  129. }
  130.  
  131. package com.thoo.bot.enums;
  132.  
  133. public enum EPaks {
  134.  
  135. S10_S1("C:\\Program Files\\Epic Games\\Fortnite\\FortniteGame\\Content\\Paks\\pakchunk10_s1-WindowsClient");
  136.  
  137. private String path;
  138.  
  139. EPaks(String path){
  140. this.path = path;
  141. }
  142.  
  143. public String getPath() {
  144. return path;
  145. }
  146. }
  147.  
  148. package com.thoo.bot.enums;
  149.  
  150. public enum ERarity {
  151.  
  152. COMMON,
  153. UNCOMMON,
  154. RARE,
  155. EPIC,
  156. MARVEL,
  157. LEGENDARY;
  158. }
  159.  
  160. package com.thoo.bot.parser;
  161.  
  162. import UE4.GameFile;
  163. import UE4.PakFileReader;
  164. import UE4_Packages.Package;
  165. import UE4_Packages.ReadException;
  166. import com.thoo.bot.enums.EEncryptionKey;
  167. import com.thoo.bot.enums.EPaks;
  168. import org.json.JSONObject;
  169.  
  170. import java.io.File;
  171. import java.io.IOException;
  172. import java.util.ArrayList;
  173. import java.util.List;
  174. import java.util.Objects;
  175.  
  176. public class Skins {
  177.  
  178. private PakFileReader reader;
  179. private List<GameFile> gameFiles;
  180.  
  181. public Skins(){
  182. try {
  183. reader = new PakFileReader(EPaks.S10_S1.getPath());
  184. } catch (Exception e){
  185. System.err.println("Error while initializing PakFileReader: " + e.getMessage());
  186. }
  187. try {
  188. if(Objects.requireNonNull(reader).isEncrypted() && reader.testKey(EEncryptionKey.V9_20.getAES())){
  189. reader.setKey(EEncryptionKey.V9_20.getAES());
  190. gameFiles = reader.readIndex();
  191. }
  192. } catch (Exception e) {
  193. System.err.println("Error while reading index of pak file S10_S1: " + e.getMessage());
  194. }
  195. }
  196.  
  197. public List<JSONObject> getSkinsData() {
  198. List<JSONObject> objects = new ArrayList<>();
  199. int c = 0;
  200. for(GameFile file : gameFiles){
  201. if(file.getName().toLowerCase().contains("cid_")){
  202. try {
  203. String skinPath = "";
  204. String uasset = reader.extractSelected(file);
  205. String uexp = null;
  206. String ubulk = null;
  207. if(file.hasUexp()) uexp = reader.extractSelected(file.getUexp());
  208. if(file.hasUbulk()) ubulk = reader.extractSelected(file.getUbulk());
  209. Package cPackage = Package.fromFiles(
  210. new File(skinPath + file.getNameWithoutExtension() + ".uasset"),
  211. new File(skinPath + file.getNameWithoutExtension() + ".uexp"),
  212. new File(skinPath + file.getNameWithoutExtension() + ".ubulk"));
  213. objects.add(new JSONObject(cPackage.toJSON()));
  214. c++;
  215. } catch (ReadException | IOException e) {
  216. e.printStackTrace();
  217. }
  218. }
  219. }
  220.  
  221. return objects;
  222. }
  223.  
  224. }
  225.  
  226. package com.thoo.bot;
  227.  
  228. import com.thoo.bot.discord.DiscordListener;
  229.  
  230. public class Main {
  231.  
  232. public static void main(String[] args){
  233. DiscordListener.start();
  234. }
  235.  
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement