Advertisement
EricDev

Untitled

Sep 2nd, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 KB | None | 0 0
  1. public static void main(String[] args) {
  2.         // [44 01] [00] [E9 23 00 00] [01 00 00 00] [36 0B 20 00]
  3.         Scanner scanner = new Scanner(System.in);
  4.         StringBuilder str = new StringBuilder();
  5.         str.append("44 01");//[44 01]
  6.         str.append(" ");
  7.         str.append("00");//[00]
  8.         str.append(" ");
  9.         System.out.println("Input the QuestID: ");
  10.         int questID = scanner.nextInt(); // 9193
  11.         System.out.println("Input the ItemID: ");
  12.         int itemID = scanner.nextInt(); // 2100022
  13.         System.out.println("Input the Count (Default 1):");
  14.         int count = scanner.nextInt();
  15.         String toQuest = Integer.toHexString(questID).toUpperCase();//[
  16.         String toItem = Integer.toHexString(itemID).toUpperCase();
  17.         String tmp;
  18.         while (toQuest.length() % 2 > 0) {
  19.             tmp = "0" + toQuest;
  20.             toQuest = tmp;
  21.         }
  22.         while (toItem.length() % 2 > 0) {
  23.             tmp = "0" + toItem;
  24.             toItem = tmp;
  25.         }
  26.         while (toQuest.length() / 2 < 4) {
  27.             tmp = "0" + toQuest;
  28.             toQuest = tmp;
  29.         }
  30.         while (toItem.length() / 2 < 4) {
  31.             tmp = "0" + toItem;
  32.             toItem = tmp;
  33.         }
  34.         tmp = "";
  35.         for (int i = toQuest.length(); i > 0; i -= 2) {
  36.             tmp += toQuest.charAt(i - 2);
  37.             tmp += toQuest.charAt(i - 1);
  38.         }
  39.         toQuest = tmp;
  40.         tmp = "";
  41.         for (int i = toItem.length(); i > 0; i -= 2) {
  42.             tmp += toItem.charAt(i - 2);
  43.             tmp += toItem.charAt(i - 1);
  44.         }
  45.         toItem = tmp;
  46.         for (int i = 0; i < toQuest.length(); i+= 2) {
  47.             str.append(toQuest.substring(i, i + 2));
  48.             str.append(" ");
  49.         }
  50.         str.append(count < 0xF ? "0" : "").append(Integer.toHexString(count).toUpperCase());//>= 0 though..
  51.         str.append(" ");
  52.         str.append("00 00 00");//count will never be > 0xFF.
  53.         str.append(" ");
  54.         for (int i = 0; i < toItem.length(); i+= 2) {
  55.             str.append(toItem.substring(i, i + 2));
  56.             str.append(" ");
  57.         }
  58.         System.out.println("Packet: " + str.toString());
  59.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement