Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- // [44 01] [00] [E9 23 00 00] [01 00 00 00] [36 0B 20 00]
- Scanner scanner = new Scanner(System.in);
- StringBuilder str = new StringBuilder();
- str.append("44 01");//[44 01]
- str.append(" ");
- str.append("00");//[00]
- str.append(" ");
- System.out.println("Input the QuestID: ");
- int questID = scanner.nextInt(); // 9193
- System.out.println("Input the ItemID: ");
- int itemID = scanner.nextInt(); // 2100022
- System.out.println("Input the Count (Default 1):");
- int count = scanner.nextInt();
- String toQuest = Integer.toHexString(questID).toUpperCase();//[
- String toItem = Integer.toHexString(itemID).toUpperCase();
- String tmp;
- while (toQuest.length() % 2 > 0) {
- tmp = "0" + toQuest;
- toQuest = tmp;
- }
- while (toItem.length() % 2 > 0) {
- tmp = "0" + toItem;
- toItem = tmp;
- }
- while (toQuest.length() / 2 < 4) {
- tmp = "0" + toQuest;
- toQuest = tmp;
- }
- while (toItem.length() / 2 < 4) {
- tmp = "0" + toItem;
- toItem = tmp;
- }
- tmp = "";
- for (int i = toQuest.length(); i > 0; i -= 2) {
- tmp += toQuest.charAt(i - 2);
- tmp += toQuest.charAt(i - 1);
- }
- toQuest = tmp;
- tmp = "";
- for (int i = toItem.length(); i > 0; i -= 2) {
- tmp += toItem.charAt(i - 2);
- tmp += toItem.charAt(i - 1);
- }
- toItem = tmp;
- for (int i = 0; i < toQuest.length(); i+= 2) {
- str.append(toQuest.substring(i, i + 2));
- str.append(" ");
- }
- str.append(count < 0xF ? "0" : "").append(Integer.toHexString(count).toUpperCase());//>= 0 though..
- str.append(" ");
- str.append("00 00 00");//count will never be > 0xFF.
- str.append(" ");
- for (int i = 0; i < toItem.length(); i+= 2) {
- str.append(toItem.substring(i, i + 2));
- str.append(" ");
- }
- System.out.println("Packet: " + str.toString());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement