RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
DebugAction.java
1package com.osroyale.game.action.impl;
2
3import com.google.gson.Gson;
4import com.google.gson.GsonBuilder;
5import com.osroyale.game.task.Task;
6import com.osroyale.net.packet.out.SendInputMessage;
7import com.osroyale.net.packet.out.SendMessage;
8import com.osroyale.game.world.entity.mob.player.Player;
9import com.osroyale.util.MessageColor;
10
11import java.io.FileWriter;
12import java.util.HashMap;
13import java.util.Map;
14
50
51public class DebugAction extends Task {
52
53 private Map<Integer, String> DATA = new HashMap<>();
54
55 private final Player player;
56
57 private int identification;
58
59 private int tick;
60
61 private boolean pause;
62
63 private boolean inputTaken;
64
65 public DebugAction(Player player) {
66 super(true, 1);
67 this.player = player;
68 this.tick = 0;
69 this.identification = 0;
70 this.inputTaken = false;
71 this.pause = false;
72 this.DATA = new HashMap<>();
73 }
74
75 private final void save() {
76 Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
77 try (FileWriter fw = new FileWriter("./data/INTERFACES.json")) {
78 fw.write(gson.toJson(DATA));
79 } catch (final Exception e) {
80 e.printStackTrace();
81 }
82 }
83
84 private void input(Player player) {
85 player.send(new SendInputMessage("Enter the itemcontainer description", 100, input -> {
86 DATA.put(identification, input);
87 inputTaken = false;
88 pause = false;
89 }));
90 }
91
92
93 @Override
94 public void execute() {
95 if (inputTaken) {
96 if (tick++ == 1) {
97 input(player);
98 }
99 return;
100 }
101
102 if (pause) {
103 player.dialogueFactory.sendOption(
104 "Empty",
105 () -> pause = false,
106
107 "Enter", () -> {
108 player.dialogueFactory.clear();
109 tick = 0;
110 inputTaken = true;
111 },
112 "Save & End",
113 () -> {
114 save();
115 cancel();
116 player.send(new SendMessage("A total of " + DATA.size() + " interfaces were saved."));
117 }).execute();
118 return;
119 }
120
121 identification++;
122 player.interfaceManager.open(identification);
123 player.send(new SendMessage("Opening itemcontainer: " + identification, MessageColor.DARK_RED));
124 pause = true;
125 }
126
127}
synchronized final void cancel()
Definition Task.java:147
Task(boolean instant, int delay)
Definition Task.java:75