aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java
blob: 0abca240d45fe5d8db0a0234c83c4e978c1215df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package io.github.moulberry.notenoughupdates.infopanes;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;

import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class DevInfoPane extends TextInfoPane {

    public DevInfoPane(NEUOverlay overlay, NEUManager manager) {
        super(overlay, manager, "Dev", "");
        text = getText();
    }

    private String getText() {
        String text = "";
        for(Map.Entry<String, JsonElement> entry : manager.getAuctionPricesJson().get("prices").getAsJsonObject().entrySet()) {
            if(!manager.getItemInformation().keySet().contains(entry.getKey())) {
                if(entry.getKey().contains("-")) {
                    continue;
                }
                if(entry.getKey().startsWith("PERFECT")) continue;
                if(Item.itemRegistry.getObject(new ResourceLocation(entry.getKey().toLowerCase())) != null) {
                    continue;
                }
                text += entry.getKey() + "\n";
            }
        }
        return text;
    }

    AtomicBoolean running = new AtomicBoolean(false);
    ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);

    @Override
    public void keyboardInput() {
        if(Keyboard.isKeyDown(Keyboard.KEY_J)) {
            running.set(!running.get());

            if(running.get()) {
                List<String> add = new ArrayList<>();
                for(Map.Entry<String, JsonObject> item : manager.getItemInformation().entrySet()) {
                    if(item.getValue().has("recipe")) {
                        if(!item.getKey().contains("-") && !item.getKey().contains(";")) {
                            add.add(item.getKey());
                        }
                    }
                }
                AtomicInteger index = new AtomicInteger(0);

                ses.schedule(new Runnable() {
                    public void run() {
                        if(!running.get()) return;

                        int i = index.getAndIncrement();
                        String item = add.get(i).split("-")[0].split(";")[0];
                        Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewrecipe " + item);
                        ses.schedule(this, 1000L, TimeUnit.MILLISECONDS);
                    }
                }, 1000L, TimeUnit.MILLISECONDS);
            }
        }
        /*if(Keyboard.isKeyDown(Keyboard.KEY_J) && !running) {
            running = true;
            List<String> add = new ArrayList<>();
            for(Map.Entry<String, JsonElement> entry : manager.getAuctionPricesJson().get("prices").getAsJsonObject().entrySet()) {
                if(!manager.getItemInformation().keySet().contains(entry.getKey())) {
                    if(entry.getKey().contains("-")) {
                        continue;
                    }
                    if(entry.getKey().startsWith("PERFECT")) continue;
                    if(Item.itemRegistry.getObject(new ResourceLocation(entry.getKey().toLowerCase())) != null) {
                        continue;
                    }
                    add.add(entry.getKey());
                }
            }
            AtomicInteger index = new AtomicInteger(0);

            ses.schedule(new Runnable() {
                public void run() {
                    int i = index.getAndIncrement();
                    String item = add.get(i).split("-")[0].split(";")[0];
                    Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewrecipe " + item);
                    ses.schedule(this, 1000L, TimeUnit.MILLISECONDS);
                }
            }, 1000L, TimeUnit.MILLISECONDS);
        }*/
    }
}