Skip to content

Commit 9e97a95

Browse files
committed
temp fix replaced with actual fix
1 parent 89aa447 commit 9e97a95

File tree

6 files changed

+13
-49
lines changed

6 files changed

+13
-49
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
// Fabric API. This is technically optional, but you probably want it anyway.
3636
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
3737

38-
implementation 'com.github.Coflnet:CoflSkyCore:main'
38+
implementation 'com.github.Coflnet:CoflSkyCore:main-SNAPSHOT'
3939
implementation "org.greenrobot:eventbus-java:3.3.1"
4040
implementation "org.java-websocket:Java-WebSocket:1.5.2"
4141
}

src/client/java/com/coflnet/CoflModClient.java

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import CoflCore.commands.models.FlipData;
1313
import CoflCore.commands.models.SoundData;
1414
import CoflCore.events.*;
15+
import CoflCore.handlers.EventRegistry;
1516
import com.coflnet.gui.RenderUtils;
1617
import com.coflnet.gui.cofl.CoflBinGUI;
1718
import com.coflnet.gui.tfm.TfmBinGUI;
@@ -50,15 +51,6 @@
5051
public class CoflModClient implements ClientModInitializer {
5152
private KeyBinding bestflipsKeyBinding;
5253

53-
public static long LastClick = System.currentTimeMillis();
54-
public static final ExecutorService chatThreadPool = Executors.newFixedThreadPool(2);
55-
public static final ExecutorService tickThreadPool = Executors.newFixedThreadPool(2);
56-
public static long LastViewAuctionInvocation = Long.MIN_VALUE;
57-
public static String LastViewAuctionUUID = null;
58-
public static Pattern chatpattern = Pattern.compile("a^", 2);
59-
private static LinkedBlockingQueue<String> chatBatch = new LinkedBlockingQueue();
60-
private static LocalDateTime lastBatchStart = LocalDateTime.now();
61-
6254
private String username = "";
6355
private static FlipData flipData = null;
6456
private static Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
@@ -83,7 +75,7 @@ public void onInitializeClient() {
8375

8476
ClientTickEvents.END_CLIENT_TICK.register(client -> {
8577
if(bestflipsKeyBinding.wasPressed()) {
86-
onOpenBestFlip(username, true);
78+
EventRegistry.onOpenBestFlip(username, true);
8779
}
8880
});
8981

@@ -106,10 +98,6 @@ public void onInitializeClient() {
10698
})));
10799
});
108100

109-
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
110-
111-
});
112-
113101
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
114102
if (screen instanceof GenericContainerScreen gcs) {
115103
System.out.println(gcs.getTitle().getString());
@@ -137,24 +125,6 @@ public static FlipData popFlipData(){
137125
return fd;
138126
}
139127

140-
public static void onOpenBestFlip(String username, boolean isInitialKeypress) {
141-
if (System.currentTimeMillis() - LastClick >= 300L) {
142-
FlipData f = CoflCore.flipHandler.fds.GetHighestFlip();
143-
System.out.println(f);
144-
if (f != null) {
145-
CoflSkyCommand.processCommand(new String[]{"openauctiongui", f.Id, "true"}, username);
146-
LastViewAuctionUUID = f.Id;
147-
LastViewAuctionInvocation = System.currentTimeMillis();
148-
LastClick = System.currentTimeMillis();
149-
String command = (new Gson()).toJson("/viewauction " + f.Id);
150-
CoflCore.Wrapper.SendMessage(new JsonStringCommand(CommandType.Clicked, command));
151-
CoflSkyCommand.processCommand(new String[]{"track", "besthotkey", f.Id, username}, username);
152-
} else if (isInitialKeypress) {
153-
CoflSkyCommand.processCommand(new String[]{"dialog", "nobestflip", username}, username);
154-
}
155-
}
156-
}
157-
158128
@Subscribe
159129
public void WriteToChat(OnWriteToChatReceive command){
160130
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(ChatComponent(command.ChatMessage));
@@ -189,8 +159,11 @@ public void onFlipReceive(OnFlipReceive event){
189159
EventBus.getDefault().post(new OnChatMessageReceive(f.getMessages()));
190160
CoflCore.flipHandler.fds.Insert(new FlipData(
191161
Arrays.stream(f.getMessages())
192-
.map(cm -> new ChatMessageData(cm.getText(), cm.getOnClick(), cm.getHover()))
193-
.toArray(ChatMessageData[]::new),
162+
.map(cm -> new ChatMessageData(
163+
cm.getText(),
164+
cm.getOnClick(),
165+
cm.getHover())
166+
).toArray(ChatMessageData[]::new),
194167
f.getId(),
195168
f.getWorth(),
196169
new SoundData(

src/client/java/com/coflnet/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static MutableText ChatComponent(ChatMessage cmd) {
1313
if (cmd.getOnClick().startsWith("http")) {
1414
message.styled((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, cmd.getOnClick())));
1515
} else {
16-
message.styled((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmd.getOnClick())));
16+
message.styled((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmd.getOnClick().replace("viewauction", "cofl openauctiongui"))));
1717
}
1818
}
1919

src/client/java/com/coflnet/gui/BinGUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public abstract class BinGUI extends Screen {
2828
protected final int CONFIRMATION_CANCEL_SLOT = 15;
2929
protected ItemWidget itemWidget;
3030
protected ItemStack currentItem;
31-
protected FlipData flipData = null;
31+
protected FlipData flipData;
3232

3333
protected AuctionStatus auctionStatus;
3434
protected GenericContainerScreenHandler gcsh;

src/client/java/com/coflnet/gui/cofl/CoflBinGUI.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public class CoflBinGUI extends BinGUI {
3434

3535
public CoflBinGUI(GenericContainerScreen gcs){
3636
super(Text.literal("Cofl Bin Gui"), gcs, 5, 4);
37-
title = flipData == null ? "" : flipData.getMessageAsString();
3837
}
3938

4039
@Override
@@ -120,14 +119,14 @@ public void onClick(double mouseX, double mouseY) {
120119
screenWidth / 2 - width / 2 + p + 3,
121120
screenHeight / 2 - height / 2 + p + 2,
122121
width - p*2 - 4, 10,
123-
Text.of(title),
122+
Text.of(flipData == null ? "" : flipData.getMessageAsString().replace("sellers ah", "")),
124123
MinecraftClient.getInstance().textRenderer
125124
).alignLeft();
126125

127126
loreScrollableTextWidget = new ScrollableDynamicTextWidget(
128127
screenWidth / 2 - width / 2 + p + 20 + p + 4,
129128
screenHeight / 2 - height / 2 + p + 12 + p + 2,
130-
width - 20 - p*4 - 4, height - 75 - 2 - screenHeight / 15 - 2,
129+
width - 20 - p*4 - 4, height - 75 - 2 - screenHeight / 15 - 2,
131130
lore, MinecraftClient.getInstance().textRenderer
132131
){
133132
@Override

src/client/java/com/coflnet/gui/tfm/TfmBinGUI.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ public class TfmBinGUI extends BinGUI {
3030

3131
public TfmBinGUI(GenericContainerScreen gcs){
3232
super(Text.of("Tfm Bin Gui"), gcs, 1, 4);
33-
34-
lore = "";
35-
if (flipData != null) {
36-
for (ChatMessageData message : flipData.Messages) {
37-
if (message.Text.contains("sellers ah")) break;
38-
lore += message.Text+"\n";
39-
};
40-
}
4133
}
4234

4335
@Override
@@ -60,7 +52,7 @@ protected void clearAndInitWidgets(int screenWidth, int screenHeight) {
6052
loreMultilineTextWidget = new MultilineTextWidget(
6153
screenWidth / 2 - width / 2 + 12,
6254
screenHeight / 2 - height / 2 + 8 + 8 + 6,
63-
Text.of(lore),
55+
Text.of(flipData.getMessageAsString().replace("sellers ah", "")),
6456
MinecraftClient.getInstance().textRenderer
6557
).setCentered(false);
6658

0 commit comments

Comments
 (0)